/* 敲码 Tap Code — Apple-minimal, self-contained (shares the site's
   token values from app-style.css; tools with their own style.css do
   not get the shared sheet, so the tokens are duplicated here). */
:root {
  color-scheme: light;
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
  --canvas: #f5f5f7;
  --surface: #fff;
  --recessed: #f5f5f7;
  --ink: #1d1d1f;
  --muted: #65656b;
  --line: rgb(0 0 0 / .06);
  --control-line: rgb(0 0 0 / .14);
  --selected: rgb(0 0 0 / .075);
  --accent: #0071e3;
  --accent-hover: #0065cc;
  --accent-ink: #fff;
  --good: #1eaa50;
  --bad: #e02028;
  --motion: .2s cubic-bezier(.16, 1, .3, 1);
  color: var(--ink);
  background: var(--canvas);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #161618;
  --surface: #1e1e20;
  --recessed: #242426;
  --ink: #f5f5f7;
  --muted: #ababaf;
  --line: rgb(255 255 255 / .08);
  --control-line: rgb(255 255 255 / .19);
  --selected: rgb(255 255 255 / .10);
  --accent: #5aaaf9;
  --accent-hover: #7bbaff;
  --accent-ink: #101820;
  --good: #4ade80;
  --bad: #f87171;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; transition: background-color var(--motion), color var(--motion); }
main { width: min(896px, calc(100% - 32px)); margin: clamp(32px, 7vw, 80px) auto; }
h1 { font-size: clamp(2.25rem, 5vw, 4rem); font-weight: 600; line-height: 1.12; letter-spacing: -.045em; margin: 16px 0 8px; }
h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -.01em; margin: 0; }
p { color: var(--muted); margin: 0; }
a { color: var(--ink); text-underline-offset: .2em; }
.subtitle { font-size: 1.125rem; color: var(--ink); }
.lede { margin-top: 8px; }
.badges { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.panel { display: grid; gap: 24px; margin-block-start: 32px; border: 1px solid var(--line); border-radius: 24px; padding: clamp(16px, 4vw, 32px); background: var(--surface); }
.of-url-note { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; }
button { display: inline-flex; justify-content: center; align-items: center; background: var(--accent); color: var(--accent-ink); border: 1px solid transparent; border-radius: 8px; min-height: 44px; font: inherit; font-size: 14px; font-weight: 500; padding: 8px 16px; cursor: pointer; transition: background-color var(--motion), transform var(--motion); }
button:not(:disabled):hover { background: var(--accent-hover); }
button:not(:disabled):active { transform: scale(.98); }
button:disabled { opacity: .5; cursor: default; }
.secondary { color: var(--ink); background: var(--recessed); }
.secondary:not(:disabled):hover { background: var(--selected); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--recessed); border: 1px solid var(--control-line); border-radius: 10px; padding: 4px; }
.seg button { background: transparent; color: var(--ink); border: 0; min-height: 36px; border-radius: 7px; }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 4px rgba(0, 0, 0, .18); }
.brand-line { text-align: center; color: var(--muted); font-size: 12.5px; letter-spacing: .14em; padding: 20px 0 28px; margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---- Tap Code ---- */
.tp-speed-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 20px; }
.tp-label { font-weight: 600; color: var(--ink); }
.tp-chart-wrap { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start; }
.tp-grid { display: grid; grid-template-columns: repeat(5, 56px); gap: 8px; padding: 16px; background: var(--recessed); border: 1px solid var(--line); border-radius: 20px; }
.tp-cell { display: grid; justify-items: center; align-content: center; gap: 0; width: 56px; height: 56px; min-height: 56px; padding: 0; border-radius: 14px; background: var(--surface); color: var(--ink); border: 1px solid var(--control-line); transition: background-color .15s ease, transform .15s ease, border-color .15s ease; }
.tp-cell:hover { background: var(--selected); }
.tp-cell-letter { font-size: 1.25rem; font-weight: 600; line-height: 1.15; }
.tp-cell-group { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tp-cell.tp-hl-row { border-color: var(--accent); }
.tp-cell.tp-hl-col { border-color: var(--accent); }
.tp-cell.tp-hl-cell { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.tp-cell.tp-hl-cell .tp-cell-group { color: var(--accent-ink); opacity: .85; }
.tp-cell.tp-flash { animation: tp-flash .18s ease; }
@keyframes tp-flash { 0% { transform: scale(1.14); } 100% { transform: scale(1); } }
.tp-readout { display: grid; gap: 2px; min-width: 120px; }
.tp-big-letter { font-size: 4.5rem; line-height: 1.1; color: var(--ink); }
.tp-readout-line { font-size: 1.5rem; font-weight: 600; color: var(--ink); }
.tp-readout-line .tp-label { font-size: 1rem; font-weight: 600; }
textarea, input[type="text"] { width: 100%; font: inherit; color: var(--ink); background: var(--recessed); border: 1px solid var(--control-line); border-radius: 12px; padding: 12px 14px; resize: vertical; }
.tp-groups-out { font-size: 1.5rem; line-height: 1.6; color: var(--ink); word-break: break-all; min-height: 2.4rem; font-variant-numeric: tabular-nums; }
.tp-groups-out:empty { display: none; }
.tp-parts { display: flex; flex-wrap: wrap; gap: 8px; }
.tp-parts:empty { display: none; }
.tp-part { display: inline-grid; grid-template-columns: auto auto; gap: 0 8px; align-items: baseline; background: var(--recessed); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 13px; }
.tp-part .tp-part-letter { color: var(--ink); font-weight: 600; }
.tp-part .tp-part-group { font-size: 1rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.tp-part .tp-part-note { color: var(--muted); grid-column: 1 / -1; }
.tp-part.tp-playing { border-color: var(--accent); }
.tp-part.tp-invalid { border-color: var(--bad); }
.tp-part.tp-invalid .tp-part-group { color: var(--bad); font-weight: 600; }
.tp-part button.tp-part-x { min-height: 0; padding: 0 6px; font-size: 14px; background: transparent; color: var(--muted); border: 0; }
.tp-decode-out { font-size: 2rem; line-height: 1.4; color: var(--ink); word-break: break-all; min-height: 2.8rem; letter-spacing: .08em; }
.tp-decode-out:empty { display: none; }
.tp-tap-btn { width: 100%; min-height: 72px; font-size: 1.25rem; font-weight: 600; border-radius: 16px; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.tp-tap-btn.tp-tapped { animation: tp-flash .18s ease; }
.tp-tap-count { font-size: 1rem; color: var(--ink); min-height: 1.5em; }
.tp-tap-count:empty { display: none; }
.tp-sub-h { font-size: 1rem; margin: 8px 0 0; }
.tp-quiz-meta { color: var(--muted); }
.tp-quiz-meta strong { color: var(--ink); }
.tp-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.tp-options button { font-size: 1.25rem; min-height: 56px; }
.tp-options button.tp-picked-correct { background: var(--good); color: #fff; }
.tp-options button.tp-picked-wrong { background: var(--bad); color: #fff; }
.tp-feedback { font-size: 1rem; color: var(--ink); min-height: 1.5em; }
.tp-feedback:empty { display: none; }
.tp-feedback.tp-good { color: var(--good); font-weight: 600; }
.tp-feedback.tp-bad { color: var(--bad); font-weight: 600; }
.tp-result-line { font-size: 1.125rem; color: var(--ink); }
.tp-result-line strong { font-variant-numeric: tabular-nums; }
.tp-review { display: grid; gap: 8px; }
.tp-review:empty { display: none; }
.tp-review-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; background: var(--recessed); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.tp-review-row .tp-review-letter { font-weight: 600; color: var(--ink); }
.tp-review-row .tp-review-wrong { color: var(--bad); }
#encode-msg:empty, #decode-manual-out:empty, #quiz-best:empty, #quiz-heard:empty { display: none; }
@media (max-width: 640px) {
  .tp-options { grid-template-columns: repeat(2, 1fr); }
  .tp-big-letter { font-size: 3.5rem; }
  .tp-grid { grid-template-columns: repeat(5, 52px); gap: 6px; padding: 12px; }
  .tp-cell { width: 52px; height: 52px; min-height: 52px; }
}
