:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --text: #1d1c1a;
  --muted: #6b6862;
  --line: #e2dfd8;
  --accent: #2f5d8a;
  --accent-text: #ffffff;
  --accent-soft: #e3ecf5;
  --ready: #cfd8e2;
  --danger: #a33a2c;
  --ok: #3b7d4f;
  --warn: #b07a1c;
  --radius: 6px;
  --ctl: 48px;
  --ctl-big: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --surface: #1f1f1d;
    --text: #ecebe7;
    --muted: #9c9991;
    --line: #34332f;
    --accent: #7fb0e0;
    --accent-text: #101418;
    --accent-soft: #243241;
    --ready: #3a4552;
    --danger: #e08a7d;
    --ok: #7dc493;
    --warn: #e0b45c;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif;
  padding-bottom: calc(190px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 1.15rem; margin: 0; }
h2 { font-size: 1rem; margin: 1.2rem 0 0.5rem; }
.hint { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); font-size: 0.9rem; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  padding-top: calc(12px + env(safe-area-inset-top));
}
.worker { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.worker .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.worker.on .dot { background: var(--ok); }
.worker.busy .dot { background: var(--warn); }

.layout { display: grid; grid-template-columns: 1fr; gap: 0 32px; padding: 0 16px; max-width: 1200px; margin: 0 auto; }
@media (min-width: 900px) {
  .layout { grid-template-columns: minmax(320px, 400px) 1fr; }
}

.compose { margin-top: 12px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.compose summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.compose form { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--muted); flex: 1; }
input[type='text'], input[type='password'], textarea, select {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 10px; color: var(--text); min-height: 40px;
}
textarea { resize: vertical; min-height: 140px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.file { flex: 0 1 auto; }
.file input { font-size: 0.85rem; }
.primary {
  background: var(--accent); color: var(--accent-text); border: 0; border-radius: var(--radius);
  padding: 10px 14px; font-weight: 600; cursor: pointer; min-height: 44px;
}
.primary:disabled { opacity: 0.6; }
.link { background: none; border: 0; padding: 4px 0; color: var(--accent); cursor: pointer; text-decoration: none; font-size: 0.9rem; }
.link.danger { color: var(--danger); }

.jobs { list-style: none; padding: 0; margin: 0; }
.jobs li { border-bottom: 1px solid var(--line); }
.jobs button {
  display: block; width: 100%; text-align: left; background: none; border: 0; padding: 10px 6px; cursor: pointer;
}
.jobs li.current button { background: var(--accent-soft); }
.jobs .jobTitle { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jobs .jobMeta { display: block; font-size: 0.82rem; color: var(--muted); }
.jobs .jobMeta.failed { color: var(--danger); }

.feed { margin: 20px 0; border-top: 1px solid var(--line); padding-top: 8px; }
.feed summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.feed input { flex: 1; min-width: 0; font-size: 0.8rem; font-family: ui-monospace, monospace; }

.reader { min-width: 0; }
.readerHead { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.readerHead h2 { font-size: 1.15rem; }
.readerActions { display: flex; gap: 16px; }
.sentences { font-size: 1.05rem; line-height: 1.7; max-width: 70ch; }
.sentences p { margin: 0 0 1em; }
.sentences span { cursor: pointer; border-radius: 3px; transition: background 0.15s; }
.sentences span.pending { color: var(--muted); cursor: default; }
.sentences span.failed { color: var(--danger); text-decoration: underline dotted; }
.sentences span.current { background: var(--accent-soft); }

/* The player bar: fixed to the bottom, large touch targets. */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.player > * { max-width: 720px; margin-left: auto; margin-right: auto; }
.playerTitle { font-size: 0.9rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { display: flex; align-items: center; gap: 10px; margin: 6px auto 4px; }
.time { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 3.4em; }
.time:last-child { text-align: right; }
.bar { position: relative; flex: 1; height: 28px; }
.bar::before, .barReady, .barPlayed {
  content: ''; position: absolute; left: 0; top: 12px; height: 4px; border-radius: 2px;
}
.bar::before { right: 0; background: var(--line); }
.barReady { background: var(--ready); width: 0; }
.barPlayed { background: var(--accent); width: 0; }
.bar input {
  position: absolute; inset: 0; width: 100%; margin: 0; opacity: 0; cursor: pointer; height: 28px;
}
.controls { display: flex; align-items: center; justify-content: center; gap: 6px; }
.ctl {
  width: var(--ctl); height: var(--ctl); border-radius: 50%; border: 0; background: transparent;
  display: grid; place-items: center; cursor: pointer; padding: 0; -webkit-tap-highlight-color: transparent;
}
.ctl:active { background: var(--accent-soft); }
.ctl:disabled { opacity: 0.35; }
.ctl svg { width: 28px; height: 28px; fill: currentColor; }
.ctl svg text { font-size: 7px; font-weight: 700; fill: currentColor; }
.ctl.big { width: var(--ctl-big); height: var(--ctl-big); background: var(--accent); color: var(--accent-text); position: relative; }
.ctl.big svg { width: 32px; height: 32px; }
.ctl.big .iconPause, .ctl.big.playing .iconPlay { display: none; }
.ctl.big.playing .iconPause { display: block; }
.spinner { display: none; position: absolute; inset: 4px; border-radius: 50%; border: 3px solid transparent; border-top-color: var(--accent-text); animation: spin 0.9s linear infinite; }
.ctl.big.waiting .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.speed, .speedSpacer { width: 52px; flex: none; }
.speed {
  height: 36px; border: 1px solid var(--line); border-radius: var(--radius); background: transparent;
  font-size: 0.9rem; font-variant-numeric: tabular-nums; cursor: pointer;
}

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); width: min(360px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / 0.4); }
dialog form { display: flex; flex-direction: column; gap: 12px; }
dialog h2 { margin-top: 0; }

@media (max-width: 420px) {
  :root { --ctl: 44px; --ctl-big: 60px; }
  .controls { gap: 2px; }
  .speed, .speedSpacer { width: 44px; }
}
