:root {
  color-scheme: dark;
  --bg: #07111b;
  --bg-soft: #0b1723;
  --panel: #0d1b28;
  --panel-2: #101f2d;
  --panel-hover: #142637;
  --border: #263747;
  --border-soft: #1a2a38;
  --text: #f4f7fa;
  --muted: #94a3b4;
  --muted-2: #6f8192;
  --accent: #ffad00;
  --accent-2: #ff8a00;
  --accent-soft: rgba(255, 173, 0, .12);
  --green: #2bdb70;
  --green-soft: rgba(22, 163, 74, .2);
  --red: #ff514c;
  --red-soft: rgba(220, 38, 38, .18);
  --shadow: 0 18px 48px rgba(0, 0, 0, .22);
  --radius: 14px;
  --question-font: 1rem;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5f8;
  --bg-soft: #f8fafc;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --panel-hover: #f1f5f9;
  --border: #d8e0e8;
  --border-soft: #e8edf2;
  --text: #172333;
  --muted: #64748b;
  --muted-2: #8996a7;
  --accent: #ed9400;
  --accent-2: #f47c00;
  --accent-soft: rgba(237, 148, 0, .1);
  --green: #15803d;
  --green-soft: rgba(34, 197, 94, .1);
  --red: #dc2626;
  --red-soft: rgba(239, 68, 68, .08);
  --shadow: 0 14px 40px rgba(20, 39, 61, .07);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); font-family: Inter, system-ui, sans-serif; font-size: 14px; transition: background .25s, color .25s; }
