/* The app's palette (Theme.swift): paper and canvas grays, ink with opacities, one accent for flags */
:root {
  --paper: #ececec;   /* white 0.925 */
  --canvas: #f6f6f6;  /* white 0.965 */
  --ink: #000000;
  --text: rgba(0, 0, 0, 0.88);
  --muted: rgba(0, 0, 0, 0.52);
  --faint: rgba(0, 0, 0, 0.32);
  --hairline: rgba(0, 0, 0, 0.09);
  --fill: rgba(0, 0, 0, 0.045);
  --selected: rgba(0, 0, 0, 0.09);
  --flag: #d64a29;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro", "PingFang TC", "Hiragino Sans", "Noto Sans TC", system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1d1d1d;  /* 0.115 */
    --canvas: #252525; /* 0.145 */
    --ink: #ffffff;
    --text: rgba(255, 255, 255, 0.88);
    --muted: rgba(255, 255, 255, 0.52);
    --faint: rgba(255, 255, 255, 0.32);
    --hairline: rgba(255, 255, 255, 0.09);
    --fill: rgba(255, 255, 255, 0.045);
    --selected: rgba(255, 255, 255, 0.09);
  }
}
:root[data-theme="dark"] {
  --paper: #1d1d1d;
  --canvas: #252525;
  --ink: #ffffff;
  --text: rgba(255, 255, 255, 0.88);
  --muted: rgba(255, 255, 255, 0.52);
  --faint: rgba(255, 255, 255, 0.32);
  --hairline: rgba(255, 255, 255, 0.09);
  --fill: rgba(255, 255, 255, 0.045);
  --selected: rgba(255, 255, 255, 0.09);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--canvas); color: var(--text);
  font: 400 15px/1.5 var(--font); -webkit-font-smoothing: antialiased;
}
p, h1, h2, h3, ul, ol, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: inherit; }
img { display: block; }
svg { flex: none; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 6px; }

html[data-lang="en"] .zh, html[data-lang="zh"] .en { display: none; }

/* Controls, as in the app */
.ink-btn, .line-btn {
  display: inline-flex; align-items: center; height: 30px; padding: 0 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; white-space: nowrap; text-decoration: none;
}
.ink-btn { background: var(--ink); color: var(--paper); }
.line-btn { box-shadow: inset 0 0 0 1px var(--hairline); color: var(--ink); }
.wordmark { display: inline-flex; align-items: center; gap: 7px; font-size: 15px; font-weight: 700; letter-spacing: -0.2px; color: var(--ink); }
.wordmark i { width: 14px; height: 14px; border-radius: 4px; background: var(--ink); }

/* ---------- Top ---------- */
.top { display: flex; justify-content: space-between; align-items: center; max-width: 1080px; margin: 0 auto; padding: 18px 16px; }
.lang { display: flex; gap: 2px; padding: 2px; border-radius: 9px; background: var(--fill); }
.lang button {
  appearance: none; border: 0; background: none; color: var(--ink); cursor: pointer;
  font: 400 12px/1 var(--font); height: 24px; padding: 0 10px; border-radius: 7px;
}
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--paper); font-weight: 600; }

/* ---------- Hero ---------- */
.hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: clamp(40px, 8vw, 88px) 16px clamp(36px, 6vw, 64px); }
.icon { width: 72px; height: 72px; border-radius: 16px; margin-bottom: 22px; }
h1 { font-size: clamp(40px, 6vw, 60px); line-height: 1.05; font-weight: 700; letter-spacing: -0.03em; color: var(--ink); }
.keys { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 18px 0 4px; padding: 0; list-style: none; }
.keys li { padding: 7px 14px; border: 1px solid var(--faint); border-radius: 999px; font-size: clamp(15px, 1.8vw, 17px); font-weight: 600; color: var(--ink); }
.tagline { margin-top: 12px; font-size: clamp(18px, 2.2vw, 22px); color: var(--muted); }
.ink-btn.big { height: 40px; padding: 0 20px; font-size: 15px; margin-top: 28px; }
.fine { margin-top: 12px; font-size: 12px; color: var(--muted); }

