:root {
  /* Blue palette. "Your line" stays amber on purpose so it stands out from the blues. */
  --bg: #f3f7fc;
  --surface: #ffffff;
  --text: #13243a;
  --muted: #56677e;
  --border: #d3deec;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --mine: #fff3c4;
  --mine-border: #e0b400;
  --mine-text: #8a6100;
  --mine-current: #ffe48a;
  --current: #dce9fb;
  --loop: #0e7c86;
  --danger: #b3261e;
  --radius: 10px;
  color-scheme: light dark;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1522; --surface: #152034; --text: #e5edf8; --muted: #98a9c0; --border: #2a3a52;
    --accent: #6aa6ff; --accent-text: #0d1522; --mine: #3a3214; --mine-border: #c9a227; --mine-text: #f0cd6a; --mine-current: #57460f;
    --current: #1d3558; --loop: #4cc9d4; --danger: #ff8a80;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); line-height: 1.45; }
h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
h3 { font-size: .95rem; margin: 1.2rem 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--danger); min-height: 1.2em; margin: .4rem 0 0; }
.warning { background: var(--mine); padding: .5rem 1rem; margin: 0; }

button, .button, input, select, textarea { font: inherit; color: inherit; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
  padding: .5rem .9rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; text-decoration: none; min-height: 2.5rem;
}
button:hover, .button:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { color: var(--danger); }
button.small { padding: .2rem .6rem; min-height: 2rem; font-size: .85rem; }
button.link { border: 0; background: none; padding: 0; min-height: 0; color: var(--accent); text-decoration: underline; }
input[type=text], input[type=password], select, textarea {
  padding: .5rem .6rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  max-width: 100%;
}
label { display: grid; gap: .3rem; }
label.check { display: flex; align-items: center; gap: .5rem; }
input[type=checkbox] { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); }

