/* =================================================================
   subject-dashboard.css  —  Subject Dashboard (Phase 3)
   Matches the premium dark/light dashboard reference design.
   Components: page header, subject tabs, two-panel layout,
   progress ring, content tabs, test list, SM cards.
   ================================================================= */

/* ── 1. Page wrapper ─────────────────────────────────────────── */
.sd-page {
  max-width: var(--content-max-width, 1200px);
  margin: 0 auto;
  padding: 20px 20px 80px;
}

/* ── 2. Compact page header ──────────────────────────────────── */
.sd-breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 10px;
  transition: color var(--dur-fast) var(--ease-out);
}
.sd-breadcrumb:hover { color: var(--primary); }
.sd-breadcrumb svg {
  width: 14px; height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sd-breadcrumb-sep {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  margin: 0 2px;
}
.sd-breadcrumb-current {
  color: var(--text-secondary);
  font-weight: 600;
}

.sd-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.sd-header-left { flex: 1; min-width: 0; }

.sd-title {
  font-size: var(--fs-3xl);
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
  line-height: var(--lh-tight);
}

.sd-exam-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}
.sd-exam-tag {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--primary-surface);
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
}

.sd-header-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.sd-header-stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  white-space: nowrap;
}
.sd-header-stat svg {
  width: 12px; height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.sd-header-stat.active {
  background: var(--badge-completed-bg);
  border-color: var(--badge-completed);
  color: var(--badge-completed);
}
.sd-header-stat.active .stat-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ── 3. Subject tabs strip (sticky) ─────────────────────────── */
.sd-subject-tabs-wrap {
  position: sticky;
  top: var(--topbar-height, 52px);
  z-index: 90;
  background: var(--bg);
  border-bottom: 1px solid var(--card-border);
  margin: 0 -20px 20px;
  padding: 0 20px;
  /* Fade edges hint that the strip scrolls; color matches --bg in both themes */
  -webkit-mask-image: linear-gradient(to right, transparent 0, black 20px, black calc(100% - 20px), transparent 100%);
  mask-image:         linear-gradient(to right, transparent 0, black 20px, black calc(100% - 20px), transparent 100%);
}

.sd-subject-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  padding: 6px 0 0;
  /* Thin scrollbar — adapts to light/dark via CSS custom properties */
  scrollbar-width: thin;
  scrollbar-color: var(--text-muted) transparent;
}
.sd-subject-tabs::-webkit-scrollbar         { height: 3px; }
.sd-subject-tabs::-webkit-scrollbar-track   { background: transparent; }
.sd-subject-tabs::-webkit-scrollbar-thumb   { background: var(--text-muted); border-radius: 2px; opacity: 0.6; }
.sd-subject-tabs::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

.sd-subject-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 14px 10px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
  transition: color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
  text-decoration: none;
}
.sd-subject-tab:hover {
  color: var(--text-secondary);
  background: var(--nav-hover-bg);
}
.sd-subject-tab.active {
  color: var(--primary);
  background: var(--primary-surface);
}
.sd-subject-tab.active::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
}
.sd-tab-icon {
  width: 22px; height: 22px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
}
.sd-subject-tab.active .sd-tab-icon {
  background: var(--primary-surface);
}
.sd-tab-icon svg {
  width: 13px; height: 13px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── 4. Two-panel layout ─────────────────────────────────────── */
.sd-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 16px;
  align-items: start;
}

.sd-main { min-width: 0; }
.sd-aside { position: sticky; top: calc(var(--topbar-height, 52px) + 60px); }

/* ── 5. Subject info card ────────────────────────────────────── */
.sd-subject-card {
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 14px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.sd-subject-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-md);
  background: var(--primary-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 15%, transparent);
}
.sd-subject-icon svg {
  width: 26px; height: 26px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sd-subject-body { flex: 1; min-width: 0; }
.sd-subject-name {
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
  line-height: var(--lh-tight);
}
.sd-subject-desc {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: var(--lh-base);
  margin: 0 0 10px;
}
.sd-subject-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.sd-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: 500;
}
.sd-meta-item svg {
  width: 12px; height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── 6. Content tabs (sticky) ────────────────────────────────── */
.sd-content-tabs-wrap {
  position: sticky;
  top: calc(var(--topbar-height, 52px) + 50px);
  z-index: 80;
  background: var(--bg);
  margin: 0 0 14px;
}
.sd-content-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--card-border);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.sd-content-tabs::-webkit-scrollbar { display: none; }