/* ---------- The window ---------- */
.window {
  display: grid; grid-template-columns: 172px 330px minmax(0, 1fr);
  max-width: 1080px; height: 560px; margin: 0 auto; overflow: hidden;
  background: var(--paper); border-radius: 12px;
  box-shadow: 0 0 0 1px var(--hairline), 0 24px 60px -24px rgba(0, 0, 0, 0.35);
}
.window svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linejoin: round; stroke-linecap: round; }

.rail { padding: 12px 10px; border-right: 1px solid var(--hairline); }
.lights { display: flex; gap: 8px; padding: 2px 4px 30px; }
.lights i { width: 12px; height: 12px; border-radius: 50%; background: var(--faint); opacity: 0.6; }
.rail .wordmark { padding: 0 10px 22px; }
.rail li { display: flex; align-items: center; gap: 9px; height: 30px; padding: 0 10px; border-radius: var(--radius); font-size: 13px; color: var(--ink); }
.rail li svg { color: var(--muted); }
.rail li.on { background: var(--selected); font-weight: 600; }
.rail li.gap { margin-top: 14px; }

.list { padding: 12px 8px 0; border-right: 1px solid var(--hairline); overflow: hidden; }
.field { display: flex; align-items: center; gap: 10px; height: 40px; margin: 30px 6px 8px; padding: 0 12px; border-radius: 10px; background: var(--fill); }
.field svg { color: var(--muted); stroke-width: 1.6; }
.query { font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; }
.caret { width: 1.5px; height: 15px; margin-left: -8px; background: var(--ink); opacity: 0; }
.window.typing .caret { opacity: 1; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.sect { padding: 8px 10px 4px; font-size: 11px; font-weight: 600; color: var(--muted); }
.rows li {
  position: relative; display: grid; grid-template-columns: 6px minmax(0, 1fr); gap: 10px;
  padding: 9px 10px; border-radius: var(--radius); transition: opacity 0.35s, transform 0.35s;
}
.rows li > i { width: 6px; height: 6px; margin-top: 6px; border-radius: 50%; }
.rows .dot { background: var(--ink); }
.rows li.sel { background: var(--selected); }
.rows li.sel::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--ink); }
.r1 { display: flex; justify-content: space-between; gap: 6px; font-size: 13px; color: var(--ink); }
.r1 b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows li:has(.dot) .r1 b { font-weight: 700; }
.r1 time { flex: none; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.r2 { display: flex; justify-content: space-between; gap: 6px; margin-top: 3px; font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r2 .flag { width: 10px; height: 10px; color: var(--flag); fill: currentColor; stroke: currentColor; }
.r3 {
  margin-top: 3px; font-size: 12px; line-height: 1.4; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.window.waiting .rows li { opacity: 0; transform: translateY(5px); }

.read { background: var(--canvas); padding: 14px 28px; overflow: hidden; }
.tools { display: flex; gap: 18px; padding: 4px 0 26px; color: var(--ink); }
.tools svg { width: 17px; height: 17px; }
.tools .sp { flex: 1; }
.subj { font-size: 20px; font-weight: 600; letter-spacing: -0.2px; color: var(--ink); }
.from { display: flex; align-items: center; gap: 10px; margin-top: 18px; font-size: 13px; color: var(--ink); }
.from b { font-weight: 500; flex: 1; }
.from time { font-size: 12px; color: var(--muted); }
.av { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--fill); box-shadow: inset 0 0 0 1px var(--hairline); font-size: 13px; }
.att { margin-top: 16px; }
.att span { display: inline-grid; padding: 7px 12px; border-radius: var(--radius); background: var(--fill); font-size: 12px; color: var(--ink); }
.att small { color: var(--muted); font-size: 11px; }
.body { display: grid; gap: 12px; margin-top: 30px; }
.body i { height: 8px; border-radius: 4px; background: var(--fill); }

/* ---------- Three beats ---------- */
.beats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px 28px;
  max-width: 1080px; margin: 0 auto; padding: clamp(64px, 10vw, 120px) 16px clamp(48px, 8vw, 96px);
}
.beats h3 { margin-top: 20px; font-size: 17px; font-weight: 600; color: var(--ink); }
.beats article > p { margin-top: 4px; font-size: 14px; color: var(--muted); }
.card {
  position: relative; height: 300px; overflow: hidden; padding: 14px;
  background: var(--paper); border-radius: 12px; box-shadow: inset 0 0 0 1px var(--hairline);
  font-size: 12px; color: var(--ink);
}

.top-row { display: flex; justify-content: space-between; align-items: center; }
.ask { padding: 6px 10px; border-radius: var(--radius); background: var(--fill); }
.prop { margin-top: 10px; padding: 12px; border-radius: var(--radius); background: var(--canvas); box-shadow: inset 0 0 0 1px var(--hairline); }
.ph { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.ph span { font-size: 12px; color: var(--muted); }
.prop ul { display: grid; gap: 7px; margin-top: 10px; }
.prop li { display: grid; grid-template-columns: 13px minmax(0, 1fr); gap: 6px; }
.prop li p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prop small { display: block; font-size: 11px; color: var(--muted); }
.prop li.off div { opacity: 0.5; }
.box { position: relative; width: 12px; height: 12px; margin-top: 2px; border-radius: 3px; box-shadow: inset 0 0 0 1.3px var(--faint); }
.box.on { background: var(--ink); box-shadow: none; }
.box.on::after { content: ""; position: absolute; left: 4px; top: 1px; width: 3px; height: 6.5px; border: solid var(--paper); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.pf { display: flex; gap: 8px; margin-top: 12px; }
.pf span { height: 26px; padding: 0 12px; font-size: 12px; }
.marks { display: flex; gap: 8px; }

.sh { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.sh .ink-btn { height: 26px; padding: 0 10px; font-size: 12px; }
.pills { display: inline-flex; gap: 2px; padding: 2px; border-radius: 9px; background: var(--fill); }
.pills span { padding: 3px 9px; border-radius: 7px; }
.pills .on { background: var(--ink); color: var(--paper); font-weight: 600; }
.card table { width: 100%; border-collapse: collapse; font-size: 13px; }
.card th { text-align: left; font-size: 11px; font-weight: 500; color: var(--muted); padding: 4px 8px 6px; border-bottom: 1px solid var(--hairline); }
.card td { padding: 7px 8px; white-space: nowrap; }
.card .n { width: 56px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.card .hv { color: var(--ink); font-weight: 700; }
.card tr.sel td { background: var(--selected); }
.card tr.sel td:first-child { border-radius: 6px 0 0 6px; }
.card tr.sel td:last-child { border-radius: 0 6px 6px 0; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 6px 2px 18px; }
.stats p { display: grid; gap: 4px; align-content: start; }
.stats small { font-size: 11px; color: var(--muted); }
.stats b { font-size: 19px; font-weight: 600; letter-spacing: -0.4px; font-variant-numeric: tabular-nums; }
.meter { display: block; height: 3px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--ink); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 2px; border-top: 1px solid var(--hairline); font-size: 13px; }
.row span { color: var(--muted); }
.toggle { position: relative; width: 28px; height: 16px; border-radius: 8px; background: var(--selected); }
.toggle::after { content: ""; position: absolute; left: 2px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--canvas); box-shadow: 0 1px 2px rgba(0,0,0,0.25); }

/* ---------- Footer ---------- */
.foot { display: flex; justify-content: center; gap: 22px; padding: 28px 16px 44px; border-top: 1px solid var(--hairline); font-size: 12px; color: var(--muted); }
.foot a { text-decoration: none; }
.foot a:hover { color: var(--ink); }

@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .invert-dark { filter: invert(1); } }
:root[data-theme="dark"] .invert-dark { filter: invert(1); }

/* ---------- Narrow ---------- */
@media (max-width: 960px) {
  .window { grid-template-columns: 172px minmax(0, 1fr); width: calc(100% - 32px); max-width: 560px; }
  .read { display: none; }
  .list { border-right: 0; }
  .beats { grid-template-columns: minmax(0, 1fr); max-width: 440px; }
}
@media (max-width: 560px) {
  .window { grid-template-columns: minmax(0, 1fr); height: 470px; }
  .rail { display: none; }
  .field { margin-top: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .rows li { transition: none; }
  .window.typing .caret { animation: none; }
}