.center { min-height: 100%; display: grid; place-items: center; padding: 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; margin-bottom: 1rem; }
.card.narrow { width: min(100%, 360px); display: grid; gap: .8rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.page { max-width: 900px; margin: 0 auto; padding: 1rem; }
.bar {
  display: flex; align-items: center; gap: .6rem; padding: .6rem 1rem;
  padding-top: max(.6rem, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.bar .title { flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spacer { flex: 1; }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 12rem; }

/* show lists */
.show-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.show-button { width: 100%; justify-content: flex-start; padding: 1rem; font-size: 1.1rem; font-weight: 600; }
.admin-show-list { list-style: none; padding: 0; margin: 0; }
.admin-show-list li { display: flex; align-items: center; gap: .5rem; padding: .6rem 0; border-top: 1px solid var(--border); }
.grow { flex: 1; }

/* player */
.player { display: flex; flex-direction: column; height: 100%; }
/* One compact row: jump-to takes the spare width, repeat sizes to its text. */
.toolbar { display: flex; flex-wrap: wrap; gap: .4rem .6rem; padding: .4rem .75rem; border-bottom: 1px solid var(--border); align-items: center; }
.toolbar label { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--muted); min-width: 0; }
.toolbar .jump { flex: 1 1 12rem; max-width: 34rem; }
.toolbar .jump select { flex: 1; min-width: 0; width: 100%; }
.toolbar .repeat { flex: 0 0 auto; }
.toolbar select { color: var(--text); min-height: 2.3rem; padding: .3rem .5rem; text-overflow: ellipsis; }
/* "Repeat: Off" already says what it is, so its label is for screen readers only. */
.toolbar .repeat .label-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.range-controls { display: flex; gap: .4rem; align-items: center; flex-basis: 100%; }
@media (max-width: 600px) {
  /* The dropdowns say what they are ("Repeat: Off", the scene name), so drop the labels. */
  .toolbar .label-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .toolbar .jump { flex-basis: 0; }
}
.script { flex: 1; overflow-y: auto; padding: 1rem; max-width: 760px; width: 100%; margin: 0 auto; }
.item { margin: 0 0 .35rem; padding: .45rem .7rem; border-radius: 8px; cursor: pointer; border-left: 4px solid transparent; }
.item:hover { background: color-mix(in srgb, var(--current) 50%, transparent); }
.item.section { margin-top: 1.4rem; font-size: 1.05rem; text-transform: uppercase; letter-spacing: .03em; color: var(--accent); }
.item.direction { font-style: italic; color: var(--muted); }
.item.silent { opacity: .6; }
.item .who { display: block; font-weight: 700; font-size: .78rem; letter-spacing: .05em; color: var(--muted); }
.item.mine { background: var(--mine); border-left-color: var(--mine-border); }
.item.mine .who::after { content: " · you"; color: var(--mine-text); }
.item.concealed .text { filter: blur(6px); user-select: none; }
.item.in-loop { box-shadow: inset 3px 0 0 var(--loop); }
.item.current { background: var(--current); border-left-color: var(--accent); }
.item.mine.current { background: var(--mine-current); border-left-color: var(--mine-border); }

.controls {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: .6rem 1rem; padding-bottom: max(.6rem, env(safe-area-inset-bottom));
}
.controls .buttons { display: flex; justify-content: center; gap: 1rem; }
.controls .buttons button { width: 3.4rem; height: 3.4rem; border-radius: 50%; font-size: 1.3rem; }
.controls .buttons .play { width: 4.2rem; height: 4.2rem; background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-size: 1.6rem; }
.pause-track { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.pause-fill { height: 100%; width: 0; background: var(--mine-border); }

dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 0; width: min(95vw, 620px); max-height: 90vh; }
dialog::backdrop { background: rgb(0 0 0 / .45); }
.settings { padding: 1.2rem; display: grid; gap: .5rem; }
.settings .row { margin-top: .4rem; }
.character-list { display: grid; gap: .4rem; }
.character { display: grid; grid-template-columns: 1fr minmax(0, 14rem) auto; gap: .5rem; align-items: center; }
.character .name { font-weight: 600; }
.character select { width: 100%; font-size: .85rem; }
.actions { display: flex; justify-content: flex-end; margin-top: 1rem; position: sticky; bottom: 0; }

/* admin editor */
.editor { max-width: 1300px; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1rem; }
.editor-left { display: grid; gap: .8rem; align-content: start; }
.editor-right { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; align-self: start; position: sticky; top: 1rem; max-height: calc(100vh - 6rem); overflow-y: auto; }
#source { min-height: 60vh; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9rem; line-height: 1.4; resize: vertical; }
.upload-row { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.file-button { display: inline-flex; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.help { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem 1rem; }
.help summary { cursor: pointer; font-weight: 600; }
.help pre { background: var(--bg); padding: .6rem; border-radius: 6px; overflow-x: auto; font-size: .85rem; }
.char-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.char-table td { padding: .25rem .2rem; border-top: 1px solid var(--border); }
.char-table td:last-child { text-align: right; }
.warn-list { padding-left: 1rem; }
.warn-list li { margin-bottom: .3rem; }

.toast {
  position: fixed; left: 50%; top: 4.5rem; transform: translateX(-50%); max-width: calc(100vw - 2rem); text-align: center;
  background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: var(--radius); z-index: 10;
}

@media (max-width: 800px) {
  .editor { grid-template-columns: 1fr; }
  .editor-right { position: static; max-height: none; }
  .character { grid-template-columns: 1fr auto; }
  .character select { grid-column: 1 / -1; grid-row: 2; }
}

.cast-current { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .8rem; }
.cast-value { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 1.05rem; background: var(--bg); padding: .25rem .6rem; border-radius: 6px; border: 1px solid var(--border); }
.head-buttons { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.pw-form { display: grid; gap: .6rem; max-width: 420px; }

/* now-reading panel */
.now { max-width: 760px; margin: 0 auto .6rem; padding: .5rem .8rem; border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius); background: var(--bg); cursor: pointer; }
.now[data-state=mine] { border-left-color: var(--mine-border); background: var(--mine); }
.now[data-state=countdown] { border-left-color: var(--loop); }
.now-state { font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.now[data-state=countdown] .now-state { color: var(--loop); font-size: .9rem; }
.now[data-state=mine] .now-state { color: var(--mine-text); }
.now-cue { font-size: .85rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.now-cue-label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; border: 1px solid var(--border); border-radius: 4px; padding: 0 .3rem; }
.now-line { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.now-who { font-size: .8rem; letter-spacing: .04em; }
.now-text.concealed { filter: blur(6px); user-select: none; }
.pause-row { display: flex; align-items: center; gap: .7rem; margin-top: .4rem; }
.pause-label { font-variant-numeric: tabular-nums; min-width: 2.5rem; text-align: right; }
