:root {
  --bg: #07050b;
  --panel: #120d19;
  --line: #2a2033;
  --text: #ece6f2;
  --dim: #9a8fa8;
  --accent: #fc8961; /* magma orange */
  --accent2: #b73779; /* magma pink */
  --key: #fcb46f;
  --query: #d8a0ff;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
header, main, footer { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
header { padding-top: 28px; }
h1 { font-size: clamp(22px, 4.2vw, 38px); line-height: 1.15; margin: 0 0 10px; letter-spacing: -0.01em; }
h1 .dim { color: var(--dim); font-weight: 400; }
h2 { font-size: 17px; margin: 0 0 8px; }
.lede { color: var(--dim); max-width: 760px; margin: 0 0 18px; }
.lede b { color: var(--text); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 14px 0; }

#loading { display: grid; gap: 6px; font-size: 13px; color: var(--dim); }
#loading.done { display: none; }
.loadrow { display: grid; grid-template-columns: 150px 1fr 190px; gap: 10px; align-items: center; }
.loadrow span:last-child { font-family: var(--mono); font-size: 12px; text-align: right; }
progress { width: 100%; height: 6px; appearance: none; border: 0; border-radius: 3px; background: var(--line); }
progress::-webkit-progress-bar { background: var(--line); border-radius: 3px; }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--accent2), var(--accent)); border-radius: 3px; }
progress::-moz-progress-bar { background: var(--accent); }

.stage { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
figure { margin: 0; min-width: 0; }
figcaption { color: var(--dim); font-size: 12px; margin-top: 6px; text-align: center; }
canvas#target, canvas#attn { display: block; width: 100%; aspect-ratio: 1; image-rendering: pixelated; border-radius: 6px; background: #000; }
canvas#target { background: #fff; }
.attn { position: relative; }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#attn { cursor: crosshair; }
#buffering { position: absolute; inset: auto 0 12px; text-align: center; font-size: 13px; color: var(--accent); }

.controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
button, select { font: inherit; color: var(--text); background: #1d1526; border: 1px solid var(--line); border-radius: 7px; padding: 6px 12px; cursor: pointer; }
button:hover:not(:disabled), select:hover { border-color: var(--accent2); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: linear-gradient(135deg, var(--accent2), var(--accent)); border: 0; color: #120612; font-weight: 700; min-width: 92px; }
.seek { position: relative; flex: 1 1 220px; min-width: 160px; }
#seek { width: 100%; accent-color: var(--accent); position: relative; z-index: 1; background: transparent; }
#bufbar { position: absolute; left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px; border-radius: 2px; background: var(--line); }
.audio { font-size: 13px; color: var(--dim); border: 1px dashed var(--line); border-radius: 7px; padding: 5px 10px; cursor: pointer; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audio:hover { border-color: var(--accent2); color: var(--text); }
.audio input { display: none; }

.readout { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin: 14px 0; }
.readout div { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.readout b { display: block; font-family: var(--mono); font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readout small { color: var(--dim); font-size: 11px; }
.readout .edited { color: var(--accent); }

.linehead { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.linehead button { font-size: 13px; padding: 4px 10px; }
#edit-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.hint { color: var(--dim); font-size: 13px; margin: 4px 0; }
#hover { font-family: var(--mono); font-size: 12px; color: var(--text); min-height: 1.5em; overflow-wrap: anywhere; }
.k { color: var(--key); }
.q { color: var(--query); }
.words { font-family: var(--mono); font-size: 11.5px; line-height: 1.55; max-height: 320px; overflow: auto; overflow-wrap: anywhere; padding: 8px; border-radius: 6px; background: #0b0810; border: 1px solid var(--line); }
.words #w-keys::after { content: "  ║  "; color: var(--dim); }
.words.editing span[data-p] { cursor: pointer; border-radius: 3px; }
.words.editing span[data-p]:hover { background: #3a2640; }
.words span.hot { background: #5a2a4a; outline: 1px solid var(--accent); border-radius: 3px; }
.words span.changed { background: #6b3a1c; color: #fff; border-radius: 3px; }
#editor { position: fixed; z-index: 10; background: #1b1323; border: 1px solid var(--accent2); border-radius: 8px; padding: 6px; width: 240px; box-shadow: 0 10px 30px #000a; }
#edit-input { width: 100%; font: 14px var(--mono); color: var(--text); background: #0b0810; border: 1px solid var(--line); border-radius: 5px; padding: 5px 7px; }
#suggest { list-style: none; margin: 4px 0 0; padding: 0; max-height: 220px; overflow: auto; font: 13px var(--mono); }
#suggest li { padding: 3px 7px; border-radius: 4px; cursor: pointer; }
#suggest li.sel, #suggest li:hover { background: #3a2640; }
#suggest li.none { color: var(--dim); cursor: default; background: none; font-family: system-ui, sans-serif; font-size: 12px; }

.prose p { color: var(--dim); max-width: 780px; }
pre { font: 12.5px/1.5 var(--mono); background: #0b0810; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; overflow-x: auto; color: var(--text); }
code { font-family: var(--mono); font-size: 0.92em; color: var(--text); }
video { width: 100%; max-width: 640px; display: block; margin: 8px auto 0; border-radius: 6px; background: #000; aspect-ratio: 1; }
footer { color: var(--dim); font-size: 12px; padding-bottom: 40px; }

@media (max-width: 720px) {
  .readout { grid-template-columns: repeat(4, 1fr); }
  .readout b { font-size: 15px; }
  .loadrow { grid-template-columns: 1fr 110px; }
  .loadrow progress { grid-column: 1 / -1; grid-row: 2; }
  .stage { gap: 8px; }
}
@media (max-width: 420px) {
  .readout { grid-template-columns: repeat(3, 1fr); }
  .readout div:last-child { grid-column: 1 / -1; }
}
