/* The voice service's two pages. Same palette as the listening page
   (a2p/voice/page.py); system fonts only, the CSP allows nothing external. */
:root {
  --paper: #f2f3f6;
  --panel: #ffffff;
  --ink: #18202e;
  --muted: #5d6678;
  --rule: #d9dde6;
  --lane: #e9ecf2;
  --lane-dark: #dfe3eb;
  --voice: #c8641e;
  --keys: #3446c4;
  --keys-ink: #ffffff;
  --chip: #e6e9f1;
  --ok: #1e7f4f;
  --warn: #a8660b;
  --bad: #b3261e;
  --stage: #0d1017;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #11141b; --panel: #181c25; --ink: #e8ebf2; --muted: #9aa3b6; --rule: #2a303d;
    --lane: #1d222c; --lane-dark: #191d26; --voice: #f09a4e; --keys: #8f9bff; --keys-ink: #11141b;
    --chip: #232936; --ok: #57c48a; --warn: #e6a646; --bad: #f28b82; --stage: #07090d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #11141b; --panel: #181c25; --ink: #e8ebf2; --muted: #9aa3b6; --rule: #2a303d;
  --lane: #1d222c; --lane-dark: #191d26; --voice: #f09a4e; --keys: #8f9bff; --keys-ink: #11141b;
  --chip: #232936; --ok: #57c48a; --warn: #e6a646; --bad: #f28b82; --stage: #07090d;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.5; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 20px 16px 48px; display: grid; gap: 16px; }
header { display: grid; gap: 8px; }
h1 { font-weight: 650; font-size: clamp(22px, 5vw, 32px); letter-spacing: -0.01em; margin: 0; line-height: 1.2; overflow-wrap: anywhere; }
h1 .arrow { color: var(--voice); }
h2 { font-weight: 600; font-size: 16px; margin: 0; }
.label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.lede { margin: 0; color: var(--muted); max-width: 64ch; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
a { color: var(--keys); }
.card { background: var(--panel); border: 1px solid var(--rule); border-radius: 14px; padding: 16px; display: grid; gap: 12px; min-width: 0; }
.status { font-size: 13px; color: var(--muted); margin: 0; }
.error { color: var(--bad); margin: 0; }
button { font: inherit; }
.primary { appearance: none; border: 0; background: var(--keys); color: var(--keys-ink); border-radius: 10px; padding: 12px 18px; font-weight: 600; cursor: pointer; justify-self: start; }
.primary:disabled { opacity: .5; cursor: progress; }
.ghost { appearance: none; border: 1px solid var(--rule); background: transparent; color: var(--ink); border-radius: 10px; padding: 8px 14px; cursor: pointer; }
.ghost.danger { color: var(--bad); }
.toggle { appearance: none; border: 1px solid var(--rule); background: transparent; color: var(--ink); border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; }
.toggle[aria-pressed="true"] { background: var(--chip); border-color: var(--muted); }
input[type=text] { font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 10px; background: var(--paper); color: var(--ink); }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--keys); outline-offset: 2px; }

/* upload page */
.drop { border: 2px dashed var(--rule); text-align: left; transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--keys); background: var(--chip); }
.bar { height: 8px; border-radius: 999px; background: var(--lane); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--keys); border-radius: 999px; transition: width .3s; }
.row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.mine { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.mine li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 8px 0; border-top: 1px solid var(--rule); align-items: center; }
.mine li:first-child { border-top: 0; }
.mine a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.mine span { font-size: 12px; color: var(--muted); }

/* result page: waiting */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.steps li { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 8px; align-items: center; color: var(--muted); }
.steps li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--rule); justify-self: center; }
.steps li.now { color: var(--ink); font-weight: 500; }
.steps li.now::before { border-color: var(--keys); background: var(--keys); animation: pulse 1.2s ease-in-out infinite; }
.steps li.past { color: var(--ink); }
.steps li.past::before { border-color: var(--ok); background: var(--ok); }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .steps li.now::before { animation: none; } .bar > i { transition: none; } }

