:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #fff;
  --ink: #172338;
  --muted: #7c8496;
  --line: #e9ecf2;
  --accent: #5558e8;
  --accent-hover: #4447d3;
  --accent-soft: #eeefff;
  --green: #16896c;
  --green-soft: #edf8f2;
  --red: #cf5262;
  --red-soft: #fff1f2;
  --amber: #a66c16;
  --amber-soft: #fff8e8;
  --sidebar-width: 232px;
  --radius: 18px;
  --shadow: 0 8px 30px rgb(31 40 71 / 4%);
  --question-font-size: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.answer-access { margin: 18px 0; }
.answer-explanation { margin-top: 15px; color: #344054; font-size: 14px; line-height: 1.9; }
.answer-explanation > strong { color: #26354d; }
.answer-explanation p { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.ordered-answer-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px; margin: 20px 0; }
.ordered-answer-fields .select { width: 100%; }
@media(max-width:560px) { .ordered-answer-fields { grid-template-columns:1fr; } .answer-explanation { font-size:14px; } }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 96px; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.6; }
body.modal-open { overflow: hidden; }
button, input, select, textarea { font: inherit; }
button, a, input, select, summary { touch-action: manipulation; }
button { color: inherit; cursor: pointer; }
button { -webkit-appearance: none; appearance: none; }
button:disabled { cursor: not-allowed; opacity: .45; }
a { color: var(--accent); text-decoration: none; }
img, svg { display: block; max-width: 100%; }
svg { flex-shrink: 0; }
button svg, a svg { pointer-events: none; }
input, select, textarea { min-width: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #a9adff; outline-offset: 4px; }
::selection { color: #24275b; background: #dfe0ff; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Navigation */
.app-shell { min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 30px 18px 20px;
  overflow: auto;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 9px; margin-bottom: 36px; color: var(--ink); }
.brand-icon { width: 43px; height: 43px; display: grid; place-items: center; border-radius: 13px; color: white; background: var(--accent); box-shadow: 0 6px 14px #5558e827; flex-shrink: 0; }
.brand-icon svg { width: 25px; height: 25px; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.25; }
.brand-copy strong, .brand-copy b { font-size: 23px; font-weight: 750; letter-spacing: 3px; }
.brand-copy span, .brand-copy small { font-size: 10px; letter-spacing: 1.5px; color: var(--muted); margin-top: 6px; }
.nav-list { display: grid; gap: 6px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 47px; padding: 11px 14px; border: 0; border-radius: 11px; background: transparent; color: #657086; text-align: left; transition: background .15s ease, color .15s ease; }
.nav-item:hover { color: var(--ink); background: #f6f7fa; }
.nav-item.active { color: var(--accent); background: var(--accent-soft); font-weight: 650; }
.nav-icon { display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex-shrink: 0; }
.nav-icon svg { width: 20px; height: 20px; }
.nav-label { flex: 1; }
.nav-count { min-width: 24px; padding: 1px 6px; background: #f0f2f6; border-radius: 6px; font-size: 11px; font-variant-numeric: tabular-nums; text-align: center; }
.nav-item.active .nav-count { color: var(--accent); background: #dfe0fd; }
.sidebar-section { margin-top: 30px; }
.sidebar-label { padding: 0 14px; margin: 0 0 10px; color: #9aa1af; font-size: 10px; font-weight: 650; letter-spacing: 1.7px; text-transform: uppercase; }
.chapter-link { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 8px 14px; border: 0; border-radius: 9px; background: transparent; color: #7a8394; font-size: 12px; text-align: left; }
.chapter-link::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: #c7cbd7; flex-shrink: 0; }
.chapter-link:hover, .chapter-link.active { color: var(--accent); background: #f7f7fe; }
.chapter-link.active::before { background: var(--accent); }
.chapter-link .nav-count { margin-left: auto; font-size: 10px; }
.sidebar-footer { margin-top: auto; padding: 28px 12px 0; color: var(--muted); font-size: 11px; }
.sidebar-footer p { margin: 0 0 8px; }
.sidebar-footer strong { color: #4a5367; font-weight: 600; }
.sidebar-progress { display: flex; justify-content: space-between; margin-bottom: 9px; }
.sidebar-footer .progress-track { height: 5px; margin-bottom: 13px; }
.main-area { margin-left: var(--sidebar-width); min-width: 0; }
.topbar { height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 40px; border-bottom: 1px solid var(--line); background: rgb(255 255 255 / 88%); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.breadcrumb { display: flex; align-items: center; gap: 10px; min-width: 0; color: #9198a8; font-size: 12px; }
.breadcrumb span:last-child { color: #3d485e; }
.breadcrumb svg { width: 15px; height: 15px; color: #afb5c1; }
.topbar-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.storage-badge { display: flex; align-items: center; gap: 7px; color: #7b8495; font-size: 11px; }
.storage-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #48ac8c; box-shadow: 0 0 0 3px #eff9f4; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 8px; border: 1px solid var(--line); border-radius: 11px; color: #7b8495; background: white; flex-shrink: 0; }
.icon-button svg { width: 19px; height: 19px; }
.icon-button:hover { color: var(--accent); border-color: #d3d4f5; background: #fafaff; }
.icon-button.active { color: var(--accent); border-color: #dddefb; background: var(--accent-soft); }
.icon-button.favorite, .icon-button[aria-pressed="true"] { color: #c78c2c; background: #fff9ed; border-color: #f3e6cb; }
.mobile-menu, .bottom-nav, .sidebar-backdrop { display: none; }

/* Page structure */
.page-content { width: 100%; max-width: 1200px; padding: 37px 40px 50px; margin: 0 auto; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.eyebrow { color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: 2.1px; text-transform: uppercase; margin: 0 0 8px; }
.page-title { margin: 0 0 9px; font-size: clamp(26px, 2.5vw, 34px); line-height: 1.25; font-weight: 700; letter-spacing: -1px; }
.page-description { color: #8b93a4; margin: 0; font-size: 12px; line-height: 1.85; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 30px 0 17px; }
.section-title { display: flex; align-items: center; gap: 9px; margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.2px; }
.section-title small { color: #9299a8; font-size: 11px; font-weight: 400; }
.text-link { display: inline-flex; align-items: center; gap: 4px; padding: 5px 0; border: 0; background: transparent; color: var(--accent); font-size: 11px; white-space: nowrap; }
.text-link svg { width: 14px; height: 14px; }
.text-link:hover { color: var(--accent-hover); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 43px; padding: 10px 19px; border: 1px solid transparent; border-radius: 10px; font-size: 12px; font-weight: 600; line-height: 1.5; text-align: center; transition: background .15s ease, border-color .15s ease, box-shadow .15s ease; }
.button svg { width: 17px; height: 17px; }
.button.primary { color: white; background: var(--accent); }
.button.primary:hover:not(:disabled) { background: var(--accent-hover); box-shadow: 0 4px 10px #5558e81a; }
.button.secondary { background: white; border-color: #e3e6ed; color: #5c677d; }
.button.secondary:hover:not(:disabled) { background: #fafaff; border-color: #bfc1f6; color: var(--accent); }
.button.ghost { background: transparent; color: #7b8497; }
.button.ghost:hover:not(:disabled) { background: #f0f2f7; color: #3d4962; }
.button.danger { color: var(--red); background: #fff7f8; border-color: #f3dce1; }
.button.danger:hover:not(:disabled) { background: #ffedf0; }
.button.small { min-height: 34px; padding: 6px 12px; border-radius: 8px; font-size: 11px; }
.button.full { width: 100%; }

/* Study overview */
.hero-card { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 28px; min-height: 218px; padding: 30px 35px; overflow: hidden; border-radius: 20px; background: linear-gradient(112deg, #6264ee 0%, #5459e5 55%, #7573ec 100%); color: white; box-shadow: 0 8px 22px #5558e815; }
.hero-copy { position: relative; z-index: 2; max-width: 590px; }
.hero-kicker { display: inline-flex; align-items: center; gap: 6px; font-size: 10px; color: #e0e0ff; letter-spacing: 1px; margin: 0 0 8px; }
.hero-kicker svg { width: 13px; height: 13px; }
.hero-title { font-size: clamp(22px, 2.2vw, 29px); font-weight: 650; line-height: 1.4; letter-spacing: -.5px; margin: 0 0 8px; }
.hero-description { color: #e0e0ff; font-size: 11px; line-height: 1.85; max-width: 400px; margin: 0; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 11px; margin-top: 22px; }
.hero-card .button.primary { color: #5759d8; background: #fff; box-shadow: 0 4px 14px #30329915; }
.hero-card .button.primary:hover:not(:disabled) { color: #3337ba; background: #f2f2ff; }
.hero-card .button.secondary, .hero-card .button.ghost { color: #fff; background: #ffffff12; border-color: #ffffff38; }
.hero-card .button.secondary:hover:not(:disabled), .hero-card .button.ghost:hover:not(:disabled) { background: #ffffff20; }
.hero-art { position: absolute; right: -42px; top: -54px; width: 350px; height: 350px; border: 1px solid #ffffff20; border-radius: 50%; pointer-events: none; }
.hero-art::before, .hero-art::after { content: ""; position: absolute; border: 1px solid #ffffff22; border-radius: 50%; }
.hero-art::before { inset: 43px; background: radial-gradient(circle at 30% 30%, #ffffff08, #ffffff00 70%); }
.hero-art::after { inset: 88px; border-color: #ffffff30; background: #ffffff06; box-shadow: 0 0 0 30px #ffffff03; }
.hero-art svg { position: absolute; inset: 130px; width: 78px; height: 78px; opacity: .35; color: white; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-top: 22px; }
.stat-card { position: relative; min-width: 0; padding: 19px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.stat-icon { display: flex; align-items: center; justify-content: center; position: absolute; top: 19px; right: 18px; width: 31px; height: 31px; border-radius: 9px; color: #7679df; background: #f2f2fe; }
.stat-icon svg { width: 16px; height: 16px; }
.stat-card:nth-child(2) .stat-icon { color: #53a18a; background: #edf8f3; }
.stat-card:nth-child(3) .stat-icon { color: #c99145; background: #fff7eb; }
.stat-card:nth-child(4) .stat-icon { color: #a17abd; background: #f7f0fc; }
.stat-value { display: block; margin: 12px 0 2px; font-size: 29px; line-height: 1.2; font-weight: 700; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.stat-value small { color: #929aab; font-size: 13px; font-weight: 400; margin-left: 2px; }
.stat-label { color: #9198a8; font-size: 11px; }
.stat-card > .stat-label:first-child { display: block; padding-right: 30px; }
.chapter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.chapter-card { position: relative; display: flex; gap: 15px; min-width: 0; width: 100%; padding: 22px; background: white; border: 1px solid var(--line); border-radius: 15px; text-align: left; box-shadow: 0 3px 10px #15274402; transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
.chapter-card:hover { border-color: #cbcdef; box-shadow: 0 6px 20px #414a8709; transform: translateY(-2px); }
.chapter-icon { width: 41px; height: 41px; display: grid; place-items: center; border-radius: 12px; flex-shrink: 0; color: #6669de; background: #f0f0fe; font-size: 17px; font-weight: 600; }
.chapter-icon svg { width: 21px; height: 21px; }
.chapter-card:nth-child(4n + 2) .chapter-icon { color: #4c9c88; background: #edf8f4; }
.chapter-card:nth-child(4n + 3) .chapter-icon { color: #b98c48; background: #fff7e9; }
.chapter-card:nth-child(4n + 4) .chapter-icon { color: #9b78bd; background: #f7f0fc; }
.chapter-meta { flex: 1; min-width: 0; }
.chapter-title { display: block; margin: 0 0 5px; font-size: 14px; font-weight: 650; letter-spacing: -.2px; }
.chapter-description { min-height: 19px; margin: 0; color: #99a0ae; font-size: 10px; line-height: 1.75; }
.chapter-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 17px 0 7px; color: #929aab; font-size: 10px; }
.chapter-footer strong { color: #788097; font-weight: 500; }
.progress-track { height: 5px; border-radius: 20px; background: #f0f1f6; overflow: hidden; }
.progress-fill { height: 100%; min-width: 0; border-radius: inherit; background: #7578ea; transition: width .25s ease; }
.empty-state { display: grid; justify-items: center; gap: 13px; padding: 56px 24px; border: 1px dashed #e0e4ed; border-radius: var(--radius); text-align: center; color: #8a93a5; background: #ffffff8c; }
.empty-state > svg { width: 43px; height: 43px; color: #a9aeda; }
.empty-state h2, .empty-state h3 { margin: 4px 0 0; color: #4d5870; font-size: 17px; font-weight: 600; }
.empty-state p { margin: 0; max-width: 410px; font-size: 12px; line-height: 1.8; }

/* Practice */
.session-banner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 15px 18px; margin-bottom: 19px; border: 1px solid #e2e3fa; border-radius: 12px; background: #f0f1ff; color: #686cb5; font-size: 12px; }
.session-banner p { margin: 0; }
.practice-layout { display: grid; grid-template-columns: minmax(0, 1fr) 216px; gap: 22px; align-items: start; }
.practice-main { min-width: 0; }
.question-card { min-width: 0; padding: 27px 29px; background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.question-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding-bottom: 20px; border-bottom: 1px solid #eff1f6; }
.question-tags { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; min-width: 0; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 6px; background: #f3f5f8; color: #8a93a6; font-size: 10px; font-weight: 500; line-height: 1.6; overflow-wrap: anywhere; }
.pill.accent { color: #676bd9; background: #f0f0fe; }
.pill.muted { color: #8b93a1; background: #f4f5f8; }
.pill.success { color: var(--green); background: var(--green-soft); }
.pill.warning { color: var(--amber); background: var(--amber-soft); }
.pill svg { width: 12px; height: 12px; }
.question-number { color: #8e96a7; font-size: 11px; font-variant-numeric: tabular-nums; }
.question-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding-top: 17px; }
.question-toolbar .icon-button { border: 0; width: 34px; height: 34px; }
.question-stem { margin: 24px 0; font-size: var(--question-font-size, 18px); font-weight: 500; line-height: 1.9; letter-spacing: .15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.question-stem p { margin: 0 0 14px; }
.question-code { padding: 17px 19px; margin: 16px 0 22px; overflow: auto; border: 1px solid #e9edf3; border-radius: 11px; background: #f7f9fc; color: #33415d; font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace; font-size: 13px; line-height: 1.8; white-space: pre; tab-size: 4; }
.options-list { display: grid; gap: 11px; margin: 23px 0 25px; }
.option-button { position: relative; display: flex; align-items: flex-start; gap: 13px; min-width: 0; width: 100%; min-height: 61px; padding: 15px 17px; border: 1px solid #e8ebf2; border-radius: 12px; background: white; text-align: left; line-height: 1.8; transition: background .15s ease, border-color .15s ease; }
.option-button:hover:not(:disabled) { border-color: #bebff3; background: #fbfbff; }
.option-button:disabled { opacity: 1; cursor: default; }
.option-letter { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid #e8eaf2; border-radius: 8px; background: #f8f9fb; color: #8f96a6; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.option-text { min-width: 0; color: #536078; font-size: calc(var(--question-font-size, 18px) - 3px); white-space: pre-wrap; overflow-wrap: anywhere; }
.option-button.selected { border-color: #8d90ed; background: #f5f5ff; }
.option-button.selected .option-letter { background: var(--accent); border-color: var(--accent); color: white; }
.option-button.selected .option-text { color: #4b50b7; }
.option-button.correct { border-color: #a8d6bf; background: #f1faf5; }
.option-button.correct .option-letter { border-color: #d0e9dc; background: #dff2e7; color: #2f9370; }
.option-button.correct .option-text { color: #34795e; }
.option-button.incorrect { border-color: #e5aab5; background: #fff5f6; }
.option-button.incorrect .option-letter { border-color: #f2d0d8; background: #fce5eb; color: #c55b71; }
.option-button.incorrect .option-text { color: #b25c6a; }
.answer-panel { margin: 24px 0 20px; padding: 18px 20px; border-radius: 12px; background: #f6f7fd; border: 1px solid #e7e9f5; }
.answer-panel.correct { color: #27795f; border-color: #d3ebdd; background: #f0faf4; }
.answer-panel.incorrect { color: #b15365; border-color: #f1d7df; background: #fff5f7; }
.answer-panel.neutral { color: #737ca3; background: #f6f7fe; border-color: #e6e8f6; }
.answer-title { display: flex; align-items: center; gap: 8px; margin: 0 0 7px; font-size: 13px; font-weight: 650; }
.answer-title svg { width: 17px; height: 17px; }
.answer-description { margin: 0; font-size: 12px; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.self-grade { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; padding-top: 15px; }
.self-grade .button { min-height: 39px; font-size: 11px; }
.self-grade .button.correct { background: #eaf7ef; border-color: #cae8d6; color: #258264; }
.self-grade .button.incorrect { background: #fff1f3; border-color: #f0d2d8; color: #be5c6d; }
.question-source { margin: 21px 0 0; padding-top: 15px; border-top: 1px solid #eff1f6; color: #a0a6b3; font-size: 10px; line-height: 1.8; overflow-wrap: anywhere; }
.practice-actions { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 11px; padding: 19px 0 4px; }
.practice-actions > div { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.progress-summary { color: #969eac; font-size: 11px; font-variant-numeric: tabular-nums; }
.progress-summary .progress-track { margin-top: 8px; height: 4px; }
.progress-summary strong { color: #646e83; font-weight: 500; }
.question-map-panel { position: sticky; top: 24px; padding: 19px 17px; border: 1px solid var(--line); border-radius: 15px; background: white; }
.question-map-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.question-map-header h2, .question-map-header h3 { margin: 0; color: #5c667b; font-size: 12px; font-weight: 600; }
.question-map-header small, .question-map-header span { color: #a2a8b4; font-size: 10px; }
.question-map { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; max-height: 420px; overflow-y: auto; padding: 2px; scrollbar-width: thin; scrollbar-color: #e1e4ed transparent; }
.question-dot { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; aspect-ratio: 1; min-height: 28px; padding: 1px; border: 1px solid #e9ecf2; border-radius: 7px; background: #fafbfc; color: #a1a8b6; font-size: 10px; font-variant-numeric: tabular-nums; }
.question-dot:hover { color: var(--accent); border-color: #b9bcf2; }
.question-dot.done { color: #499880; background: #eef8f3; border-color: #d8ece1; }
.question-dot.wrong { color: #c87785; background: #fff3f5; border-color: #f2dce2; }
.question-dot.favorite::after { content: ""; position: absolute; right: 3px; top: 3px; width: 4px; height: 4px; border-radius: 50%; background: #d7ac5d; }
.question-dot.current { color: white; background: var(--accent); border-color: var(--accent); box-shadow: 0 2px 5px #5558e81c; }
.map-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 9px 12px; padding-top: 15px; margin-top: 16px; border-top: 1px solid #eff1f6; color: #a3a9b5; font-size: 9px; }
.map-legend span { display: inline-flex; align-items: center; gap: 4px; }
.map-legend i { width: 6px; height: 6px; border-radius: 2px; background: #eff1f6; }
.map-legend .done { background: #a7d5bd; }
.map-legend .wrong { background: #eabac5; }
.map-legend .current { background: var(--accent); }
.scan-image { display: block; max-width: 100%; height: auto; margin: 18px auto; border: 1px solid #eef0f5; border-radius: 9px; cursor: zoom-in; background: #fff; }
.reference-details { margin-top: 20px; border: 1px solid #e9edf3; border-radius: 11px; overflow: hidden; }
.reference-details summary { padding: 13px 16px; color: #838c9f; background: #fafbfc; font-size: 11px; cursor: pointer; }
.reference-details[open] summary { border-bottom: 1px solid #edf0f5; }
.reference-details > p { padding: 0 16px; color: #9ca3b1; font-size: 10px; }
.reference-details img { max-width: calc(100% - 24px); margin: 12px auto; }

/* Search and question collections */
.filter-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 11px; margin-bottom: 21px; }
.input, .select { min-height: 42px; padding: 10px 13px; color: #657086; background: white; border: 1px solid #e4e8f0; border-radius: 10px; font-size: 12px; line-height: 1.6; outline: none; }
.input:focus, .select:focus { border-color: #a4a7ee; box-shadow: 0 0 0 3px #5558e80b; }
.input::placeholder { color: #a1a9b7; }
.select { max-width: 100%; cursor: pointer; }
.search-box { position: relative; display: flex; align-items: center; flex: 1; min-width: 180px; }
.search-box > svg { position: absolute; left: 14px; width: 17px; height: 17px; color: #a0a7b6; pointer-events: none; }
.search-box .input { width: 100%; padding-left: 41px; }
.library-list { display: grid; gap: 10px; }
.library-item { display: flex; align-items: center; gap: 16px; min-width: 0; width: 100%; padding: 19px 21px; border: 1px solid var(--line); border-radius: 13px; background: white; text-align: left; }
.library-item:hover { border-color: #ccd0ec; background: #fefeff; }
.library-number { min-width: 40px; flex-shrink: 0; color: #a0a7b7; font-size: 12px; font-variant-numeric: tabular-nums; }
.library-title { display: block; margin: 0 0 6px; overflow: hidden; color: #5a667d; font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.library-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: #a1a8b5; font-size: 10px; }
.library-item > div { flex: 1; min-width: 0; }
.library-item > svg { width: 16px; height: 16px; color: #b9beca; flex-shrink: 0; }
.library-item .icon-button { flex-shrink: 0; }

/* Settings and data controls */
.settings-card { padding: 25px 28px; margin-bottom: 20px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.settings-card h2 { font-size: 15px; font-weight: 650; margin: 0 0 9px; }
.settings-card > p { margin: 0 0 22px; color: #8f98aa; font-size: 12px; line-height: 1.9; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.settings-field { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 0; }
.settings-field .select, .settings-field .input { width: 100%; }
.settings-label { display: block; margin: 0; color: #5f6b81; font-size: 12px; font-weight: 500; }
.settings-hint { display: block; margin: 0; color: #a0a7b5; font-size: 10px; line-height: 1.8; }
.settings-field input[type="range"] { max-width: 100%; accent-color: var(--accent); }
.settings-field input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); }
.switch { position: relative; display: inline-flex; align-items: center; width: 40px; height: 23px; padding: 3px; border: 0; border-radius: 20px; background: #dee2eb; cursor: pointer; }
.switch::after { content: ""; width: 17px; height: 17px; border-radius: 50%; background: white; box-shadow: 0 1px 4px #1c2a4d15; transition: transform .15s ease; }
.switch[aria-checked="true"], .switch.active { background: var(--accent); }
.switch[aria-checked="true"]::after, .switch.active::after { transform: translateX(17px); }
.notice { display: flex; align-items: flex-start; gap: 10px; padding: 15px 18px; border: 1px solid #e7eaf3; border-radius: 11px; background: #f5f7fc; color: #8590a5; font-size: 11px; line-height: 1.85; }
.notice > svg { width: 17px; height: 17px; margin-top: 2px; color: #8b98b6; }
.notice p { margin: 0; }
.notice strong { font-weight: 600; color: #626e89; }
.notice.warning { background: #fffbf1; border-color: #f3e8ce; color: #a28c60; }
.notice.warning > svg { color: #b99b57; }
.result-card { width: 100%; max-width: 680px; padding: 42px 35px; margin: 35px auto; background: white; border: 1px solid var(--line); border-radius: 22px; text-align: center; box-shadow: var(--shadow); }
.result-card > svg { width: 45px; height: 45px; margin: 0 auto 20px; color: var(--accent); }
.result-card h2 { margin: 0 0 10px; font-size: 25px; font-weight: 650; }
.result-card > p { margin: 0; color: #969eae; font-size: 12px; }
.result-score { font-size: 65px; font-weight: 700; letter-spacing: -3px; line-height: 1.3; color: var(--accent); margin: 25px 0 0; font-variant-numeric: tabular-nums; }
.result-score small { font-size: 24px; margin-left: 3px; color: #9da1d9; }
.result-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; margin: 28px 0; padding: 22px 0; border-block: 1px solid var(--line); color: #a0a6b3; font-size: 11px; }
.result-stats strong { display: block; margin-bottom: 3px; color: #536078; font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.result-card .hero-actions { justify-content: center; }

/* Dialogs and feedback */
.toast { position: fixed; bottom: 30px; left: calc(50% + var(--sidebar-width) / 2); transform: translateX(-50%); z-index: 130; display: flex; align-items: center; gap: 9px; max-width: min(480px, calc(100vw - 40px)); padding: 12px 20px; border: 1px solid #e1e4ee; border-radius: 12px; background: #fff; color: #647088; box-shadow: 0 8px 40px #1b2a4b17; font-size: 12px; text-align: center; animation: toast-in .2s ease-out; }
.toast svg { width: 17px; height: 17px; color: var(--green); }
@keyframes toast-in { from { opacity: 0; margin-bottom: -7px; } to { opacity: 1; margin-bottom: 0; } }
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; background: #16213b8c; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal { display: flex; flex-direction: column; width: 100%; max-width: 520px; max-height: min(90vh, 850px); max-height: min(90dvh, 850px); overflow: hidden; border-radius: 20px; background: white; box-shadow: 0 24px 100px #12214738; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 21px 25px; border-bottom: 1px solid var(--line); }
.modal-header h2, .modal-header h3 { margin: 0; font-size: 16px; font-weight: 650; }
.modal-header .icon-button { border: 0; background: #f7f8fb; width: 33px; height: 33px; }
.modal-body { padding: 24px 25px; overflow: auto; overscroll-behavior: contain; color: #7d879a; font-size: 12px; line-height: 1.9; }
.modal-body p { margin-top: 0; }
.modal-body .settings-field { margin-bottom: 18px; }
.modal-footer { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; padding: 17px 25px; border-top: 1px solid var(--line); }
.image-viewer { max-width: min(1250px, 95vw); width: 100%; }
.image-viewer .modal-body { background: #edf0f4; padding: 20px; }
.image-viewer img { width: auto; max-width: 100%; height: auto; margin: 0 auto; border-radius: 3px; background: white; }

/* Account sign-in and cross-device progress */
.auth-card { position: relative; width: 100%; max-width: 410px; max-height: 90vh; max-height: 90dvh; padding: 32px; overflow-y: auto; overscroll-behavior: contain; border: 1px solid #e8ebf4; border-radius: 22px; background: white; box-shadow: 0 18px 65px #18284414; }
.auth-logo { display: grid; place-items: center; width: 49px; height: 49px; margin: 0 auto 18px; border-radius: 15px; color: white; background: var(--accent); box-shadow: 0 6px 16px #5558e820; }
.auth-logo svg { width: 28px; height: 28px; }
.auth-card h1, .auth-card h2 { margin: 0 0 9px; text-align: center; font-size: 23px; font-weight: 650; letter-spacing: -.5px; }
.auth-card > p { margin: 0 0 22px; color: #929aab; font-size: 11px; line-height: 1.8; text-align: center; }
.auth-card > .icon-button { position: absolute; top: 15px; right: 15px; border: 0; background: #f7f8fb; width: 30px; height: 30px; }
.auth-tabs { display: flex; gap: 5px; padding: 4px; margin: 20px 0 24px; background: #f3f4f9; border-radius: 10px; }
.auth-tab { display: inline-flex; justify-content: center; align-items: center; flex: 1; min-height: 37px; padding: 8px 12px; border: 0; border-radius: 7px; color: #9aa1b0; background: transparent; font-size: 12px; }
.auth-tab.active { color: var(--accent); background: white; box-shadow: 0 2px 7px #27315e07; font-weight: 600; }
.auth-form { display: flex; flex-direction: column; gap: 17px; }
.auth-form .button.primary { width: 100%; min-height: 44px; margin-top: 3px; }
.form-field { display: flex; flex-direction: column; align-items: stretch; gap: 7px; min-width: 0; }
.form-field label, .form-field > span:first-child { color: #627089; font-size: 11px; font-weight: 500; }
.form-field .input, .form-field input:not([type="checkbox"]):not([type="range"]) { width: 100%; min-height: 44px; padding: 10px 13px; border: 1px solid #e4e8f0; border-radius: 10px; background: white; color: #5e6b84; font-size: 12px; line-height: 1.7; outline: none; }
.form-field input:focus { border-color: #a4a7ee !important; box-shadow: 0 0 0 3px #5558e80b; }
.form-field input::placeholder { color: #a5adbc; }
.form-field input[aria-invalid="true"] { border-color: #e9b4c0 !important; background: #fffafb; }
.form-field small { color: #a2a9b6; font-size: 10px; line-height: 1.7; }
.form-error { margin: 0; padding: 9px 11px; border: 1px solid #f1d4dc; border-radius: 8px; background: #fff5f7; color: #c16a7c; font-size: 11px; line-height: 1.8; }
.auth-caption { margin: 22px 0 0 !important; color: #a1a8b6 !important; font-size: 10px !important; line-height: 1.9; text-align: center; }
.auth-caption a, .auth-caption button { color: var(--accent); }
.auth-caption button { border: 0; padding: 0; background: transparent; font-size: inherit; }
.account-badge { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; max-width: 170px; padding: 7px 11px; border: 1px solid #e4e7f3; border-radius: 10px; background: #fff; color: #65718c; font-size: 11px; white-space: nowrap; }
.account-badge span { overflow: hidden; text-overflow: ellipsis; }
.account-badge svg { width: 15px; height: 15px; color: #9299b7; }
.account-badge:hover { background: #f9f9ff; border-color: #d2d4f4; }
.sync-indicator { display: inline-flex; align-items: center; gap: 6px; color: #929aab; font-size: 10px; line-height: 1.5; white-space: nowrap; }
.sync-indicator::before { content: ""; width: 6px; height: 6px; flex-shrink: 0; border-radius: 50%; background: #b9bfce; }
.sync-indicator.online { color: #7d998e; }
.sync-indicator.online::before { background: #54ac8c; box-shadow: 0 0 0 3px #f0f9f4; }
.sync-indicator.offline { color: #b09a77; }
.sync-indicator.offline::before { background: #cba86d; box-shadow: 0 0 0 3px #fff9ed; }
.password-input { position: relative; display: flex; align-items: center; min-width: 0; }
.password-input input { flex: 1; width: 100%; padding-right: 43px !important; }
.password-input > button { position: absolute; right: 6px; display: grid; place-items: center; width: 32px; height: 32px; padding: 7px; border: 0; border-radius: 7px; background: transparent; color: #a0a8b9; }
.password-input > button:hover { color: var(--accent); background: #f7f7fe; }
.password-input svg { width: 17px; height: 17px; }

/* Application components */
.icon { display: inline-block; vertical-align: middle; width: 20px; height: 20px; flex-shrink: 0; }
[data-font="large"] { --question-font-size: 22px; }
.skip-link { position: fixed; top: 14px; left: 14px; z-index: 200; padding: 11px 18px; border: 1px solid #bfc2ef; border-radius: 9px; color: var(--accent); background: #fff; transform: translateY(-160%); box-shadow: var(--shadow); }
.skip-link:focus { transform: translateY(0); }
.initial-loading, .load-error { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 70vh; gap: 16px; padding: 40px 24px; color: #8a94a7; text-align: center; font-size: 14px; }
.initial-loading::before { content: ""; width: 29px; height: 29px; border: 3px solid #e4e6fc; border-top-color: #7478e5; border-radius: 50%; animation: loading-turn 1s linear infinite; }
.load-error { max-width: 620px; margin-inline: auto; }
.load-error h1 { margin: 0; color: #4b5670; font-size: 23px; }
.load-error p { margin: 0; overflow-wrap: anywhere; }
@keyframes loading-turn { to { transform: rotate(360deg); } }
.sidebar-label { display: flex; justify-content: space-between; }
.chapter-link { gap: 9px; }
.chapter-link::before { display: none; }
.chapter-order { font-size: 10px; color: #b1b8c7; font-variant-numeric: tabular-nums; }
.chapter-link > small { margin-left: auto; color: #b2b8c6; font-size: 10px; }
.chapter-link.active .chapter-order, .chapter-link:hover .chapter-order { color: #9094e1; }
.sidebar-footer .nav-item { margin: 16px -9px -2px; width: calc(100% + 18px); padding-inline: 9px; font-size: 12px; }
.sidebar-footer .nav-item .icon { width: 17px; height: 17px; }
.breadcrumb strong { color: #4e5b73; font-weight: 500; }
.breadcrumb > span { color: #c0c5d0; margin-inline: 2px; }
.site-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; max-width: 1200px; padding: 8px 40px 28px; margin: 0 auto; color: #b0b6c3; font-size: 10px; }
.site-footer > span { color: #b8bdc8; }
.hero-card .hero-primary { color: #5759d8; background: white; box-shadow: 0 4px 14px #30329915; }
.hero-card .hero-primary:hover:not(:disabled) { color: #363ac1; background: #f1f1ff; }
.hero-card .hero-secondary { color: #fff; border-color: #ffffff38; background: #ffffff0a; }
.hero-card .hero-secondary:hover:not(:disabled) { background: #ffffff1c; }
.hero-note { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; color: #cbcfff; font-size: 10px; margin-top: 16px; }
.hero-note .icon { width: 13px; height: 13px; }
.hero-note > span { opacity: .55; margin-inline: 1px; }
.status-dot { display: inline-block; width: 5px; height: 5px; flex-shrink: 0; border-radius: 50%; background: #d4d7ff; box-shadow: 0 0 0 3px #ffffff0a; }
.hero-art { top: 50%; right: 22px; width: 300px; height: 250px; border: 0; border-radius: 0; transform: translateY(-50%); }
.hero-art::before, .hero-art::after { display: none; }
.art-orbit { position: absolute; width: 253px; height: 253px; top: -5px; left: 36px; border: 1px solid #ffffff26; border-radius: 50%; }
.art-orbit.orbit-two { width: 183px; height: 183px; top: 30px; left: 71px; border-color: #ffffff20; background: #ffffff03; }
.art-node { position: absolute; display: grid; place-items: center; width: 43px; height: 43px; border: 1px solid #ffffff30; border-radius: 13px; background: #8281ee; color: #f1f1ff; box-shadow: 0 9px 20px #343bb51a; }
.hero-art .art-node svg { position: static; width: 23px; height: 23px; opacity: .9; color: inherit; }
.art-node.node-main { left: 131px; top: 80px; width: 64px; height: 64px; border-radius: 20px; background: #ffffff1f; box-shadow: 0 10px 25px #3c44bf18; }
.hero-art .node-main svg { width: 32px; height: 32px; }
.art-node.node-one { top: 14px; left: 56px; transform: rotate(-8deg); }
.art-node.node-two { top: 43px; right: 0; transform: rotate(9deg); }
.art-node.node-three { top: 171px; left: 76px; transform: rotate(-9deg); }
.art-chip { position: absolute; display: flex; align-items: center; gap: 7px; bottom: 8px; right: -3px; padding: 8px 13px; border: 1px solid #ffffff28; border-radius: 8px; background: #7a79ec; color: #dfe1ff; font-size: 9px; white-space: nowrap; box-shadow: 0 5px 12px #4149bf08; }
.art-chip .status-dot { width: 4px; height: 4px; background: #c1e8d5; }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-top .stat-icon { position: static; }
.stat-caption { margin: 6px 0 0; color: #a7aebe; font-size: 10px; line-height: 1.7; }
.chapter-card { display: flex; flex-direction: column; gap: 0; padding: 24px; }
.chapter-card-top { display: flex; align-items: center; gap: 11px; width: 100%; margin-bottom: 18px; }
.chapter-index { color: #b4bac7; font-size: 9px; font-weight: 500; letter-spacing: 1.1px; }
.chapter-arrow { width: 17px; height: 17px; margin-left: auto; color: #b9c0cf; }
.chapter-card:hover .chapter-arrow { color: var(--accent); }
.chapter-card .chapter-meta { flex: auto; margin-bottom: 18px; }
.chapter-card .chapter-title { margin-bottom: 5px; font-size: 15px; }
.chapter-description { font-size: 12px; color: #9ca4b4; }
.chapter-card .progress-track { width: 100%; }
.chapter-footer { width: 100%; margin: 9px 0 0; }
.divider { padding-inline: 4px; color: #c9ced9; }
.home-notice { margin-top: 24px; }
.session-banner > span { display: flex; align-items: center; gap: 10px; }
.session-banner .icon { width: 16px; height: 16px; }
.session-banner { margin-top: 20px; }
.question-header .question-toolbar { padding: 0; }
.question-number { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 14px; margin-top: 23px; }
.question-number strong { color: #66728b; font-size: 12px; font-weight: 500; }
.question-number > span { color: #a7aebe; font-size: 10px; }
.question-number:focus-visible { border-radius: 5px; }
.question-hint { margin: 16px 0 0; color: #9a92b7; font-size: 12px; }
.question-stem { font-weight: 400; }
.option-text { flex: 1; }
.option-button > .icon { align-self: center; width: 18px; height: 18px; color: #8a9698; }
.option-button.correct > .icon { color: #52a27f; }
.option-button.incorrect > .icon { color: #d38497; }
.answer-description > span { display: inline-block; margin-left: 12px; font-size: 11px; opacity: .75; }
.answer-footnote { margin: 10px 0 0; font-size: 10px; opacity: .65; }
.progress-summary { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin: 2px 0 15px; }
.practice-actions-main { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.keyboard-hint { display: flex; align-items: flex-start; justify-content: center; gap: 6px; margin: 13px 0 0; color: #b2b8c5; font-size: 10px; line-height: 1.8; }
.keyboard-hint .icon { width: 13px; height: 13px; margin-top: 2px; }
.map-tip { margin-top: 18px; color: #b2b8c6; font-size: 10px; line-height: 1.95; }
.scan-notice { margin-top: 20px; }
.scan-images { display: flex; flex-direction: column; gap: 17px; margin-block: 22px; }
.scan-image-button { display: block; width: 100%; min-width: 0; padding: 0; border: 0; border-radius: 9px; background: transparent; text-align: center; cursor: zoom-in; }
.scan-image-button .scan-image { max-width: 100%; height: auto; margin: 0 auto; }
.scan-image-button > span { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 33px; padding: 7px 12px; margin-top: 7px; color: #a1a9b9; border-radius: 7px; font-size: 10px; }
.scan-image-button:hover > span { color: var(--accent); background: #f8f8ff; }
.scan-image-button > span .icon { width: 13px; height: 13px; }
.reference-details summary { display: flex; align-items: center; gap: 8px; }
.reference-details summary .icon { width: 14px; height: 14px; }
.reference-details summary::after { content: "+"; margin-left: auto; font-size: 15px; color: #aab1bf; }
.reference-details[open] summary::after { content: "−"; }
.reference-details .scan-image-button { padding: 12px; }
.reference-details .scan-image-button .scan-image { max-width: 100%; margin: 0 auto; }
.icon-button.is-favorite { color: #c78c2c; background: #fff9ed; border-color: #f3e6cb; }
.icon-button.is-favorite svg { fill: #f8dfaa; }
.library-open { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 0; padding: 0; border: 0; background: transparent; text-align: left; }
.library-open .library-main { display: block; flex: 1; min-width: 0; }
.library-open > .icon { width: 16px; height: 16px; color: #b8c0cf; }
.library-open .library-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; font-weight: 500; }
.library-result-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; color: #a3aaba; font-size: 11px; }
.library-result-heading strong { color: #6f7a92; font-weight: 500; }
.auto-tag { padding: 1px 6px; color: #a3a4c4; background: #f7f7fd; border-radius: 4px; font-size: 9px; }
.pagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 17px; margin-top: 24px; }
.pagination > span { min-width: 42px; text-align: center; color: #959fb1; font-size: 11px; font-variant-numeric: tabular-nums; }
.settings-card h2 { display: flex; align-items: center; gap: 9px; margin-bottom: 19px; }
.settings-card h2 .icon { width: 17px; height: 17px; color: #969db9; }
.settings-grid { grid-template-columns: 1fr; gap: 0; }
.settings-grid .settings-field { flex-direction: row; align-items: center; justify-content: space-between; gap: 20px; padding-block: 17px; border-bottom: 1px solid #eff1f6; }
.settings-grid .settings-field:first-child { padding-top: 3px; }
.settings-grid .settings-field:last-child { border-bottom: 0; padding-bottom: 3px; }
.settings-grid .settings-field > span { flex: 1; }
.settings-grid .settings-field .select { width: 152px; flex-shrink: 0; }
.settings-hint { font-size: 12px; }
.settings-grid .settings-hint { margin-top: 5px; font-size: 11px; }
.settings-field input.switch[type="checkbox"] { -webkit-appearance: none; appearance: none; width: 40px; height: 23px; margin: 0; border: 0; flex-shrink: 0; }
.settings-field input.switch:checked { background: var(--accent); }
.settings-field input.switch:checked::after { transform: translateX(17px); }
.settings-account-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 20px; }
.account-profile { display: flex; flex-wrap: wrap; align-items: center; gap: 13px; }
.account-avatar { display: grid; place-items: center; width: 43px; height: 43px; flex-shrink: 0; border: 1px solid #e4e4fa; border-radius: 13px; background: #f1f1ff; color: #7679d9; font-size: 18px; font-weight: 600; }
.account-profile > div { flex: 1; min-width: 100px; }
.account-profile strong { color: #606e87; font-size: 13px; font-weight: 600; }
.account-profile p { margin: 4px 0 0; color: #a3aabb; font-size: 11px; line-height: 1.8; }
.account-profile .button { margin-left: auto; }
.about-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; padding: 18px 22px; margin: 20px 0; border: 1px solid #eceef5; border-radius: 11px; background: #fafbfe; }
.about-grid strong { display: block; color: #727ab4; font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.about-grid span { color: #a1a9bb; font-size: 11px; }
.danger-zone { border-color: #f0e4e8; }
.danger-zone h2 { color: #a57885; }
.form-field { font-size: 12px; color: #748199; }
.auth-submit { gap: 10px; }
.password-input > .password-toggle { width: 44px; padding: 4px; font-size: 11px; }
.password-input > input { padding-right: 58px !important; }
.modal-body > .auth-card { max-width: 370px; max-height: none; margin-inline: auto; padding: 5px 4px 9px; overflow: visible; border: 0; border-radius: 0; box-shadow: none; }
.auth-card > .auth-caption { margin: 8px 0 20px !important; font-size: 12px !important; }
.modal-body > .result-card { margin: 0; padding: 5px 0 15px; border: 0; box-shadow: none; }
.modal:has(.image-viewer) { max-width: min(1250px, calc(100vw - 48px)); }
.modal:has(.image-viewer) > .modal-body { background: #edf0f4; padding: 18px; }
.image-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.image-tools > span { margin-left: auto; color: #8993a6; font-size: 12px; }
.image-viewer { width: 100%; max-width: 100%; max-height: 60vh; max-height: 60dvh; overflow: auto; overscroll-behavior: contain; }
.image-viewer img { width: auto; max-width: 100%; }
.image-viewer[data-zoomed] img, [data-zoomed] .image-viewer img { max-width: none; }
.image-zoom-hint { margin: 12px 0 0; color: #919aab; font-size: 12px; line-height: 1.8; }
.result-emblem { display: grid; place-items: center; width: 55px; height: 55px; margin: 0 auto 22px; border: 1px solid #e3e4fa; border-radius: 18px; background: #f1f2fe; color: var(--accent); }
.result-emblem .icon { width: 28px; height: 28px; }
.result-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Medium screens keep the primary work area generous. */
@media (min-width: 1600px) {
  .page-content { max-width: 1240px; padding-top: 45px; }
  .topbar { padding-inline: 46px; }
}
@media (max-width: 1190px) {
  :root { --sidebar-width: 210px; }
  .sidebar { padding-inline: 12px; }
  .topbar { padding-inline: 28px; }
  .page-content { padding-inline: 28px; }
  .hero-card { padding-inline: 29px; }
  .practice-layout { grid-template-columns: minmax(0, 1fr) 185px; gap: 17px; }
  .question-card { padding: 23px; }
  .question-map-panel { padding-inline: 13px; }
  .question-map { gap: 5px; }
  .stat-card { padding-inline: 16px; }
  .stat-icon { right: 13px; width: 28px; height: 28px; }
}
@media (max-width: 960px) {
  :root { --sidebar-width: 198px; }
  .sidebar { padding: 27px 10px 20px; }
  .brand { padding-inline: 8px; gap: 9px; margin-bottom: 28px; }
  .brand-icon { width: 37px; height: 37px; border-radius: 11px; }
  .brand-copy strong, .brand-copy b { font-size: 21px; }
  .brand-copy span, .brand-copy small { font-size: 9px; letter-spacing: .7px; }
  .nav-item { gap: 10px; padding-inline: 13px; font-size: 12px; }
  .chapter-link { font-size: 11px; padding-inline: 13px; }
  .topbar { height: 69px; padding-inline: 23px; }
  .page-content { padding: 30px 23px 40px; }
  .stats-grid { gap: 10px; }
  .stat-card { padding: 16px 13px; }
  .stat-icon { top: 16px; right: 11px; width: 25px; height: 25px; }
  .stat-icon svg { width: 13px; height: 13px; }
  .stat-value { font-size: 25px; }
  .stat-label { font-size: 10px; }
  .chapter-card { padding: 18px; gap: 12px; }
  .chapter-icon { width: 35px; height: 35px; border-radius: 10px; }
  .chapter-title { font-size: 13px; }
  .chapter-description { font-size: 10px; }
  .practice-layout { display: flex; flex-direction: column; gap: 20px; }
  .practice-main { width: 100%; }
  .question-map-panel { position: static; width: 100%; padding: 19px; }
  .question-map { grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 7px; max-height: 160px; }
  .question-dot { min-height: 30px; max-height: 39px; }
  .question-map-header { margin-bottom: 10px; }
  .hero-art { right: -150px; opacity: .65; }
  .hero-copy { max-width: 480px; }
}

/* Tablet and mobile navigation */
@media (max-width: 760px) {
  :root { --sidebar-width: 232px; }
  html { scroll-padding-top: 80px; }
  .sidebar { transform: translateX(-100%); visibility: hidden; pointer-events: none; transition: transform .2s ease; padding: 27px 18px; box-shadow: none; }
  .sidebar.mobile-open, .mobile-open .sidebar { transform: translateX(0); visibility: visible; pointer-events: auto; box-shadow: 14px 0 60px #14233c20; }
  .sidebar-backdrop.mobile-open, .mobile-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 45; background: #1e2a474d; border: 0; }
  .brand { padding-inline: 9px; gap: 11px; margin-bottom: 31px; }
  .brand-icon { width: 43px; height: 43px; border-radius: 13px; }
  .brand-copy strong, .brand-copy b { font-size: 23px; }
  .brand-copy span, .brand-copy small { font-size: 10px; letter-spacing: 1.5px; }
  .nav-item { min-height: 47px; font-size: 13px; }
  .chapter-link { min-height: 38px; font-size: 12px; }
  .main-area { margin-left: 0; }
  .topbar { position: sticky; top: 0; z-index: 35; height: 67px; padding-inline: 23px; }
  .mobile-menu { display: inline-flex; width: 37px; height: 37px; margin-right: 4px; border-color: transparent; }
  .breadcrumb { flex: 1; font-size: 11px; gap: 6px; }
  .topbar-actions { gap: 9px; }
  .storage-badge { font-size: 10px; }
  .account-badge { max-width: 135px; font-size: 10px; }
  .sync-indicator { font-size: 9px; }
  .page-content { padding: 29px 23px 110px; }
  .page-title { font-size: 29px; }
  .page-heading { margin-bottom: 23px; }
  .hero-card { min-height: 214px; padding: 27px; }
  .hero-art { right: -50px; opacity: .7; }
  .hero-title { font-size: 25px; }
  .hero-copy { max-width: 430px; }
  .hero-description { max-width: 340px; }
  .stat-card { padding: 18px 16px; }
  .stat-icon { top: 18px; right: 14px; width: 28px; height: 28px; }
  .stat-value { font-size: 27px; }
  .chapter-card { padding: 19px; }
  .chapter-title { font-size: 14px; }
  .chapter-description { font-size: 10px; }
  .bottom-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: fixed; inset: auto 0 0; z-index: 40; padding: 7px 10px calc(7px + env(safe-area-inset-bottom)); border-top: 1px solid #e9ecf3; background: rgb(255 255 255 / 96%); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 -4px 22px #20345203; }
  .bottom-nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 47px; padding: 4px 6px; border: 0; border-radius: 10px; background: transparent; color: #9aa2b2; font-size: 9px; font-weight: 500; }
  .bottom-nav-item svg { width: 20px; height: 20px; }
  .bottom-nav-item.active { color: var(--accent); }
  .toast { bottom: calc(85px + env(safe-area-inset-bottom)); left: 50%; }
  .question-map { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .question-map-panel { margin-top: 2px; }
}
@media (max-width: 560px) {
  .topbar { height: 62px; padding-inline: 14px; gap: 8px; }
  .breadcrumb > span:first-child:not(:last-child), .breadcrumb > svg { display: none; }
  .topbar-actions .icon-button { width: 35px; height: 35px; }
  .storage-badge { max-width: 95px; line-height: 1.4; font-size: 9px; gap: 6px; }
  .storage-badge::before { width: 5px; height: 5px; }
  .account-badge { max-width: 99px; min-height: 34px; padding-inline: 8px; font-size: 10px; gap: 5px; }
  .account-badge svg { width: 14px; height: 14px; }
  .sync-indicator { font-size: 8px; gap: 5px; }
  .sync-indicator::before { width: 5px; height: 5px; }
  .auth-card { padding: 27px 24px; border-radius: 18px; }
  .auth-card h1, .auth-card h2 { font-size: 21px; }
  .auth-tab { min-height: 41px; }
  .page-content { padding: 26px 16px 105px; }
  .page-heading { align-items: flex-start; gap: 12px; }
  .page-heading > .button { min-height: 37px; padding-inline: 11px; font-size: 10px; }
  .page-title { font-size: 27px; letter-spacing: -.7px; }
  .eyebrow { font-size: 9px; letter-spacing: 1.8px; margin-bottom: 8px; }
  .page-description { font-size: 11px; line-height: 1.8; }
  .hero-card { min-height: 223px; padding: 24px; border-radius: 17px; }
  .hero-kicker { font-size: 9px; }
  .hero-title { font-size: 23px; max-width: 280px; }
  .hero-description { font-size: 10px; max-width: 290px; }
  .hero-art { right: -173px; top: -18px; opacity: .6; }
  .hero-actions { gap: 9px; margin-top: 20px; }
  .hero-actions .button { min-height: 40px; padding: 9px 14px; font-size: 11px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; margin-top: 17px; }
  .stat-card { min-height: 107px; padding: 16px 17px; border-radius: 12px; }
  .stat-icon { right: 16px; top: 16px; width: 29px; height: 29px; }
  .stat-value { font-size: 29px; margin-top: 11px; }
  .stat-label { font-size: 10px; }
  .section-heading { margin: 26px 0 14px; }
  .section-title { font-size: 16px; }
  .section-title small { font-size: 10px; }
  .chapter-grid { grid-template-columns: 1fr; gap: 11px; }
  .chapter-card { padding: 20px; gap: 15px; border-radius: 14px; }
  .chapter-icon { width: 39px; height: 39px; border-radius: 11px; }
  .chapter-description { font-size: 10px; }
  .chapter-footer { margin-top: 13px; }
  .button { min-height: 44px; padding-inline: 16px; font-size: 12px; }
  .button.small { min-height: 38px; font-size: 11px; }
  .session-banner { padding: 13px 14px; font-size: 11px; border-radius: 10px; }
  .question-card { padding: 19px 17px; border-radius: 15px; }
  .question-header { padding-bottom: 16px; gap: 8px; }
  .question-number { font-size: 10px; }
  .question-tags { gap: 5px; }
  .pill { padding: 3px 7px; font-size: 9px; }
  .question-toolbar { padding-top: 13px; }
  .question-stem { font-size: var(--question-font-size, 18px); line-height: 1.95; margin: 19px 0 22px; letter-spacing: 0; }
  .question-code { font-size: 12px; padding: 14px; }
  .options-list { gap: 10px; margin: 19px 0 22px; }
  .option-button { gap: 11px; min-height: 60px; padding: 14px 12px; border-radius: 10px; }
  .option-letter { width: 27px; height: 27px; border-radius: 7px; font-size: 11px; }
  .option-text { font-size: calc(var(--question-font-size, 18px) - 3px); }
  .answer-panel { padding: 15px; margin-top: 20px; }
  .answer-description { font-size: 11px; }
  .self-grade { gap: 7px; }
  .self-grade .button { flex: 1; padding-inline: 10px; }
  .question-source { font-size: 9px; }
  .practice-actions { position: sticky; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 20; gap: 8px; padding: 12px 0 10px; margin-inline: -2px; background: var(--bg); }
  .practice-actions .button { padding-inline: 14px; min-height: 43px; }
  .practice-actions .progress-summary { display: none; }
  .practice-actions > div { gap: 7px; }
  .practice-actions .button.ghost { padding-inline: 10px; }
  .question-map-panel { padding: 17px; border-radius: 13px; }
  .question-map { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 7px; max-height: 190px; }
  .question-dot { max-height: 42px; font-size: 11px; }
  .map-legend { font-size: 10px; padding-top: 13px; }
  .scan-image { margin-block: 16px; border-radius: 6px; }
  .reference-details summary { padding-inline: 13px; font-size: 10px; }
  .filter-bar { gap: 9px; }
  .search-box { flex-basis: 100%; }
  .filter-bar .select { flex: 1; width: 0; min-width: 0; font-size: 11px; padding-inline: 10px; }
  .filter-bar .button { min-height: 41px; font-size: 11px; }
  .input, .select { min-height: 44px; font-size: 12px; }
  .library-item { gap: 11px; padding: 17px 14px; border-radius: 11px; align-items: flex-start; }
  .library-number { min-width: 32px; font-size: 11px; padding-top: 2px; }
  .library-title { font-size: 12px; }
  .library-meta { gap: 4px; font-size: 9px; }
  .library-item > svg { width: 13px; height: 13px; margin-top: 4px; }
  .library-item .icon-button { width: 31px; height: 31px; padding: 6px; }
  .settings-card { padding: 21px 19px; border-radius: 14px; }
  .settings-card h2 { font-size: 14px; }
  .settings-card > p { font-size: 11px; }
  .settings-grid { grid-template-columns: 1fr; gap: 20px; }
  .notice { font-size: 10px; padding: 13px 14px; gap: 8px; }
  .empty-state { padding: 44px 20px; }
  .empty-state h2, .empty-state h3 { font-size: 16px; }
  .empty-state p { font-size: 11px; }
  .modal-backdrop { padding: 16px; }
  .modal { max-height: 88vh; max-height: 88dvh; border-radius: 16px; }
  .modal-header { padding: 17px 20px; }
  .modal-header h2, .modal-header h3 { font-size: 15px; }
  .modal-body { padding: 20px; font-size: 12px; }
  .modal-footer { padding: 15px 20px; }
  .modal-footer .button { flex: 1; }
  .image-viewer { max-width: 100%; }
  .image-viewer .modal-body { padding: 10px; }
  .result-card { padding: 33px 22px; margin-top: 20px; border-radius: 18px; }
  .result-card h2 { font-size: 22px; }
  .result-score { font-size: 57px; }
  .result-stats { gap: 6px; padding-block: 19px; }
  .result-stats strong { font-size: 19px; }
  .toast { max-width: calc(100vw - 32px); padding-inline: 16px; font-size: 11px; }
}
@media (max-width: 359px) {
  .page-content { padding-inline: 12px; }
  .topbar { padding-inline: 10px; }
  .storage-badge { max-width: 77px; font-size: 8px; }
  .page-title { font-size: 24px; }
  .hero-card { padding: 22px 19px; }
  .hero-title { font-size: 21px; }
  .hero-actions .button { padding-inline: 11px; font-size: 10px; }
  .question-card { padding-inline: 14px; }
  .practice-actions .button { padding-inline: 10px; font-size: 11px; }
  .practice-actions > div { gap: 5px; }
  .question-map { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .stat-icon { right: 12px; }
  .stat-card { padding-inline: 13px; }
}
@media (max-width: 760px) {
  .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 45; padding: 0; border: 0; border-radius: 0; background: #1e2a474d; }
  .site-footer { padding-inline: 23px; padding-bottom: calc(90px + env(safe-area-inset-bottom)); font-size: 9px; }
  .chapter-card { display: flex; flex-direction: column; gap: 0; }
  .chapter-card-top { margin-bottom: 16px; }
  .chapter-card .chapter-meta { margin-bottom: 17px; }
  .keyboard-hint { display: none; }
  .settings-grid { gap: 0; }
}
@media (max-width: 560px) {
  .page-description { font-size: 12px; }
  .filter-bar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-bar .select { width: 100%; font-size: 12px; }
  .filter-bar > .button { width: 100%; }
  .filter-bar .search-box { grid-column: 1 / -1; min-width: 0; }
  .hero-description { font-size: 12px; line-height: 1.9; }
  .hero-kicker { font-size: 10px; }
  .hero-note { font-size: 9px; gap: 5px; margin-top: 14px; }
  .hero-card { padding-bottom: 24px; }
  .hero-art { right: -178px; }
  .chapter-card { padding: 20px; }
  .chapter-card-top { gap: 11px; }
  .chapter-card .chapter-meta { margin-bottom: 16px; }
  .chapter-card .chapter-title { font-size: 16px; }
  .chapter-description { font-size: 12px; }
  .chapter-footer { margin-top: 9px; font-size: 11px; }
  .stat-label { font-size: 11px; }
  .stat-caption { font-size: 10px; }
  .notice, .empty-state p, .settings-card > p { font-size: 12px; line-height: 1.9; }
  .library-item { align-items: center; padding: 17px 14px; gap: 10px; }
  .library-open { gap: 10px; }
  .library-open > .icon { display: none; }
  .library-open .library-title { font-size: 13px; line-height: 1.8; }
  .library-open .library-meta { font-size: 10px; }
  .library-result-heading { font-size: 11px; }
  .library-number { min-width: 31px; font-size: 11px; }
  .question-number { margin-top: 19px; }
  .question-number > span { font-size: 10px; }
  .question-number strong { font-size: 12px; }
  .question-hint, .answer-description { font-size: 12px; }
  .answer-description > span { margin: 4px 0 0; display: block; }
  .answer-footnote { font-size: 10px; }
  .practice-actions { flex-wrap: nowrap; align-items: center; }
  .practice-actions-main { justify-content: flex-end; flex-wrap: nowrap !important; }
  .practice-actions .button { padding-inline: 11px; gap: 5px; white-space: nowrap; font-size: 11px; }
  .practice-actions .button svg { width: 15px; height: 15px; }
  .settings-grid { gap: 0; }
  .settings-grid .settings-field { gap: 14px; }
  .settings-grid .settings-field .select { width: 106px; font-size: 12px; }
  .settings-label { font-size: 13px; }
  .settings-grid .settings-hint { font-size: 11px; }
  .settings-hint { font-size: 12px; }
  .account-profile { gap: 11px; }
  .account-profile .button { font-size: 10px; padding-inline: 10px; }
  .account-profile p { font-size: 10px; }
  .about-grid { padding: 16px; gap: 15px; }
  .about-grid strong { font-size: 20px; }
  .about-grid span { font-size: 11px; }
  .modal-body > .auth-card { padding-inline: 0; }
  .auth-form { gap: 17px; }
  .auth-submit { font-size: 13px; }
  .form-field, .form-field .input { font-size: 13px; }
  .form-field input:not([type="checkbox"]):not([type="range"]) { min-height: 46px; font-size: 16px; }
  .search-box .input { font-size: 16px; }
  .password-input > .password-toggle { font-size: 11px; }
  .site-footer { display: none; }
  .session-banner { font-size: 11px; }
  .session-banner > span { align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media print {
  .sidebar, .topbar, .bottom-nav, .practice-actions, .question-map-panel, .toast, .modal-backdrop, .question-toolbar { display: none !important; }
  .main-area { margin: 0; }
  .page-content { max-width: none; padding: 0; }
  .practice-layout { display: block; }
  .question-card { border: 0; padding: 0; box-shadow: none; }
  .option-button { break-inside: avoid; }
  body { background: #fff; }
}
