/* iOS 风格练习站：浅色系统、安全区、底部 Tab、全屏答题。 */

:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --ink: #1c1c1e;
  --secondary: #8e8e93;
  --tertiary: #c7c7cc;
  --blue: #007aff;
  --blue-press: #0066d6;
  --blue-soft: rgba(0, 122, 255, 0.12);
  --red: #ff3b30;
  --red-soft: rgba(255, 59, 48, 0.12);
  --green: #34c759;
  --green-soft: rgba(52, 199, 89, 0.14);
  --orange: #ff9500;
  --fill: #e5e5ea;
  --fill-2: #d1d1d6;
  --sep: rgba(60, 60, 67, 0.12);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
  --radius: 20px;
  --radius-sm: 14px;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --title: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tab-h: 49px;
  --nav-h: 52px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}
body { min-height: 100dvh; }
a { color: var(--blue); text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
img { max-width: 100%; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: #fff; padding: 8px 12px; z-index: 80; }

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* —— 顶栏 —— */
.nav-ios {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  min-height: calc(var(--nav-h) + var(--safe-t));
  padding: calc(6px + var(--safe-t)) 12px 6px;
  background: rgba(242, 242, 247, 0.78);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--sep);
}
.nav-ios.exam {
  background: rgba(255, 255, 255, 0.82);
}
.nav-title {
  flex: 1; min-width: 0;
  font-family: var(--title);
  font-size: 17px; font-weight: 600;
  text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-side {
  flex: 0 0 72px;
  display: flex; align-items: center;
}
.nav-side.right { justify-content: flex-end; flex-basis: auto; min-width: 72px; gap: 8px; }
.nav-btn {
  min-height: 44px; min-width: 44px;
  padding: 8px 10px;
  color: var(--blue);
  font-size: 17px; font-weight: 400;
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
.nav-btn:active { opacity: 0.5; }
.nav-btn.strong { font-weight: 600; }
.nav-btn.danger { color: var(--red); font-weight: 600; }
.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 15px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--ink);
}
.timer.warn { background: rgba(255, 149, 0, 0.16); color: #c93400; }
.timer.hot { background: var(--red-soft); color: var(--red); }

.progress {
  height: 3px; background: var(--fill);
  width: 100%;
}
.progress > i {
  display: block; height: 100%; width: 0;
  background: var(--blue);
  transition: width 0.25s ease;
}

/* —— 正文 —— */
main {
  flex: 1;
  width: min(780px, 100%);
  margin: 0 auto;
  padding: 8px 16px 24px;
}
.mode-tabs main {
  padding-bottom: calc(24px + var(--tab-h) + var(--safe-b) + 8px);
}
.mode-exam main {
  width: min(720px, 100%);
  max-width: 720px;
  align-self: center;
  padding: 8px 16px calc(18px + 64px + var(--safe-b));
}

.large-title {
  font-family: var(--title);
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 8px 0 4px;
  line-height: 1.15;
}
.subhead {
  color: var(--secondary);
  font-size: 15px;
  margin: 0 0 16px;
  line-height: 1.45;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 18px;
  box-shadow: 0 1px 0 var(--sep);
}
.stat {
  padding: 14px 6px 12px;
  text-align: center;
  position: relative;
}
.stat + .stat::before {
  content: "";
  position: absolute; left: 0; top: 14px; bottom: 14px;
  width: 0.5px; background: var(--sep);
}
.stat b {
  display: block;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.stat span { font-size: 11px; color: var(--secondary); }

.segment {
  display: flex;
  background: var(--fill);
  border-radius: 10px;
  padding: 2px;
  margin: 0 0 16px;
}
.segment button {
  flex: 1;
  min-height: 32px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.segment button.on {
  background: var(--card);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.section-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary);
  text-transform: none;
  margin: 18px 4px 8px;
  letter-spacing: 0.01em;
}

.paper-list { display: grid; gap: 12px; }
.paper-card {
  display: block;
  background: var(--card);
  border-radius: var(--radius);
  padding: 0;
  color: inherit;
  overflow: hidden;
  box-shadow: 0 1px 0 var(--sep);
  transform: translateZ(0);
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}
.paper-card:active { transform: scale(0.985); }
.paper-card .wash {
  height: 8px;
  background: linear-gradient(90deg, #5b7cfa, #007aff);
}
.paper-card.web .wash { background: linear-gradient(90deg, #30d158, #00c7be); }
.paper-card .body { padding: 14px 16px 16px; }
.paper-card h3 {
  margin: 6px 0 6px;
  font-family: var(--title);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.paper-card p {
  margin: 0;
  color: var(--secondary);
  font-size: 14px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.meta {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.chip {
  font-size: 12px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px;
  background: var(--fill); color: var(--ink);
}
.chip.pdf { background: var(--blue-soft); color: var(--blue); }
.chip.web { background: rgba(0, 199, 190, 0.14); color: #0f8a84; }
.foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 12px; font-size: 13px; color: var(--secondary);
}
.foot .go {
  color: var(--blue); font-weight: 600;
  display: inline-flex; align-items: center; gap: 2px;
}
.score-ok { color: var(--green); font-weight: 600; }

/* —— 答题 —— */
.q-wrap { display: flex; flex-direction: column; gap: 14px; }
.q-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.q-kicker {
  font-size: 13px; font-weight: 600; color: var(--blue);
  background: var(--blue-soft);
  padding: 4px 10px; border-radius: 999px;
}
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  color: var(--orange);
  background: transparent;
}
.icon-btn.on { background: rgba(255, 149, 0, 0.14); }
.icon-btn:active { opacity: 0.55; }

.stem {
  font-size: 20px;
  font-weight: 590;
  letter-spacing: -0.02em;
  line-height: 1.55;
  margin: 0;
}
.stem .blank {
  display: inline-flex;
  min-width: 76px;
  max-width: 100%;
  margin: 0 3px;
  padding: 2px 6px 4px;
  border: 0;
  border-bottom: 1.5px solid var(--fill-2);
  background: transparent;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  color: var(--blue);
  border-radius: 0;
}
.stem .blank:focus {
  outline: none;
  border-bottom-color: var(--blue);
}

.tf {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.tf .opt {
  min-height: 56px;
  justify-content: center;
  font-size: 18px;
  font-weight: 650;
  border-radius: 16px;
  border: 0;
  background: var(--card);
  box-shadow: 0 1px 0 var(--sep);
}
.tf .opt.picked {
  background: var(--blue);
  color: #fff;
  box-shadow: none;
}
.tf .opt.correct { background: var(--green); color: #fff; }
.tf .opt.incorrect { background: var(--red); color: #fff; }

.options {
  background: var(--card);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 0 var(--sep);
}
.opt {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  min-height: 52px;
  padding: 14px 16px;
  background: var(--card);
  position: relative;
}
.opt + .opt { box-shadow: inset 0 0.5px 0 var(--sep); }
.opt:active { background: #f2f2f7; }
.opt .tag {
  flex: 0 0 28px;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  color: var(--blue);
  background: var(--blue-soft);
  margin-top: 1px;
}
.opt.picked { background: #f0f6ff; }
.opt.picked .tag { background: var(--blue); color: #fff; }
.opt.correct { background: var(--green-soft); }
.opt.correct .tag { background: var(--green); color: #fff; }
.opt.incorrect { background: var(--red-soft); }
.opt.incorrect .tag { background: var(--red); color: #fff; }
.opt span:last-child { flex: 1; font-size: 16px; line-height: 1.45; }

.hint { font-size: 13px; color: var(--secondary); margin: 4px 4px 0; }
.essay {
  width: 100%;
  min-height: 200px;
  resize: vertical;
  border: 0;
  border-radius: 16px;
  padding: 14px 16px;
  background: var(--card);
  line-height: 1.6;
  font-size: 17px;
  box-shadow: 0 1px 0 var(--sep);
}
.essay:focus { outline: 2px solid var(--blue-soft); }

.explain {
  background: var(--card);
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  box-shadow: 0 1px 0 var(--sep);
}
.explain .ok { color: var(--green); font-weight: 700; display: block; margin-bottom: 6px; }
.explain .bad { color: var(--red); font-weight: 700; display: block; margin-bottom: 6px; }
.muted { color: var(--secondary); font-size: 13px; }

/* —— 底部答题坞 —— */
.exam-dock {
  position: fixed;
  left: 0; right: 0; bottom: 0; z-index: 25;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px max(12px, calc(50vw - 360px)) calc(8px + var(--safe-b));
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep);
}
.dock-btn {
  min-height: 44px;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 600;
  color: var(--blue);
  padding: 0 8px;
}
.dock-btn:disabled { color: var(--tertiary); }
.dock-btn:active:not(:disabled) { opacity: 0.45; }
.dock-btn.next { text-align: right; }
.pager {
  min-height: 40px;
  min-width: 108px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--fill);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
}
.pager:active { transform: scale(0.97); }

/* —— Tab bar —— */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(249, 249, 249, 0.92);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--secondary); font-size: 10px; font-weight: 500;
  min-height: var(--tab-h);
}
.tab svg { width: 25px; height: 25px; }
.tab.on { color: var(--blue); }

/* —— 列表 —— */
.list { display: flex; flex-direction: column; background: var(--card); border-radius: 16px; overflow: hidden; }
.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  min-height: 56px;
  color: inherit;
  background: var(--card);
}
.row + .row { box-shadow: inset 0 0.5px 0 var(--sep); }
.row:active { background: #f2f2f7; }
.row b { font-size: 16px; font-weight: 600; display: block; }
.row .muted { margin-top: 2px; }
.chev { color: var(--tertiary); font-size: 20px; font-weight: 300; }
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--secondary);
  background: var(--card);
  border-radius: 16px;
}

/* —— 成绩 —— */
.result {
  text-align: center;
  background: var(--card);
  border-radius: 24px;
  padding: 28px 20px 22px;
  margin-bottom: 16px;
}
.ring { width: 168px; height: 168px; margin: 0 auto 8px; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .label {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: var(--title);
}
.ring .label b { font-size: 44px; letter-spacing: -0.04em; line-height: 1; display: block; }
.ring .label span { color: var(--secondary); font-size: 13px; font-weight: 600; }
.result h1 { font-size: 22px; margin: 8px 0 6px; font-family: var(--title); }
.actions { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.btn {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  font-size: 17px;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn:active { background: var(--blue-press); }
.btn.ghost {
  background: var(--fill);
  color: var(--ink);
}
.btn.danger { background: var(--red); color: #fff; }
.breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0 4px;
}
.bd {
  background: var(--bg);
  border-radius: 14px;
  padding: 12px;
  text-align: left;
}
.bd b { display: block; font-variant-numeric: tabular-nums; font-size: 18px; }
.bd span { font-size: 12px; color: var(--secondary); }

/* —— Sheet —— */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.36);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.22s ease;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.sheet {
  width: min(560px, 100%);
  max-height: min(86dvh, 720px);
  background: #f2f2f7;
  border-radius: 16px 16px 0 0;
  padding: 6px 12px calc(16px + var(--safe-b));
  transform: translateY(24px);
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
  overflow: auto;
}
.overlay.show .sheet { transform: none; }
.handle {
  width: 36px; height: 5px; border-radius: 99px;
  background: var(--fill-2); margin: 6px auto 10px;
}
.sheet h3 {
  text-align: center; margin: 0 0 12px;
  font-size: 17px; font-weight: 700;
}
.q-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.q-dot {
  height: 40px;
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.q-dot.current { background: var(--blue); color: #fff; }
.q-dot.done { background: var(--blue-soft); color: var(--blue); }
.q-dot.flag { box-shadow: inset 0 0 0 1.5px var(--orange); }
.q-dot.right { background: var(--green-soft); color: #18843b; }
.q-dot.wrong { background: var(--red-soft); color: var(--red); }
.q-dot.skip { background: var(--fill); color: var(--secondary); }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.sheet-actions .btn { width: 100%; }

@media (min-width: 860px) {
  .tabbar { display: none; }
  .mode-tabs main { padding-bottom: 40px; width: min(920px, calc(100% - 48px)); padding-top: 12px; }
  .paper-list { grid-template-columns: 1fr 1fr; }
  .nav-ios .desktop-only { display: flex; }
  .breakdown { grid-template-columns: repeat(3, 1fr); }
  .overlay { align-items: center; }
  .sheet {
    border-radius: 18px;
    padding-bottom: 18px;
    max-height: min(78vh, 640px);
  }
  .q-grid { grid-template-columns: repeat(8, 1fr); }
}
@media (max-width: 859px) {
  .desktop-only { display: none !important; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .stat b { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
