:root {
  --bg: #111217;
  --card: #1b1d25;
  --line: #2d303c;
  --text: #ececf1;
  --muted: #a2a5b5;
  --accent: #e0a458;
  --accent-ink: #1a1206;
  --good: #6fcf8f;
  --bad: #f08080;
  --mark: rgba(224, 164, 88, .28);
  --radius: 14px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f4ef;
    --card: #fff;
    --line: #ded9cf;
    --text: #1d1b18;
    --muted: #625d54;
    --accent: #8a5311;
    --accent-ink: #fff;
    --good: #1e7a42;
    --bad: #b3261e;
    --mark: rgba(214, 148, 58, .3);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
#view, #banner {
  max-width: 640px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
#view {
  padding-top: calc(env(safe-area-inset-top) + 8px);
  padding-bottom: calc(env(safe-area-inset-bottom) + 96px);
}
#view > * { margin: 0 0 14px; }
#banner {
  padding-top: calc(env(safe-area-inset-top) + 10px);
  padding-bottom: 10px;
  margin-bottom: 0;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

h1 { font-size: 28px; line-height: 1.2; margin: 12px 0 2px; }
h2 { font-size: 20px; line-height: 1.3; margin: 0; }
h3 { font-size: 16px; margin: 0 0 4px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.note { color: var(--accent); font-size: 14px; margin-top: 8px; overflow-wrap: anywhere; }
.note:empty { display: none; }
.clip { overflow-wrap: anywhere; margin-top: 8px; }
.sr { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 14px;
}
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; align-items: flex-start; }
label.between { align-items: center; min-height: 44px; }
.wrap { flex-wrap: wrap; }

button, .btn, select, input { font: inherit; color: inherit; }
button, .btn { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  font-weight: 600;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.good { color: var(--good); }
.btn.bad { color: var(--bad); }
.btn.good[aria-pressed="true"] { background: var(--good); border-color: var(--good); color: var(--bg); }
.btn.bad[aria-pressed="true"] { background: var(--bad); border-color: var(--bad); color: var(--bg); }
button:disabled { opacity: .4; cursor: default; }
:focus-visible, .btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.link {
  background: none;
  border: 0;
  min-height: 44px;
  padding: 0 4px;
  color: var(--accent);
  text-decoration: underline;
}
.chip {
  min-height: 44px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  font-size: 14px;
  text-align: left;
}

input[type="search"], select {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  font-size: 16px;                 /* stops iOS zooming on focus */
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}
input[type="search"] { -webkit-appearance: none; appearance: none; }
select { width: auto; max-width: 70%; }
input[type="range"] { width: 100%; min-height: 44px; accent-color: var(--accent); margin: 0; }
input[type="checkbox"] { width: 26px; height: 26px; accent-color: var(--accent); }

.seg { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: 1 0 auto;
  min-height: 44px;
  padding: 6px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
}
.seg button.on { border-color: var(--accent); color: var(--accent); font-weight: 700; }

.bar { height: 10px; margin: 8px 0; border-radius: 6px; background: var(--line); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); }
.bar.unknown { background: repeating-linear-gradient(45deg, var(--line) 0 6px, transparent 6px 12px); }
.pct { font-size: 22px; white-space: nowrap; color: var(--accent); }
.big { font-size: 48px; font-weight: 700; line-height: 1.1; color: var(--accent); }
.tag { display: inline-block; font-size: 12px; color: var(--muted); }
.badge { font-size: 12px; font-weight: 700; color: var(--accent); }
.recap { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.recap section { margin-bottom: 14px; }

.play {
  width: 96px;
  height: 96px;
  margin: 10px auto;
  display: block;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 18px;
  font-weight: 700;
}
.slider { display: grid; grid-template-columns: auto 1fr 3.5em; align-items: center; gap: 12px; text-align: left; font-size: 14px; }
.slider output { text-align: right; color: var(--muted); }
.moods { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mood {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.mood.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.mood small { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.mood small.ok { color: var(--good); }
.mood small.warn { color: var(--accent); }

.ask { display: flex; gap: 8px; }
blockquote { margin: 0 0 14px; }
blockquote:not(.card) { margin-top: 12px; padding-left: 12px; border-left: 3px solid var(--accent); }
cite { display: block; font-size: 13px; font-style: normal; color: var(--muted); }
mark { background: var(--mark); color: inherit; border-radius: 3px; }
.refuse { border-color: var(--accent); }

.script .hook { font-size: 18px; font-weight: 700; }
.script .lines { white-space: pre-line; }
.script .row { margin-top: 12px; }
.script.approved { border-color: var(--good); }
.script.rejected { opacity: .65; }

.reading { font-family: Georgia, "Times New Roman", serif; font-size: 17px; }
.reading .past { color: var(--muted); }
.reading .here { border-left: 3px solid var(--accent); padding-left: 10px; }
.panel { height: 42vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.panel:empty { display: none; }
.locked { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; text-align: center; }

.seek { margin-top: 8px !important; }
.transport { display: flex; align-items: center; justify-content: center; gap: 18px; }
.transport .play { margin: 4px 0 12px; width: 84px; height: 84px; }

#tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 4px env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#tabs a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  min-height: 54px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  -webkit-tap-highlight-color: transparent;
}
#tabs a[aria-current="page"] { color: var(--accent); font-weight: 700; }
#tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
