/* ScrollSloth — pro dark UI, sloth accents */
:root {
  --bg: #0c0f14;
  --panel: #151a23;
  --panel-2: #1c2330;
  --line: #262f3f;
  --text: #e8ecf3;
  --muted: #8b94a7;
  --accent: #a3c585;
  --accent-strong: #b9dd97;
  --danger: #e0715f;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
button:hover { background: #232c3c; }
button:active { transform: scale(0.98); }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #14210c;
  font-weight: 650;
}
button.primary:hover { background: var(--accent-strong); }
button.ghost { background: transparent; }
button.danger { color: var(--danger); }
button:disabled { opacity: 0.45; cursor: default; }
input[type="text"], textarea {
  font: inherit;
  color: var(--text);
  background: #0f131b;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  outline: none;
}
input[type="text"]:focus, textarea:focus { border-color: var(--accent); }
input[type="range"] { accent-color: var(--accent); }
input[type="color"] {
  inline-size: 34px; block-size: 34px; padding: 0; border: 1px solid var(--line);
  border-radius: 8px; background: none; cursor: pointer;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }
.chip.on .dot { background: var(--accent); }

/* ---------- landing ---------- */
.hero {
  min-height: 100svh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px; padding: 24px; text-align: center;
}
.wordmark { display: flex; align-items: center; gap: 14px; }
.wordmark h1 { font-size: clamp(34px, 7vw, 56px); margin: 0; letter-spacing: -0.02em; }
.wordmark h1 b { color: var(--accent); font-weight: 800; }
.tagline { color: var(--muted); margin: 0 0 18px; font-size: 17px; }
.joinrow { display: flex; gap: 10px; }
.joinrow input { width: 150px; text-transform: uppercase; letter-spacing: 0.2em; text-align: center; }
.footnote { position: fixed; bottom: 14px; color: #56607451; font-size: 12px; }

/* ---------- room / role picker ---------- */
.roompage { max-width: 900px; margin: 0 auto; padding: 28px 20px 60px; }
.roomhead { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; }
.codebadge {
  font-size: 34px; font-weight: 800; letter-spacing: 0.25em;
  background: var(--panel); border: 1px solid var(--line);
  padding: 10px 22px 10px 26px; border-radius: var(--radius);
}
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-top: 26px; }
.card {
  display: block; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; color: var(--text);
  transition: border-color 0.15s, transform 0.1s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card .emoji { font-size: 30px; }
.card h3 { margin: 10px 0 6px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.qrbox { margin-top: 30px; display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.qrbox svg { background: #fff; border-radius: 10px; padding: 8px; width: 148px; height: 148px; }
.qrbox p { color: var(--muted); font-size: 14px; max-width: 320px; }

/* ---------- prompter ---------- */
.stage-wrap { position: fixed; inset: 0; overflow: hidden; background: #000; }
#stage {
  position: absolute; left: 0; right: 0; top: 0;
  will-change: transform; white-space: pre-wrap; word-wrap: break-word;
}
#stage p { margin: 0 0 0.65em; }
.marker {
  position: fixed; left: 0; right: 0; pointer-events: none; display: none;
}
.marker.on { display: block; }
.marker::before, .marker::after {
  content: ""; position: absolute; top: -9px; border: 9px solid transparent;
}
.marker::before { left: 6px; border-left-color: var(--accent); }
.marker::after { right: 6px; border-right-color: var(--accent); }
.timerchip {
  position: fixed; top: calc(12px + env(safe-area-inset-top)); right: 14px; z-index: 6;
  font-variant-numeric: tabular-nums; font-size: 15px; color: #ffffffb0;
  background: #00000080; padding: 5px 12px; border-radius: 999px; display: none;
}
.timerchip.on { display: block; }
#countdown {
  position: fixed; inset: 0; z-index: 8; display: none; align-items: center; justify-content: center;
  font-size: min(46vw, 46vh); font-weight: 800; color: var(--accent);
  background: #000000d9; font-variant-numeric: tabular-nums;
}
#countdown.on { display: flex; }
.pbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: 3px; z-index: 6; background: #ffffff14;
}
.pbar i { display: block; height: 100%; width: 0; background: var(--accent); }
.hud {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 7;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px max(14px, env(safe-area-inset-left)) calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, #000000e0 40%);
  transition: opacity 0.25s; flex-wrap: wrap;
}
.hud.hidden { opacity: 0; pointer-events: none; }
.hud button { background: #10151dd9; }
.pausedhint {
  position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 14px; z-index: 6;
  color: #ffffff90; font-size: 13px; background: #00000080; padding: 5px 12px; border-radius: 999px;
}
/* settings drawer (prompter) */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 9; width: min(340px, 92vw);
  background: #141922f2; border-left: 1px solid var(--line);
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); overflow-y: auto;
  transform: translateX(105%); transition: transform 0.22s ease;
}
.drawer.open { transform: none; }
.drawer h3 { margin: 4px 0 14px; }
.set { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 13px 0; }
.set label { color: var(--muted); font-size: 14px; }
.set .val { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text); min-width: 38px; text-align: right; }
.swatches { display: flex; gap: 8px; }
.swatches button { width: 30px; height: 30px; padding: 0; border-radius: 8px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 7px 12px; background: transparent; }
.seg button.on { background: var(--accent); color: #14210c; }
.switch { appearance: none; width: 44px; height: 26px; border-radius: 999px; background: #2a3446; position: relative; cursor: pointer; transition: background 0.15s; }
.switch:checked { background: var(--accent); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left 0.15s; }
.switch:checked::after { left: 21px; }

/* ---------- remote ---------- */
.remote { max-width: 470px; margin: 0 auto; min-height: 100svh; display: flex; flex-direction: column; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); gap: 14px; }
.rhead { display: flex; align-items: center; justify-content: space-between; }
.rhead .code { font-weight: 800; letter-spacing: 0.18em; }
.playbig {
  height: 130px; font-size: 44px; border-radius: 22px;
  display: flex; align-items: center; justify-content: center; gap: 14px;
}
.playbig.playing { background: var(--accent); color: #14210c; border-color: var(--accent); }
.ctlgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ctl { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.ctl h4 { margin: 0 0 10px; font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.steprow { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.steprow .val { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.steprow button { width: 46px; height: 42px; font-size: 20px; padding: 0; }
.nudges { display: flex; gap: 12px; }
.nudges button { flex: 1; height: 58px; font-size: 22px; }
.seekwrap { padding: 6px 2px 0; }
.seekwrap input { width: 100%; }
.togglerow { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.togglerow span { color: var(--muted); font-size: 14px; }

/* ---------- master ---------- */
.master { display: grid; grid-template-columns: 220px 1fr 330px; gap: 0; height: 100svh; }
.mcol { border-right: 1px solid var(--line); overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.mcol:last-child { border-right: 0; }
.mhead { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-bottom: 6px; }
.mhead h3 { margin: 0; font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 650; }
.scriptitem {
  text-align: left; display: block; width: 100%;
  background: transparent; border: 1px solid transparent; padding: 10px 12px;
}
.scriptitem.on { background: var(--panel-2); border-color: var(--line); }
.scriptitem small { display: block; color: var(--muted); margin-top: 3px; }
#editor { flex: 1; resize: none; line-height: 1.6; font-size: 15.5px; min-height: 0; }
.editbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.editbar .grow { flex: 1; }
.dirty { color: #eecf6d; font-size: 13px; display: none; }
.dirty.on { display: inline; }
.stat { color: var(--muted); font-size: 12.5px; }
#livepane {
  flex: 1; min-height: 140px; overflow-y: auto; background: #0f131b;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; font-size: 14px; line-height: 1.55;
}
#livepane p { margin: 0 0 0.6em; color: var(--muted); }
#livepane p.now { color: var(--text); background: #a3c58522; border-radius: 6px; outline: 4px solid #a3c58522; }
.transport { display: flex; gap: 8px; flex-wrap: wrap; }
.transport button { flex: 1; }
.devlist { display: flex; flex-direction: column; gap: 6px; }
.devlist .chip { justify-content: flex-start; }
.masterctl .set { margin: 9px 0; }
@media (max-width: 980px) {
  .master { grid-template-columns: 1fr; height: auto; }
  .mcol { border-right: 0; border-bottom: 1px solid var(--line); }
  #editor { min-height: 45svh; }
}