button, input, select, textarea { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button { border: 0; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.skip-link { position: fixed; z-index: 100; left: 16px; top: -60px; padding: 12px 18px; background: var(--accent); color: #101820; font-weight: 700; border-radius: 8px; transition: top .2s; }
.skip-link:focus { top: 12px; }
.app-shell { width: min(1580px, calc(100% - 24px)); min-height: calc(100vh - 24px); margin: 12px auto; overflow: hidden; border: 1px solid var(--border-soft); border-radius: 20px; background: linear-gradient(145deg, var(--bg), var(--bg-soft)); box-shadow: 0 24px 80px rgba(0,0,0,.2); }

.topbar { height: 74px; display: grid; grid-template-columns: 160px minmax(250px, 370px) 1fr auto; align-items: center; gap: 22px; padding: 0 26px; border-bottom: 1px solid var(--border-soft); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(18px); }
.brand { display: flex; color: var(--text); }
.brand img { width: 148px; height: auto; }
.global-search, .filter-search { display: flex; align-items: center; gap: 10px; min-width: 0; height: 42px; padding: 0 13px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; color: var(--muted); }
.global-search input, .filter-search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; }
.global-search input::placeholder, .filter-search input::placeholder, textarea::placeholder { color: var(--muted-2); }
.global-search kbd { padding: 3px 6px; border: 1px solid var(--border); border-radius: 5px; font-size: 10px; color: var(--muted-2); white-space: nowrap; }
.desktop-nav { height: 100%; display: flex; justify-content: center; gap: clamp(16px, 2.2vw, 38px); }
.desktop-nav a { position: relative; display: flex; align-items: center; color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; }
.desktop-nav a:hover, .desktop-nav a.active { color: var(--text); }
.desktop-nav a.active { color: var(--accent); font-weight: 700; }
.desktop-nav a.active::after { content: ""; position: absolute; height: 2px; left: 0; right: 0; bottom: 0; background: var(--accent); border-radius: 2px 2px 0 0; }
.top-actions { display: flex; align-items: center; gap: 5px; }
.icon-button { position: relative; display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border-radius: 9px; background: transparent; color: var(--muted); }
.icon-button:hover { background: var(--panel-2); color: var(--text); }
.notification span { position: absolute; top: 1px; right: 1px; display: grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; background: var(--accent); color: #171717; font-size: 9px; font-weight: 800; }
.moon-icon { display: none; }
[data-theme="light"] .sun-icon { display: none; }
[data-theme="light"] .moon-icon { display: block; }
.profile-button { display: flex; align-items: center; gap: 8px; padding: 4px 7px; background: transparent; border-radius: 30px; }
.profile-button:hover { background: var(--panel-2); }
.profile-button svg { width: 14px; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border: 2px solid var(--accent); border-radius: 50%; background: linear-gradient(135deg,#263748,#101821); color: white; font-size: 11px; font-weight: 700; }
.profile-name { font-size: 12px; }

main { padding: 0 26px 30px; }
.hero { display: grid; grid-template-columns: minmax(270px, 1fr) minmax(620px, 1.9fr); align-items: end; gap: 36px; padding: 18px 2px 22px; }
.breadcrumb { margin: 0 0 10px; color: var(--muted); font-size: 12px; }
.breadcrumb span { padding: 0 9px; color: var(--muted-2); }
h1 { margin: 0; font-size: clamp(25px, 2.4vw, 36px); line-height: 1.1; letter-spacing: -.7px; }
.hero-copy { margin: 8px 0 0; color: var(--muted); }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stat-card { min-width: 0; display: flex; align-items: center; gap: 14px; min-height: 86px; padding: 14px 18px; border: 1px solid var(--border-soft); border-radius: var(--radius); background: linear-gradient(145deg, var(--panel), var(--panel-2)); box-shadow: var(--shadow); }
.stat-icon { flex: 0 0 auto; display: grid; place-items: center; width: 47px; height: 47px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.stat-icon svg { width: 25px; height: 25px; }
.stat-card div { display: grid; gap: 2px; min-width: 0; }
.stat-card small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-card strong { font-size: 22px; letter-spacing: -.3px; }
.stat-card strong b { font-size: 13px; }
.stat-card em { color: var(--green); font-size: 11px; font-style: normal; font-weight: 600; }

.workspace { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 14px; }
.filters-panel, .questions-panel { border: 1px solid var(--border); border-radius: var(--radius); background: linear-gradient(155deg, var(--panel), color-mix(in srgb, var(--panel-2) 84%, var(--bg))); }
.filters-panel { align-self: start; position: sticky; top: 12px; padding: 18px 16px; }
.panel-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.panel-title h2 { margin: 2px 0 0; font-size: 19px; }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; }
.close-filters { display: none; }
.filter-search { height: 39px; margin-bottom: 14px; background: transparent; }
.filter-search svg { width: 17px; }
.filter-fields { display: grid; gap: 10px; }
.filter-fields label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 500; }
select { width: 100%; height: 38px; padding: 0 34px 0 10px; outline: 0; border: 1px solid var(--border); border-radius: 7px; background: var(--panel-2); color: var(--text); font-size: 12px; }
select:focus, input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.switch-list { display: grid; gap: 4px; margin: 14px 0; padding: 12px 0; border-top: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft); }
.switch-list label { display: flex; align-items: center; justify-content: space-between; min-height: 34px; color: var(--muted); font-size: 12px; cursor: pointer; }
.switch-list input { position: absolute; opacity: 0; pointer-events: none; }
.switch-list i { position: relative; width: 34px; height: 19px; border-radius: 20px; background: #526170; transition: .2s; }
.switch-list i::after { content: ""; position: absolute; width: 15px; height: 15px; top: 2px; left: 2px; border-radius: 50%; background: white; transition: .2s; }
.switch-list input:checked + i { background: var(--accent); }
.switch-list input:checked + i::after { transform: translateX(15px); }
.section-label { display: flex; align-items: center; gap: 7px; margin-bottom: 9px; color: var(--muted); font-size: 12px; }
.section-label b { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 10px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-list button { display: flex; align-items: center; gap: 5px; padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel-2); color: var(--muted); font-size: 10px; }
.tag-list button:hover { border-color: var(--accent); color: var(--text); }
.tag-list svg { width: 12px; height: 12px; }
.filter-actions { display: grid; grid-template-columns: .9fr 1.2fr; gap: 8px; margin-top: 22px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 8px; font-weight: 600; font-size: 12px; transition: transform .15s, border-color .2s, background .2s; }
.button:active { transform: translateY(1px); }
.button svg { width: 17px; }
.button.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #141414; box-shadow: 0 7px 20px rgba(255, 157, 0, .16); }
.button.primary:hover { filter: brightness(1.06); }
.button.secondary { border: 1px solid var(--border); background: color-mix(in srgb, var(--panel-2) 70%, transparent); color: var(--muted); }
.button.secondary:hover { border-color: var(--accent); color: var(--text); }

.questions-panel { min-width: 0; padding: 16px; }
.results-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.results-toolbar p { margin: 0; color: var(--muted); }
.results-toolbar p strong { color: var(--text); }
.toolbar-controls { display: flex; gap: 8px; }
.toolbar-controls label { position: relative; }
.toolbar-controls label span { position: absolute; width: 1px; height: 1px; overflow: hidden; }
.toolbar-controls select { width: auto; min-width: 128px; }
.font-controls { display: flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.font-controls button { width: 38px; background: var(--panel-2); color: var(--muted); }
.font-controls button + button { border-left: 1px solid var(--border); }
.font-controls button:hover { color: var(--accent); }
.question-card, .explanation-card { border: 1px solid var(--border); border-radius: 11px; background: color-mix(in srgb, var(--panel) 88%, transparent); }
.question-card { padding: 18px; font-size: var(--question-font); }
.question-header { display: flex; justify-content: space-between; gap: 15px; }
.question-number { margin: 0 0 10px; font-size: 1.08em; font-weight: 600; }
.question-number span, .question-number small { color: var(--muted); font-weight: 400; }
.topic-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.topic-tags span { padding: 5px 9px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel-2); color: var(--muted); font-size: .72em; }
.difficulty { height: 34px; display: flex; align-items: center; gap: 3px; padding: 0 9px; border: 1px solid var(--border); border-radius: 7px; background: transparent; color: var(--muted); }
.difficulty i { width: 3px; border-radius: 2px; background: var(--accent); }
.difficulty i:nth-child(1) { height: 7px; }.difficulty i:nth-child(2) { height: 12px; }.difficulty i:nth-child(3) { height: 17px; opacity: .3; }
.difficulty span { margin: 0 6px; font-size: .74em; }
.difficulty svg { width: 13px; }
.metadata { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 14px 0 12px; color: var(--muted); font-size: .73em; }
.metadata i { width: 3px; height: 3px; border-radius: 50%; background: var(--muted-2); }
.question-text { max-width: 900px; margin: 0 0 14px; line-height: 1.55; color: color-mix(in srgb, var(--text) 91%, var(--muted)); }
.feedback { display: none; align-items: center; gap: 9px; margin: 0 0 12px; padding: 10px 11px; border-top: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft); color: var(--muted); font-size: .78em; }
.feedback.visible { display: flex; }
.feedback svg { flex: 0 0 auto; width: 17px; color: var(--red); }
.feedback strong { color: var(--red); }.feedback em { color: var(--green); font-style: normal; font-weight: 700; }
.answers { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; }
.answers legend { position: absolute; width: 1px; height: 1px; overflow: hidden; }
.answers label { position: relative; display: grid; grid-template-columns: 29px 1fr 20px; align-items: center; gap: 9px; min-height: 43px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--panel-2); color: var(--muted); cursor: pointer; transition: .15s; }
.answers label:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); color: var(--text); }
.answers input { position: absolute; opacity: 0; pointer-events: none; }
.answers .letter { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--muted-2); border-radius: 50%; color: var(--text); }
.answers label > svg { display: none; color: currentColor; }
.answers label.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.answers label.selected .letter { border-color: var(--accent); color: var(--accent); }
.answers.answered label.wrong { border-color: var(--red); background: var(--red-soft); color: color-mix(in srgb, var(--red) 68%, var(--text)); }
.answers.answered label.wrong .letter { border-color: var(--red); background: var(--red); color: white; }
.answers.answered label.correct { border-color: var(--green); background: var(--green-soft); color: color-mix(in srgb, var(--green) 70%, var(--text)); }
.answers.answered label.correct .letter { border-color: var(--green); background: color-mix(in srgb, var(--green) 80%, #061b0d); color: white; }
.answers.answered label.wrong > svg, .answers.answered label.correct > svg { display: block; }
.question-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.answer-button { min-width: 150px; }
.next-button { margin-left: auto; }
.toggle-action.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.explanation-card { display: none; margin-top: 10px; overflow: hidden; }
.explanation-card.visible { display: block; }
.tabs { display: flex; gap: 18px; padding: 0 16px; border-bottom: 1px solid var(--border-soft); overflow-x: auto; }
.tabs button { position: relative; min-height: 44px; padding: 0 5px; background: transparent; color: var(--muted); white-space: nowrap; font-size: 12px; }
.tabs button.active { color: var(--accent); font-weight: 700; }
.tabs button.active::after { content: ""; position: absolute; height: 2px; left: 0; right: 0; bottom: 0; background: var(--accent); }
.tabs button span { padding: 2px 5px; border-radius: 10px; background: var(--panel-hover); font-size: 9px; }
.tab-content { display: none; padding: 14px 18px; color: var(--muted); line-height: 1.55; }
.tab-content.active { display: block; }
.tab-content p { margin: 0 0 7px; }
.tab-content strong { color: var(--accent); }
.reference { font-size: 12px; }
.stats-content.active { display: flex; gap: 10px; }
.stats-content div { flex: 1; display: grid; place-items: center; gap: 3px; padding: 12px; border: 1px solid var(--border-soft); border-radius: 8px; background: var(--panel-2); }
.stats-content div strong { font-size: 20px; }
.stats-content div span { font-size: 11px; }
.tab-content textarea { width: 100%; min-height: 90px; padding: 12px; resize: vertical; outline: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); }
.tab-content textarea + button { margin-top: 8px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 16px 0 2px; }
.pagination button { display: grid; place-items: center; min-width: 38px; height: 38px; padding: 0 9px; border: 1px solid var(--border); border-radius: 7px; background: var(--panel-2); color: var(--muted); }
.pagination button:hover, .pagination button.active { border-color: var(--accent); color: var(--text); }
.pagination button.active { background: var(--accent); color: #151515; font-weight: 800; }
.pagination svg { width: 15px; }
.mobile-filter-trigger, .mobile-nav { display: none; }
.filters-backdrop { display: none; }
.toast { position: fixed; z-index: 80; left: 50%; bottom: 25px; display: flex; align-items: center; gap: 9px; padding: 11px 16px; border: 1px solid var(--green); border-radius: 9px; background: var(--panel); color: var(--text); box-shadow: var(--shadow); transform: translate(-50%, 120px); opacity: 0; transition: .3s; }
.toast.visible { transform: translate(-50%, 0); opacity: 1; }
.toast svg { color: var(--green); }

@media (max-width: 1180px) {
  .topbar { grid-template-columns: 150px minmax(220px, 1fr) auto; }
  .desktop-nav { display: none; }
  .hero { grid-template-columns: 1fr; gap: 18px; }
  .stats-grid { max-width: 760px; }
  .question-actions { flex-wrap: wrap; }
  .next-button { margin-left: 0; }
}

@media (max-width: 860px) {
  .app-shell { width: 100%; min-height: 100vh; margin: 0; border: 0; border-radius: 0; padding-bottom: 70px; }
  .topbar { height: 64px; grid-template-columns: 144px 1fr auto; padding: 0 18px; position: sticky; top: 0; z-index: 40; }
  .global-search { justify-self: end; width: 40px; padding: 0; justify-content: center; border: 0; background: transparent; }
  .global-search input, .global-search kbd { display: none; }
  .profile-name { display: none; }
  main { padding: 0 18px 26px; }
  .hero { padding-top: 16px; }
  .stats-grid { gap: 8px; }
  .stat-card { min-height: 74px; padding: 11px; }
  .stat-icon { width: 38px; height: 38px; }
  .stat-icon svg { width: 21px; }
  .stat-card strong { font-size: 18px; }
  .workspace { grid-template-columns: 1fr; }
  .mobile-filter-trigger { display: flex; align-items: center; width: 100%; height: 46px; margin-bottom: 10px; padding: 0 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel); color: var(--text); font-weight: 700; }
  .mobile-filter-trigger svg { margin-right: 9px; }.mobile-filter-trigger b { margin-left: auto; padding: 5px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 10px; }
  .filters-backdrop { position: fixed; z-index: 50; inset: 0; background: rgba(0,0,0,.5); backdrop-filter: blur(3px); }
  .filters-backdrop.visible { display: block; }
  .filters-panel { position: fixed; z-index: 60; top: 0; left: 0; bottom: 0; width: min(360px, 90vw); overflow-y: auto; border-radius: 0 14px 14px 0; transform: translateX(-105%); transition: transform .25s; }
  .filters-panel.open { transform: translateX(0); }
  .close-filters { display: grid; }
  .questions-panel { padding: 12px; }
  .mobile-nav { position: fixed; z-index: 45; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); height: calc(64px + env(safe-area-inset-bottom)); padding: 7px 10px env(safe-area-inset-bottom); border-top: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 95%, transparent); backdrop-filter: blur(18px); }
  .mobile-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); text-decoration: none; font-size: 9px; }
  .mobile-nav a.active { color: var(--accent); }
  .mobile-nav svg { width: 19px; height: 19px; }
}

