/* Layout and components. Colors and type come from tokens.css only. */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); }
body {
  background: var(--paper); color: var(--ink);
  font: 17px/1.4 var(--font-body);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--lane); outline-offset: 2px; }
a { color: var(--lane); }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.fine { font-size: 12px; color: var(--ink-2); }

/* ---------- Today: one screen, no scroll ---------- */
#app {
  height: 100dvh; max-width: 560px; margin: 0 auto;
  display: grid; grid-template-rows: auto auto 1fr auto auto auto; gap: var(--s3);
  padding: calc(var(--safe-top) + var(--s3)) var(--s4) calc(var(--safe-bottom) + var(--s2));
}
.test-banner { background: var(--warn); color: #fff; text-align: center; font-size: 13px; border-radius: var(--r-pill); padding: 2px 10px; }
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s3); }
.date { margin: 0; font-size: 14px; color: var(--ink-2); }
.daytype { margin: 0; font: 700 24px/1.1 var(--font-display); }
.daytype .muted { display: block; font: 500 14px var(--font-body); }
.verse-pill {
  display: grid; text-align: right; background: none; border: 1px solid var(--line);
  border-radius: var(--r-btn); padding: var(--s2) var(--s3);
}
.verse-ref { font: 600 16px var(--font-verse); color: var(--spirit); white-space: nowrap; }
.verse-theme { font-size: 12px; color: var(--ink-2); }

/* The one bold element: the next block, drawn as a running track lane. */
.next {
  align-self: stretch; display: flex; flex-direction: column; justify-content: flex-end;
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(25% - 2px), color-mix(in srgb, var(--lane-ink) 22%, transparent) calc(25% - 2px) 25%),
    var(--lane);
  color: var(--lane-ink); border-radius: var(--r-card); padding: var(--s5) var(--s4) var(--s4);
  min-height: 0; overflow: hidden;
}
.next.done { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.next-when { margin: 0; font-weight: 600; opacity: .85; }
.next-name { margin: 0 0 var(--s1); font: 700 clamp(52px, 17vw, 88px)/.92 var(--font-display); letter-spacing: -.01em; }
.next-meta { margin: 0 0 var(--s4); opacity: .85; }
.next-actions { display: flex; gap: var(--s2); }
.next .btn { background: var(--lane-ink); color: var(--lane); }
.next .btn.ghost { background: transparent; color: var(--lane-ink); border-color: color-mix(in srgb, var(--lane-ink) 50%, transparent); }
.next.done .btn { background: var(--lane); color: var(--lane-ink); }

.upcoming-toggle { width: 100%; text-align: left; background: none; border: 0; padding: var(--s1) 0; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upcoming-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s1); }
.upcoming-list button { width: 100%; display: flex; justify-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-btn); padding: var(--s2) var(--s3); }
.upcoming-list .closed button { opacity: .55; }

.counters { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2); }
.counter {
  position: relative; display: grid; justify-items: start; gap: 0; text-align: left; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-btn); padding: var(--s2) var(--s2) var(--s3);
}
.count { font: 700 28px/1 var(--font-display); }
.clbl { font-size: 13px; font-weight: 600; }
.csub { font-size: 11px; color: var(--ink-2); line-height: 1.2; }
.meter { position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; background: var(--lane); transform-origin: left; transform: scaleX(var(--p, 0)); }

.bar { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s2); }
.bar button { background: none; border: 1px solid var(--line); border-radius: var(--r-btn); padding: var(--s3) 0; font-weight: 600; }

/* ---------- Buttons and inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
  background: var(--lane); color: var(--lane-ink); border: 1px solid transparent;
  border-radius: var(--r-btn); padding: var(--s3) var(--s4); font-weight: 600; min-height: 48px;
}
.btn.big { flex: 1; font-size: 19px; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn:disabled { opacity: .35; }
.btn.file { position: relative; overflow: hidden; }
.btn.file input { position: absolute; inset: 0; opacity: 0; }
.icon-btn { background: none; border: 0; font-size: 20px; width: 44px; height: 44px; }
.chip { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-btn); padding: var(--s3); font-weight: 600; }
.seg { display: flex; gap: var(--s1); }
.seg.wrap { flex-wrap: wrap; }
.seg button { flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-btn); padding: var(--s2) var(--s3); white-space: nowrap; }
.seg button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.seg.big button { padding: var(--s4); font-size: 19px; }
.stack { display: grid; gap: var(--s3); }
.row { display: flex; gap: var(--s2); }
.row input { flex: 1; min-width: 0; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2); }
input, textarea { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-btn); padding: var(--s3); font-size: 17px; }
textarea { resize: vertical; }

/* ---------- Sheets ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; }
.sheet-scrim { position: absolute; inset: 0; background: rgb(0 0 0 / .35); opacity: 0; transition: opacity .2s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; max-height: 88dvh;
  background: var(--paper); border-radius: var(--r-card) var(--r-card) 0 0;
  padding: var(--s2) var(--s4) calc(var(--safe-bottom) + var(--s4));
  display: flex; flex-direction: column; transform: translateY(100%); transition: transform .22s ease-out;
}
.sheet.full { height: 88dvh; }
.sheet-wrap.open .sheet { transform: none; }
.sheet-wrap.open .sheet-scrim { opacity: 1; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { margin: 0; font: 700 26px var(--font-display); }
.sheet-body { overflow-y: auto; overflow-x: hidden; min-height: 0; }

.log-form { display: grid; gap: var(--s3); }
.fields { display: grid; gap: var(--s3); }
.field { display: grid; gap: var(--s1); }
.lbl { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.derived { color: var(--ink-2); font-size: 15px; }

/* ---------- Verse ---------- */
.verse-sheet { display: grid; gap: var(--s3); min-width: 0; grid-template-columns: minmax(0, 1fr); }
.verse-top { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); }
.version-select { width: 11em; min-width: 0; text-overflow: ellipsis; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-btn); padding: var(--s2) var(--s3); font: inherit; font-size: 15px; }
.verse-theme { margin: 0; color: var(--spirit); font-weight: 600; }
.verse-block { margin: 0; padding: var(--s4); border-left: 4px solid var(--spirit); background: var(--surface); border-radius: 0 var(--r-btn) var(--r-btn) 0; font: 400 20px/1.55 var(--font-verse); font-style: normal; }
.verse-block p { margin: 0 0 var(--s2); }
.verse-block cite { font: 600 15px var(--font-verse); font-style: normal; color: var(--spirit); }
.layer { border-top: 1px solid var(--line); padding: var(--s2) 0; }
.layer summary { font-weight: 600; cursor: pointer; }
.layer-body { padding-top: var(--s2); }

