﻿:root {
  --bg: #f3f5fa; --card: #ffffff; --text: #202838; --muted: #727d91; --faint: #9aa4b6;
  --border: #e4e8f1; --accent: #3b6ff5; --accent-dark: #2d5bd8; --accent-soft: #eaf0ff;
  --green: #14875a; --green-soft: #e8f7ef; --red: #c03a36; --red-soft: #fdeceb;
  --amber: #a66a12; --amber-soft: #fff5e3; --purple: #7a4dd6; --purple-soft: #f2edff;
  --orange: #c06a16; --orange-soft: #fff0df; --scale: 1;
}
body.dark {
  --bg: #111827; --card: #1f2937; --text: #e5e7eb; --muted: #a7b0c0; --faint: #7c8799;
  --border: #374151; --accent: #6d95ff; --accent-dark: #8aa9ff; --accent-soft: #1e2d4f;
  --green: #4ade80; --green-soft: #123528; --red: #f87171; --red-soft: #3b1d1d;
  --amber: #fbbf24; --amber-soft: #3a2d12; --purple: #b794ff; --purple-soft: #2b2145;
  --orange: #fb923c; --orange-soft: #3b2414;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
[hidden] { display: none !important; }

.topbar {
  height: 62px; background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 15px; position: relative; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo, .hero-mark {
  width: 38px; height: 38px; border-radius: 11px; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px; flex: none;
}
.brand-text { min-width: 0; }
.brand h1 { margin: 0; font-size: 17px; line-height: 1.2; }
.brand p { margin: 3px 0 0; font-size: 10px; color: var(--faint); max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 5px; align-items: center; }
.icon-btn {
  background: var(--accent-soft); color: var(--accent); border-radius: 8px;
  padding: 7px 9px; font-size: 11px; font-weight: 700; flex: none;
}
.timer-pill { background: var(--amber-soft); color: var(--amber); font-variant-numeric: tabular-nums; }
.timer-pill.danger { background: var(--red-soft); color: var(--red); }

.welcome { height: calc(100% - 62px); overflow-y: auto; padding: 18px 15px calc(24px + env(safe-area-inset-bottom)); }
.hero-card { background: var(--card); border-radius: 18px; padding: 24px 21px 21px; box-shadow: 0 8px 28px rgba(20, 35, 70, .06); border: 1px solid var(--border); }
.hero-mark { width: 52px; height: 52px; font-size: 28px; border-radius: 15px; background: var(--accent-soft); color: var(--accent); }
.hero-card h2 { font-size: 24px; line-height: 1.35; margin: 16px 0 9px; }
.hero-card > p { font-size: 13px; line-height: 1.8; color: var(--muted); margin: 0 0 18px; }
.primary-btn { display: block; width: 100%; text-align: center; padding: 13px 16px; border-radius: 11px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 700; box-shadow: 0 6px 16px rgba(59, 111, 245, .22); }
.upload-btn { cursor: pointer; }
.hint { font-size: 10px !important; line-height: 1.6 !important; color: var(--faint) !important; margin: 12px 0 0 !important; }
.feature-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 15px; }
.feature-row span { background: var(--bg); color: var(--muted); border-radius: 7px; padding: 5px 8px; font-size: 10px; }
.library { margin-top: 20px; }
.library-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 3px; }
.library-head h3 { font-size: 15px; margin: 0; }
.library-head span { font-size: 10px; color: var(--faint); }
.bank-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.bank-item { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 13px; display: flex; align-items: center; gap: 10px; }
.bank-main { flex: 1; min-width: 0; }
.bank-main strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bank-main small { display: block; color: var(--faint); font-size: 9px; margin-top: 3px; }
.bank-open { background: var(--accent-soft); color: var(--accent); border-radius: 7px; padding: 7px 10px; font-size: 11px; font-weight: 700; flex: none; }
.bank-del { background: transparent; color: var(--faint); font-size: 16px; padding: 4px 6px; flex: none; }
.library-empty { text-align: center; color: var(--faint); font-size: 11px; padding: 18px 0; }
.welcome-tip { text-align: center; font-size: 10px; color: var(--faint); margin: 16px 0 0; }

