:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --ink: #1d1b19;
  --muted: #6a645c;
  --line: #ddd6cb;
  --accent: #b4442b;
  --accent-ink: #ffffff;
  --key-w: #fdfcfa;
  --key-b: #1d1b19;
  --key-on: #e8a33d;
  --key-on-b: #e8a33d;
  --radius: 14px;
  --font: system-ui, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161412;
    --surface: #211e1b;
    --ink: #f1ece4;
    --muted: #a39b8f;
    --line: #3a352f;
    --accent: #e0694c;
    --accent-ink: #1a0d08;
    --key-w: #ece7de;
    --key-b: #0d0c0b;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--font);
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.top, main, .foot { max-width: 980px; margin: 0 auto; padding-inline: 16px; }
.top { padding-top: 28px; padding-bottom: 8px; }
h1 { margin: 0; font-size: clamp(1.7rem, 5vw, 2.4rem); letter-spacing: -0.02em; }
.sub { margin: 4px 0 0; color: var(--muted); }
main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; padding-block: 16px; }
.card {
  min-width: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.card[hidden] { display: none; }
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 32px 16px; border: 2px dashed var(--line); border-radius: var(--radius);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over, .drop:focus-within { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-big { font-weight: 600; }
.drop-small { color: var(--muted); font-size: .9rem; }
.row { margin-top: 12px; }
.btn {
  min-height: 44px; padding: 0 18px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible, input[type=range]:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.help { margin-top: 14px; color: var(--muted); font-size: .95rem; }
.help summary { cursor: pointer; }
.msg { margin: 10px 0 0; min-height: 1.5em; color: var(--accent); font-weight: 600; }
.title { margin: 0; font-size: 1.3rem; overflow-wrap: anywhere; }
.meta { margin: 2px 0 14px; color: var(--muted); font-size: .92rem; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.speed { display: flex; align-items: center; gap: 8px; margin-left: auto; color: var(--muted); font-size: .92rem; }
.speed input { width: 130px; }
.seek { display: flex; align-items: center; gap: 10px; margin: 14px 0; }
.seek input { flex: 1; min-width: 0; }
.time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9rem; min-width: 3ch; }
input[type=range] { accent-color: var(--accent); height: 28px; }

.kb-wrap { overflow-x: auto; padding-bottom: 6px; }
.kb { position: relative; display: flex; height: 150px; min-width: 100%; touch-action: manipulation; }
.wk {
  flex: 1 0 22px; border: 1px solid #00000033; border-top: 0;
  background: var(--key-w); border-radius: 0 0 6px 6px; position: relative;
}
.wk.on { background: var(--key-on); }
.bk {
  position: absolute; top: 0; height: 62%; background: var(--key-b);
  border-radius: 0 0 4px 4px; z-index: 2; transform: translateX(-50%);
}
.bk.on { background: var(--key-on-b); outline: 2px solid var(--key-b); }
.wk .lbl { position: absolute; bottom: 4px; left: 0; right: 0; text-align: center; font-size: 10px; color: #6a645c; pointer-events: none; }
.hint { margin: 6px 0 0; color: var(--muted); font-size: .85rem; }
.score { margin-top: 16px; overflow-x: auto; background: #fff; border-radius: 10px; padding: 8px; }
.foot { padding-block: 24px; color: var(--muted); font-size: .85rem; }
@media (max-width: 560px) {
  .speed { margin-left: 0; width: 100%; }
  .speed input { flex: 1; }
  .kb { height: 130px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.nav { margin: 12px 0 0; }
.linkbtn { display: inline-flex; align-items: center; text-decoration: none; }
.inst { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .92rem; }
select {
  min-height: 44px; max-width: 100%; padding: 0 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit;
}
select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.msg.small { font-size: .9rem; margin: 6px 0 0; }
.cap { position: absolute; left: 0; right: 0; text-align: center; font-size: 11px; font-weight: 700; pointer-events: none; }
.wk .cap { bottom: 20px; color: #8a8378; }
.bk .cap { bottom: 6px; color: #d8d2c8; }
.wk.live { background: var(--key-on); }
.bk.live { background: var(--key-on-b); outline: 2px solid var(--key-b); }
.wk, .bk { user-select: none; -webkit-user-select: none; touch-action: none; }
