/* Attention — shared styles. Phone-first (375px), dark theme matching the animations:
   Q = yellow, K = blue, V = green, scores = orange. */

:root {
  --bg: #0d0f12;
  --surface: #161a20;
  --surface-2: #1d222a;
  --border: #2a313b;
  --text: #e6e9ee;
  --muted: #9aa4b2;
  --accent: #f2c14e;
  --q: #f2c14e;
  --k: #5aa9f0;
  --v: #5fd08a;
  --s: #f0904a;
  --warn: #ef6b6b;
  --radius: 12px;
  --max: 720px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC",
    "Microsoft JhengHei", "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.75;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

main, .topbar-inner, footer { max-width: var(--max); margin: 0 auto; padding: 0 20px; }

a { color: var(--k); text-underline-offset: 3px; }

/* Top bar */
.topbar { border-bottom: 1px solid var(--border); background: var(--bg); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.home-link {
  display: inline-flex; align-items: center; min-height: 44px; min-width: 44px;
  color: var(--text); text-decoration: none; font-weight: 600;
}
.brand { color: var(--accent); font-weight: 700; letter-spacing: 0.02em; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }

/* Typography */
h1 { font-size: 1.75rem; line-height: 1.3; margin: 32px 0 8px; }
h2 { font-size: 1.3rem; line-height: 1.4; margin: 44px 0 12px; padding-top: 8px; border-top: 1px solid var(--border); }
h3 { font-size: 1.08rem; margin: 28px 0 8px; }
p { margin: 0 0 16px; }
.lead { font-size: 1.08rem; color: var(--text); }
.meta { color: var(--muted); font-size: 0.92rem; margin-bottom: 24px; }
strong { color: #fff; }
ul, ol { padding-left: 1.4em; margin: 0 0 16px; }
li { margin-bottom: 6px; }

.q { color: var(--q); } .k { color: var(--k); } .v { color: var(--v); } .s { color: var(--s); }

/* Code and formulas: scroll inside their own box */
code { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 0.9em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
pre {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  font-size: 0.86rem; line-height: 1.6; margin: 0 0 18px;
}
pre code { background: none; padding: 0; font-size: inherit; }
.formula {
  background: var(--surface); border-left: 3px solid var(--accent); border-radius: 8px;
  padding: 12px 16px; margin: 0 0 18px; overflow-x: auto;
  font-family: "Times New Roman", "Songti TC", serif; font-size: 1.1rem; white-space: nowrap;
}

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 0 18px; border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; min-width: 480px; font-size: 0.92rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Callouts */
.callout { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 18px; }
.callout.key { border-color: var(--accent); }
.callout p:last-child { margin-bottom: 0; }
.callout-title { font-weight: 700; color: var(--accent); margin-bottom: 4px; }

/* Bars for the IO comparison */
.bars { margin: 0 0 18px; }
.bar-row { margin-bottom: 12px; }
.bar-label { display: flex; justify-content: space-between; font-size: 0.92rem; color: var(--muted); }
.bar-track { background: var(--surface-2); border-radius: 6px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; }

/* Video slot */
.video-slot {
  border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface);
  padding: 20px; text-align: center; color: var(--muted); margin: 0 0 18px;
}

/* TOC */
.toc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 8px; }
.toc ol { margin: 0; }
.toc a { display: inline-block; min-height: 32px; padding: 4px 0; color: var(--text); }

/* Home: paper cards */
.tagline { color: var(--muted); margin-top: 0; }
.cards { list-style: none; padding: 0; margin: 24px 0; display: grid; gap: 14px; }
.card {
  display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; color: var(--text); text-decoration: none; min-height: 44px;
}
a.card:active, a.card:focus-visible { border-color: var(--accent); }
.card h3 { margin: 0 0 4px; font-size: 1.12rem; }
.card .card-meta { color: var(--muted); font-size: 0.88rem; margin-bottom: 6px; }
.card p { margin: 0; font-size: 0.95rem; }
.badge { display: inline-block; font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); margin-left: 6px; vertical-align: middle; }
.badge.ready { color: var(--v); border-color: var(--v); }
.card.soon { opacity: 0.6; }

footer { color: var(--muted); font-size: 0.85rem; padding-top: 24px; padding-bottom: 40px; border-top: 1px solid var(--border); margin-top: 48px; }

@media (min-width: 760px) {
  body { font-size: 18px; }
  h1 { font-size: 2.2rem; margin-top: 48px; }
  .cards { grid-template-columns: 1fr 1fr; }
}