.quiz { height: 100%; display: flex; flex-direction: column; }
.filter-bar { background: var(--card); border-bottom: 1px solid var(--border); padding: 7px 10px 8px; flex: none; }
.filter-scroll { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.filter-scroll::-webkit-scrollbar { display: none; }
.chip { background: var(--bg); color: var(--muted); border-radius: 14px; padding: 5px 10px; font-size: 10px; font-weight: 700; flex: none; }
.chip.active { background: var(--accent); color: #fff; }
.filter-second { display: flex; gap: 6px; margin-top: 6px; }
.filter-second select, .filter-second input {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 8px; font-size: 10px; min-width: 0;
}
.filter-second select { flex: 0 0 38%; }
.filter-second input { flex: 1; }

.exam-banner { background: var(--amber-soft); color: var(--amber); margin: 9px 12px 0; border-radius: 9px; padding: 8px 10px; display: flex; align-items: center; justify-content: space-between; font-size: 10px; }
.banner { margin: 9px 12px 0; padding: 9px 10px; background: var(--amber-soft); color: var(--amber); border-radius: 9px; display: flex; align-items: center; gap: 7px; font-size: 10px; line-height: 1.5; }
.banner-text { flex: 1; min-width: 0; }
.banner-actions { display: flex; gap: 5px; flex: none; }
.mini-btn { background: var(--card); color: var(--amber); border-radius: 7px; padding: 5px 8px; font-size: 10px; font-weight: 700; }
.mini-link { background: transparent; color: var(--amber); font-size: 9px; text-decoration: underline; }
.scroll-area { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 12px 0; }
.question-card { background: var(--card); border-radius: 15px; padding: 18px 16px; border: 1px solid var(--border); box-shadow: 0 6px 20px rgba(20, 35, 70, .04); }
.meta-row { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.pill { border-radius: 7px; padding: 4px 7px; font-size: 9px; font-weight: 700; }
.pill.primary { background: var(--accent-soft); color: var(--accent); }
.type-pill.single { background: var(--accent-soft); color: var(--accent); }
.type-pill.multiple { background: var(--purple-soft); color: var(--purple); }
.type-pill.judge { background: var(--orange-soft); color: var(--orange); }
.type-pill.unknown { background: var(--bg); color: var(--muted); }
.star-btn { background: transparent; color: var(--faint); font-size: 18px; margin-left: auto; padding: 0 2px; line-height: 1; }
.star-btn.on { color: #e5a21a; }
.status-pill { margin-left: auto; border-radius: 7px; padding: 4px 7px; background: var(--bg); color: var(--muted); font-size: 9px; font-weight: 700; }
.status-pill.right { background: var(--green-soft); color: var(--green); }
.status-pill.wrong { background: var(--red-soft); color: var(--red); }
.status-pill.missing { background: var(--amber-soft); color: var(--amber); }
.status-pill.exam { background: var(--purple-soft); color: var(--purple); }
.section-name { font-size: 9px; color: var(--faint); margin-top: 8px; }
.stem { font-size: calc(18px * var(--scale)); line-height: 1.75; margin: 10px 0 14px; white-space: pre-wrap; }
.images { display: flex; flex-direction: column; gap: 9px; margin: 4px 0 13px; }
.image-box { background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 7px; display: block; }
.image-box img { display: block; max-width: 100%; height: auto; border-radius: 4px; margin: 0 auto; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.option-list { display: flex; flex-direction: column; gap: 8px; }
.option { width: 100%; display: flex; align-items: flex-start; gap: 9px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 10px; text-align: left; color: var(--text); }
.option .marker { width: 19px; height: 19px; border: 2px solid var(--border); border-radius: 50%; flex: none; margin-top: 1px; position: relative; }
.option.multiple .marker { border-radius: 5px; }
.option .label { font-size: calc(13px * var(--scale)); line-height: 1.6; font-weight: 700; flex: none; min-width: 17px; }
.option .text { font-size: calc(13px * var(--scale)); line-height: 1.65; flex: 1; }
.option .badge { font-size: 9px; color: var(--muted); flex: none; padding-top: 3px; }
.option.selected { background: var(--accent-soft); border-color: var(--accent); }
.option.selected .marker { border-color: var(--accent); }
.option.selected .marker::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent); }
.option.multiple.selected .marker::after { border-radius: 2px; }
.option.correct { background: var(--green-soft); border-color: var(--green); }
.option.correct .marker { border-color: var(--green); }
.option.correct .marker::after { background: var(--green); }
.option.correct .badge { color: var(--green); }
.option.wrong { background: var(--red-soft); border-color: var(--red); }
.option.wrong .marker { border-color: var(--red); }
.option.wrong .marker::after { background: var(--red); }
.option.wrong .badge { color: var(--red); }
.option.correct .label, .option.correct .text { color: var(--green); }
.option.wrong .label, .option.wrong .text { color: var(--red); }
.option[disabled] { cursor: default; }
.option.revealed-correct { background: var(--green-soft); border-color: var(--green); }
.option.revealed-correct .marker { border-color: var(--green); }
.option.revealed-correct .marker::after { background: var(--green); }

.feedback { border-radius: 11px; padding: 12px 12px 13px; margin-top: 12px; }
.feedback.good { background: var(--green-soft); }
.feedback.bad { background: var(--red-soft); }
.feedback.warn { background: var(--amber-soft); }
.feedback.study { background: var(--accent-soft); }
.feedback h3 { margin: 0; font-size: 14px; display: flex; gap: 7px; align-items: center; }
.feedback.good h3 { color: var(--green); }
.feedback.bad h3 { color: var(--red); }
.feedback.warn h3 { color: var(--amber); }
.feedback.study h3 { color: var(--accent); }
.feedback .answer-line { margin-top: 7px; font-size: 12px; line-height: 1.7; }
.feedback .source-line { margin-top: 5px; font-size: 9px; color: var(--muted); }
.feedback .explain { margin-top: 8px; font-size: calc(11px * var(--scale)); line-height: 1.8; color: var(--muted); white-space: pre-wrap; }
.feedback .explain b { color: var(--text); }
.feedback .ai-label { color: var(--amber); font-weight: 700; }
.feedback .note-box { margin-top: 9px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 8px 9px; font-size: 11px; line-height: 1.7; white-space: pre-wrap; }
.feedback .note-label { font-size: 9px; color: var(--faint); margin-top: 8px; }
.feedback-actions { display: flex; gap: 6px; margin-top: 9px; flex-wrap: wrap; }
.feedback-actions button { background: var(--card); color: var(--accent); border-radius: 7px; padding: 6px 9px; font-size: 10px; font-weight: 700; }
.feedback-actions button:disabled { color: var(--faint); }
.safe-bottom { height: 12px; }
.empty-state { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 40px 20px; text-align: center; color: var(--muted); font-size: 12px; }

.bottom-bar { flex: none; background: var(--card); border-top: 1px solid var(--border); padding: 7px 8px calc(7px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 7px; box-shadow: 0 -4px 14px rgba(20, 35, 70, .04); }
.bottom-top { display: flex; align-items: center; gap: 5px; }
.top-spacer { flex: 0 0 22px; }
.bottom-actions { display: flex; align-items: stretch; gap: 6px; }
.nav-back { background: transparent; color: var(--muted); font-size: 24px; line-height: 1; padding: 0 3px 4px; flex: 0 0 22px; }
.nav-btn { background: var(--bg); color: var(--muted); border-radius: 9px; padding: 9px 2px; font-size: 9.5px; font-weight: 700; flex: 1; white-space: nowrap; }
.nav-btn:disabled { color: var(--faint); opacity: .55; }
.bottom-tool { background: var(--accent-soft); color: var(--accent); border-radius: 9px; padding: 9px 2px; font-size: 9.5px; font-weight: 700; flex: 1; white-space: nowrap; }
.progress-box { flex: 1; text-align: center; min-width: 0; }
.progress-box strong { display: block; font-size: 13px; font-weight: 800; white-space: nowrap; letter-spacing: .2px; }
.progress-box span { display: block; font-size: 8px; color: var(--faint); margin-top: 1px; white-space: nowrap; }
.progress-box .timer-inline { color: var(--amber); font-weight: 700; font-size: 9px; font-variant-numeric: tabular-nums; }
.submit-btn { background: var(--accent); color: #fff; border-radius: 9px; padding: 9px 2px; font-size: 10px; font-weight: 800; flex: 1; white-space: nowrap; box-shadow: 0 3px 9px rgba(59, 111, 245, .2); }
.submit-btn:disabled { background: var(--border); color: var(--faint); }
.submit-btn.next-mode { background: var(--green); }

.modal, .image-modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .48); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 14px; backdrop-filter: blur(2px); }
.modal-card { background: var(--card); color: var(--text); border-radius: 16px; width: 100%; max-width: 520px; max-height: 86vh; overflow: auto; padding: 18px; box-shadow: 0 18px 50px rgba(0,0,0,.25); }
.modal-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-title h3 { margin: 0; font-size: 16px; }
.modal-close { background: transparent; color: var(--faint); font-size: 22px; line-height: 1; }
.modal-section { margin-top: 14px; }
.modal-section label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.modal-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.modal-row:last-child { border-bottom: 0; }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: var(--border); border-radius: 24px; transition: .2s; }
.slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.range-row input[type=range] { width: 55%; accent-color: var(--accent); }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.modal-btn { background: var(--accent); color: #fff; border-radius: 8px; padding: 9px 13px; font-size: 11px; font-weight: 700; }
.modal-btn.secondary { background: var(--bg); color: var(--text); }
.modal-btn.danger { background: var(--red-soft); color: var(--red); }
.modal-btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--border); }

.sheet-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; margin-top: 8px; }
.sheet-item { height: 36px; border-radius: 7px; background: var(--bg); color: var(--muted); font-size: 11px; font-weight: 700; border: 1px solid var(--border); position: relative; }
.sheet-item.current { outline: 2px solid var(--accent); }
.sheet-item.right { background: var(--green-soft); color: var(--green); border-color: var(--green); }
.sheet-item.wrong { background: var(--red-soft); color: var(--red); border-color: var(--red); }
.sheet-item.answered { background: var(--accent-soft); color: var(--accent); }
.sheet-item.fav::after { content: "★"; position: absolute; top: -3px; right: 1px; font-size: 8px; color: #e5a21a; }
.sheet-legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 9px; color: var(--faint); margin-top: 10px; }
.sheet-legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 3px; }
.sheet-legend .l-right::before { background: var(--green); }
.sheet-legend .l-wrong::before { background: var(--red); }
.sheet-legend .l-answered::before { background: var(--accent); }

