:root {
  --bg: #f5f3ee;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #fff;
  --surface-soft: #f0eee8;
  --ink: #20232c;
  --muted: #747987;
  --line: rgba(30, 35, 50, 0.1);
  --primary: #5b57d9;
  --primary-strong: #4540c6;
  --primary-soft: #eae9ff;
  --accent: #f28b67;
  --accent-soft: #fff0e9;
  --success: #248c69;
  --success-soft: #e2f5ed;
  --danger: #d4555d;
  --danger-soft: #fde9eb;
  --warning: #b97a20;
  --warning-soft: #fff2d8;
  --shadow: 0 22px 70px rgba(48, 43, 89, 0.1);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --sidebar: 252px;
}

[data-theme="dark"] {
  --bg: #15161b;
  --surface: rgba(35, 36, 44, 0.86);
  --surface-solid: #22232b;
  --surface-soft: #2a2b33;
  --ink: #f4f2ed;
  --muted: #a8abb6;
  --line: rgba(255, 255, 255, 0.1);
  --primary: #918cff;
  --primary-strong: #aba7ff;
  --primary-soft: #333052;
  --accent: #ff9b78;
  --accent-soft: #4b3028;
  --success: #61c8a1;
  --success-soft: #1d4136;
  --danger: #ff7b83;
  --danger-soft: #4a292d;
  --warning: #f0b45c;
  --warning-soft: #4a3820;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
.hidden { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.18;
  pointer-events: none;
}

.ambient-one { top: -180px; right: 8%; background: #7772ff; }
.ambient-two { bottom: -240px; left: 20%; background: #ff9d76; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) 1fr; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  padding: 26px max(18px, env(safe-area-inset-right, 0px)) max(20px, env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--surface-solid) 88%, transparent);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(24px);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand-mark {
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 15px; color: white; font: 700 22px/1 Georgia, serif;
  background: linear-gradient(145deg, var(--primary), #8883ff);
  box-shadow: 0 10px 24px rgba(91, 87, 217, 0.26);
}
.brand strong { display: block; font-size: 19px; letter-spacing: .08em; }
.brand span { color: var(--muted); font-size: 12px; }

.nav-list { display: grid; gap: 6px; }
.nav-item {
  width: 100%; min-height: 46px; display: flex; align-items: center; gap: 12px;
  padding: 10px 13px; border: 0; border-radius: 13px; background: transparent;
  color: var(--muted); cursor: pointer; text-align: left; transition: .2s ease;
}
.nav-item:hover { color: var(--ink); background: var(--surface-soft); transform: translateX(2px); }
.nav-item.active { color: var(--primary); background: var(--primary-soft); font-weight: 650; }
.nav-item em {
  margin-left: auto; min-width: 24px; padding: 2px 7px; border-radius: 99px;
  background: var(--surface-solid); color: var(--muted); font-size: 11px; font-style: normal; text-align: center;
}
.nav-icon { width: 20px; text-align: center; font-size: 18px; }
.sidebar-spacer { flex: 1; }
.utility { min-height: 40px; }

.daily-card {
  display: flex; align-items: center; gap: 11px; margin: 16px 3px; padding: 13px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface);
}
.daily-card strong, .daily-card span { display: block; }
.daily-card strong { font-size: 13px; }
.daily-card span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.daily-ring {
  --progress: 0deg;
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--accent) var(--progress), var(--surface-soft) 0);
  position: relative; font-weight: 700; font-size: 11px;
}
.daily-ring::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--surface-solid); }
.daily-ring span { z-index: 1; color: var(--ink); }

.main-shell { grid-column: 2; min-width: 0; }
.topbar {
  height: 108px; display: flex; align-items: center; justify-content: space-between; gap: 28px;
  padding: max(22px, env(safe-area-inset-top, 0px)) max(42px, env(safe-area-inset-right, 0px)) 18px max(42px, env(safe-area-inset-left, 0px)); position: sticky; top: 0; z-index: 20;
  background: linear-gradient(to bottom, var(--bg) 72%, transparent);
}
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 12px; letter-spacing: .08em; }
.topbar h1 { margin: 0; font-size: clamp(22px, 2vw, 30px); letter-spacing: -.04em; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.global-search {
  width: min(380px, 32vw); height: 46px; display: flex; align-items: center; gap: 10px;
  padding: 0 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  box-shadow: 0 8px 30px rgba(40, 40, 70, .04); backdrop-filter: blur(18px);
}
.global-search input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; }
.global-search input::placeholder { color: var(--muted); }
kbd { padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: var(--surface-soft); font-size: 10px; white-space: nowrap; }
.avatar { min-width: 46px; height: 46px; padding: 0 10px; border: 0; border-radius: 14px; color: var(--primary); background: var(--primary-soft); font-size: 12px; font-weight: 700; }
.mobile-menu { display: none; }

