/* 知序 · DefectLab — single visual system (dark default, light optional). */
:root {
  color-scheme: dark;
  --bg: #0e0e12;
  --surface: #16161c;
  --surface-2: #1c1c24;
  --surface-3: #24242e;
  --border: #2a2a35;
  --border-strong: #3b3b48;
  --text: #ededf4;
  --text-2: #a8a8b8;
  --text-3: #868698;
  --accent: #8b74ff;
  --accent-strong: #ab9cff;
  --accent-soft: rgba(139, 116, 255, .14);
  --accent-line: rgba(139, 116, 255, .42);
  --accent-2: #5fc8ff;
  --success: #3fcf8e;
  --success-text: #63dda6;
  --success-soft: rgba(63, 207, 142, .12);
  --success-line: rgba(63, 207, 142, .55);
  --danger: #ff6b81;
  --danger-text: #ff8d9e;
  --danger-soft: rgba(255, 107, 129, .12);
  --danger-line: rgba(255, 107, 129, .55);
  --warning-text: #f2bd70;
  --warning-soft: rgba(242, 180, 92, .12);
  --on-ink: #0e0e12;
  --glass: rgba(14, 14, 18, .78);
  --scrim: rgba(6, 6, 9, .72);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .28);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, .28);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
  --hero-glow: radial-gradient(120% 140% at 0% 0%, rgba(139, 116, 255, .2), transparent 55%), radial-gradient(90% 120% at 100% 100%, rgba(95, 200, 255, .1), transparent 60%);
  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --sidebar-width: 244px;
  --topbar-height: 68px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "SF Mono", "SFMono-Regular", Consolas, "PingFang SC", "Microsoft YaHei", monospace;
}
:root[data-theme=light] {
  color-scheme: light;
  --bg: #f5f5f8;
  --surface: #ffffff;
  --surface-2: #f4f4f8;
  --surface-3: #ebebf2;
  --border: #e3e3eb;
  --border-strong: #cfcfdc;
  --text: #1c1c26;
  --text-2: #5c5c6d;
  --text-3: #6e6e80;
  --accent: #6d56e0;
  --accent-strong: #5640c8;
  --accent-soft: #efebff;
  --accent-line: rgba(109, 86, 224, .38);
  --accent-2: #2a9fd6;
  --success: #16a063;
  --success-text: #0f7f4d;
  --success-soft: #e8f7ef;
  --success-line: #6cc79b;
  --danger: #dc3a54;
  --danger-text: #bf2a43;
  --danger-soft: #fdedf0;
  --danger-line: #eb8f9e;
  --warning-text: #8f5f19;
  --warning-soft: #fbf3e4;
  --on-ink: #ffffff;
  --glass: rgba(245, 245, 248, .82);
  --scrim: rgba(28, 28, 38, .36);
  --shadow-sm: 0 1px 2px rgba(28, 28, 50, .05);
  --shadow-md: 0 10px 30px rgba(28, 28, 50, .07);
  --shadow-lg: 0 24px 60px rgba(28, 28, 50, .16);
  --hero-glow: radial-gradient(120% 140% at 0% 0%, rgba(109, 86, 224, .11), transparent 55%), radial-gradient(90% 120% at 100% 100%, rgba(42, 159, 214, .08), transparent 60%);
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  min-width: 320px; min-height: 100%; margin: 0; overflow-x: hidden;
  color: var(--text); background: var(--bg);
  font: 15px/1.65 var(--font-body);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  transition: background-color .25s, color .25s;
}
button, input, select, textarea { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
button { line-height: 1.35; touch-action: manipulation; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
a { color: inherit; }
h1, h2, h3 { text-wrap: balance; }
p { overflow-wrap: anywhere; }
::selection { background: var(--accent-line); color: var(--text); }
[hidden] { display: none !important; }
.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; }
.icon { display: block; flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* Shell */
.app-frame { min-height: 100vh; min-height: 100svh; }
.sidebar {
  position: fixed; z-index: 20; inset: 0 auto 0 0;
  display: flex; flex-direction: column; width: var(--sidebar-width); min-height: 0;
  padding: 22px 14px max(14px, env(safe-area-inset-bottom));
  overflow-y: auto; border-right: 1px solid var(--border); background: var(--surface);
}
.brand { display: inline-flex; align-items: center; gap: 11px; max-width: 100%; margin: 2px 0 30px 8px; color: inherit; text-decoration: none; border-radius: var(--radius-sm); }
.brand-mark {
  display: grid; flex: none; width: 34px; height: 34px; grid-template: repeat(2, 1fr) / repeat(2, 1fr); gap: 3px; padding: 7px;
  border-radius: 11px; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px rgba(139, 116, 255, .28);
}
.brand-mark span { display: block; border-radius: 2px; background: rgba(255, 255, 255, .92); }
.brand-mark span:nth-child(2), .brand-mark span:nth-child(3) { background: rgba(255, 255, 255, .58); }
.brand-copy, .auth-brand > div { display: flex; min-width: 0; flex-direction: column; gap: 1px; }
.brand-copy strong, .auth-brand strong { font-size: 18px; line-height: 1.2; font-weight: 700; letter-spacing: .08em; }
.brand-copy small, .auth-brand small { color: var(--text-3); font: 10.5px/1.4 var(--font-mono); letter-spacing: .18em; }
.sidebar-caption { margin: 0 0 8px; padding: 0 12px; color: var(--text-3); font-size: 12px; line-height: 1.4; font-weight: 600; letter-spacing: .12em; }
.primary-nav { display: grid; gap: 3px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 8px 12px;
  border: 0; border-radius: var(--radius-sm); color: var(--text-2); background: transparent; text-align: left; font-size: 14.5px; cursor: pointer;
  transition: color .16s, background-color .16s;
}
.nav-item:hover { color: var(--text); background: var(--surface-2); }
.nav-item.is-active { color: var(--text); background: var(--accent-soft); font-weight: 600; }
.nav-item.is-active::before { content: ""; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-icon { display: grid; flex: none; width: 22px; height: 22px; place-items: center; color: var(--text-3); transition: color .16s; }
.nav-icon .icon { width: 19px; height: 19px; }
.nav-item:hover .nav-icon { color: var(--text-2); }
.nav-item.is-active .nav-icon { color: var(--accent-strong); }
.sidebar-bottom { margin-top: auto; padding-top: 14px; }
.sidebar-note { display: flex; gap: 11px; padding: 14px 12px; margin: 0 0 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.note-dot, .eyebrow-dot { display: block; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.note-dot { margin-top: 7px; }
.sidebar-note strong { font-size: 13px; line-height: 1.5; font-weight: 600; }
.sidebar-note p { margin: 3px 0 0; color: var(--text-3); font-size: 12.5px; line-height: 1.6; }
.profile-button {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 56px; padding: 8px; border: 1px solid transparent; border-radius: var(--radius);
  background: transparent; text-align: left; cursor: pointer; transition: border-color .16s, background-color .16s;
}
.profile-button:hover { border-color: var(--border); background: var(--surface-2); }
.avatar, .topbar-avatar {
  display: grid; flex: none; width: 36px; height: 36px; place-items: center; border-radius: 11px;
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); font-size: 15px; line-height: 1; font-weight: 700; text-transform: uppercase;
}
.profile-copy { display: grid; min-width: 0; gap: 1px; }
.profile-copy strong { overflow: hidden; font-size: 13.5px; line-height: 1.4; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.profile-copy small { color: var(--text-3); font-size: 12px; line-height: 1.4; }
.profile-more { margin-left: auto; color: var(--text-3); }
.app-main { min-width: 0; min-height: 100vh; min-height: 100svh; margin-left: var(--sidebar-width); }
.is-practice .sidebar, .is-practice .topbar { display: none; }
.is-practice .app-main { margin-left: 0; }

.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; height: var(--topbar-height);
  padding: 0 clamp(20px, 3vw, 44px); border-bottom: 1px solid var(--border);
  background: var(--glass); -webkit-backdrop-filter: saturate(160%) blur(14px); backdrop-filter: saturate(160%) blur(14px);
}
.breadcrumb { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--text-3); font-size: 13.5px; line-height: 1.4; white-space: nowrap; }
.breadcrumb > span:first-child { color: var(--text-2); }
.breadcrumb strong { overflow: hidden; color: var(--text); font-weight: 600; text-overflow: ellipsis; }
.global-search {
  display: flex; align-items: center; gap: 6px; width: min(340px, 34vw); min-width: 0; height: 40px; padding: 0 8px 0 6px; margin-left: auto;
  border: 1px solid var(--border); border-radius: 12px; color: var(--text-3); background: var(--surface);
  transition: border-color .16s, box-shadow .16s;
}
.global-search:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft); }
.search-icon { display: grid; flex: none; width: 30px; height: 30px; place-items: center; padding: 0; border: 0; border-radius: 8px; color: inherit; background: transparent; cursor: pointer; }
.search-icon .icon { width: 18px; height: 18px; }
.global-search input { width: 100%; min-width: 0; height: 100%; padding: 0; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 14px; }
.global-search input::placeholder { color: var(--text-3); }
.global-search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.global-search kbd { flex: none; padding: 1px 6px; border: 1px solid var(--border); border-radius: 6px; color: var(--text-3); background: var(--surface-2); font: 11px/1.5 var(--font-mono); }
.icon-button, .theme-toggle {
  display: grid; flex: none; width: 40px; height: 40px; place-items: center; padding: 0;
  border: 1px solid var(--border); border-radius: 12px; color: var(--text-2); background: var(--surface); cursor: pointer;
  transition: color .16s, border-color .16s, background-color .16s;
}
.icon-button:hover, .theme-toggle:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.theme-toggle .icon { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme=light] .theme-toggle .icon-sun { display: block; }
:root[data-theme=light] .theme-toggle .icon-moon { display: none; }
.topbar-avatar, .mobile-menu { display: none; }
.topbar-avatar { border: 0; cursor: pointer; }

.main-content {
  width: min(100%, 1440px); min-width: 0; min-height: calc(100vh - var(--topbar-height)); min-height: calc(100svh - var(--topbar-height));
  padding: 36px clamp(20px, 3vw, 44px) 72px; margin: 0 auto; outline: none; animation: page-enter .28s var(--ease) both;
}

/* Typography blocks */
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 0 0 28px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; color: var(--text-3); font: 11px/1.4 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; }
.page-heading h1 { margin: 10px 0 6px; font-size: clamp(26px, 2.4vw, 32px); line-height: 1.3; font-weight: 700; letter-spacing: -.02em; overflow-wrap: anywhere; }
.page-heading p { max-width: 64ch; margin: 0; color: var(--text-2); font-size: 15px; line-height: 1.7; }
.date-stamp { flex: none; padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px; color: var(--text-2); background: var(--surface); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 0 0 14px; }
.section-heading h2 { margin: 0; font-size: 18px; line-height: 1.45; font-weight: 650; letter-spacing: -.01em; }
.section-heading p { margin: 3px 0 0; color: var(--text-2); font-size: 14px; line-height: 1.6; }
.text-link { display: inline-flex; align-items: center; gap: 4px; flex: none; padding: 4px 2px; border: 0; color: var(--accent-strong); background: transparent; font-size: 14px; font-weight: 550; cursor: pointer; border-radius: 6px; }
.text-link .icon { width: 16px; height: 16px; transition: transform .16s var(--ease); }
.text-link:hover .icon { transform: translate(2px, -2px); }

/* Buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 16px;
  border: 1px solid transparent; border-radius: 12px; font-size: 14px; line-height: 1.4; font-weight: 600; text-align: center; cursor: pointer;
  transition: color .15s, background-color .15s, border-color .15s, box-shadow .15s, transform .15s, opacity .15s;
}
.button .icon { width: 17px; height: 17px; }
.button:active:not(:disabled) { transform: scale(.97); transition-duration: .06s; }
.button:disabled { opacity: .45; }
.button-primary, .continue-button { color: var(--on-ink); background: var(--text); }
.button-primary:hover:not(:disabled), .continue-button:hover:not(:disabled) { background: var(--text); box-shadow: 0 6px 18px rgba(0, 0, 0, .18), 0 0 0 4px var(--accent-soft); }
.button-secondary { border-color: var(--border); color: var(--text); background: var(--surface-2); }
.button-secondary:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-3); }
.button-lime { color: #fff; background: var(--accent); }
.button-lime:hover:not(:disabled) { background: var(--accent); box-shadow: 0 6px 20px rgba(139, 116, 255, .35); }

/* Overview */
.overview-hero { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .9fr); gap: 16px; margin: 0 0 16px; }
.hero-resume, .hero-progress { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--surface); }
.hero-resume { display: flex; flex-direction: column; justify-content: space-between; gap: 22px; padding: 28px 30px; background: var(--hero-glow), var(--surface); }
.hero-resume::after {
  content: ""; position: absolute; right: -90px; bottom: -130px; width: 320px; height: 320px; border-radius: 50%; pointer-events: none;
  border: 1px solid var(--accent-line); opacity: .35; box-shadow: 0 0 0 48px var(--accent-soft), 0 0 0 96px rgba(139, 116, 255, .04);
}
.hero-kicker { display: inline-flex; align-items: center; gap: 8px; color: var(--text-3); font: 11px/1.5 var(--font-mono); letter-spacing: .14em; }
.hero-kicker::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 10px var(--accent-2); }
.hero-resume h2 { position: relative; z-index: 1; margin: 12px 0 8px; font-size: clamp(22px, 2vw, 28px); line-height: 1.35; font-weight: 700; letter-spacing: -.02em; }
.hero-resume p { position: relative; z-index: 1; max-width: 46ch; margin: 0; color: var(--text-2); font-size: 14.5px; line-height: 1.7; }
.hero-actions { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 10px; }
.hero-progress { display: flex; align-items: center; gap: 24px; padding: 24px 26px; }
.orbit-visual { position: relative; width: 132px; height: 132px; flex: none; }
.orbit-visual svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.orbit-track { fill: none; stroke: var(--surface-3); stroke-width: 10; }
.orbit-fill { fill: none; stroke: url(#study-gradient); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .9s var(--ease); }
.orbit-value { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.orbit-value strong { font-size: 30px; line-height: 1; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.orbit-value strong small { margin-left: 1px; color: var(--text-3); font-size: 14px; font-weight: 600; }
.orbit-value > span { margin-top: 6px; color: var(--text-3); font-size: 12px; }
.progress-facts { display: grid; flex: 1; min-width: 0; gap: 12px; margin: 0; }
.progress-facts div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.progress-facts div:last-child { padding-bottom: 0; border-bottom: 0; }
.progress-facts dt { color: var(--text-2); font-size: 13.5px; }
.progress-facts dd { margin: 0; font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.progress-facts dd small { margin-left: 3px; color: var(--text-3); font-size: 12px; font-weight: 500; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 0 0 36px; }
.stats-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-text { font-size: 16px; font-weight: 600; letter-spacing: 0; color: var(--text-2); }
.stat-card {
  display: flex; min-width: 0; min-height: 112px; flex-direction: column; justify-content: space-between; padding: 18px 18px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); color: inherit; background: var(--surface); text-align: left;
  transition: border-color .18s, transform .18s var(--ease), box-shadow .18s;
}
.stat-card.is-actionable { width: 100%; margin: 0; font: inherit; cursor: pointer; appearance: none; }
.stat-card.is-actionable:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-label { color: var(--text-2); font-size: 13.5px; }
.stat-symbol { display: grid; flex: none; width: 32px; height: 32px; place-items: center; border-radius: 10px; color: var(--accent-strong); background: var(--accent-soft); }
.stat-symbol .icon { width: 17px; height: 17px; }
.stat-card.is-good .stat-symbol { color: var(--success-text); background: var(--success-soft); }
.stat-card.is-warn .stat-symbol { color: var(--danger-text); background: var(--danger-soft); }
.stat-value { display: flex; align-items: baseline; gap: 5px; margin-top: 14px; font-size: 30px; line-height: 1.1; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat-unit { color: var(--text-3); font-size: 13px; font-weight: 500; letter-spacing: 0; }
.stat-foot { margin-top: 6px; color: var(--text-3); font-size: 12.5px; line-height: 1.5; }

.bank-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.bank-card {
  position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 188px; padding: 18px; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius-lg); color: inherit; background: var(--surface); text-align: left; cursor: pointer;
  transition: transform .2s var(--ease), box-shadow .2s, border-color .2s;
}
.bank-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 2px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); opacity: 0; transition: opacity .2s; }
.bank-card:hover:not(.is-disabled) { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.bank-card:hover:not(.is-disabled)::before { opacity: 1; }
.bank-card.is-disabled { color: var(--text-3); background: var(--surface-2); cursor: not-allowed; }
.bank-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bank-icon { display: grid; flex: none; width: 38px; height: 38px; place-items: center; border-radius: 11px; color: var(--accent-strong); background: var(--accent-soft); font: 600 13px/1 var(--font-mono); font-variant-numeric: tabular-nums; }
.bank-status { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 9px; border-radius: 999px; color: var(--text-2); background: var(--surface-2); font-size: 12px; line-height: 1.4; white-space: nowrap; }
.bank-status::before { content: ""; display: block; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.bank-status.is-started::before { background: var(--accent); }
.bank-status.is-good { color: var(--success-text); background: var(--success-soft); }
.bank-status.is-good::before { background: var(--success); }
.is-disabled .bank-status::before { background: var(--border-strong); }
.bank-card h3 { margin: 16px 0 4px; font-size: 17px; line-height: 1.45; font-weight: 650; overflow-wrap: anywhere; }
.bank-count { color: var(--text-2); font-size: 13px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.bank-count strong { color: var(--text); font-weight: 650; }
.bank-progress, .chapter-progress, .practice-progress { overflow: hidden; border-radius: 999px; background: var(--surface-3); }
.bank-progress { height: 5px; margin-top: auto; }
.bank-progress span, .chapter-progress span, .practice-progress span { display: block; height: 100%; min-width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .5s var(--ease); }
.bank-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 11px; color: var(--text-3); font-size: 12.5px; line-height: 1.45; }
.bank-arrow { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; color: var(--text-2); background: var(--surface-2); transition: color .2s, background-color .2s, transform .2s var(--ease); }
.bank-arrow .icon { width: 15px; height: 15px; }
.bank-card:hover:not(.is-disabled) .bank-arrow { color: var(--on-ink); background: var(--text); transform: translate(1px, -1px); }

/* Generic panels and states */
.panel { min-width: 0; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.empty-state { padding: 52px 20px; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); text-align: center; }
.empty-art { display: grid; width: 52px; height: 52px; place-items: center; margin: 0 auto 14px; border-radius: 16px; color: var(--accent-strong); background: var(--accent-soft); font-size: 22px; line-height: 1; }
.empty-art .icon { width: 24px; height: 24px; }
.empty-state h2 { margin: 0 0 6px; font-size: 18px; line-height: 1.45; font-weight: 650; }
.empty-state p { max-width: 44ch; margin: 0 auto 18px; color: var(--text-2); font-size: 14.5px; line-height: 1.7; }
.empty-state p:last-child { margin-bottom: 0; }
.error-panel { padding: 16px 18px; border: 1px solid var(--danger-line); border-radius: var(--radius); color: var(--danger-text); background: var(--danger-soft); font-size: 14px; line-height: 1.65; overflow-wrap: anywhere; }
.error-panel .button { min-height: 38px; margin: 12px 0 0; }
.inline-notice { padding: 11px 14px; margin-bottom: 14px; border-radius: var(--radius-sm); color: var(--warning-text); background: var(--warning-soft); font-size: 14px; line-height: 1.6; }
.loading-stage { padding-top: 6px; }
.skeleton { position: relative; overflow: hidden; border-radius: var(--radius-sm); background: var(--surface-2); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .05), transparent); animation: shimmer 1.5s ease-in-out infinite; }
:root[data-theme=light] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .75), transparent); }
.loading-heading { width: min(240px, 70%); height: 34px; margin-bottom: 12px; }
.loading-copy { width: min(340px, 88%); height: 14px; margin-bottom: 30px; }
.stat-skeleton { height: 128px; border-radius: var(--radius-lg); }
.loading-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.bank-skeleton { height: 188px; border-radius: var(--radius-lg); }