@media (max-width: 600px) {
  body { font-size: 13px; }
  .topbar { grid-template-columns: 138px 1fr auto; gap: 6px; padding: 0 12px; }
  .brand img { width: 135px; }
  .top-actions .icon-button:nth-child(2) { display: none; }
  .avatar { width: 30px; height: 30px; }
  main { padding: 0 10px 22px; }
  .hero { gap: 13px; padding-bottom: 14px; }
  .breadcrumb { margin-bottom: 8px; font-size: 10px; }
  h1 { font-size: 23px; }
  .hero-copy { font-size: 11px; }
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-card { display: grid; gap: 6px; min-height: 94px; padding: 9px; }
  .stat-icon { width: 30px; height: 30px; }
  .stat-icon svg { width: 17px; }
  .stat-card small { font-size: 8px; }
  .stat-card strong { font-size: 16px; }
  .stat-card strong b { font-size: 9px; }
  .stat-card em { font-size: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .results-toolbar { align-items: flex-start; }
  .results-toolbar p { padding-top: 8px; font-size: 11px; }
  .toolbar-controls label:first-child, .font-controls { display: none; }
  .toolbar-controls select { min-width: 112px; height: 34px; font-size: 10px; }
  .question-card { padding: 13px; }
  .question-header { align-items: flex-start; }
  .question-number { font-size: 1em; }
  .topic-tags span { font-size: .63em; }
  .difficulty { flex: 0 0 auto; height: 31px; padding: 0 7px; }
  .difficulty i { display: none; }
  .metadata { gap: 7px; }
  .question-text { line-height: 1.48; }
  .answers label { grid-template-columns: 25px 1fr 17px; min-height: 42px; padding: 7px; font-size: .87em; }
  .answers .letter { width: 24px; height: 24px; }
  .question-actions { display: grid; grid-template-columns: repeat(3, 1fr); }
  .question-actions .button { min-width: 0; padding: 0 8px; }
  .question-actions .button span { display: none; }
  .answer-button { grid-column: 1 / -1; }
  .next-button { grid-column: 1 / -1; }
  .tabs { gap: 11px; padding: 0 10px; }
  .tabs button { font-size: 10px; }
  .tab-content { padding: 12px; font-size: 11px; }
  .stats-content.active { display: grid; }
  .pagination { gap: 5px; }
  .pagination button { min-width: 32px; height: 34px; padding: 0 7px; }
  .pagination button:nth-of-type(4), .pagination button:nth-of-type(5), .pagination span { display: none; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