.view-root { width: min(1460px, 100%); margin: 0 auto; padding: 12px 42px calc(70px + env(safe-area-inset-bottom, 0px)); }
.surface { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(22px); }
.grid { display: grid; gap: 20px; }
.library-hero {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 34px; align-items: end;
  padding: 34px 38px; border-radius: var(--radius-xl); color: white;
  background: radial-gradient(circle at 82% 15%, rgba(255,255,255,.18), transparent 24%), linear-gradient(130deg, #252651, #5350b9 58%, #736ee0);
  box-shadow: 0 26px 70px rgba(53, 50, 132, .22);
}
.library-hero .eyebrow { color: rgba(255,255,255,.6); }
.library-hero h2 { max-width: 760px; margin: 10px 0 12px; font: 500 clamp(30px, 4vw, 52px)/1.12 Georgia, "Songti SC", serif; letter-spacing: -.04em; }
.library-hero p { max-width: 720px; margin: 0; color: rgba(255,255,255,.72); line-height: 1.75; }
.library-total { min-width: 148px; display: grid; justify-items: end; }
.library-total strong { font: 600 48px/1 Georgia, serif; }
.library-total span { margin-top: 6px; color: rgba(255,255,255,.8); }
.library-total small { margin-top: 16px; color: rgba(255,255,255,.55); }
.book-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; margin-top: 24px; }
.book-card {
  min-width: 0; overflow: hidden; display: grid; grid-template-columns: 145px minmax(0, 1fr);
  border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow);
  animation: book-in .45s ease both; animation-delay: var(--delay);
}
.book-cover { position: relative; overflow: hidden; min-height: 390px; padding: 24px 19px; display: flex; flex-direction: column; color: white; background: linear-gradient(155deg, #5550cc, #7974ed); }
.book-cover::before { content: ""; position: absolute; width: 180px; height: 180px; border: 1px solid rgba(255,255,255,.22); border-radius: 50%; right: -95px; top: 50px; }
.book-cover::after { content: ""; position: absolute; inset: 0 auto 0 8px; width: 1px; background: rgba(255,255,255,.2); box-shadow: 3px 0 rgba(0,0,0,.08); }
.book-card.coral .book-cover { background: linear-gradient(155deg, #cc624b, #ec9271); }
.book-card.emerald .book-cover { background: linear-gradient(155deg, #176e5d, #38a27d); }
.book-cover span { font-size: 10px; letter-spacing: .18em; opacity: .66; }
.book-cover strong { margin-top: 48px; font: 600 26px/1.35 Georgia, "Songti SC", serif; writing-mode: vertical-rl; letter-spacing: .08em; }
.book-cover em { margin-top: auto; font-size: 10px; font-style: normal; line-height: 1.6; opacity: .72; }
.book-card-body { min-width: 0; padding: 25px 22px; display: flex; flex-direction: column; }
.book-title-row { display: flex; gap: 10px; justify-content: space-between; align-items: start; }
.book-title-row p { margin: 0 0 7px; color: var(--muted); font-size: 10px; letter-spacing: .12em; }
.book-title-row h3 { margin: 0; font: 600 20px/1.35 Georgia, "Songti SC", serif; }
.book-title-row > span { flex: 0 0 auto; padding: 5px 8px; border-radius: 99px; color: var(--primary); background: var(--primary-soft); font-size: 10px; }
.book-card-body > p { margin: 16px 0 9px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.book-subtitle { color: var(--ink); font-size: 11px; line-height: 1.65; }
.book-progress { margin-top: auto; padding-top: 24px; }
.book-progress > div:first-child { display: flex; justify-content: space-between; margin-bottom: 9px; color: var(--muted); font-size: 11px; }
.book-progress > div strong { color: var(--ink); }
.book-progress small { display: block; margin-top: 9px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.enter-book { width: 100%; margin-top: 18px; }
.dashboard-grid { grid-template-columns: minmax(0, 1.65fr) minmax(280px, .75fr); }

.hero-card {
  position: relative; overflow: hidden; min-height: 264px; padding: 34px;
  background: linear-gradient(135deg, #5550cc, #716be7 58%, #8b85f1);
  color: white; border-radius: var(--radius-xl); box-shadow: 0 28px 70px rgba(76, 69, 183, .25);
}
.hero-card::before, .hero-card::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.16); border-radius: 50%; }
.hero-card::before { width: 320px; height: 320px; right: -120px; top: -170px; }
.hero-card::after { width: 190px; height: 190px; right: 80px; bottom: -145px; }
.hero-card .eyebrow { color: rgba(255,255,255,.7); }
.hero-card h2 { max-width: 620px; margin: 12px 0 14px; font: 500 clamp(30px, 4vw, 48px)/1.13 Georgia, "Songti SC", serif; letter-spacing: -.04em; }
.hero-card p { max-width: 580px; margin: 0; color: rgba(255,255,255,.78); line-height: 1.7; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.button {
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 18px; border: 1px solid transparent; border-radius: 13px; cursor: pointer;
  font-weight: 650; transition: .2s ease;
}
.button:hover { transform: translateY(-2px); }
.button.primary { color: white; background: var(--primary); box-shadow: 0 10px 25px rgba(91,87,217,.24); }
.hero-card .button.primary { color: var(--primary-strong); background: white; box-shadow: none; }
.button.secondary { color: var(--ink); border-color: var(--line); background: var(--surface-solid); }
.hero-card .button.secondary { color: white; border-color: rgba(255,255,255,.28); background: rgba(255,255,255,.1); }
.button.danger { color: var(--danger); background: var(--danger-soft); }
.button.ghost { color: var(--muted); background: transparent; }
.button.small { min-height: 34px; padding: 0 12px; border-radius: 10px; font-size: 12px; }

.streak-card { padding: 24px; display: flex; flex-direction: column; justify-content: space-between; }
.streak-card h3, .section-title { margin: 0; font-size: 17px; }
.streak-number { margin: 8px 0 0; font: 600 56px/1 Georgia, serif; color: var(--accent); }
.streak-number span { font: 500 14px/1 sans-serif; color: var(--muted); }
.week-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 26px; }
.day-dot { display: grid; gap: 7px; justify-items: center; color: var(--muted); font-size: 9px; }
.day-dot i { width: 24px; height: 34px; border-radius: 9px; background: var(--surface-soft); }
.day-dot.done i { background: linear-gradient(to top, var(--accent), #ffb091); }
.day-dot.today i { outline: 2px solid var(--primary); outline-offset: 2px; }

.metrics { grid-template-columns: repeat(4, 1fr); margin-top: 20px; }
.metric-card { padding: 20px; }
.metric-label { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.metric-value { margin-top: 15px; font: 600 30px/1.1 Georgia, serif; }
.metric-note { margin-top: 8px; color: var(--muted); font-size: 11px; }
.metric-note.good { color: var(--success); }

.content-grid { grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); margin-top: 20px; }
.panel { padding: 24px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; }
.panel-header p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.chapter-list { display: grid; gap: 11px; }
.chapter-row {
  display: grid; grid-template-columns: minmax(150px, 1fr) 2fr 64px; gap: 16px; align-items: center;
  padding: 13px 14px; border-radius: 13px; transition: .2s;
}
.chapter-row:hover { background: var(--surface-soft); }
.chapter-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.progress-track { height: 8px; overflow: hidden; border-radius: 99px; background: var(--surface-soft); }
.progress-track i { display: block; width: var(--value); height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #8e89ff); }
.chapter-row span { color: var(--muted); text-align: right; font-size: 11px; }

.type-bars { display: grid; gap: 14px; }
.type-bar { display: grid; grid-template-columns: 76px 1fr 42px; align-items: center; gap: 10px; font-size: 12px; }
.type-bar .bar { height: 10px; border-radius: 99px; background: var(--surface-soft); overflow: hidden; }
.type-bar i { display: block; width: var(--value); height: 100%; border-radius: inherit; background: var(--color); }
.type-bar em { color: var(--muted); font-style: normal; text-align: right; }

.setup-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 22px; }
.setup-card { padding: 30px; }
.setup-card h2 { margin: 0 0 8px; font-size: 26px; }
.setup-card > p { margin: 0 0 26px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.field { display: grid; gap: 8px; }
.field.full { grid-column: 1 / -1; }
.field span { color: var(--muted); font-size: 12px; }
.control {
  width: 100%; min-height: 46px; padding: 10px 12px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; outline: none; background: var(--surface-solid);
}
.control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.segmented { display: flex; gap: 8px; flex-wrap: wrap; }
.segment { padding: 9px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-solid); cursor: pointer; color: var(--muted); }
.segment.active { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.setup-summary { padding: 26px; background: linear-gradient(155deg, var(--surface-solid), var(--primary-soft)); }
.big-count { margin: 16px 0 4px; font: 600 56px/1 Georgia, serif; color: var(--primary); }
.setup-summary p { color: var(--muted); line-height: 1.7; }
.setup-summary ul { padding-left: 18px; color: var(--muted); line-height: 1.9; font-size: 13px; }

.practice-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 22px; align-items: start; }
.question-card { padding: clamp(22px, 4vw, 42px); }
.question-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.badge { padding: 5px 9px; border-radius: 99px; color: var(--primary); background: var(--primary-soft); font-size: 11px; font-weight: 650; }
.badge.warning { color: var(--warning); background: var(--warning-soft); }
.question-title { margin: 22px 0 24px; font: 500 clamp(20px, 2.2vw, 28px)/1.7 Georgia, "Songti SC", serif; white-space: pre-wrap; }
.question-image { display: block; max-width: min(100%, 680px); margin: 20px auto; border-radius: 14px; }
.options { display: grid; gap: 12px; }
.option {
  display: grid; grid-template-columns: 38px 1fr; gap: 12px; align-items: center;
  width: 100%; min-height: 58px; padding: 11px 16px; text-align: left;
  border: 1px solid var(--line); border-radius: 15px; background: var(--surface-solid); cursor: pointer; transition: .18s ease;
}
.option:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); transform: translateX(3px); }
.option.selected { border-color: var(--primary); background: var(--primary-soft); }
.option.correct { border-color: var(--success); background: var(--success-soft); }
.option.wrong { border-color: var(--danger); background: var(--danger-soft); }
.option-key { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; color: var(--muted); background: var(--surface-soft); font-weight: 700; }
.option.selected .option-key { color: white; background: var(--primary); }
.option.correct .option-key { color: white; background: var(--success); }
.option.wrong .option-key { color: white; background: var(--danger); }
.subjective-input { min-height: 150px; resize: vertical; line-height: 1.75; }
.question-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.question-actions .push { margin-left: auto; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-solid); cursor: pointer; }
.icon-button.active { color: var(--warning); border-color: var(--warning); background: var(--warning-soft); }

.feedback { margin-top: 22px; padding: 22px; border-radius: 16px; background: var(--surface-soft); border-left: 4px solid var(--primary); animation: reveal .25s ease; }
.feedback.correct { border-left-color: var(--success); background: var(--success-soft); }
.feedback.wrong { border-left-color: var(--danger); background: var(--danger-soft); }
.feedback h3 { margin: 0 0 9px; font-size: 16px; }
.feedback p { margin: 8px 0 0; line-height: 1.8; white-space: pre-wrap; }
.answer-token { font-size: 20px; font-weight: 800; color: var(--primary); }
.self-grade { display: flex; gap: 8px; margin-top: 16px; }

.session-side { position: sticky; top: 124px; display: grid; gap: 16px; }
.session-panel { padding: 19px; }
.session-progress { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.session-progress strong { color: var(--ink); }
.session-panel .progress-track { margin: 12px 0 18px; }
.answer-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; max-height: 280px; overflow: auto; padding-right: 3px; }
.answer-dot { aspect-ratio: 1; border: 0; border-radius: 9px; color: var(--muted); background: var(--surface-soft); cursor: pointer; font-size: 10px; }
.answer-dot.current { color: white; background: var(--primary); }
.answer-dot.correct { color: var(--success); background: var(--success-soft); }
.answer-dot.wrong { color: var(--danger); background: var(--danger-soft); }
.shortcut-list { display: grid; gap: 9px; margin-top: 12px; color: var(--muted); font-size: 11px; }
.shortcut-list div { display: flex; justify-content: space-between; }

.filter-bar { display: grid; grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(150px, .7fr)); gap: 12px; padding: 16px; margin-bottom: 18px; }
.bank-list { display: grid; gap: 12px; }
.bank-item { padding: 18px 20px; cursor: pointer; transition: .2s; }
.bank-item:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--primary) 35%, var(--line)); }
.bank-item-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--muted); font-size: 11px; }
.bank-item h3 { margin: 0; font: 500 16px/1.7 Georgia, "Songti SC", serif; }
.bank-item-footer { display: flex; justify-content: space-between; margin-top: 12px; color: var(--muted); font-size: 11px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-dot.correct { background: var(--success); }
.status-dot.wrong { background: var(--danger); }
.pagination { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 22px; color: var(--muted); font-size: 12px; }

.empty-state { padding: 70px 30px; text-align: center; }
.empty-icon { width: 64px; height: 64px; display: grid; place-items: center; margin: 0 auto 18px; border-radius: 20px; color: var(--primary); background: var(--primary-soft); font-size: 30px; }
.empty-state h2 { margin: 0 0 8px; }
.empty-state p { color: var(--muted); }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.settings-card { padding: 24px; }
.settings-card h2 { margin: 0 0 8px; font-size: 18px; }
.settings-card p { min-height: 42px; color: var(--muted); line-height: 1.6; font-size: 13px; }
.file-input { display: none; }
.pwa-ready { display: inline-flex; min-height: 34px; align-items: center; padding: 0 12px; border-radius: 10px; color: var(--success); background: var(--success-soft); font-size: 12px; font-weight: 650; }
.data-note { margin-top: 20px; padding: 18px; border-radius: 15px; background: var(--warning-soft); color: var(--warning); line-height: 1.7; font-size: 13px; }

.toast-stack { position: fixed; right: 24px; bottom: 24px; z-index: 60; display: grid; gap: 10px; }
.toast { min-width: 230px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-solid); box-shadow: var(--shadow); animation: toast-in .25s ease; }

