/* Final visual layer. It changes presentation only; page and navigation handlers
   remain in the existing application. */
:root {
  --bg: #f4f6fa;
  --surface: #fff;
  --surface-alt: #f7f9fc;
  --surface-elevated: #fff;
  --sidebar: #ffffff;
  --text: #192b48;
  --muted: #64738b;
  --border: #e2e8f1;
  --primary: #176bd1;
  --primary-dark: #105bb8;
  --primary-soft: #e9f2ff;
  --shadow: 0 2px 8px rgba(16,43,92,.035);
  --shadow-raised: 0 8px 24px rgba(16,43,92,.075);
  --radius-sm: 9px;
  --radius-md: 15px;
  --radius-lg: 20px;
  --ui-space-1: 4px;
  --ui-space-2: 8px;
  --ui-space-3: 12px;
  --ui-space-4: 16px;
  --ui-space-5: 20px;
  --ui-space-6: 24px;
  --ui-space-8: 32px;
}
[data-theme="dark"] {
  --bg: #0c1626;
  --surface: #142238;
  --surface-alt: #192b43;
  --surface-elevated: #1e324c;
  --sidebar: #101c2f;
  --text: #f0f5fc;
  --muted: #a7b8d0;
  --border: #273951;
  --primary: #74b1ff;
  --primary-dark: #5499ed;
  --primary-soft: #18385e;
  --shadow: 0 6px 22px rgba(0,0,0,.1);
  --shadow-raised: 0 13px 34px rgba(0,0,0,.18);
}
body { background: var(--bg); }
.top-nav[hidden] { display: none !important; }
body:has(.top-nav[hidden]) { padding-left: 0 !important; }
body:has(.top-nav[hidden]) .top { display: none !important; }
.wrap { max-width: 1440px; }
.top { backdrop-filter: none; }
.logo { font-size: 17px; font-weight: 740; letter-spacing: -.035em; }
.brand { gap: 11px; }
.brand-mark { width: 38px; height: 38px; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.top small { letter-spacing: .005em; }
.ui-nav-icon, .ui-metric-icon, .ui-folder-icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.ui-nav-icon svg { width: 19px; height: 19px; stroke-width: 1.8; }
.ui-nav-group { display: grid; gap: 2px; }
.ui-nav-heading { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; padding: 0 11px; margin: 7px 0 3px; }
.ui-nav-group:first-of-type .ui-nav-heading { margin-top: 0; }
.top-nav button[data-icon]::before { content: none !important; display: none !important; }
.top-nav button[data-icon] { box-shadow: none; font-size: 13px; font-weight: 600; line-height: 1.25; letter-spacing: 0; }
.top-nav button[data-icon] .ui-nav-icon { color: var(--muted); transition: color .18s ease; }
.top-nav button[data-icon]:hover .ui-nav-icon { color: var(--text); }
.top-nav button[data-icon].active .ui-nav-icon { color: var(--primary); }
.top-nav button[data-icon].active { color: var(--text); background: color-mix(in srgb, var(--primary) 11%, var(--sidebar)); border-color: transparent; box-shadow: inset 2px 0 0 var(--primary); font-weight: 690; }
.top-nav button[data-icon].active::after { display: none !important; }
.top-nav button[data-icon]:hover:not(.active) { color: var(--text); background: color-mix(in srgb, var(--text) 5%, var(--sidebar)); border-color: transparent; }
.top-nav button[data-icon]:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.ui-drawer-brand { display: none; }
.top-right { background: none !important; }
.sidebar-user { border: 0; background: color-mix(in srgb, var(--surface-alt) 80%, var(--sidebar)); border-radius: 12px; padding: 10px; }
.sidebar-avatar { border-radius: 10px; background: var(--primary-soft); color: var(--primary); }
.sidebar-profile-link { color: var(--muted); }
.sidebar-profile-link:hover { color: var(--primary); }
.theme, .menu-toggle { display: inline-grid; place-items: center; color: var(--muted); background: transparent; box-shadow: none; }
.theme svg, .menu-toggle svg { width: 18px; height: 18px; stroke-width: 1.8; }
.ui-action-icon { display: inline-flex; align-items: center; justify-content: center; margin-right: 7px; vertical-align: middle; }
.ui-action-icon svg { width: 16px; height: 16px; }
.theme:hover, .menu-toggle:hover { color: var(--text); background: var(--surface-alt); }
.button { box-shadow: none; font-weight: 680; white-space: nowrap; }
[data-theme="dark"] .button:not(.secondary):not(.ghost):not(.danger) { color: var(--bg); }
.button:not(:disabled):hover { transform: translateY(-1px); }
.button.ghost { background: transparent; }
.button.ghost:hover { border-color: var(--border); background: var(--surface-alt); color: var(--text); }
.card, .panel { border-color: color-mix(in srgb, var(--border) 70%, transparent); box-shadow: var(--shadow); }
.card:hover { transform: none; border-color: color-mix(in srgb, var(--border) 70%, transparent); box-shadow: var(--shadow); }
.metric-card { background: var(--surface); border-color: color-mix(in srgb, var(--border) 65%, transparent); box-shadow: var(--shadow); min-height: 124px; }
.metric-card::before { content: none !important; }
.ui-metric-icon { position: absolute; right: 17px; top: 17px; width: 34px; height: 34px; border-radius: 9px; color: var(--primary); background: var(--primary-soft); }
.ui-metric-icon svg { width: 18px; height: 18px; }
.metric-card b { margin-top: 12px; font-size: clamp(28px, 2.5vw, 33px); }
.dashboard-quote { color: var(--muted); font-size: 12px; font-weight: 500; }
.dashboard-welcome h1 { font-size: clamp(28px, 2.6vw, 36px); }
.dashboard-panel h2 { font-size: 16px; font-weight: 700; }
.dashboard-panel { min-height: 0; }
.dashboard-columns { align-items: start; }
.error-question h2 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden; white-space: normal; line-height: 1.45; font-weight: 650; }
.continue-premium { background: var(--surface-alt); border-color: transparent; }
.continue-icon { width: 42px; height: 42px; background: var(--primary-soft); color: var(--primary); }
.continue-icon svg, .dashboard-mini span svg { width: 19px; height: 19px; }
.dashboard-mini { border-color: color-mix(in srgb, var(--border) 70%, transparent); box-shadow: var(--shadow); min-height: 116px; }
.dashboard-mini span { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: var(--primary-soft); margin-bottom: 8px; }
.dashboard-mini:hover { transform: translateY(-1px); box-shadow: var(--shadow-raised); }
.dashboard-row { border-color: color-mix(in srgb, var(--border) 75%, transparent); }
.exam-head { margin-bottom: 20px; padding-top: 8px; }
.exam-head h1 { font-size: clamp(27px, 2.7vw, 36px); }
.breadcrumbs { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.breadcrumbs > span { display: inline-flex; align-items: center; color: var(--muted); opacity: .6; }
.breadcrumbs > span svg { width: 14px; height: 14px; }
.breadcrumbs strong { color: var(--muted); font-weight: 600; }
.breadcrumb-link:hover { color: var(--primary); }
.library-root-card, .subject-folder { border-color: color-mix(in srgb, var(--border) 70%, transparent); box-shadow: var(--shadow); background: var(--surface); }
.library-root-card:hover, .subject-folder:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); box-shadow: var(--shadow-raised); }
.library-root-card > span:first-child, .ui-folder-icon { width: 36px; height: 36px; border-radius: 9px; background: var(--primary-soft); color: var(--primary); display: inline-grid; place-items: center; }
.library-root-card > span:first-child svg, .ui-folder-icon svg { width: 19px; height: 19px; }
.subject-folder { position: relative; display: grid; grid-template-columns: 38px 1fr; gap: 2px 11px; align-items: center; text-align: left; }
.subject-folder .ui-folder-icon { grid-row: 1 / 3; }
.subject-folder strong, .subject-folder small { grid-column: 2; }
.official-exam-card { background: var(--surface); border-color: color-mix(in srgb, var(--border) 75%, transparent); box-shadow: var(--shadow); }
.official-exam-card:hover { box-shadow: var(--shadow-raised); }
.library-kind { background: var(--surface-alt); color: var(--muted); }
.library-assessment { background: var(--primary-soft); }
.library-status { font-weight: 700; }
.library-search input { background: var(--surface); box-shadow: none; }
.question-card { box-shadow: var(--shadow); }
.question { line-height: 1.72; }
.option { border-color: var(--border); }
.option:not(:disabled):hover { transform: none; border-color: color-mix(in srgb, var(--primary) 55%, var(--border)); }
.option.selected { box-shadow: inset 3px 0 0 var(--primary); }
.settings-panel, .settings-tabs { box-shadow: var(--shadow); }
.settings-tabs { border-color: transparent; background: var(--surface-alt); }
.settings-tabs button { font-weight: 630; }
.settings-tabs button.active { border-color: transparent; background: var(--primary-soft); color: var(--primary); }
.settings-panel { border-color: color-mix(in srgb, var(--border) 65%, transparent); }
.builder-layout { gap: 18px; }
.builder-chooser, .builder-settings, .builder-saved { border-color: color-mix(in srgb, var(--border) 65%, transparent); }
.builder-chooser h2, .builder-settings h2 { margin: 0 0 12px; font-size: 17px; font-weight: 690; }
.builder-filter-row { gap: 12px; }
.builder-source-tree { border: 0; background: var(--surface-alt); padding: 8px 12px; }
.builder-period { border-color: var(--border); }
.builder-period summary, .builder-subject summary { border-radius: 8px; font-weight: 650; }
.builder-period summary:hover, .builder-subject summary:hover { background: color-mix(in srgb, var(--primary) 7%, var(--surface-alt)); }
.builder-source { border-color: transparent; }
.builder-source:has(input:checked) { background: var(--primary-soft); }
.builder-summary { background: var(--surface-alt); }
.builder-settings #builder-create { width: 100%; }
.error-filters { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); padding: 12px; border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow); }
.error-question { gap: 20px; border-color: var(--border); }
.error-question-main { min-width: 0; }
.error-question h2 { line-height: 1.5; font-weight: 650; }
.error-question .result-actions { justify-content: flex-end; }
.custom-exam-row { align-items: center; }
.custom-exam-row > div:first-child { min-width: 0; }
.custom-exam-row strong { overflow-wrap: anywhere; }
.empty-state { border-style: solid; border-color: color-mix(in srgb, var(--border) 68%, transparent); background: var(--surface); }
.empty-state-icon { font-size: 0; }
.empty-state-icon svg { width: 20px; height: 20px; }
.toast { display: flex; align-items: center; gap: 9px; background: var(--surface-elevated); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-raised); }
.ui-toast-icon { display: inline-flex; color: var(--primary); }
.ui-toast-icon svg { width: 18px; height: 18px; }
.auth-kicker > span { display: inline-flex; align-items: center; }
.auth-kicker svg, .auth-trust svg { width: 15px; height: 15px; stroke-width: 1.8; }
.auth-trust span { gap: 6px; }
.auth-trust svg { color: var(--good); }
.pdf-action > span { display: inline-flex; align-items: center; }
.pdf-action svg { width: 16px; height: 16px; }
@media (min-width: 681px) {
  :root { --sidebar-width: 250px; }
  .top { padding: 15px 13px 10px; gap: 8px; border-color: var(--border); background: var(--sidebar) !important; box-shadow: none !important; }
  .brand { padding: 3px 7px 7px; }
  .top-nav { justify-content: flex-start; gap: 0; overflow-y: auto; overflow-x: hidden; min-height: 0; scrollbar-width: thin; }
  .top-nav .ui-nav-group { width: 100%; }
  .top-nav button[data-icon] { min-height: 39px; padding: 8px 11px; gap: 11px; border-radius: 9px; }
  .top-right { grid-template-columns: minmax(0,1fr) 36px 36px; padding: 8px 4px 0; border-color: var(--border); }
  .top-right .sidebar-user, .top-right .header-status { grid-column: 1 / -1; }
  .top-right #account-button { grid-column: 1; }
  .top-right .theme { grid-column: 2; }
  .top-right .menu-toggle { grid-column: 3; }
  .top-right #account-button { background: transparent; border-color: transparent; color: var(--muted); text-align: left; }
  .top-right #account-button:hover { background: var(--surface-alt); color: var(--text); }
  .sidebar-collapsed .top-nav button[data-icon] { font-size: 0; justify-content: center; padding: 10px; }
  .sidebar-collapsed .ui-nav-heading { font-size: 0; height: 1px; padding: 0; background: var(--border); margin: 10px 5px; }
  .sidebar-collapsed .ui-nav-icon svg { width: 20px; height: 20px; }
  .sidebar-collapsed .top-nav button[data-icon].active { box-shadow: inset 2px 0 0 var(--primary); }
  .sidebar-collapsed .top-right { grid-template-columns: 1fr; }
  .sidebar-collapsed .top-right .theme, .sidebar-collapsed .top-right .menu-toggle { grid-column: 1; }
  .wrap { padding-top: 32px; }
}
@media (min-width: 681px) and (max-width: 1100px) {
  :root { --sidebar-width: 76px; }
  .brand { justify-content: center; padding: 4px 0 8px; }
  .brand > div { display: none; }
  .brand-mark { width: 36px; height: 36px; }
  .top-nav button[data-icon] { font-size: 0; justify-content: center; padding: 10px; }
  .ui-nav-heading { font-size: 0; height: 1px; padding: 0; background: var(--border); margin: 10px 5px; }
  .top-right { grid-template-columns: 1fr; justify-items: center; padding-inline: 0; }
  .top-right .sidebar-user { display: flex; justify-content: center; width: 40px; padding: 4px; }
  .top-right .sidebar-user > span:nth-child(2), .top-right .header-status { display: none; }
  .top-right #account-button { display: grid; place-items: center; width: 38px; height: 38px; padding: 8px; font-size: 0; }
  .top-right #account-button .ui-action-icon { margin: 0; }
  .top-right .theme, .top-right .menu-toggle { grid-column: 1; }
}
@media (max-width: 900px) {
  .builder-settings { order: 0; }
}
@media (max-width: 680px) {
  html:has(body.mobile-menu-open) { overflow: hidden; }
  .top { background: var(--sidebar); border-color: var(--border); }
  .mobile-menu-open .top { z-index: 40; }
  .top-nav { padding: 17px 15px 20px; background: var(--sidebar); gap: 0; justify-content: flex-start; scrollbar-width: none; }
  .top-nav::-webkit-scrollbar { display: none; }
  .ui-drawer-brand { display: flex; align-items: center; gap: 11px; padding: 2px 7px 16px; margin-bottom: 3px; border-bottom: 1px solid var(--border); }
  .ui-drawer-brand img { width: 37px; height: 37px; object-fit: contain; }
  .ui-drawer-brand span { display: grid; }
  .ui-drawer-brand strong { font-size: 15px; line-height: 1.2; }
  .ui-drawer-brand small { display: block; font-size: 11px; color: var(--muted); }
  .top-nav button[data-icon] { min-height: 46px; padding: 11px 12px; gap: 12px; color: var(--muted); border-color: transparent; }
  .ui-nav-heading { margin-top: 17px; }
  .mobile-nav-actions { margin-top: 19px; }
  .mobile-nav-actions .ui-mobile-profile { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border: 0; border-radius: 10px; background: var(--surface-alt); color: var(--text); text-align: left; }
  .ui-mobile-profile > span:nth-child(2) { display: grid; gap: 2px; min-width: 0; flex: 1; }
  .ui-mobile-profile strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
  .ui-mobile-profile small { color: var(--muted); font-size: 11px; }
  .ui-mobile-profile > svg { width: 17px; height: 17px; color: var(--muted); }
  .mobile-menu-overlay { background: rgba(3,12,26,.61); }
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .metric-card:last-child { grid-column: 1 / -1; }
  .metric-card { min-height: 106px; }
  .ui-metric-icon { width: 28px; height: 28px; right: 12px; top: 12px; }
  .ui-metric-icon svg { width: 16px; height: 16px; }
  .wrap { padding-top: 22px; }
  .subject-folder { min-height: 76px !important; }
  .error-filters { grid-template-columns: repeat(2,minmax(0,1fr)); padding: 10px; }
  .error-question .result-actions .button, .custom-exam-row .result-actions .button { min-height: 44px; }
}
@media (max-width: 400px) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card:last-child { grid-column: auto; }
  .top-nav { width: min(89vw, 330px); }
  .error-filters { grid-template-columns: 1fr; }
}