.sd-content-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
  transition: color var(--dur-fast) var(--ease-out);
}
.sd-content-tab:hover { color: var(--text-secondary); }
.sd-content-tab.active { color: var(--primary); }
.sd-content-tab.active::after {
  content: "";
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 2px;
  background: var(--primary);
}
.sd-content-tab svg {
  width: 13px; height: 13px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  opacity: 0.75;
}
.sd-content-tab.active svg { opacity: 1; }

/* Tab panel visibility */
.sd-tab-panel { display: none; }
.sd-tab-panel.active { display: block; }

/* ── 7. Continue learning (within subject) ───────────────────── */
.sd-continue {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow var(--dur-fast) var(--ease-out);
}
.sd-continue:hover { box-shadow: var(--shadow-md); }
.sd-continue-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}
.sd-continue-icon svg {
  width: 15px; height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sd-continue-body { flex: 1; min-width: 0; }
.sd-continue-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
}
.sd-continue-title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sd-continue-prog {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.sd-continue-bar {
  flex: 1;
  height: 3px;
  background: var(--ring-track);
  border-radius: 2px;
  overflow: hidden;
  max-width: 160px;
}
.sd-continue-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
}
.sd-continue-pct {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-secondary);
}
.sd-continue-arrow {
  color: var(--primary);
  flex-shrink: 0;
}
.sd-continue-arrow svg {
  width: 16px; height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── 8. Quick access grid ────────────────────────────────────── */
.sd-quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.sd-quick-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow   var(--dur-fast) var(--ease-out);
}
.sd-quick-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.sd-quick-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sd-quick-icon svg {
  width: 16px; height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sd-quick-body { flex: 1; min-width: 0; }
.sd-quick-title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
  display: block;
  line-height: var(--lh-tight);
}
.sd-quick-sub {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  display: block;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sd-quick-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
}
.sd-quick-arrow svg {
  width: 14px; height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── 9. Section header (Recent Mock Tests, etc.) ─────────────── */
.sd-section-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}
.sd-section-title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.sd-section-link {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}
.sd-section-link:hover { text-decoration: underline; }
.sd-section-link svg {
  width: 12px; height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── 10. Recent tests list ───────────────────────────────────── */
.sd-test-list {
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
}

.sd-test-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--card-border);
  text-decoration: none;
  color: inherit;
  transition: background var(--dur-fast) var(--ease-out);
  min-height: var(--list-row-height, 52px);
}
.sd-test-row:last-child { border-bottom: none; }
.sd-test-row:hover { background: var(--nav-hover-bg); }

.sd-test-num {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.sd-test-body { flex: 1; min-width: 0; }
.sd-test-name {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sd-test-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
  flex-wrap: wrap;
}
.sd-test-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.sd-test-meta-item svg {
  width: 11px; height: 11px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* Status badges */
.sd-test-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-xs);
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  flex-shrink: 0;
}
.sd-test-badge.completed {
  background: var(--badge-completed-bg);
  color: var(--badge-completed);
}
.sd-test-badge.in-progress {
  background: var(--badge-progress-bg);
  color: var(--badge-progress);
}
.sd-test-badge.start {
  background: var(--primary);
  color: #fff;
}

/* Score / progress text */
.sd-test-score {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 60px;
  text-align: right;
}

.sd-test-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
}
.sd-test-arrow svg {
  width: 14px; height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── 11. Study material horizontal scroll ────────────────────── */
.sd-sm-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 4px;
  margin-bottom: 4px;
}
.sd-sm-scroll::-webkit-scrollbar { display: none; }