/* result page: player */
.player { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.player.portrait { grid-template-columns: minmax(0, 300px) minmax(0, 1fr); align-items: start; }
@media (max-width: 760px) { .player.portrait { grid-template-columns: minmax(0, 1fr); } }
.screen { background: var(--stage); border-radius: 14px; overflow: hidden; display: grid; place-items: center; min-width: 0; }
.screen video { display: block; width: 100%; max-height: min(62vh, 560px); object-fit: contain; background: var(--stage); }
.player.portrait .screen video { max-height: min(70vh, 540px); }
@media (max-width: 760px) { .player.portrait .screen video { max-height: 46vh; } }
.desk { background: var(--panel); border: 1px solid var(--rule); border-radius: 14px; padding: 14px; display: grid; gap: 12px; min-width: 0; align-content: start; }
.rollbox { position: relative; min-width: 0; }
canvas { display: block; width: 100%; touch-action: none; cursor: crosshair; border-radius: 8px; }
.hover { position: absolute; pointer-events: none; background: var(--ink); color: var(--paper); font-family: var(--mono); font-size: 12px; padding: 3px 7px; border-radius: 6px; white-space: nowrap; transform: translate(-50%, -130%); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); align-items: center; }
.legend i { display: inline-block; width: 16px; height: 8px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.legend i.line { height: 2px; border-radius: 0; background: var(--voice); }
.legend i.note { background: var(--keys); }
.legend i.alt { background: var(--keys); outline: 1.5px dashed var(--warn); outline-offset: 1px; }
.transport { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.play { appearance: none; border: 0; background: var(--keys); color: var(--keys-ink); width: 52px; height: 52px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; flex: none; }
.play svg { width: 22px; height: 22px; fill: currentColor; }
.play:disabled { opacity: .5; cursor: progress; }
.time { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); }
.time b { color: var(--ink); font-weight: 500; }
.mix { display: grid; gap: 10px; }
.mixrow { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 6px 12px; align-items: center; }
@media (max-width: 520px) { .mixrow { grid-template-columns: minmax(0, 1fr); } }
.mixrow > span { font-size: 13px; font-weight: 500; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; border: 1px solid var(--rule); border-radius: 10px; background: var(--lane); max-width: 100%; justify-self: start; }
.seg button { appearance: none; border: 0; background: transparent; color: var(--muted); border-radius: 8px; padding: 6px 11px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--muted); }
.seg button.original[aria-pressed="true"] { box-shadow: 0 0 0 1px var(--voice); }
.level { display: flex; align-items: center; gap: 10px; min-width: 0; }
.level input[type=range] { flex: 1; min-width: 0; accent-color: var(--keys); }
.facts { display: flex; flex-wrap: wrap; gap: 6px 22px; }
.fact { display: grid; min-width: 0; }
.fact b { font-family: var(--mono); font-weight: 500; font-size: 15px; }
.downloads { display: flex; flex-wrap: wrap; gap: 8px; }
.downloads a { text-decoration: none; border: 1px solid var(--rule); border-radius: 10px; padding: 7px 12px; font-size: 13px; color: var(--ink); }
.downloads a:hover { border-color: var(--keys); }
.share { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toast { font-size: 13px; color: var(--ok); }
footer { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; }
a.primary { display: inline-block; text-decoration: none; }
.player.novideo { grid-template-columns: minmax(0, 1fr); }
.dock { display: grid; gap: 10px; }
.screen video { border-radius: 0; }
@media (max-width: 760px) {
  .screen { background: transparent; }
  .screen video, .player.portrait .screen video { width: auto; max-width: 100%; max-height: 40vh; border-radius: 12px; }
  /* On a phone the controls stay at the bottom of the screen while the roll and the video scroll. */
  .dock { position: sticky; bottom: 0; z-index: 5; background: var(--panel); margin-inline: -14px; padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
          border-top: 1px solid var(--rule); box-shadow: 0 -8px 18px -12px rgba(0, 0, 0, .35); }
  .dock .mixrow { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .dock .mixrow > span { display: none; }
  .seg { width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .seg button { flex: 1 0 auto; padding: 7px 4px; font-size: 12px; }
  .play { width: 46px; height: 46px; }
  .transport { gap: 6px 10px; }
  .transport .toggle { padding: 5px 10px; font-size: 12.5px; }
  .transport .status { flex-basis: 100%; order: 9; }
  .transport .status:empty { display: none; }
  .time .total { display: none; }
}
.downloads a.export { background: var(--keys); color: var(--keys-ink); border-color: var(--keys); font-weight: 600; }
.downloads .mixnote { flex-basis: 100%; margin-top: -2px; }