/* Bank detail */
.detail-top { margin-bottom: 20px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 2px; margin: 0 0 14px; border: 0; border-radius: 8px; color: var(--text-2); background: transparent; font-size: 14px; cursor: pointer; transition: color .15s; }
.back-link .icon { width: 16px; height: 16px; transition: transform .15s var(--ease); }
.back-link:hover { color: var(--text); }
.back-link:hover .icon { transform: translateX(-2px); }
.detail-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.detail-title-group { display: flex; align-items: center; gap: 16px; min-width: 0; }
.detail-title-group .bank-icon { width: 52px; height: 52px; border-radius: 15px; font-size: 16px; }
.detail-title-group h1 { margin: 0; font-size: clamp(26px, 2.4vw, 32px); line-height: 1.3; font-weight: 700; letter-spacing: -.02em; overflow-wrap: anywhere; }
.detail-title-group p { margin: 4px 0 0; color: var(--text-2); font-size: 14.5px; line-height: 1.6; }
.detail-actions { display: flex; flex: none; flex-wrap: wrap; gap: 8px; }
.detail-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin-bottom: 28px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.summary-divider { display: none; }
.summary-item { display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: 2px; padding: 16px 20px; color: var(--text-2); font-size: 13px; line-height: 1.5; border-left: 1px solid var(--border); }
.summary-item:first-child { border-left: 0; }
.summary-item strong { color: var(--text); font-size: 24px; line-height: 1.25; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.detail-summary .summary-item:nth-of-type(2) strong { color: var(--success-text); }
.detail-summary .summary-item:nth-of-type(3) strong { color: var(--danger-text); }
.summary-progress { grid-column: 1 / -1; height: 3px; border-radius: 0; background: var(--surface-3); }
.summary-progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .5s var(--ease); }

.chapter-list { display: grid; gap: 8px; min-width: 0; }
.chapter-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px; min-width: 0; min-height: 74px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); transition: border-color .16s, background-color .16s;
}
.chapter-row:hover { border-color: var(--border-strong); }
.chapter-row.is-disabled { color: var(--text-3); background: var(--surface-2); }
.chapter-index { display: grid; flex: none; width: 34px; height: 34px; place-items: center; border-radius: 10px; color: var(--text-2); background: var(--surface-2); font: 600 12px/1 var(--font-mono); font-variant-numeric: tabular-nums; }
.chapter-copy { flex: 1 1 200px; min-width: 0; }
.chapter-copy strong { display: block; font-size: 15px; line-height: 1.5; font-weight: 600; overflow-wrap: anywhere; }
.chapter-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0; margin-top: 2px; }
.chapter-meta small { color: var(--text-3); font-size: 12.5px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.chapter-meta small + small::before { content: "·"; margin: 0 7px; color: var(--border-strong); }
.chapter-meta .chapter-result { color: var(--text-2); }
.chapter-meta .chapter-rate.is-good { color: var(--success-text); }
.chapter-progress { width: min(100%, 280px); height: 4px; margin-top: 9px; }
.chapter-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; max-width: 100%; margin-left: auto; }
.chapter-list .chapter-actions .button { flex: 0 0 auto; min-width: max-content; min-height: 36px; margin: 0; padding: 7px 13px; border-radius: 10px; font-size: 13px; white-space: nowrap; }
.chapter-list .chapter-actions .button[data-action=start-chapter] { color: var(--on-ink); border-color: transparent; background: var(--text); }
.chapter-review-button:not(:disabled), .book-review-button:not(:disabled) { color: var(--danger-text); }