.sd-sm-card {
  flex-shrink: 0;
  width: 140px;
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 12px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow   var(--dur-fast) var(--ease-out),
              transform    var(--dur-fast) var(--ease-out);
}
.sd-sm-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}
.sd-sm-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sd-sm-icon svg {
  width: 18px; height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sd-sm-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  line-height: var(--lh-snug);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sd-sm-footer {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: auto;
}
.sd-sm-tag {
  font-size: var(--fs-xs);
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: 1px solid var(--card-border);
}
.sd-sm-pages {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* ── 12. Aside — Progress Panel ──────────────────────────────── */
.sd-progress-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
}
.sd-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.sd-progress-title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.sd-analytics-link {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 3px;
}
.sd-analytics-link:hover { text-decoration: underline; }
.sd-analytics-link svg {
  width: 11px; height: 11px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── 13. SVG progress ring ───────────────────────────────────── */
.sd-ring-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.sd-progress-ring {
  width: var(--ring-size, 72px);
  height: var(--ring-size, 72px);
  transform: rotate(-90deg);
  overflow: visible;
}
.sd-ring-track {
  fill: none;
  stroke: var(--ring-track);
  stroke-width: 6;
}
.sd-ring-fill {
  fill: none;
  stroke: var(--ring-fill);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s var(--ease-out);
}
.sd-ring-text {
  font-size: 14px;
  font-weight: 700;
  fill: var(--ring-text);
  text-anchor: middle;
  dominant-baseline: central;
  transform: rotate(90deg);
  transform-origin: 50% 50%;
}
.sd-ring-label {
  font-size: 8px;
  font-weight: 500;
  fill: var(--text-muted);
  text-anchor: middle;
  dominant-baseline: central;
  transform: rotate(90deg);
  transform-origin: 50% 50%;
}

/* ── 14. Progress legend ─────────────────────────────────────── */
.sd-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sd-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sd-legend-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sd-legend-dot.completed { background: var(--badge-completed); }
.sd-legend-dot.progress  { background: var(--badge-progress); }
.sd-legend-dot.pending   { background: var(--text-muted); }

.sd-legend-label {
  flex: 1;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}
.sd-legend-count {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text);
}

/* ── Analytics tab stats grid ── */
.sd-analytics-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 20px 0 8px;
}
.sd-stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.sd-stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.sd-stat-label {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── 15. Aside extra card (active exam info) ─────────────────── */
.sd-aside-card {
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.sd-aside-card-title {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text);
  margin: 0 0 10px;
}
.sd-aside-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sd-aside-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}
.sd-aside-list li strong {
  font-weight: 700;
  color: var(--text);
}

/* ── 16. Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
  .sd-layout {
    grid-template-columns: 1fr;
  }
  .sd-aside {
    position: static;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .sd-aside > * { margin-bottom: 0; }
}

@media (max-width: 768px) {
  .sd-page { padding: 16px 14px 80px; }
  .sd-title { font-size: var(--fs-2xl); }
  .sd-subject-tabs-wrap { margin: 0 -14px 16px; padding: 0 14px; }
  .sd-aside { grid-template-columns: 1fr; }
  .sd-quick-grid { grid-template-columns: repeat(2, 1fr); }
  .sd-test-score { display: none; }
  .sd-content-tabs-wrap {
    top: calc(var(--topbar-height, 52px) + 48px);
  }
}

@media (max-width: 480px) {
  .sd-quick-grid { grid-template-columns: 1fr; }
  .sd-header-stats { gap: 4px; }
  .sd-header-stat { padding: 3px 8px; font-size: 10px; }
}

/* ── 17. PYQ Generator ───────────────────────────────────────── */
.pyq-generator { padding: 4px 0 24px; }
.pyq-gen-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.pyq-count-hint {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-surface);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
  white-space: nowrap;
}
.pyq-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}
.pyq-form-group { display: flex; flex-direction: column; gap: 6px; }
.pyq-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.pyq-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text);
  font-family: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  padding-right: 32px;
}
.pyq-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}
.pyq-select--sm { width: auto; flex: 1; }
.pyq-year-range { display: flex; align-items: center; gap: 8px; }
.pyq-range-sep { font-size: var(--fs-sm); color: var(--text-muted); flex-shrink: 0; }
.pyq-exam-radios {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}
.pyq-radio-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--card-border);
  background: var(--bg-secondary);
  transition: border-color var(--dur-fast) var(--ease-out),
              background   var(--dur-fast) var(--ease-out);
}
.pyq-radio-label:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-surface);
  color: var(--primary);
}
.pyq-radio-label input { display: none; }
.pyq-generate-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--fs-md);
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.pyq-generate-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.pyq-generate-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.pyq-generate-btn svg {
  width: 16px; height: 16px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.pyq-no-data {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px dashed var(--card-border);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.pyq-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: pyq-spin 0.7s linear infinite;
}
@keyframes pyq-spin { to { transform: rotate(360deg); } }

/* ── 18. Formula Sheets ──────────────────────────────────────── */
.formula-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.formula-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 7px 12px;
  flex: 1;
  max-width: 360px;
}
.formula-search-bar svg {
  width: 14px; height: 14px;
  stroke: var(--text-muted); fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}