/* Shared visual finish: no changes to navigation or study behavior. */
body { -webkit-font-smoothing: antialiased; }
main h1 { letter-spacing: -.035em; line-height: 1.16; font-weight: 720; }
main h2 { letter-spacing: -.018em; }
main p.muted { line-height: 1.65; }
.eyebrow { font-size: 10px; letter-spacing: .13em; font-weight: 700; }
.top-nav button[data-icon] { font-weight: 550; }
.top-nav button[data-icon].active { font-weight: 650; }
.sidebar-user { background: transparent; padding: 10px 4px; }
.sidebar-avatar { border-radius: 50%; }
.header-status { font-size: 10px; }
.button { border-radius: var(--radius-sm); font-weight: 620; transition: background .18s ease, border-color .18s ease, box-shadow .18s ease; }
.button:not(:disabled):hover { transform: none; }
.button:focus-visible, .subject-folder:focus-visible, .library-root-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.button.secondary { background: var(--surface-alt); color: var(--text); border-color: var(--border); }
.button.secondary:hover { border-color: var(--primary); }
main :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), select, textarea) {
  border-radius: var(--radius-sm); box-shadow: none; transition: border-color .18s ease, box-shadow .18s ease;
}
main :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), select, textarea):focus-visible {
  outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.metric-card { padding: 20px 22px; min-height: 130px; }
.metric-card > span:not(.ui-metric-icon) { font-weight: 550; padding-right: 28px; }
.ui-metric-icon { background: transparent; color: var(--muted); }
.metric-card b { font-weight: 650; letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.dashboard-welcome { padding-bottom: 6px; }
.dashboard-panel { padding: 22px; border-radius: var(--radius-md); }
.dashboard-panel h2 { font-weight: 650; }
.dashboard-panel-head .button.ghost { font-size: 12px; min-height: 32px; padding: 6px 9px; }
.dashboard-row strong { font-weight: 600; }
.dashboard-row small { font-size: 12px; }
.dashboard-score { font-size: 15px; font-weight: 650; }
.continue-premium { padding: 18px 0 0; border-radius: 0; border: 0; border-top: 1px solid var(--border); background: transparent; gap: 12px; }
.continue-premium h3 { font-weight: 650; }
.subject-progress-track { height: 6px; background: var(--surface-alt); }
.subject-progress-track i { background: var(--primary); }
.dashboard-mini { padding: 20px; min-height: 132px; text-align: left; }
.dashboard-mini strong { font-size: 15px; font-weight: 650; }
.dashboard-mini small { font-size: 12px; line-height: 1.6; }
.dashboard-mini span { background: transparent; color: var(--primary); width: 24px; height: 24px; }
.library-root-card::after { display: none; }
.library-root-card strong, .subject-folder strong { font-weight: 650; }
.library-kind { padding-left: 0; background: transparent; font-weight: 550; }
.official-exam-card h2 { font-size: 17px; font-weight: 650; }
.official-card-actions .pdf-action { text-decoration: none; }
.library-status, .library-assessment { font-weight: 600; }
.question { font-weight: 400; line-height: 1.8; }
.option-choice { line-height: 1.65; }
.settings-tabs button, .builder-filter-row label { font-weight: 600; }
.empty-state { padding: 36px 24px; }
.empty-state h2 { font-weight: 650; }

@media (min-width: 1101px) {
  .dashboard-shell { grid-template-columns: minmax(0,1.15fr) minmax(0,1fr); gap: 20px; align-items: start; }
  .dashboard-shell > .dashboard-welcome, .dashboard-shell > .metric-grid { grid-column: 1 / -1; }
  .dashboard-shell > .dashboard-columns:not(.custom-dashboard-links) { display: contents; }
  .dashboard-columns:has(#dashboard-history) > article:first-child { grid-column: 1; grid-row: 3; }
  .dashboard-columns:has(#dashboard-history) > article:last-child { grid-column: 2; grid-row: 3 / span 2; align-self: stretch; }
  .dashboard-columns:has(#dashboard-performance) > article { grid-column: 1; grid-row: 4; }
  .dashboard-mini-grid { grid-column: 1; grid-row: 5; gap: 16px; }
  .dashboard-shell > .custom-dashboard-links { grid-column: 2; grid-row: 5; grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .dashboard-panel { padding: 18px; }
  .metric-card { padding: 18px; min-height: 118px; }
  .continue-premium { gap: 12px; }
  .continue-premium .button { margin-left: 54px; }
  .empty-state { padding: 28px 18px; }
}