/* ---------- Runner ---------- */
.runner {
  position: fixed; inset: 0; z-index: 30; background: var(--paper);
  display: grid; grid-template-rows: auto auto 1fr auto;
  padding: calc(var(--safe-top) + var(--s2)) var(--s4) calc(var(--safe-bottom) + var(--s3));
  animation: rise .2s ease-out;
}
.runner.closing { animation: sink .2s ease-in forwards; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
@keyframes sink { to { transform: translateY(24px); opacity: 0; } }
.runner-head { display: flex; align-items: center; gap: var(--s2); }
.runner-title { flex: 1; font: 700 22px var(--font-display); }
.runner-count { color: var(--ink-2); font-size: 14px; }
.lanes { display: flex; gap: 2px; margin: var(--s2) 0; }
.lanes span { flex: 1; height: 6px; background: var(--line); border-radius: 3px; }
.lanes .done { background: var(--lane); }
.lanes .now { background: var(--spirit); }
.runner-main { display: flex; flex-direction: column; justify-content: center; gap: var(--s3); min-height: 0; max-width: 560px; width: 100%; margin: 0 auto; }
.step-kind { margin: 0; font-weight: 600; color: var(--ink-2); }
.step-kind.rest { color: var(--ok); }
.step-kind.upnext { color: var(--spirit); }
.getready-label { margin: 0; color: var(--spirit); font-weight: 600; }
.getready .clock { color: var(--spirit); }
.getready .clock-fill { background: var(--spirit); }
.step-text { margin: 0; font: 700 clamp(36px, 10vw, 56px)/1 var(--font-display); }
.step-note { margin: 0; color: var(--ink-2); }
.step-cue { margin: 0; padding-left: var(--s3); border-left: 3px solid var(--lane); font-size: 18px; line-height: 1.4; max-width: 34ch; }
.links { display: flex; gap: var(--s4); }
.clock-wrap { display: grid; gap: var(--s2); }
.clock { font: 700 clamp(72px, 26vw, 120px)/1 var(--font-display); font-variant-numeric: tabular-nums; }
.clock-bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.clock-fill { height: 100%; background: var(--lane); transform-origin: left; transform: scaleX(0); }
.log { display: grid; gap: var(--s2); }
.stepper { display: flex; align-items: center; gap: var(--s3); }
.stepper label { flex: 1; display: flex; align-items: baseline; gap: var(--s2); }
.num { font: 700 48px var(--font-display); text-align: center; padding: var(--s2); }
.round { width: 64px; height: 64px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 30px; }
.runner-foot { display: grid; grid-template-columns: 1fr 2fr; gap: var(--s2); max-width: 560px; width: 100%; margin: 0 auto; }
.pulse { animation: pulse 1s ease-in-out 3; }
@keyframes pulse { 50% { transform: scale(1.04); } }
.runner-menu {
  position: absolute; left: var(--s4); right: var(--s4); top: 30%; display: grid; gap: var(--s2);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--s4);
  box-shadow: 0 12px 40px rgb(0 0 0 / .25);
}
.runner-menu p { margin: 0 0 var(--s2); font-weight: 600; }

/* ---------- Misc ---------- */
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 80px); transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: var(--paper); padding: var(--s2) var(--s4); border-radius: var(--r-pill); z-index: 50; transition: .2s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.update { position: fixed; top: calc(var(--safe-top) + 8px); left: 50%; transform: translateX(-50%); z-index: 60; background: var(--spirit); color: #fff; border: 0; border-radius: var(--r-pill); padding: var(--s2) var(--s4); font-weight: 600; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