/* Collections */
.collection-filters { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; min-width: 0; padding: 16px; margin: 0 0 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.filter-field { display: grid; flex: 1 1 200px; min-width: min(100%, 160px); gap: 6px; }
.filter-field > span { color: var(--text-2); font-size: 13px; font-weight: 600; }
.filter-select, .filter-field select, select.text-field {
  width: 100%; min-width: 0; min-height: 42px; padding: 8px 36px 8px 12px; border: 1px solid var(--border); border-radius: 11px;
  color: var(--text); background-color: var(--surface-2); font-size: 14px; line-height: 1.4; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8a9c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
.filter-select:focus { outline: 0; border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft); }
.filter-select option { color: var(--text); background: var(--surface); }
.collection-filters > .button { flex: none; min-height: 42px; }
.collection-toolbar { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; color: var(--text-2); font-size: 14px; line-height: 1.5; }
.collection-toolbar > span:first-child { color: var(--text); font-weight: 600; }
.collection-toolbar > span:nth-child(2) { color: var(--text-3); }
.collection-toolbar > .button { margin-left: auto; }
.collection-list { display: grid; gap: 8px; min-width: 0; }
.collection-item { display: flex; align-items: center; gap: 14px; min-width: 0; min-height: 70px; padding: 13px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); transition: border-color .16s, transform .16s var(--ease); }
.collection-item:hover { border-color: var(--border-strong); }
.collection-num { display: grid; flex: none; min-width: 38px; height: 34px; padding: 0 6px; place-items: center; border-radius: 10px; color: var(--accent-strong); background: var(--accent-soft); font: 600 12px/1 var(--font-mono); font-variant-numeric: tabular-nums; }
.collection-copy { flex: 1 1 auto; min-width: 0; }
.collection-copy strong { display: -webkit-box; overflow: hidden; font-size: 15px; line-height: 1.55; font-weight: 600; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.collection-copy small { display: block; margin-top: 3px; overflow: hidden; color: var(--text-3); font-size: 12.5px; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.collection-item .button { flex: none; min-height: 36px; margin-left: auto; padding: 6px 10px 6px 14px; border-radius: 10px; font-size: 13px; gap: 4px; }
.collection-open .icon { width: 15px; height: 15px; transition: transform .16s var(--ease); }
.collection-item:hover .collection-open .icon { transform: translateX(2px); }

/* Practice */
.practice-page { --answer-green: var(--success); --answer-red: var(--danger); width: min(100%, 1240px); min-width: 0; padding: 18px 0 18px; margin: 0 auto; }
.is-practice .main-content { width: min(100%, 1300px); max-width: none; min-height: 100vh; min-height: 100svh; padding: 18px clamp(16px, 3vw, 40px) 48px; animation: none; transform: none; }
.practice-top { display: flex; align-items: center; gap: 14px; min-width: 0; padding-bottom: 14px; }
.practice-close { display: grid; flex: none; width: 40px; height: 40px; min-height: 0; place-items: center; padding: 0; border: 1px solid var(--border); border-radius: 12px; color: var(--text-2); background: var(--surface); }
.practice-close:hover:not(:disabled) { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.practice-close .icon { width: 18px; height: 18px; }
.practice-meta { min-width: 0; }
.practice-meta strong { display: block; overflow: hidden; font-size: 15px; line-height: 1.4; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.practice-meta span { display: block; overflow: hidden; margin-top: 2px; color: var(--text-3); font-size: 13px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.practice-page .practice-theme { flex: none; margin-left: auto; min-height: 0; }
.practice-count { flex: none; margin-left: auto; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; color: var(--text-3); background: var(--surface); font-size: 13px; line-height: 1.4; font-variant-numeric: tabular-nums; white-space: nowrap; }
.practice-page .practice-theme + .practice-count { margin-left: 0; }
.practice-count strong { color: var(--text); font-size: 14px; font-weight: 700; }
.practice-progress { height: 4px; margin: 0 0 20px; }
.practice-grid { display: grid; grid-template-columns: minmax(0, 1fr) 272px; align-items: start; gap: 18px; overflow-x: clip; }

.question-card {
  position: relative; min-width: 0; padding: clamp(22px, 2.6vw, 34px); border: 1px solid var(--border); border-radius: var(--radius-xl);
  background: var(--surface); box-shadow: var(--shadow-sm); touch-action: pan-y; animation: page-enter .2s ease both;
}
.practice-page .question-card.is-entering-next { animation: practice-slide-next 240ms var(--ease) both; }
.practice-page .question-card.is-entering-previous { animation: practice-slide-previous 240ms var(--ease) both; }
.practice-page .is-loading-question { pointer-events: none; opacity: .7; transition: opacity .2s; }
.question-card-top { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; margin-bottom: 18px; }
.question-type { flex: none; padding: 4px 10px; border-radius: 999px; color: var(--accent-strong); background: var(--accent-soft); font-size: 12.5px; font-weight: 600; line-height: 1.4; }
.question-topic { min-width: 0; overflow: hidden; color: var(--text-3); font-size: 13px; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.redo-question { min-height: 34px; margin-left: auto; padding: 6px 12px; border-radius: 10px; font-size: 13px; font-weight: 550; white-space: nowrap; }
.favorite-button { display: grid; flex: none; width: 36px; height: 36px; min-height: 0; place-items: center; padding: 0; border: 1px solid var(--border); border-radius: 10px; color: var(--text-2); background: var(--surface-2); font-size: 18px; }
.favorite-button .icon { width: 18px; height: 18px; }
.favorite-button:hover:not(:disabled) { color: var(--danger-text); border-color: var(--border-strong); }
.favorite-button.is-favorite { color: var(--danger-text); border-color: var(--danger-line); background: var(--danger-soft); }
.favorite-button.is-favorite .icon { fill: currentColor; }
.question-card h1 { margin: 0 0 14px; color: var(--text-3); font: 600 13px/1.4 var(--font-mono); letter-spacing: .08em; }
.question-content { color: var(--text); font-size: 17.5px; line-height: 1.85; font-weight: 500; overflow-wrap: anywhere; }
.question-content p { margin: 0 0 12px; }
.question-content p:last-child { margin-bottom: 0; }
.question-content img, .option-body img, .result-explanation img { display: inline-block; max-width: 100%; height: auto; vertical-align: middle; border-radius: 8px; }
.question-content table, .option-body table, .result-explanation table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; overscroll-behavior-inline: contain; }
.question-content td, .question-content th, .result-explanation td, .result-explanation th { padding: 6px 10px; border: 1px solid var(--border); }
.question-content pre, .option-body pre, .result-explanation pre { max-width: 100%; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.question-content iframe, .question-content video, .option-body iframe, .option-body video { max-width: 100%; }
.question-images { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 0; }
.question-images img { display: block; max-width: min(100%, 620px); max-height: min(55vh, 440px); object-fit: contain; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.choice-help { margin: 22px 0 10px; color: var(--text-3); font-size: 13px; line-height: 1.5; }
.option-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.question-content + .option-list, .question-images + .option-list { margin-top: 22px; }
.option-list li { min-width: 0; }
.option-label {
  position: relative; display: flex; align-items: flex-start; gap: 12px; min-height: 54px; padding: 13px 15px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer;
  transition: border-color .15s, background-color .15s, box-shadow .15s, transform .15s var(--ease);
}
.option-label:hover:not(.is-correct):not(.is-wrong):not(.is-readonly) { border-color: var(--accent-line); background: var(--surface-2); }
.option-label:has(input:disabled):hover:not(.is-correct):not(.is-wrong) { border-color: var(--border); background: var(--surface); }
.option-label:active:not(.is-readonly):not(:has(input:disabled)) { background: var(--surface-3); }
.option-label:focus-within:not(.is-correct):not(.is-wrong) { border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft); }
.option-label input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.option-letter {
  display: grid; flex: none; place-items: center; width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 9px;
  color: var(--text-2); background: var(--surface-2); font: 600 13px/1 var(--font-mono); transition: color .15s, background-color .15s, border-color .15s;
}
.option-body { align-self: center; min-width: 0; color: var(--text); font-size: 16px; line-height: 1.7; overflow-wrap: anywhere; }
.option-body p { margin: 0 0 6px; }
.option-body p:last-child { margin-bottom: 0; }
.option-label.is-selected:not(.is-correct):not(.is-wrong) { border-color: var(--accent); background: var(--accent-soft); }
.option-label.is-selected:not(.is-correct):not(.is-wrong) .option-letter { color: #fff; border-color: var(--accent); background: var(--accent); }
.option-label.is-correct { border-color: var(--success-line); background: var(--success-soft); }
.option-label.is-correct .option-letter { color: #fff; border-color: var(--success); background: var(--success); }
.option-label.is-wrong { border-color: var(--danger-line); background: var(--danger-soft); }
.option-label.is-wrong .option-letter { color: #fff; border-color: var(--danger); background: var(--danger); }
.is-just-graded .option-label.is-correct { animation: glow-success .9s var(--ease) both; }
.is-just-graded .option-label.is-wrong { animation: glow-danger .9s var(--ease) both; }
.option-label:has(input:disabled):not(.is-correct):not(.is-wrong):not(.is-selected) { opacity: .72; cursor: default; }
.option-label.is-readonly { cursor: default; background: var(--surface-2); }
.answer-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
.answer-hint { margin: 14px 0 0; color: var(--text-3); font-size: 13px; line-height: 1.5; }
.answer-actions .answer-hint { margin: 0; }
.answer-explanation { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); font-size: 14px; }
.answer-explanation > summary { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 14px; color: var(--text); cursor: pointer; list-style: none; border-radius: var(--radius); }
.answer-explanation > summary::-webkit-details-marker { display: none; }
.explain-toggle { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; color: var(--text-2); font-size: 13px; font-weight: 600; white-space: nowrap; }
.explain-toggle::after { content: ""; width: 6px; height: 6px; margin-bottom: 3px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform .2s var(--ease); }
.answer-explanation[open] .explain-toggle::after { margin: 3px 0 0; transform: rotate(-135deg); }
.answer-explanation > summary:hover .explain-toggle { color: var(--text); }
.answer-explanation .result-explanation { padding: 0 16px 14px; font-size: 15px; line-height: 1.75; }
.result-explanation { color: var(--text); font-size: 15px; line-height: 1.8; overflow-wrap: anywhere; }
.reference-answer { padding: 14px 16px; margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); background: var(--surface-2); font-size: 15px; }
.reference-answer p { margin: 0 0 8px; }
.result-label { font-weight: 650; }
.readonly-options { margin-top: 4px; }
.subjective-box { margin-top: 20px; }
.subjective-box > p { margin: 0 0 12px; color: var(--text-2); font-size: 14.5px; line-height: 1.7; }
.subjective-actions, .subjective-grade { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

.navigator { position: sticky; top: 18px; width: 100%; max-width: 100%; min-width: 0; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--surface); }
.navigator-head { display: flex; align-items: center; gap: 8px; min-height: 24px; margin: 0; cursor: pointer; list-style: none; }
.navigator-head::-webkit-details-marker { display: none; }
.navigator-head strong { font-size: 14px; font-weight: 650; white-space: nowrap; }
.navigator-head > span { margin-left: auto; color: var(--text-3); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.navigator-head::after { content: ""; flex: none; width: 7px; height: 7px; margin: 0 4px 3px 2px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(45deg); transition: transform .2s var(--ease); }
.navigator[open] > .navigator-head::after { margin-bottom: -3px; transform: rotate(-135deg); }
.question-map {
  position: relative; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; max-height: min(55vh, 480px);
  padding: 4px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
}
.navigator[open] .question-map { margin-top: 12px; }
.question-map button {
  position: relative; box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%; height: 40px; min-height: 40px; padding: 0;
  border: 1px solid var(--border); border-radius: 10px; color: var(--text-2); background: var(--surface-2);
  font: 500 12.5px/1 var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; cursor: pointer;
  transition: border-color .15s, color .15s, background-color .15s;
}
.question-map button:hover:not(:disabled) { border-color: var(--accent-line); color: var(--text); }
.question-map button.is-visited:not(.is-current):not(.is-answered-correct):not(.is-answered-wrong) { color: var(--text); border-color: var(--border-strong); }
.question-map button.is-answered-correct { color: var(--success-text); border-color: var(--success-line); background: var(--success-soft); }
.question-map button.is-answered-wrong { color: var(--danger-text); border-color: var(--danger-line); background: var(--danger-soft); }
.question-map button.is-current { color: var(--text); border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), inset 0 0 0 1px var(--accent); font-weight: 700; }
.question-map button.is-current:not(.is-answered-correct):not(.is-answered-wrong) { background: var(--accent-soft); }
.question-map button.is-answered-correct::after, .question-map button.is-answered-wrong::after { content: ""; position: absolute; top: 4px; right: 4px; width: 5px; height: 5px; border-radius: 50%; }
.question-map button.is-answered-correct::after { background: var(--success); }
.question-map button.is-answered-wrong::after { background: var(--danger); }
.navigator-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; padding-top: 12px; margin-top: 12px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 12px; line-height: 1.45; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-square { display: block; flex: none; width: 9px; height: 9px; border: 1px solid var(--border-strong); border-radius: 3px; background: var(--surface-2); }
.legend-square.correct { border-color: var(--success); background: var(--success); }
.legend-square.wrong { border-color: var(--danger); background: var(--danger); }
.practice-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; }
.practice-nav .button { min-width: 120px; }
.practice-nav .button-primary { padding-inline: 20px; }
.practice-nav .button .icon { transition: transform .18s var(--ease); }
.nav-next:hover:not(:disabled) .icon { transform: translateX(3px); }
.nav-previous:hover:not(:disabled) .icon { transform: translateX(-3px); }
.nav-next.is-ready { animation: ready-pulse 1.6s var(--ease) .35s 1 both; }

/* Papers */
.paper-builder, .saved-papers { margin-bottom: 24px; }
.paper-builder { padding: 24px; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--surface); }
.paper-title-field { display: grid; gap: 8px; margin-bottom: 24px; color: var(--text-2); font-size: 13.5px; font-weight: 600; }
.paper-title-field input { width: 100%; max-width: 520px; }
.paper-books { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; padding: 0; margin: 0 0 24px; border: 0; }
.paper-books legend, .paper-chapters legend { margin-bottom: 12px; padding: 0; color: var(--text-2); font-size: 13.5px; font-weight: 600; }
.paper-book {
  position: relative; display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-height: 40px; padding: 8px 14px 8px 10px;
  border: 1px solid var(--border); border-radius: 999px; color: var(--text-2); background: var(--surface-2); font-size: 14px; cursor: pointer;
  transition: color .15s, border-color .15s, background-color .15s;
}
.paper-book:hover { border-color: var(--border-strong); color: var(--text); }
.paper-book input { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.paper-book span { overflow-wrap: anywhere; }
.paper-book:has(input:checked) { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.paper-book:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.paper-chapters { min-width: 0; padding: 8px 16px; margin: 0 0 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2); }
.paper-chapters legend { padding: 0 6px; margin-left: -6px; color: var(--text); }
.paper-chapters > p { margin: 8px 0; color: var(--text-3); font-size: 14px; }
.paper-chapter-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.paper-chapter-row:last-child { border-bottom: 0; }
.paper-chapter-row > span { min-width: 0; overflow-wrap: anywhere; }
.paper-chapter-row strong { display: block; font-size: 14px; font-weight: 500; line-height: 1.5; }
.paper-chapter-row small, .saved-paper small { display: block; margin-top: 2px; color: var(--text-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.paper-chapter-row .paper-count { flex: none; width: 88px; min-width: 74px; min-height: 40px; padding: 8px; text-align: center; font-variant-numeric: tabular-nums; }
.paper-builder-actions {
  position: sticky; bottom: 12px; z-index: 4; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px;
  padding: 12px 12px 12px 18px; margin-top: 20px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--glass); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: var(--shadow-md);
}
.paper-total { font-size: 15px; font-variant-numeric: tabular-nums; }
.paper-total.is-error { color: var(--danger-text); }
.saved-papers > p { padding: 22px; margin: 0; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); color: var(--text-3); text-align: center; }
.saved-paper { display: flex; align-items: center; gap: 10px; padding: 16px 18px; margin-bottom: 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.saved-paper > div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.saved-paper strong { font-size: 15px; font-weight: 600; }
.saved-paper .button { min-height: 38px; padding: 7px 14px; border-radius: 10px; font-size: 13px; white-space: nowrap; }

/* Admin */
.admin-management { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); align-items: start; gap: 16px; min-width: 0; }
.admin-form, .admin-users-panel { min-width: 0; padding: 22px; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--surface); }
.admin-form { display: grid; gap: 10px; }
.admin-form .field-label { margin: 6px 0 -2px; }
.admin-form .button { justify-self: start; margin-top: 6px; }
.admin-form-heading h2, .admin-users-panel > h2 { margin: 0 0 4px; font-size: 17px; line-height: 1.45; font-weight: 650; }
.admin-form-heading p, .admin-users-panel > p { margin: 0 0 6px; color: var(--text-2); font-size: 13.5px; line-height: 1.65; }
.admin-users-panel > p { margin-bottom: 16px; }
.admin-form-status { padding: 10px 12px; margin: 0; border-radius: var(--radius-sm); color: var(--warning-text); background: var(--warning-soft); font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.admin-form-status.is-error { color: var(--danger-text); background: var(--danger-soft); }
.admin-form-status.is-success { color: var(--success-text); background: var(--success-soft); }
.admin-users { display: grid; gap: 8px; }
.admin-user-row { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.admin-user-row::before { content: attr(data-initial); display: grid; flex: none; width: 34px; height: 34px; place-items: center; border-radius: 10px; color: var(--accent-strong); background: var(--accent-soft); font-weight: 700; text-transform: uppercase; }
.admin-user-identity { display: grid; flex: 1 1 auto; min-width: 0; gap: 1px; }
.admin-user-name { font-size: 15px; line-height: 1.45; font-weight: 600; overflow-wrap: anywhere; }
.admin-user-identity small { color: var(--text-3); font-size: 12.5px; }
.admin-user-role { flex: none; padding: 3px 10px; border-radius: 999px; color: var(--text-2); background: var(--surface-3); font-size: 12px; font-weight: 600; }
.admin-user-role.is-admin { color: var(--accent-strong); background: var(--accent-soft); }
.admin-users-empty { padding: 18px 14px; margin: 0; border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--text-3); font-size: 14px; }

/* Forms */
.field-label { display: block; margin: 18px 0 8px; color: var(--text); font-size: 14px; line-height: 1.45; font-weight: 600; }
.text-field {
  display: block; width: 100%; min-width: 0; min-height: 46px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); background: var(--surface-2); font-size: 15px; line-height: 1.45; transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.text-field:hover { border-color: var(--border-strong); }
.text-field:focus { border-color: var(--accent-line); outline: 0; background: var(--surface); box-shadow: 0 0 0 4px var(--accent-soft); }
.text-field::placeholder { color: var(--text-3); }
textarea.text-field { min-height: 120px; resize: vertical; }
.form-error { padding: 10px 12px; margin-top: 14px; border-radius: var(--radius-sm); color: var(--danger-text); background: var(--danger-soft); font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }

/* Login */
.auth-screen { position: fixed; z-index: 100; inset: 0; display: grid; grid-template-columns: minmax(340px, 1fr) minmax(0, 1fr); min-width: 320px; overflow: auto; overscroll-behavior-y: contain; color: var(--text); background: var(--bg); }
.auth-aside {
  position: relative; display: flex; min-height: max(100vh, 620px); min-height: max(100svh, 620px); flex-direction: column; justify-content: space-between;
  padding: 40px clamp(32px, 5vw, 80px); overflow: hidden; border-right: 1px solid var(--border);
  background: radial-gradient(90% 70% at 15% 40%, rgba(139, 116, 255, .22), transparent 70%), radial-gradient(70% 60% at 90% 100%, rgba(95, 200, 255, .14), transparent 70%), var(--surface);
}
.auth-aside::before, .auth-aside::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.auth-aside::before { right: -160px; bottom: 8%; width: 460px; height: 460px; border: 1px solid var(--accent-line); opacity: .45; box-shadow: 0 0 0 60px rgba(139, 116, 255, .05), 0 0 0 120px rgba(139, 116, 255, .03); }
.auth-aside::after { right: 120px; bottom: calc(8% + 214px); width: 10px; height: 10px; background: var(--accent-2); box-shadow: 0 0 18px var(--accent-2); animation: orbit-pulse 3.2s ease-in-out infinite; }
.auth-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; }
.brand-mark-large { width: 40px; height: 40px; padding: 8px; }
.auth-message { position: relative; z-index: 1; max-width: 480px; padding: 48px 0; margin: auto 0; }
.auth-message .eyebrow { color: var(--text-2); }
.auth-message h1 { margin: 22px 0 16px; font-size: clamp(34px, 3.8vw, 52px); line-height: 1.32; font-weight: 700; letter-spacing: -.035em; }
.auth-message p { max-width: 36ch; margin: 0; color: var(--text-2); font-size: 16px; line-height: 1.8; }
.auth-aside-foot { position: relative; z-index: 1; display: flex; justify-content: space-between; gap: 16px; color: var(--text-3); font: 11.5px/1.45 var(--font-mono); letter-spacing: .12em; }
.auth-main { display: grid; min-width: 0; min-height: max(100vh, 620px); min-height: max(100svh, 620px); place-items: center; padding: 44px 28px; }
.auth-card { width: min(100%, 384px); }
.auth-card-brand { display: none; margin-bottom: 18px; }
.auth-kicker { display: inline-flex; padding: 4px 11px; border-radius: 999px; color: var(--accent-strong); background: var(--accent-soft); font-size: 12.5px; font-weight: 600; }
.auth-card h2 { margin: 16px 0 6px; font-size: 30px; line-height: 1.3; font-weight: 700; letter-spacing: -.025em; }
.auth-intro { margin: 0 0 24px; color: var(--text-2); font-size: 15px; line-height: 1.7; }
.login-submit { width: 100%; min-height: 48px; margin-top: 26px; font-size: 15px; }
.login-submit span:first-child { margin: 0 auto; }
.login-submit span:last-child { position: absolute; right: 18px; display: grid; }
.login-submit { position: relative; }
.login-submit .icon { width: 18px; height: 18px; transition: transform .2s var(--ease); }
.login-submit:hover .icon { transform: translateX(3px); }
.login-submit.is-loading { opacity: .72; pointer-events: none; }
.auth-footnote { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 20px 0 0; color: var(--text-3); font-size: 13px; line-height: 1.55; text-align: center; }
.lock-icon { display: grid; color: var(--text-3); }
.lock-icon .icon { width: 15px; height: 15px; }

/* Overlays */
.sidebar-scrim { position: fixed; z-index: 19; inset: 0; background: var(--scrim); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); animation: scrim-in .16s ease both; }
.toast-region { position: fixed; z-index: 80; right: max(20px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom)); display: grid; gap: 8px; max-width: calc(100vw - 32px); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; max-width: min(380px, calc(100vw - 32px)); padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); background: var(--surface); box-shadow: var(--shadow-lg); font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; animation: toast-in .24s var(--ease) both; }
.toast::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.toast.is-error { border-color: var(--danger-line); }
.toast.is-error::before { background: var(--danger); }
.account-menu { position: fixed; z-index: 50; left: 14px; bottom: 82px; width: min(232px, calc(100vw - 28px)); padding: 6px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); background: var(--surface); box-shadow: var(--shadow-lg); animation: menu-enter .16s var(--ease) both; }
.account-menu-user { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 9px 9px 11px; margin-bottom: 4px; border-bottom: 1px solid var(--border); font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.avatar-small { width: 30px; height: 30px; border-radius: 9px; font-size: 13px; }
.account-menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 8px 10px; border: 0; border-radius: var(--radius-sm); color: var(--danger-text); background: transparent; text-align: left; font-size: 14px; cursor: pointer; }
.account-menu button .icon { width: 17px; height: 17px; }
.account-menu button:hover { background: var(--danger-soft); }

/* Answer feedback slot: height reserved before grading so options never move (see 2026-11-04 stable-options fix). */
.practice-page .answer-feedback { display: flow-root; min-height: 55px; }
.practice-page .answer-feedback.is-multiple { min-height: 64px; }
.practice-page .question-card.is-updating { animation: none; }
.answer-verdict { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-width: 0; min-height: 44px; font-size: 14px; line-height: 1.4; }
.answer-feedback > .answer-verdict { margin-top: 12px; min-height: 0; }
.answer-verdict .icon { width: 20px; height: 20px; padding: 3px; border-radius: 50%; color: #fff; stroke-width: 2.6; }
.answer-verdict strong { font-weight: 650; }
.answer-verdict span { color: var(--text-2); font-variant-numeric: tabular-nums; }
.answer-verdict span::before { content: "·"; margin-right: 8px; color: var(--border-strong); }
.answer-verdict.is-correct strong { color: var(--success-text); }
.answer-verdict.is-correct .icon { background: var(--success); }
.answer-verdict.is-wrong strong { color: var(--danger-text); }
.answer-verdict.is-wrong .icon { background: var(--danger); }
.is-just-graded .answer-verdict .icon { animation: verdict-pop .45s var(--ease) both; }

/* Route enter: bars fill and the accuracy ring draws in. */
.is-entering .bank-progress span, .is-entering .chapter-progress span, .is-entering .summary-progress span { animation: bar-grow .9s var(--ease) .12s both; }
.is-entering .orbit-fill { animation: ring-draw 1.1s var(--ease) .1s both; }
.is-theme-switching, .is-theme-switching *, .is-theme-switching *::before, .is-theme-switching *::after { transition: background-color .3s ease, border-color .3s ease, color .3s ease, fill .3s ease, stroke .3s ease !important; }

/* Motion */
@keyframes shimmer { 100% { transform: translateX(100%); } }
@keyframes page-enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes practice-slide-next { from { opacity: 0; transform: translateX(36px); } to { opacity: 1; transform: translateX(0); } }
@keyframes practice-slide-previous { from { opacity: 0; transform: translateX(-36px); } to { opacity: 1; transform: translateX(0); } }
@keyframes glow-success { 0% { box-shadow: 0 0 0 0 var(--success-line); } 100% { box-shadow: 0 0 0 10px transparent; } }
@keyframes glow-danger { 0% { box-shadow: 0 0 0 0 var(--danger-line); } 100% { box-shadow: 0 0 0 10px transparent; } }
@keyframes verdict-pop { 0% { transform: scale(.4); opacity: 0; } 60% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
@keyframes bar-grow { from { width: 0; } }
@keyframes ring-draw { from { stroke-dashoffset: 326.73; } }
@keyframes ready-pulse { 0% { box-shadow: 0 0 0 0 var(--accent-line); } 100% { box-shadow: 0 0 0 12px transparent; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes menu-enter { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes orbit-pulse { 0%, 100% { opacity: .55; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.15); } }

/* Desktop practice density (is-compact / is-dense are set by fitPracticeToViewport). */
@media (min-width: 901px) {
  .practice-page.is-compact .question-card { padding: 20px 24px; }
  .practice-page.is-compact .question-card-top { margin-bottom: 12px; }
  .practice-page.is-compact .question-card h1 { margin-bottom: 10px; }
  .practice-page.is-compact .question-content { font-size: 16.5px; line-height: 1.65; }
  .practice-page.is-compact .choice-help { margin: 12px 0 8px; }
  .practice-page.is-compact .option-list { gap: 8px; }
  .practice-page.is-compact .option-label { min-height: 44px; padding: 8px 12px; }
  .practice-page.is-compact .option-letter { width: 27px; height: 27px; }
  .practice-page.is-dense .question-card { padding: 16px 20px; }
  .practice-page.is-dense .question-content, .practice-page.is-dense .option-body { font-size: 15px; line-height: 1.5; }
  .practice-page.is-dense .option-label { padding: 6px 10px; }
}

@media (min-width: 1600px) {
  .practice-grid { grid-template-columns: minmax(0, 1fr) 288px; gap: 22px; }
}
@media (max-width: 1180px) {
  .stats-grid, .loading-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .admin-management { grid-template-columns: minmax(0, 1fr); }
  .overview-hero { grid-template-columns: minmax(0, 1fr) minmax(260px, .85fr); }
}
@media (max-width: 1023px) {
  .overview-hero { grid-template-columns: minmax(0, 1fr); }
  .detail-heading { align-items: flex-start; flex-direction: column; gap: 16px; }
}

@media (max-width: 900px) {
  :root { --topbar-height: 62px; }
  .sidebar { z-index: 30; width: min(284px, calc(100vw - 54px)); transform: translateX(-102%); transition: transform .26s var(--ease), box-shadow .26s; }
  body.sidebar-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .nav-item.is-active::before { display: none; }
  .app-main { margin-left: 0; }
  .topbar { gap: 8px; padding: 0 14px; }
  .mobile-menu { display: grid; }
  .menu-lines { position: relative; display: block; width: 16px; height: 2px; border-radius: 2px; background: currentColor; }
  .menu-lines::before, .menu-lines::after { content: ""; position: absolute; left: 0; width: 16px; height: 2px; border-radius: 2px; background: currentColor; }
  .menu-lines::before { top: -5px; }
  .menu-lines::after { top: 5px; }
  .breadcrumb { max-width: 120px; }
  .breadcrumb > span { display: none; }
  .global-search { flex: 1 1 auto; width: auto; min-width: 44px; }
  .topbar-avatar { display: grid; width: 40px; height: 40px; border-radius: 12px; }
  .account-menu { top: calc(var(--topbar-height) + 6px); right: 12px; bottom: auto; left: auto; }
  .main-content { padding: 26px 20px 56px; }
  .auth-screen { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { display: none; }
  .auth-card-brand { display: block; }
  .auth-main { min-height: max(100vh, 560px); min-height: max(100svh, 560px); padding: 34px 24px; background: radial-gradient(80% 50% at 50% 0%, var(--accent-soft), transparent 70%); }

  /* Practice: question first, fixed bottom navigation, collapsible navigator. */
  .is-practice .main-content { padding: 8px 10px calc(76px + env(safe-area-inset-bottom)); }
  .practice-page { padding-top: 0; }
  .practice-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .practice-page .practice-top { gap: 9px; padding-bottom: 7px; }
  .practice-page .practice-close { width: 34px; height: 34px; border-radius: 10px; }
  .practice-page .practice-theme { width: 34px; min-width: 34px; height: 34px; border-radius: 10px; }
  .practice-page .practice-meta strong { font-size: 13.5px; line-height: 1.3; }
  .practice-page .practice-meta span { margin-top: 1px; font-size: 11.5px; line-height: 1.3; }
  .practice-page .practice-count { padding: 4px 9px; font-size: 12px; }
  .practice-page .practice-count strong { font-size: 13px; }
  .practice-page .practice-progress { height: 3px; margin-bottom: 8px; }
  .practice-page .question-card { padding: 14px 13px; border-radius: 16px; box-shadow: none; }
  .practice-page .question-card-top { flex-wrap: nowrap; gap: 7px; margin-bottom: 9px; }
  .practice-page .question-type { padding: 2px 8px; font-size: 11.5px; }
  .practice-page .question-topic { flex: 1; font-size: 11.5px; }
  .practice-page .redo-question { min-height: 32px; padding: 5px 9px; font-size: 12px; }
  .practice-page .favorite-button { width: 32px; height: 32px; }
  .practice-page .question-card h1 { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
  .practice-page .question-content { font-size: 16px; line-height: 1.6; }
  .practice-page .question-content p { margin: 0 0 7px; }
  .practice-page .question-content p:last-child { margin-bottom: 0; }
  .practice-page .choice-help { margin: 10px 0 6px; font-size: 12px; line-height: 1.3; }
  .practice-page .option-list { gap: 6px; }
  .practice-page .question-content + .option-list, .practice-page .question-images + .option-list { margin-top: 12px; }
  .practice-page .option-label { min-height: 44px; padding: 8px 9px; gap: 9px; align-items: center; border-radius: 12px; }
  .practice-page .option-letter { width: 26px; height: 26px; border-radius: 8px; font-size: 12px; }
  .practice-page .option-body { font-size: 15px; line-height: 1.45; }
  .practice-page .option-body p { margin-bottom: 4px; }
  .practice-page .answer-hint { display: none; }
  .practice-page .answer-feedback.is-multiple { min-height: 55px; }
  .practice-page .answer-feedback > .answer-verdict { margin-top: 9px; font-size: 13px; }
  .practice-page .answer-explanation > summary { min-height: 40px; }
  .practice-page .answer-explanation { margin-top: 9px; }
  .practice-page .answer-explanation > summary { padding: 9px 12px; }
  .practice-page .answer-actions { margin-top: 10px; }
  .practice-page .answer-actions .button { min-height: 40px; padding: 8px 14px; }
  .practice-page .question-images { margin-top: 8px; gap: 6px; }
  .practice-page .question-images img { max-height: 240px; }
  .practice-page .navigator { position: static; order: 2; padding: 10px 12px; border-radius: 14px; }
  .practice-page .navigator-head strong { font-size: 12.5px; }
  .practice-page .navigator-head > span { font-size: 11.5px; }
  .practice-page .question-map { grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); max-height: 240px; }
  .practice-page .question-map button { height: 44px; min-height: 44px; }
  .practice-page .practice-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; gap: 8px; margin: 0; padding: 8px 10px max(8px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border); background: var(--glass); -webkit-backdrop-filter: saturate(160%) blur(14px); backdrop-filter: saturate(160%) blur(14px);
  }
  .practice-page .practice-nav .button { flex: 1; min-width: 0; min-height: 44px; padding: 10px 14px; font-size: 14px; }
  .practice-page.is-compact .question-card { padding: 11px; }
  .practice-page.is-compact .question-content { font-size: 15px; line-height: 1.45; }
  .practice-page.is-compact .choice-help { margin-top: 7px; }
  .practice-page.is-compact .option-list { gap: 5px; }
  .practice-page.is-compact .option-label { padding: 6px 8px; }
  .practice-page.is-dense .question-content, .practice-page.is-dense .option-body { font-size: 14px; line-height: 1.4; }
  .practice-page.is-dense .option-label { padding: 5px 7px; }
  .practice-page.is-dense .question-card-top { margin-bottom: 4px; }
}

@media (max-width: 650px) {
  .chapter-actions { display: grid; grid-template-columns: 1.2fr 1fr 1fr; flex: 1 1 100%; width: 100%; margin: 0; }
  .chapter-list .chapter-actions .button { width: 100%; min-width: 0; min-height: 40px; padding-inline: 6px; gap: 6px; }
  .paper-builder { padding: 16px; }
  .paper-chapters { padding: 6px 12px; }
  .paper-book { font-size: 13px; }
  .saved-paper { flex-wrap: wrap; }
  .saved-paper > div { flex-basis: 100%; }
  .saved-paper > .button { flex: 1; }
  .paper-builder-actions > .button { width: 100%; }
  .question-card-top .question-topic { flex: 1; }
}

@media (max-width: 600px) {
  body { font-size: 14.5px; }
  .topbar { padding: 0 10px; }
  .breadcrumb { display: none; }
  .global-search kbd { display: none; }
  .main-content { padding: 22px 16px 48px; }
  .page-heading { align-items: flex-start; gap: 12px; margin-bottom: 20px; }
  .page-heading h1 { font-size: 26px; }
  .page-heading p { font-size: 14.5px; }
  .date-stamp { display: none; }
  .hero-resume { gap: 18px; padding: 22px 20px; border-radius: var(--radius-lg); }
  .hero-resume h2 { font-size: 22px; }
  .hero-actions .button { flex: 1 1 auto; }
  .hero-progress { gap: 18px; padding: 18px 20px; border-radius: var(--radius-lg); }
  .orbit-visual { width: 108px; height: 108px; }
  .orbit-value strong { font-size: 25px; }
  .progress-facts { gap: 9px; }
  .progress-facts div { padding-bottom: 9px; }
  .progress-facts dd { font-size: 16px; }
  .stats-grid { gap: 10px; margin-bottom: 28px; }
  .stats-grid-3 .stat-card { min-height: 0; padding: 12px; }
  .stats-grid-3 .stat-head { flex-direction: row-reverse; justify-content: flex-end; }
  .stats-grid-3 .stat-label { font-size: 12.5px; }
  .stats-grid-3 .stat-value { margin-top: 8px; font-size: 22px; }
  .stats-grid-3 .stat-unit { display: none; }
  .stat-text { font-size: 13px; }
  .stat-card { min-height: 116px; padding: 14px; border-radius: var(--radius); }
  .stat-value { margin-top: 10px; font-size: 26px; }
  .stat-symbol { width: 28px; height: 28px; }
  .bank-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .bank-card { min-height: 172px; padding: 14px; border-radius: var(--radius); }
  .bank-icon { width: 34px; height: 34px; font-size: 12px; }
  .bank-card h3 { margin-top: 12px; font-size: 15.5px; }
  .bank-status { padding: 3px 7px; font-size: 11px; }
  .bank-count, .bank-card-foot { font-size: 12px; }
  .bank-arrow { display: none; }
  .section-heading { align-items: center; }
  .section-heading h2 { font-size: 17px; }
  .section-heading p { display: none; }
  .detail-title-group .bank-icon { width: 44px; height: 44px; font-size: 14px; }
  .detail-title-group h1 { font-size: 25px; }
  .detail-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .detail-actions .button { min-width: 0; padding-inline: 8px; white-space: nowrap; }
  .detail-actions .button-primary, .detail-actions .book-review-button { grid-column: 1 / -1; }
  .detail-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-item { padding: 12px 14px; }
  .summary-item:nth-of-type(3) { border-left: 0; }
  .summary-item:nth-of-type(3), .summary-item:nth-of-type(4) { border-top: 1px solid var(--border); }
  .summary-item strong { font-size: 20px; }
  .chapter-row { gap: 10px; padding: 12px; }
  .chapter-copy { flex: 1 1 calc(100% - 50px); }
  .collection-filters { gap: 10px; padding: 12px; }
  .filter-field { flex-basis: calc(50% - 5px); min-width: min(100%, 140px); }
  .collection-filters > .button { width: 100%; }
  .collection-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; }
  .collection-toolbar > span:first-child { grid-column: 1; grid-row: 1; }
  .collection-toolbar > span:nth-child(2) { grid-column: 1; grid-row: 2; font-size: 12px; }
  .collection-toolbar > .button { grid-column: 2; grid-row: 1 / 3; min-width: 88px; white-space: nowrap; }
  .collection-item { align-items: flex-start; flex-wrap: wrap; gap: 10px; padding: 12px; }
  .collection-copy { flex: 1 1 calc(100% - 52px); }
  .collection-copy small { white-space: normal; }
  .collection-item .button { margin-left: 52px; }
  .empty-state { padding: 40px 16px; }
  .admin-form, .admin-users-panel { padding: 16px; }
  .admin-user-row { flex-wrap: wrap; gap: 10px; padding: 11px; }
  .auth-card h2 { font-size: 27px; }
  .toast-region { right: 12px; left: 12px; bottom: max(12px, env(safe-area-inset-bottom)); justify-items: center; }
  .is-practice .toast-region { bottom: calc(72px + env(safe-area-inset-bottom)); }
}

@media (max-width: 380px) {
  .topbar { gap: 6px; padding: 0 8px; }
  .mobile-menu, .topbar-avatar, .topbar .theme-toggle { width: 40px; height: 40px; }
  .main-content { padding-right: 12px; padding-left: 12px; }
  .stats-grid, .bank-grid { gap: 8px; }
  .stat-card, .bank-card { padding: 12px; }
  .stat-label, .stat-foot { font-size: 12px; }
  .bank-card h3 { font-size: 15px; }
  .hero-progress { flex-direction: column; align-items: stretch; }
  .orbit-visual { align-self: center; }
  .filter-field { flex-basis: 100%; }
  .is-practice .main-content { padding-right: 8px; padding-left: 8px; }
  .practice-page .question-card { padding: 12px 11px; }
  .chapter-actions .button:not([data-action=start-chapter]) .icon { display: none; }
}

/* Short landscape phones: two option columns so the whole question fits. */
@media (min-width: 600px) and (max-width: 900px) and (max-height: 540px) and (orientation: landscape) {
  .is-practice .main-content { padding-top: 4px; }
  .practice-page .practice-top { padding-bottom: 3px; gap: 6px; }
  .practice-page .practice-close, .practice-page .practice-theme { width: 30px; min-width: 30px; height: 30px; }
  .practice-page .practice-progress { margin-bottom: 4px; }
  .practice-page .question-card, .practice-page.is-compact .question-card, .practice-page.is-dense .question-card { padding: 8px 10px; }
  .practice-page .question-card-top { margin-bottom: 4px; }
  .practice-page .question-content { font-size: 14px; line-height: 1.4; }
  .practice-page .choice-help { display: none; }
  .practice-page .option-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
  .practice-page .option-label { min-height: 40px; padding: 5px 7px; }
  .practice-page .option-body { font-size: 13px; line-height: 1.35; }
  .practice-page .answer-explanation { margin-top: 5px; }
  .practice-page .answer-explanation > summary { min-height: 32px; padding: 4px 10px; }
  .practice-page .answer-feedback { min-height: 36px; }
  .practice-page .answer-feedback.is-multiple { min-height: 48px; }
  .practice-page .answer-feedback > .answer-verdict { margin-top: 5px; }
}

@media (max-height: 540px) and (min-width: 901px) {
  .auth-screen { align-items: start; }
  .auth-aside, .auth-main { min-height: 620px; }
  .auth-main { place-items: start center; padding-top: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .practice-page .question-card { animation: none !important; transition: none !important; }
}

/* Paper mode switch and random-draw picking. */
.mode-switch { display: inline-flex; gap: 4px; max-width: 100%; padding: 4px; margin: 0 0 22px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); }
.mode-option { position: relative; min-height: 38px; padding: 7px 16px; border: 0; border-radius: 10px; color: var(--text-2); background: transparent; font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer; transition: color .18s, background-color .18s, box-shadow .18s; }
.mode-option:hover:not(:disabled):not(.is-active) { color: var(--text); }
.mode-option.is-active { color: var(--text); background: var(--surface); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border-strong); }
.paper-chapters legend { display: flex; align-items: center; gap: 14px; }
.paper-pick-all { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; font-weight: 500; cursor: pointer; }
.paper-pick-all input, .paper-pick { flex: none; width: 17px; height: 17px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.paper-chapter-row.is-pickable { justify-content: flex-start; gap: 12px; margin: 0 -8px; padding: 10px 8px; border-radius: 10px; cursor: pointer; transition: background-color .15s; }
.paper-chapter-row.is-pickable:hover { background: var(--surface-3); }
.paper-chapter-row.is-picked strong { color: var(--accent-strong); }
.paper-random-count { display: flex; align-items: center; gap: 10px; margin-left: auto; color: var(--text-2); font-size: 14px; font-weight: 600; }
.paper-random-count .paper-count { width: 92px; min-height: 40px; padding: 8px; text-align: center; font-variant-numeric: tabular-nums; }
.paper-random-hint { min-width: 7em; color: var(--text-3); font-size: 12.5px; font-weight: 500; }
.paper-random-hint.is-error { color: var(--danger-text); }
@media (max-width: 650px) {
  .mode-switch { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .mode-option { padding-inline: 8px; }
  .paper-builder-actions { gap: 8px 10px; padding: 10px 12px; }
  .paper-total { flex-basis: 100%; font-size: 13px; }
  .paper-random-count { flex: 0 0 auto; gap: 8px; margin-left: 0; font-size: 13px; }
  .paper-random-count .paper-count { width: 72px; min-height: 40px; }
  .paper-random-hint { display: none; }
  .paper-total.is-error { color: var(--danger-text); }
  .paper-builder-actions > .button { flex: 1 1 140px; width: auto; }
}

/* Mobile practice uses a bounded content pane and an in-flow footer.
   The footer owns a row, so Safari chrome and long questions cannot cover it. */
@media (max-width: 900px) {
  body.is-practice { height:100vh; height:var(--practice-viewport-height,100dvh); min-height:0; overflow:hidden; }
  .is-practice .app-frame { height:100%; min-height:0; }
  .is-practice .app-main { height:100%; min-height:0; }
  .is-practice .main-content {
    display:flex; flex-direction:column; height:100%; min-height:0; overflow:hidden;
    padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  }
  .is-practice .main-content > .practice-page { flex:1; min-height:0; padding:0; }
  .is-practice .practice-page.has-practice-nav {
    display:grid; grid-template-rows:auto auto minmax(0,1fr) auto;
    width:100%; height:100%; min-height:0; overflow:hidden;
  }
  .is-practice .practice-page.has-practice-nav > .practice-grid {
    min-height:0; align-content:start; grid-auto-rows:max-content;
    overflow-x:hidden; overflow-y:auto; overscroll-behavior-y:contain;
    scroll-behavior:auto; scroll-padding-block:8px 16px; padding-bottom:8px;
    -webkit-overflow-scrolling:touch;
  }
  .is-practice .practice-page.has-practice-nav > .practice-nav {
    position:static; inset:auto; z-index:auto; flex:none; align-self:stretch;
    width:100%; margin:8px 0 0; padding:8px 0 max(8px,env(safe-area-inset-bottom));
    background:var(--bg); -webkit-backdrop-filter:none; backdrop-filter:none;
  }
  .is-practice .practice-page:not(.has-practice-nav) { overflow-y:auto; }
}

.practice-page.has-practice-nav > .practice-grid:focus-visible {outline:2px solid var(--border-strong);outline-offset:-2px}

/* Keep phone forms from triggering Safari's focus zoom; allow user pinch zoom. */
@media (max-width: 900px) {
  :root input:not([type=checkbox]):not([type=radio]):not([type=range]),
  :root select, :root textarea { font-size:16px; }
  .app-frame { width:100%; max-width:100%; min-width:0; }
  .app-main { width:100%; max-width:100%; }
  .main-content, .loading-stage, .practice-top, .practice-grid,
  .question-card, .navigator, .practice-nav { max-width:100%; }
  .global-search input { flex:1 1 0%; width:0; }
  /* Do not reserve an empty result block under the options. */
  .practice-page .answer-feedback { min-height:0; }
  .practice-page .answer-feedback > .answer-verdict,
  .practice-page .answer-explanation .answer-verdict { display:none; }
  .practice-page .answer-feedback.is-multiple { min-height:0; }
  .practice-page .question-card { align-self:start; }
}
@media (max-width: 600px) {
  .topbar {
    display:grid; grid-template-columns:40px minmax(0,1fr) 40px 40px;
    gap:8px; width:100%; min-width:0;
    padding-left:max(12px,env(safe-area-inset-left));
    padding-right:max(12px,env(safe-area-inset-right));
  }
  .topbar .global-search { width:100%; min-width:0; max-width:100%; margin:0; }
  .topbar > .mobile-menu, .topbar > .theme-toggle, .topbar > .topbar-avatar { width:40px; height:40px; }
  .main-content { padding-left:max(12px,env(safe-area-inset-left)); padding-right:max(12px,env(safe-area-inset-right)); }
}

/* 20261106: shuffle and chapter-scoped wrong-answer reset. */
.collection-toolbar{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.collection-toolbar > .button{margin-left:0;grid-column:auto;grid-row:auto;white-space:nowrap}
.collection-toolbar > span:first-child{flex:1 1 100%}
.wrong-reset-dialog{color:var(--text);background:var(--surface, var(--bg, #19191e));border:1px solid var(--border, #555);border-radius:18px;padding:22px;width:min(620px,calc(100% - 24px));max-height:85dvh;overflow:auto;box-sizing:border-box}
.wrong-reset-dialog::backdrop{background:rgba(0,0,0,.6)}
.wrong-reset-dialog h2{margin:0 0 8px;font-size:21px}
.wrong-reset-dialog > p{font-size:14px;color:var(--text-2);line-height:1.6}
.wrong-reset-chapters{display:grid;gap:8px;margin:18px 0;max-height:48dvh;overflow:auto}
.wrong-reset-row{display:flex;align-items:center;gap:10px;padding:10px;border:1px solid var(--border, #555);border-radius:10px;min-width:0}
.wrong-reset-row input{width:18px;height:18px;flex:0 0 18px;accent-color:var(--accent, #8f83ff)}
.wrong-reset-row span{flex:1;min-width:0;overflow-wrap:anywhere;font-size:14px}
.wrong-reset-row small{white-space:nowrap;color:var(--text-2)}
.wrong-reset-actions{display:flex;justify-content:flex-end;gap:8px;flex-wrap:wrap;position:sticky;bottom:-22px;background:inherit;padding:12px 0}
@media(max-width:640px){.chapter-list .chapter-actions{display:grid;grid-template-columns:repeat(4,minmax(0,1fr))}.chapter-list .chapter-actions .button{min-width:0;width:100%;padding-inline:4px;font-size:12px}.collection-toolbar > .button{flex:1 1 auto;min-width:0}}

/* Question AI: independent dialog, leaves the question viewport sizing intact. */
.question-card-top{flex-wrap:wrap}
.question-ai-button{white-space:nowrap;min-height:36px;padding:7px 11px}
.question-ai-dialog{display:none;width:min(760px,calc(100% - 24px));max-height:88dvh;padding:22px;border:1px solid var(--border);border-radius:18px;color:var(--text);background:var(--surface);box-shadow:var(--shadow-lg);box-sizing:border-box}
.question-ai-dialog[open]{display:flex;flex-direction:column;gap:12px}
.question-ai-dialog::backdrop{background:var(--scrim)}
.question-ai-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;flex:none}
.question-ai-heading h2{margin:0;font-size:21px}.question-ai-subtitle{font-size:13px;color:var(--text-3);margin:0}
.question-ai-content{overflow-y:auto;min-height:60px;max-height:55dvh;overscroll-behavior:contain;line-height:1.8;font-size:15px}
.question-ai-text,.question-ai-ask{white-space:pre-wrap;overflow-wrap:anywhere}
.question-ai-followup{margin-top:24px;padding-top:16px;border-top:1px solid var(--border)}
.question-ai-ask{color:var(--text-2);padding:10px 12px;background:var(--surface-2);border-radius:10px;margin:8px 0 12px}
.question-ai-status{font-size:12px;line-height:1.5;margin:0;color:var(--text-3)}.question-ai-error{color:var(--danger-text)}
.question-ai-form{display:flex;align-items:flex-end;gap:10px;flex:none}.question-ai-form textarea{flex:1;min-width:0;min-height:58px;max-height:140px;resize:vertical;font:inherit;font-size:16px}.question-ai-form button{flex:none}
@media(max-width:640px){.question-ai-dialog{padding:16px;gap:10px}.question-ai-content{font-size:15px;max-height:51dvh}.question-card-top .question-ai-button{min-height:34px;font-size:12px;padding:6px 9px}}

/* Render saved AI Markdown locally; no regenerated answers or remote library. */
.question-ai-content .question-ai-text{white-space:normal;line-height:1.8}
.question-ai-text p{margin:0 0 .8em}.question-ai-text > :last-child{margin-bottom:0}
.question-ai-text h3,.question-ai-text h4{margin:1.2em 0 .55em;line-height:1.5;color:var(--text);font-weight:650}
.question-ai-text h3{font-size:17px}.question-ai-text h4{font-size:15px}.question-ai-text > :first-child{margin-top:0}
.question-ai-text strong{font-weight:700;color:var(--text)}
.question-ai-text ul,.question-ai-text ol{margin:.5em 0 .9em;padding-left:1.5em}.question-ai-text li{margin:.3em 0}
.question-ai-text hr{border:0;border-top:1px solid var(--border);margin:1.1em 0}
.question-ai-text blockquote{margin:.7em 0;padding:.25em .8em;border-left:3px solid var(--border-strong);color:var(--text-2)}
.question-ai-text code{font-family:var(--font-mono);font-size:.88em;padding:.12em .3em;background:var(--surface-3);border-radius:4px;overflow-wrap:anywhere}
.question-ai-text pre{white-space:pre-wrap;margin:.8em 0;padding:12px;background:var(--surface-2);border-radius:10px;overflow:auto}.question-ai-text pre code{padding:0;background:none}
.question-ai-text a{color:var(--accent-2);text-decoration:underline;text-underline-offset:3px}
.question-ai-table{max-width:100%;overflow-x:auto;margin:.8em 0}.question-ai-table table{width:100%;border-collapse:collapse;font-size:14px;line-height:1.65}.question-ai-table th,.question-ai-table td{border:1px solid var(--border);padding:8px 10px;text-align:left;vertical-align:top;overflow-wrap:anywhere}.question-ai-table th{background:var(--surface-2);font-weight:650}

/* Read-only rehab material, after the chapter list. */
.bank-reading { margin-top:28px; min-width:0; }
.bank-reading-note,.bank-reading-source { color:var(--text-3); font-size:13px; }
.bank-reading-group { color:var(--text-2); margin:22px 0 10px; font-size:14px; }
.bank-reading-item { margin:9px 0; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); overflow:hidden; }
.bank-reading-item summary { padding:15px 17px; cursor:pointer; font-weight:600; overflow-wrap:anywhere; }
.bank-reading-answer { padding:0 17px 16px; overflow-wrap:anywhere; }
.bank-reading-answer p { margin:10px 0; line-height:1.85; }
.bank-reading-ref { display:block; margin-top:8px; color:var(--accent-strong); font-size:13px; overflow-wrap:anywhere; }
@media(max-width:600px){.bank-reading-item summary{padding:13px 14px}.bank-reading-answer{padding:0 14px 14px}}


/* Offline download controls and sync status indicator */
.bank-card-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  transition: transform .2s var(--ease), box-shadow .2s, border-color .2s;
}
.bank-card-wrap:hover:not(.is-disabled) {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
.bank-card-wrap > .bank-card {
  flex: 1;
  width: 100%;
  border: 0;
  border-radius: 0;
  transform: none;
  box-shadow: none;
}
.bank-card-wrap > .bank-card:hover:not(.is-disabled) {
  transform: none;
  box-shadow: none;
  border-color: transparent;
}
.bank-offline-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px;
  line-height: 1.4;
}
.offline-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  cursor: pointer;
  transition: border-color .15s, color .15s, background-color .15s;
}
.offline-toggle-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}
.offline-checked-badge {
  color: var(--success-text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.offline-progress-label {
  color: var(--accent-strong);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.offline-bar-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
.offline-mini-btn {
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
}
.offline-mini-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.offline-mini-btn.is-danger:hover {
  border-color: var(--danger-line);
  color: var(--danger-text);
}
.offline-detail-btn.is-downloaded {
  border-color: var(--success);
  color: var(--success-text);
}
.offline-sync-pill {
  flex: none;
  max-width: 190px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.offline-sync-pill:hover { border-color: var(--border-strong); color: var(--text); }
.offline-sync-pill.is-offline { color: var(--warning-text); background: var(--warning-soft); border-color: var(--warning-text); }
.offline-sync-pill.is-pending,
.offline-sync-pill.is-syncing { color: var(--accent-strong); background: var(--accent-soft); border-color: var(--accent); }
.offline-sync-pill.is-auth { color: var(--danger-text); background: var(--danger-soft); border-color: var(--danger-line); }
@media (max-width: 900px) {
  .offline-sync-pill { max-width: 120px; padding: 4px 8px; font-size: 11.5px; }
  .bank-offline-bar { padding: 8px 12px; }
}
@media (max-width: 600px) {
  .topbar { display: flex; align-items: center; gap: 6px; }
  .topbar .mobile-menu,
  .topbar .theme-toggle,
  .topbar .topbar-avatar,
  .topbar .offline-sync-pill { flex: none; }
  .topbar .global-search { flex: 1 1 auto; min-width: 0; }
  .topbar .offline-sync-pill { max-width: 96px; padding: 4px 7px; font-size: 11px; }
}