.image-modal { background: rgba(0,0,0,.86); flex-direction: column; padding: 0; }
.image-toolbar { width: 100%; display: flex; gap: 8px; justify-content: center; padding: 10px; }
.image-toolbar button { background: rgba(255,255,255,.16); color: #fff; border-radius: 8px; padding: 7px 12px; font-size: 12px; }
.image-stage { flex: 1; width: 100%; overflow: auto; display: flex; align-items: center; justify-content: center; touch-action: none; }
.image-stage img { max-width: 96vw; max-height: 80vh; transform-origin: center; transition: transform .1s; }

.loading { position: fixed; inset: 0; background: rgba(20, 30, 50, .35); display: flex; align-items: center; justify-content: center; z-index: 120; backdrop-filter: blur(2px); }
.loading-box { background: var(--card); border-radius: 14px; padding: 22px 26px; text-align: center; min-width: 180px; box-shadow: 0 12px 40px rgba(0,0,0,.18); }
.loading-box p { margin: 13px 0 0; font-size: 12px; color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; margin: 0 auto; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: calc(82px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: rgba(32, 40, 56, .94); color: #fff; border-radius: 9px; padding: 9px 13px; font-size: 11px; z-index: 130; max-width: 86vw; line-height: 1.5; text-align: center; }

@media (min-width: 720px) {
  .topbar, .quiz, .welcome { max-width: 760px; margin: 0 auto; }
  .topbar { border-radius: 0 0 14px 14px; }
  .quiz { height: calc(100% - 62px); }
  .stem { font-size: calc(20px * var(--scale)); }
  .option .text { font-size: calc(15px * var(--scale)); }
  .sheet-grid { grid-template-columns: repeat(10, 1fr); }
}

/* v3 pages / tabs */
.page { height: calc(100% - 68px); overflow-y: auto; padding: 16px 15px calc(18px + env(safe-area-inset-bottom)); }
.home-page { padding-top: 8px; }
.home-hero { position: relative; overflow: hidden; background: linear-gradient(135deg, #eef3ff 0%, #f8f5ff 100%); border-radius: 20px; padding: 22px 20px 20px; margin-bottom: 12px; border: 1px solid #e6ebfa; }
body.dark .home-hero { background: linear-gradient(135deg, #1e2d4f, #2b2145); border-color: var(--border); }
.home-hero h2 { font-size: 27px; line-height: 1.35; margin: 6px 0 8px; }
.eyebrow { color: var(--accent); font-size: 9px; letter-spacing: 2px; font-weight: 800; margin: 0; }
.home-sub { color: var(--muted); font-size: 11px; line-height: 1.8; margin: 0; max-width: 78%; }
.hero-orbs { position: absolute; right: -10px; top: 16px; width: 100px; height: 80px; }
.hero-orbs span { position: absolute; border-radius: 50%; display: block; }
.hero-orbs span:nth-child(1) { width: 55px; height: 55px; background: #c9d8ff; right: 18px; top: 2px; opacity: .8; }
.hero-orbs span:nth-child(2) { width: 26px; height: 26px; background: #ffcf8a; right: 2px; top: 48px; opacity: .8; }
.hero-orbs span:nth-child(3) { width: 16px; height: 16px; background: #a8e8c5; right: 66px; top: 58px; opacity: .8; }
.entry-list { display: flex; flex-direction: column; gap: 9px; }
.entry-card { display: flex; align-items: center; gap: 12px; width: 100%; border-radius: 15px; padding: 14px 15px; text-align: left; color: #fff; box-shadow: 0 6px 16px rgba(40, 72, 150, .12); }
.entry-card.blue { background: linear-gradient(135deg, #5d8bff, #3d6ff5); }
.entry-card.green { background: linear-gradient(135deg, #35c58b, #18a86b); }
.entry-card.purple { background: linear-gradient(135deg, #9a7cff, #7856e8); }
.entry-icon { width: 37px; height: 37px; border-radius: 11px; background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center; font-size: 20px; flex: none; }
.entry-text { flex: 1; min-width: 0; }
.entry-text strong { display: block; font-size: 16px; }
.entry-text span { display: block; font-size: 9px; opacity: .82; margin-top: 3px; line-height: 1.5; }
.entry-arrow { font-size: 25px; opacity: .8; flex: none; }
.home-section { margin-top: 18px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; }
.section-head h3 { margin: 0; font-size: 15px; }
.text-btn { background: transparent; color: var(--faint); font-size: 10px; }
.home-features { margin-top: 16px; }
.page-title { padding: 6px 2px 12px; }
.page-title h2 { font-size: 23px; margin: 0 0 5px; }
.page-title p { font-size: 11px; color: var(--muted); margin: 0; line-height: 1.6; }
.page-actions { display: flex; gap: 8px; margin-bottom: 13px; }
.primary-btn.small { flex: 1; padding: 11px 12px; font-size: 12px; }
.secondary-btn { background: var(--card); color: var(--accent); border: 1px solid var(--border); border-radius: 10px; padding: 11px 14px; font-size: 12px; font-weight: 700; }
.bank-list { display: flex; flex-direction: column; gap: 8px; }
.exam-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.mode-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px 13px; text-align: left; color: var(--text); box-shadow: 0 4px 12px rgba(30,45,70,.04); }
.mode-card.exam { border-color: #e7d7b8; background: linear-gradient(145deg, var(--card), var(--amber-soft)); }
.mode-icon { display: block; font-size: 21px; color: var(--accent); margin-bottom: 9px; }
.mode-card strong { display: block; font-size: 14px; }
.mode-card small { display: block; font-size: 9px; color: var(--faint); margin-top: 4px; }
.stats-card, .profile-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 15px; margin-top: 14px; font-size: 12px; line-height: 1.9; color: var(--muted); }
.stats-card b, .profile-card b { color: var(--text); }
.settings-list { background: var(--card); border: 1px solid var(--border); border-radius: 14px; margin-top: 11px; overflow: hidden; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 14px; border-bottom: 1px solid var(--border); font-size: 12px; }
.setting-row:last-child { border-bottom: 0; }
.setting-row input[type=range] { width: 48%; accent-color: var(--accent); }
.list-btn { width: 100%; background: var(--card); color: var(--text); border-bottom: 1px solid var(--border); padding: 13px 14px; font-size: 12px; text-align: left; display: flex; justify-content: space-between; }
.list-btn:last-child { border-bottom: 0; }
.list-btn span { color: var(--faint); }
.about-text { text-align: center; color: var(--faint); font-size: 9px; line-height: 1.7; margin: 18px 0 4px; }
.back-btn { background: transparent; color: var(--faint); font-size: 28px; line-height: 1; padding: 0 6px 3px 0; display: none; }
.back-btn.visible { display: block; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: 68px; background: var(--card); border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-around; padding-bottom: env(safe-area-inset-bottom); z-index: 30; }
.tab { background: transparent; color: var(--faint); font-size: 9px; display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 1; padding: 6px 0; }
.tab-icon { font-size: 21px; line-height: 1.1; }
.tab.active { color: var(--accent); }
.tab.plus { flex: 0 0 20%; }
.tab-plus { width: 42px; height: 42px; border-radius: 13px; background: linear-gradient(135deg, #6f8cff, #7b5cf0); color: #fff; font-size: 27px; line-height: 38px; display: block; box-shadow: 0 6px 15px rgba(90, 95, 240, .32); }
@media (min-width: 720px) { .page, .quiz, .topbar, .tabbar { max-width: 760px; margin: 0 auto; } .tabbar { left: 50%; transform: translateX(-50%); width: 760px; border-radius: 14px 14px 0 0; } }

body.tabs-mode .page { height: calc(100% - 68px); }
body.tabs-mode .topbar { display: none; }
.progress-box .timer-inline.danger { color: var(--red); }

.answer-detail-list { display: flex; flex-direction: column; gap: 8px; }
.answer-detail-row { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.answer-detail-row strong { display: block; font-size: 11px; color: var(--accent); margin-bottom: 4px; }
.answer-detail-stem { font-size: 11px; line-height: 1.6; color: var(--text); margin-bottom: 5px; }
.answer-detail-answer { font-size: 12px; font-weight: 700; color: var(--green); line-height: 1.6; }
.answer-detail-note { font-size: 9px; color: var(--faint); margin-top: 4px; line-height: 1.5; }

.tab-icon { display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; }
.tab-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.stats-pie-wrap { position: relative; width: 150px; height: 150px; margin: 4px auto 16px; }
.stats-pie { width: 150px; height: 150px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--border); }
.stats-pie-wrap strong { position: absolute; left: 45px; top: 45px; width: 60px; height: 60px; border-radius: 50%; background: var(--card); color: var(--text); display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 800; }
.stats-summary { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; font-size: 11px; line-height: 1.9; color: var(--muted); }
.stats-summary b { color: var(--text); }
.stats-legend { display: flex; justify-content: center; gap: 13px; flex-wrap: wrap; font-size: 10px; color: var(--muted); margin-top: 12px; }
.stats-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; }
.modal-select, .modal-input { width: 100%; margin-top: 5px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 9px; font-size: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.form-grid label { font-size: 10px; color: var(--muted); }
.mastery-row { display: flex; align-items: center; gap: 9px; padding: 9px 2px; border-bottom: 1px solid var(--border); font-size: 10px; }
.mastery-row:last-child { border-bottom: 0; }
.mastery-row .name { flex: 1; min-width: 0; line-height: 1.5; }
.mastery-row .bar { width: 58px; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; flex: none; }
.mastery-row .bar i { display: block; height: 100%; background: var(--green); }
.mastery-row .pct { width: 32px; text-align: right; color: var(--muted); flex: none; }
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tool-grid button { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px 9px; color: var(--text); font-size: 11px; text-align: left; }
.tool-grid button strong { display: block; margin-bottom: 3px; }
.tool-grid button small { display: block; color: var(--faint); font-size: 9px; line-height: 1.4; }
.chat-messages { max-height: 46vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-bottom: 9px; }
.chat-item { border-radius: 10px; padding: 9px 10px; font-size: 11px; line-height: 1.7; white-space: pre-wrap; }
.chat-item.ai { background: var(--bg); color: var(--text); align-self: flex-start; }
.chat-item.user { background: var(--accent-soft); color: var(--accent); align-self: flex-end; max-width: 88%; }




.crop-stage { position: relative; width: 100%; max-height: 48vh; min-height: 120px; background: #111; border-radius: 8px; overflow: hidden; display: flex; justify-content: center; align-items: center; margin-bottom: 9px; }
.crop-stage img { max-width: 100%; max-height: 48vh; display: block; pointer-events: none; user-select: none; }
.crop-box { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.45); pointer-events: none; }

.quiz-body { flex: 1; min-height: 0; display: flex; }
.answer-side { display: none; }
.side-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 9px; }
.side-head h3 { margin: 0; font-size: 15px; }
.side-head span { color: var(--faint); font-size: 9px; }
.side-sheet { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; overflow-y: auto; flex: 1; padding-right: 2px; }
.side-sheet .sheet-item { height: 30px; font-size: 9px; }
.side-legend { display: flex; gap: 9px; padding-top: 9px; font-size: 8px; color: var(--faint); }
.side-legend span::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 2px; margin-right: 3px; }
.side-legend .l-right::before { background: var(--green); }
.side-legend .l-wrong::before { background: var(--red); }
.side-legend .l-answered::before { background: var(--accent); }
@media (min-width: 820px), (orientation: landscape) and (min-width: 640px) {
  .quiz { max-width: 1120px; margin: 0 auto; }
  .quiz-body { padding: 12px 12px 0; gap: 12px; overflow: hidden; }
  .scroll-area { padding: 0; min-width: 0; }
  .answer-side { display: flex; flex-direction: column; width: 300px; flex: none; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 12px; overflow: hidden; }
  .bottom-bar { max-width: 1120px; margin: 0 auto; width: 100%; }
}

.home-quick { display: flex; align-items: center; justify-content: space-between; margin: 0 0 12px; padding: 9px 11px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; font-size: 11px; color: var(--muted); }
.segmented { display: flex; background: var(--bg); border-radius: 8px; padding: 2px; gap: 2px; }
.segmented button { border: 0; background: transparent; color: var(--muted); border-radius: 6px; padding: 5px 10px; font-size: 10px; font-weight: 700; }
.segmented button.active { background: var(--accent); color: #fff; }
.orientation-row { align-items: center; }


/* Fill the whole WebView even after orientation changes. */
.quiz { position: fixed; left: 0; right: 0; top: 0; bottom: 0; height: auto; }
@media (min-width: 820px), (orientation: landscape) and (min-width: 640px) {
  .quiz { left: 0; right: 0; margin: 0 auto; }
}

/* Dynamic viewport height for Android landscape after rotation. */
.quiz { height: 100vh; height: 100dvh; }
.quiz-body { min-height: 0; }

.question-grid { display: block; }
.question-left, .question-right { min-width: 0; }
@media (min-width: 820px), (orientation: landscape) and (min-width: 640px) {
  .question-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 24px; align-items: start; }
  .question-right .divider { display: none; }
  .question-left .stem { margin-top: 6px; }
  .question-right .option-list { margin-top: 4px; }
}

.filter-head { display: flex; align-items: center; justify-content: space-between; font-size: 9px; color: var(--faint); margin-bottom: 4px; }
.filter-head button { background: transparent; color: var(--accent); font-size: 9px; padding: 2px 4px; }
.filter-collapsed-bar { flex: none; padding: 6px 10px; background: var(--card); border-bottom: 1px solid var(--border); }
.filter-collapsed-bar button { background: var(--accent-soft); color: var(--accent); border-radius: 8px; padding: 6px 12px; font-size: 10px; font-weight: 700; }

/* Independent scrolling columns in landscape */
@media (min-width: 820px), (orientation: landscape) and (min-width: 640px) {
  .scroll-area { overflow: hidden; }
  .question-card { height: 100%; padding: 0; display: flex; flex-direction: column; overflow: hidden; }
  .question-head { flex: none; padding: 13px 16px 9px; border-bottom: 1px solid var(--border); }
  .question-grid { flex: 1; min-height: 0; gap: 0; grid-template-columns: 1fr 1fr; align-items: stretch; overflow: hidden; }
  .question-left, .question-right { min-height: 0; height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 14px 16px 18px; }
  .question-left { border-right: 1px solid var(--border); }
  .question-left .stem { margin-top: 4px; overflow-wrap: anywhere; word-break: break-word; }
  .question-right .option-list { margin-top: 0; }
  .question-right .divider { display: none; }
  .safe-bottom { display: none; }
}
@media (min-width: 820px), (orientation: landscape) and (min-width: 640px) {
  .scroll-area { display: flex; flex-direction: column; }
  .question-card { flex: 1; height: auto; }
}

/* Two-panel layout: metadata lives in the left panel. */
.star-btn { margin-left: 2px; }
.status-pill { margin-left: auto; }
.question-head { padding: 0 0 8px; border-bottom: 0; }
@media (min-width: 820px), (orientation: landscape) and (min-width: 640px) {
  .question-head { padding: 0 0 8px; }
}

/* Full-width root layout, safe-area aware in landscape. */
html, body { width: 100%; min-height: 100%; overflow-x: hidden; }
body { box-sizing: border-box; }
@media (orientation: landscape) {
  body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}
@media (min-width: 720px) {
  .tabbar { left: 0; right: 0; width: auto; max-width: 760px; margin: 0 auto; transform: none; }
}
@media (orientation: landscape) and (min-width: 640px) {
  .tabbar { max-width: 1120px; }
}

.ai-field { display: block; margin: 0 0 10px; }
.ai-field span { display: block; font-size: 10px; color: var(--muted); margin-bottom: 4px; }
.ai-field input, .ai-field select { width: 100%; box-sizing: border-box; border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; background: var(--bg); color: var(--text); font-size: 12px; }
.ai-help { font-size: 10px; color: var(--faint); line-height: 1.6; margin: 0 0 10px; }
.ai-status { font-size: 10px; line-height: 1.6; min-height: 16px; color: var(--muted); margin: 4px 0 0; }

/* Daily practice + library management */
.daily-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 12px; padding: 15px 16px; border: 1px solid var(--border); border-radius: 16px; background: linear-gradient(135deg, #eef4ff, #f8fbff); }
.daily-info { min-width: 0; }
.daily-info .eyebrow { margin: 0 0 3px; color: var(--accent); font-size: 9px; letter-spacing: .18em; }
.daily-info h3 { margin: 0 0 4px; font-size: 17px; color: #172033; }
.daily-text { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.5; }
.daily-btn { flex: none; width: auto; padding: 10px 13px; font-size: 12px; }
.library-actions { display: flex; gap: 8px; margin: 12px 0 4px; }
.library-actions .mini-btn { flex: 1; padding: 9px 10px; font-size: 11px; }
.bank-picker { display: flex; flex-direction: column; gap: 7px; margin: 6px 0 10px; }
.bank-pick-row { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); font-size: 12px; }
.bank-pick-row input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.bank-pick-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.dark .daily-card { background: linear-gradient(135deg, #18253d, #172033); }
body.dark .daily-info h3 { color: var(--text); }

.bank-rename { flex: none; border: 1px solid var(--border); background: var(--card); color: var(--muted); border-radius: 8px; padding: 6px 7px; font-size: 10px; }
