:root {
  --wall: #e9e4da;
  --ink: #1f1c18;
  --ink-2: #5e574d;
  --ink-3: #8b8377;
  --paper: #fcfbf8;
  --line: #e2dccf;
  --meet: #d9472b;
  --free: #ebe6dc;
  --serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--wall);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#board {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh; height: 100dvh;
  display: block;
  cursor: grab;
  touch-action: none;
}
#board.dragging { cursor: grabbing; }

.num { font-family: var(--mono); font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: 0.4; }

/* ---------- panel ---------- */
.panel {
  position: fixed; top: 16px; left: 16px; bottom: 16px;
  width: 380px;
  display: flex; flex-direction: column;
  background: var(--paper);
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(40, 30, 20, .08), 0 10px 30px rgba(40, 30, 20, .12);
  overflow: hidden;
  opacity: 0; transition: opacity .4s;
}
body.ready .panel { opacity: 1; }

.panel-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 18px 22px 0;
}
.kicker { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--meet); font-weight: 600; }
.stepnum { font: 12px var(--mono); color: var(--ink-3); }

.question {
  margin: 8px 22px 0;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px; line-height: 1.5; color: var(--ink-2);
}

.step {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 6px 22px 16px;
}
.step h2 {
  font: 400 34px/1.1 var(--serif);
  margin: 12px 0 12px;
  letter-spacing: -0.01em;
}
.step p { margin: 0 0 12px; color: #2f2a24; }
.step p.muted { color: var(--ink-3); font-size: 13.5px; }
.step b { font-weight: 600; }
.step b.num, .step span.num { font-weight: 500; color: var(--meet); }

/* controls */
.ctl { margin: 16px 0 6px; }
.ctl-label { font-size: 12.5px; color: var(--ink-2); margin: 12px 0 6px; display: flex; justify-content: space-between; }
.ctl-label b.num { color: var(--ink); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 5px; padding: 2px; gap: 2px; background: #f4f1ea; }
.seg button {
  flex: 1; border: 0; background: transparent; border-radius: 3px;
  padding: 7px 8px; font-size: 13px; color: var(--ink-2);
}
.seg button.on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.1); font-weight: 500; }
.seg-layout { margin-top: 16px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.presets button {
  border: 1px solid var(--line); background: transparent; border-radius: 99px;
  padding: 4px 10px; font-size: 12px; color: var(--ink-2);
}
.presets button.on { border-color: var(--ink); color: var(--ink); }

.result { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 0; }
.result div { background: #f4f1ea; border-radius: 4px; padding: 8px 10px; }
.result dt { font-size: 11px; color: var(--ink-3); }
.result dd { margin: 2px 0 0; font-size: 15px; color: var(--ink); }

input[type=range] { width: 100%; accent-color: var(--meet); margin: 0; }

/* playback + tally */
.play { border-top: 1px solid var(--line); padding: 12px 22px; background: #faf8f3; }
.play-row { display: flex; align-items: center; gap: 12px; }
.btn-play {
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  border-radius: 4px; padding: 4px 12px; font-size: 13px; min-width: 64px;
}
.clock { font-size: 12px; color: var(--ink-2); white-space: nowrap; min-width: 96px; text-align: right; }
.tally { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 10px; margin: 12px 0 0; }
.tally dt { font-size: 11px; color: var(--ink-3); line-height: 1.3; }
.tally dd { margin: 2px 0 0; font-size: 17px; }
.tally div:first-child dd { color: var(--meet); }

.nav {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 22px 16px;
  border-top: 1px solid var(--line);
}
.btn { border: 1px solid var(--line); background: transparent; border-radius: 4px; padding: 7px 16px; font-size: 14px; }
.btn-primary { background: var(--meet); border-color: var(--meet); color: #fff; font-weight: 500; }
.dots { display: flex; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; border: 0; padding: 0; background: var(--line); }
.dot.on { background: var(--ink); }

/* ---------- hud ---------- */
.hud {
  position: fixed; top: 16px; right: 16px;
  display: flex; align-items: center; gap: 10px;
}
.scale {
  font: 12px var(--mono); color: var(--ink-2);
  background: rgba(252, 251, 248, .85); padding: 5px 9px; border-radius: 4px;
}
.zoom { display: flex; background: var(--paper); border-radius: 4px; box-shadow: 0 1px 3px rgba(40,30,20,.15); overflow: hidden; }
.zoom button { border: 0; background: transparent; padding: 6px 11px; font-size: 13px; border-left: 1px solid var(--line); }
.zoom button:first-child { border-left: 0; font-size: 15px; }
.zoom button:nth-child(2) { font-size: 15px; }
.zoom button:hover { background: #f4f1ea; }

.legend {
  position: fixed; right: 16px; bottom: 16px;
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: flex-end;
  font-size: 12px; color: var(--ink-2);
  background: rgba(252, 251, 248, .85); padding: 6px 10px; border-radius: 4px;
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; display: inline-block; border-radius: 1px; }
.sw-free { background: var(--free); outline: 1px solid #d6cfc1; }
.sw-meet { background: var(--meet); }
.legend .hint { color: var(--ink-3); }

.tip {
  position: fixed; left: 0; top: 0; pointer-events: none;
  background: var(--ink); color: var(--paper);
  padding: 7px 10px; border-radius: 4px; font-size: 12.5px; line-height: 1.4;
  display: flex; flex-direction: column; max-width: 280px;
  box-shadow: 0 4px 14px rgba(0,0,0,.2);
}
.tip[hidden] { display: none; }
.tip b { font-weight: 600; }
.tip span { color: #cfc8bc; }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; }

/* ---------- phones ---------- */
@media (max-width: 759px) {
  .panel {
    top: auto; left: 0; right: 0; bottom: 0;
    width: auto; height: 50dvh;
    border-radius: 12px 12px 0 0;
  }
  .panel-head { padding: 12px 16px 0; }
  .question { display: none; }
  .step { padding: 0 16px 10px; }
  .step h2 { font-size: 26px; margin: 6px 0 8px; }
  .step p { font-size: 14px; margin-bottom: 8px; }
  .play { padding: 10px 16px; }
  .tally { margin-top: 8px; }
  .tally dd { font-size: 14px; }
  .nav { padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px)); }
  .hud { top: calc(10px + env(safe-area-inset-top, 0px)); right: 10px; }
  .scale { display: none; }
  .legend { display: none; }
}