@keyframes reveal { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } }
@keyframes book-in { from { opacity: 0; transform: translateY(14px); } }

@media (hover: none) and (pointer: coarse) {
  .button, .nav-item, .option, .icon-button { min-height: 46px; }
  .button:hover, .nav-item:hover, .option:hover, .bank-item:hover { transform: none; }
  .answer-grid { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
  .answer-dot { min-height: 44px; }
}

@media (max-width: 1300px) and (min-width: 1051px) {
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1050px) {
  .book-grid { grid-template-columns: 1fr; }
  .book-card { grid-template-columns: 180px minmax(0, 1fr); }
  .book-cover { min-height: 330px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid, .content-grid, .setup-layout { grid-template-columns: 1fr; }
  .streak-card { min-height: 220px; }
  .practice-layout { grid-template-columns: 1fr; }
  .session-side { position: static; grid-template-columns: 1fr 1fr; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 820px) {
  :root { --sidebar: 268px; }
  .app-shell { display: block; }
  .sidebar { transform: translateX(-105%); transition: .25s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .main-shell { width: 100%; }
  .topbar { height: calc(88px + env(safe-area-inset-top, 0px)); padding: calc(14px + env(safe-area-inset-top, 0px)) max(18px, env(safe-area-inset-right, 0px)) 14px max(18px, env(safe-area-inset-left, 0px)); }
  .mobile-menu { display: block; }
  .top-actions { margin-left: auto; }
  .global-search { width: 44px; padding: 0; justify-content: center; border: 0; background: transparent; }
  .global-search input, .global-search kbd { display: none; }
  .avatar { display: none; }
  .view-root { padding: 8px max(16px, env(safe-area-inset-right, 0px)) calc(50px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
  .library-hero { grid-template-columns: 1fr; padding: 27px 23px; }
  .library-total { justify-items: start; }
  .book-card { grid-template-columns: 105px minmax(0, 1fr); }
  .book-cover { min-height: 390px; padding: 20px 15px; }
  .book-cover strong { font-size: 22px; }
  .hero-card { padding: 26px 22px; }
  .metrics, .form-grid, .settings-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .chapter-row { grid-template-columns: 1fr 74px; }
  .chapter-row .progress-track { grid-column: 1 / -1; grid-row: 2; }
  .filter-bar { grid-template-columns: 1fr; }
  .session-side { grid-template-columns: 1fr; }
  .question-actions .push { margin-left: 0; }
}