.formula-search-input {
  border: none; background: none; outline: none;
  font-family: inherit; font-size: var(--fs-sm);
  color: var(--text); width: 100%;
}
.formula-search-input::placeholder { color: var(--text-muted); }
.formula-print-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  font-family: inherit; font-size: var(--fs-sm); font-weight: 600;
  color: var(--text-secondary); cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out);
}
.formula-print-btn:hover { border-color: var(--primary); color: var(--primary); }
.formula-print-btn svg {
  width: 14px; height: 14px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.formula-topic-section { margin-bottom: 24px; }
.formula-topic-hdr {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid color-mix(in srgb, var(--primary) 20%, transparent);
  display: flex; align-items: center; gap: 8px;
}
.formula-topic-hdr::before {
  content: '';
  width: 4px; height: 16px;
  background: var(--primary);
  border-radius: 2px;
  flex-shrink: 0;
}
.formula-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.formula-card {
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  transition: border-color var(--dur-fast) var(--ease-out);
}
.formula-card:hover { border-color: var(--primary); }
.formula-card.hidden { display: none; }
.formula-eq {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.5;
}
.formula-note {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  margin: 6px 0 0;
  line-height: var(--lh-base);
}
.formula-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
@media print {
  .sidebar, .topbar, .bottom-nav, .sd-subject-tabs-wrap,
  .sd-content-tabs-wrap, .sd-aside, .formula-toolbar,
  .sd-header-stats, .sd-subject-card, .sd-quick-grid,
  .sd-continue, .sd-section-hdr .sd-section-link { display: none !important; }
  .sd-layout { display: block !important; }
  .sd-tab-panel { display: block !important; }
  .formula-topic-section { page-break-inside: avoid; }
  body { font-size: 11pt; }
}

/* ── 19. Notes Editor ────────────────────────────────────────── */
.notes-wrapper {
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.notes-editor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--card-border);
  flex-wrap: wrap;
}
.notes-title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
}
.notes-sync-badge {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}
.notes-sync-badge--synced {
  background: var(--badge-completed-bg);
  color: var(--badge-completed);
}
.notes-sync-badge--guest {
  background: color-mix(in srgb, #f59e0b 12%, transparent);
  color: #b45309;
}
[data-theme="dark"] .notes-sync-badge--guest { color: #fbbf24; }
.notes-status {
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
  align-self: flex-start;
  margin-top: 2px;
}
.notes-status--ok    { color: var(--badge-completed); }
.notes-status--error { color: #dc2626; }
.notes-status--idle  { color: var(--text-muted); }
.notes-guest-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: color-mix(in srgb, #f59e0b 8%, transparent);
  border-bottom: 1px solid color-mix(in srgb, #f59e0b 20%, transparent);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}
.notes-guest-banner svg {
  width: 14px; height: 14px;
  stroke: #f59e0b; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}
.notes-guest-banner a { color: var(--primary); font-weight: 600; text-decoration: none; }
.notes-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--card-border);
}
.notes-toolbar-btn {
  padding: 4px 10px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  font-family: inherit; font-size: var(--fs-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out),
              color         var(--dur-fast) var(--ease-out);
  min-width: 32px;
}
.notes-toolbar-btn:hover { border-color: var(--primary); color: var(--primary); }
.notes-toolbar-sep {
  width: 1px; height: 20px;
  background: var(--card-border);
  margin: 0 4px;
  flex-shrink: 0;
}
.notes-save-btn {
  margin-left: auto;
  padding: 4px 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: var(--fs-sm); font-weight: 600;
  cursor: pointer;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.notes-save-btn:hover { opacity: 0.88; }
.notes-clear-btn {
  padding: 4px 10px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: inherit; font-size: var(--fs-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out),
              color         var(--dur-fast) var(--ease-out);
}
.notes-clear-btn:hover { border-color: #dc2626; color: #dc2626; }
.notes-editor {
  min-height: 280px;
  padding: 16px;
  font-family: inherit;
  font-size: var(--fs-md);
  color: var(--text);
  line-height: var(--lh-base);
  outline: none;
  word-break: break-word;
}
.notes-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}
.notes-editor ul { padding-left: 20px; margin: 4px 0; }
.notes-editor-footer {
  display: flex;
  justify-content: flex-end;
  padding: 6px 16px;
  border-top: 1px solid var(--card-border);
  background: var(--bg-tertiary);
}
.notes-char-count { font-size: var(--fs-xs); color: var(--text-muted); }

/* ── 20. Enhanced Analytics ──────────────────────────────────── */
.sd-analytics-section-hdr {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text);
  margin: 20px 0 10px;
  padding-top: 16px;
  border-top: 1px solid var(--card-border);
}
.sd-topic-bars { display: flex; flex-direction: column; gap: 10px; }
.sd-topic-bar-row { display: flex; align-items: center; gap: 10px; }
.sd-topic-bar-label {
  font-size: var(--fs-sm); color: var(--text-secondary);
  min-width: 110px; flex-shrink: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sd-topic-bar-track {
  flex: 1; height: 8px;
  background: var(--ring-track);
  border-radius: 4px; overflow: hidden;
}
.sd-topic-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.6s var(--ease-out);
}
.sd-topic-bar-fill.weak { background: #ef4444; }
.sd-topic-bar-score {
  font-size: var(--fs-xs); font-weight: 700;
  color: var(--text-secondary);
  min-width: 36px; text-align: right; flex-shrink: 0;
}
.sd-attempts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.sd-attempts-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--card-border);
  background: var(--bg-tertiary);
}
.sd-attempts-table td {
  padding: 9px 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--card-border);
}
.sd-attempts-table tr:last-child td { border-bottom: none; }
.sd-attempts-table td:last-child { font-weight: 700; color: var(--text); }
.sd-weakest-callout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: color-mix(in srgb, #ef4444 8%, transparent);
  border: 1px solid color-mix(in srgb, #ef4444 20%, transparent);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}
.sd-weakest-callout strong { color: var(--text); }
.sd-weakest-callout a {
  margin-left: auto; white-space: nowrap;
  color: var(--primary); font-weight: 600; text-decoration: none;
  flex-shrink: 0;
}

/* ── 21. Overview Enhancements ───────────────────────────────── */
.sd-overview-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
}
.sd-overview-stat-item {
  display: flex; flex-direction: column; align-items: center;
  flex: 1; min-width: 80px;
  gap: 2px;
}
.sd-overview-stat-item + .sd-overview-stat-item {
  border-left: 1px solid var(--card-border);
  padding-left: 8px;
}
.sd-overview-stat-val {
  font-size: var(--fs-xl); font-weight: 700; color: var(--text);
  line-height: 1;
}
.sd-overview-stat-lbl {
  font-size: 10px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em;
  text-align: center;
}
.sd-syllabus-wrap { margin-top: 20px; margin-bottom: 4px; }
.sd-syllabus-accordion { display: flex; flex-direction: column; gap: 6px; }
.sd-syllabus-item {
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-secondary);
}
.sd-syllabus-toggle {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: none; border: none;
  font-family: inherit; font-size: var(--fs-sm); font-weight: 700;
  color: var(--text); cursor: pointer;
  text-align: left;
}
.sd-syllabus-toggle:hover { background: var(--nav-hover-bg); }
.sd-syllabus-toggle svg {
  width: 14px; height: 14px;
  stroke: var(--text-muted); fill: none;
  stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
  transition: transform var(--dur-fast) var(--ease-out);
}
.sd-syllabus-item.open .sd-syllabus-toggle svg { transform: rotate(180deg); }
.sd-syllabus-body {
  display: none;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--card-border);
}
.sd-syllabus-item.open .sd-syllabus-body { display: block; }
.sd-topic-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sd-topic-chip {
  font-size: var(--fs-xs); font-weight: 600;
  padding: 3px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
}

@media (max-width: 640px) {
  .pyq-form-grid { grid-template-columns: 1fr; }
  .formula-cards-grid { grid-template-columns: 1fr; }
  .sd-topic-bar-label { min-width: 80px; font-size: 11px; }
}
