/* timer.kituwa.com — Kituwa's own visual language: paper and ink, jade for
   running, a warm ember for the finish. One ring, one set of digits, calm
   spacing. No web fonts, no images, no framework. */

:root {
  --paper: #f2f1ea;
  --paper-deep: #e9e7dc;
  --surface: #fffef9;
  --surface-2: #f8f7f1;
  --ink: #0e1411;
  --muted: #5c655e;
  --line: #e0ddd1;
  --line-strong: #cbc7b8;
  --accent: #3f6a51;
  --accent-deep: #2c4b3a;
  --accent-soft: #e2eee4;
  --accent-ink: #ffffff;
  --ember: #b96a38;
  --ember-soft: #f6e7dc;
  --danger: #a83f36;
  --ring-track: #e2dfd2;
  --digit: #0b110e;
  --shadow-sm: 0 1px 2px rgba(18, 28, 22, 0.05), 0 10px 30px -18px rgba(18, 28, 22, 0.22);
  --shadow-md: 0 30px 80px -40px rgba(18, 28, 22, 0.4);
  --radius: 18px;
  --radius-sm: 11px;
  --ease-spring: cubic-bezier(0.2, 1.18, 0.32, 1);
  --ease-out: cubic-bezier(0.16, 0.8, 0.3, 1);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --dim: 0;
}

[data-theme="dark"] {
  --paper: #090d0b;
  --paper-deep: #060908;
  --surface: #121815;
  --surface-2: #0e1411;
  --ink: #e9efe9;
  --muted: #9aa79e;
  --line: #222c26;
  --line-strong: #34423a;
  --accent: #8ed3a8;
  --accent-deep: #a7e3bd;
  --accent-soft: #16241c;
  --accent-ink: #08100c;
  --ember: #e0a06a;
  --ember-soft: #2a1d14;
  --danger: #e08379;
  --ring-track: #1e2822;
  --digit: #f3f8f4;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 34px -20px rgba(0, 0, 0, 0.8);
  --shadow-md: 0 34px 90px -40px rgba(0, 0, 0, 0.9);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(1100px 620px at 50% -18%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  opacity: 0;
  background: radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--ember) 26%, transparent), transparent 62%);
}
body.finish-flash::before { animation: flash-tint 1500ms var(--ease-out) forwards; }
body.is-dimming::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 55;
  background: #050807;
  opacity: var(--dim);
  transition: opacity 700ms linear;
}
@keyframes flash-tint {
  0% { opacity: 0; }
  18% { opacity: 1; }
  100% { opacity: 0; }
}

::selection { background: var(--accent); color: var(--accent-ink); }

h1, h2, h3 { line-height: 1.15; letter-spacing: -0.02em; font-weight: 650; margin: 0; }
h1 { font-size: clamp(1.7rem, 3.6vw, 2.35rem); }
h2 { font-size: 1.22rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-deep); }
code, kbd, .mono { font-family: var(--mono); font-size: 0.86em; }
code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 0.1em 0.35em; }
kbd {
  display: inline-block;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 0.08em 0.4em;
  background: var(--surface);
  font-size: 0.78em;
  color: var(--muted);
}
hr { border: 0; border-top: 1px solid var(--line); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 16px;
  border-radius: 0 0 10px 10px;
  font-weight: 600;
  text-decoration: none;
  transition: top 160ms var(--ease-out);
}
.skip:focus { top: 0; color: var(--accent-ink); }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; line-height: 1.5; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- header ---------- */

.top {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px clamp(14px, 4vw, 40px);
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
  min-height: 44px;
}
.brand:hover { color: var(--ink); }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  color: var(--accent);
  background: var(--accent-soft);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-text { color: var(--muted); font-weight: 500; }
.brand-text strong { color: var(--ink); font-weight: 650; }

.top-nav { display: flex; gap: 4px; margin-left: auto; }
.top-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.93rem;
  font-weight: 500;
}
.top-nav a:hover { color: var(--ink); background: var(--surface-2); }
.top-nav a[aria-current="page"] { color: var(--ink); background: var(--surface); border: 1px solid var(--line); }

.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 160ms, color 160ms, transform 200ms var(--ease-spring);
}
.theme-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.theme-btn:active { transform: scale(0.97); }
.theme-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ink) 0 50%, transparent 50% 100%);
  border: 1.5px solid var(--ink);
}
[data-theme="dark"] .theme-dot { background: var(--ink); }

/* ---------- stage ---------- */

#stage {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px clamp(14px, 4vw, 40px) 72px;
}
#stage.wide { max-width: 1240px; }
#stage.narrow { max-width: 820px; }

.hero-line {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  padding: 8px 0 14px;
}
.hero-line h1 { font-size: clamp(1.55rem, 3vw, 2.05rem); letter-spacing: -0.03em; }
.hero-line p { color: var(--muted); max-width: 64ch; font-size: 0.94rem; }

.mode-rail {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px;
  margin: 0 -4px 18px;
  border-bottom: 1px solid var(--line);
}
.mode-rail::-webkit-scrollbar { display: none; }
.mode-tab {
  position: relative;
  flex: none;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px 10px 0 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 550;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: color 160ms, background 160ms;
}
.mode-tab:hover { color: var(--ink); background: var(--surface-2); }
.mode-tab[aria-selected="true"] { color: var(--ink); background: var(--surface); }
.mode-tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 14px; right: 14px; bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
@media (min-width: 1020px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 286px; }
}

.stage-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: clamp(18px, 3vw, 30px);
  min-height: 520px;
}
/* Visible by default; the entrance is an animation, never a hidden base state,
   so a page whose JS is slow still shows the timer. */
.stage-panel.is-in { animation: panel-in 340ms var(--ease-spring); }
@keyframes panel-in {
  from { opacity: 0; transform: translateY(8px) scale(0.996); }
  to { opacity: 1; transform: none; }
}
.stage-panel:focus { outline: none; }

.mode-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.mode-head h2 { font-size: 1.16rem; }
.mode-sub { color: var(--muted); font-size: 0.87rem; margin-top: 3px; max-width: 46ch; }
.mode-meta { color: var(--muted); font-size: 0.78rem; white-space: nowrap; padding-top: 4px; }
.mode-meta kbd { font-size: 0.72rem; }

/* ---------- dial ---------- */

.dial-wrap {
  display: grid;
  place-items: center;
  margin: 6px auto 22px;
  width: min(360px, 78vw);
}
.dial {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}
.dial svg.ring {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  transform: rotate(0deg);
  overflow: visible;
}
.ring-track {
  fill: none;
  stroke: var(--ring-track);
  stroke-width: 7;
}
.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 7;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 130px 130px;
  transition: stroke 300ms;
}
.ring-head {
  fill: var(--accent);
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 55%, transparent));
  transition: opacity 200ms;
}
[data-tone="pomodoro"] .ring-progress { stroke: color-mix(in srgb, var(--accent) 82%, var(--ember)); }
[data-tone="stopwatch"] .ring-progress { stroke: color-mix(in srgb, var(--accent) 60%, #3d7f9e); }
[data-tone="sleep"] .ring-progress { stroke: color-mix(in srgb, var(--accent) 55%, #6b6fa8); }

.ticks {
  position: absolute;
  inset: 11px;
  border-radius: 50%;
  background: repeating-conic-gradient(from -0.35deg,
    color-mix(in srgb, var(--ink) 26%, transparent) 0deg 0.7deg,
    transparent 0.7deg 6deg);
  -webkit-mask: radial-gradient(circle, transparent 0 calc(50% - 14px), #000 calc(50% - 13.5px) calc(50% - 9px), transparent calc(50% - 8.5px));
          mask: radial-gradient(circle, transparent 0 calc(50% - 14px), #000 calc(50% - 13.5px) calc(50% - 9px), transparent calc(50% - 8.5px));
  opacity: 0.5;
  pointer-events: none;
}

.dial-face {
  position: relative;
  z-index: 2;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 0 14%;
  text-align: center;
}
.dial-label {
  font-size: 0.8rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  max-width: 22ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.digits {
  font-size: clamp(2.9rem, 12.5vw, 4.6rem);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "ss01" 1;
  color: var(--digit);
  transition: transform 260ms var(--ease-spring);
}
.dial-label + .digits { margin-top: 4px; }
.dial-sub { color: var(--muted); font-size: 0.8rem; min-height: 1.2em; }
.dial-actions { display: flex; gap: 8px; margin-top: 10px; }

.dial.is-finish .digits { animation: digit-pop 900ms var(--ease-spring); }
@keyframes digit-pop {
  0% { transform: scale(1); }
  22% { transform: scale(1.09); }
  100% { transform: scale(1); }
}

.burst { position: absolute; inset: 0; pointer-events: none; display: grid; place-items: center; }
.burst .pulse {
  position: absolute;
  width: 62%; aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
}
.dial.is-finish .burst .pulse { animation: pulse-ring 1900ms var(--ease-out) forwards; }
.dial.is-finish .burst .pulse:nth-child(2) { animation-delay: 220ms; border-color: color-mix(in srgb, var(--ember) 70%, var(--accent)); }
.dial.is-finish .burst .pulse:nth-child(3) { animation-delay: 440ms; }
@keyframes pulse-ring {
  0% { opacity: 0.55; transform: scale(0.72); }
  70% { opacity: 0.16; }
  100% { opacity: 0; transform: scale(1.65); }
}
.burst .particle {
  position: absolute;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transform: rotate(var(--a)) translateY(0);
}
.dial.is-finish .burst .particle { animation: particle 1200ms var(--ease-out) forwards; }
.burst .particle:nth-child(3n) { background: var(--ember); }
.burst .particle:nth-child(4n) { width: 3px; height: 3px; }
@keyframes particle {
  0% { opacity: 0.9; transform: rotate(var(--a)) translateY(calc(var(--d) * 0.35)); }
  70% { opacity: 0.5; }
  100% { opacity: 0; transform: rotate(var(--a)) translateY(var(--d)); }
}
.dial[data-phase="work"] .ring-progress { stroke: var(--accent); }
.dial[data-phase="rest"] .ring-progress { stroke: color-mix(in srgb, var(--accent) 45%, #4f8ea8); }
.dial[data-phase="prepare"] .ring-progress { stroke: var(--muted); }

/* ---------- controls ---------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: center;
  margin: 0 auto 16px;
}
.chip {
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: transform 160ms var(--ease-spring), border-color 160ms, background 160ms;
}
.chip span { color: var(--muted); font-size: 0.78em; margin-left: 3px; }
.chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.chip:active { transform: scale(0.96); }
.chip.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.is-on span { color: color-mix(in srgb, var(--accent-ink) 72%, transparent); }

.custom-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 0 auto 18px;
  flex-wrap: wrap;
}
.custom-row .field-inline { min-width: 220px; }

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 16px;
}
.btn {
  min-height: 44px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
  transition: background 150ms, border-color 150ms, transform 180ms var(--ease-spring), box-shadow 150ms;
}
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn:active { transform: scale(0.975); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 8px 20px -12px color-mix(in srgb, var(--accent) 80%, transparent);
}
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); color: var(--accent-ink); }
.btn-lg { min-height: 52px; padding: 0 26px; font-size: 1rem; border-radius: 14px; }
.btn-sm { min-height: 44px; padding: 0 13px; font-size: 0.84rem; border-radius: 10px; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn-quiet:hover { background: var(--surface-2); border-color: var(--line); color: var(--ink); }
.btn-toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-deep); }

.icon-btn {
  width: 44px; height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line); }

/* ---------- fields ---------- */

.field { display: grid; gap: 5px; font-size: 0.82rem; color: var(--muted); min-width: 0; }
.field > span { font-weight: 550; letter-spacing: 0.01em; }
.field em { font-style: normal; font-weight: 400; opacity: 0.75; }
input[type="text"], input[type="email"], input[type="number"], input[type="search"],
input[type="datetime-local"], select {
  min-height: 44px;
  width: 100%;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.94rem;
  transition: border-color 140ms, box-shadow 140ms;
}
input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
input[type="number"] { font-variant-numeric: tabular-nums; }
select { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 20px, calc(100% - 12px) 20px; background-size: 5px 5px; background-repeat: no-repeat; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row-end { grid-template-columns: minmax(0, 1fr) auto; align-items: center; margin: 10px 0 12px; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }

.inline-settings {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  max-width: 640px;
  margin: 0 auto 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
@media (max-width: 620px) { .inline-settings { grid-template-columns: 1fr; } }

.cfg-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  max-width: 640px;
  margin: 0 auto 18px;
}
@media (max-width: 620px) { .cfg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- email alert ---------- */

.alert-box {
  max-width: 640px;
  margin: 18px auto 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  overflow: hidden;
}
.alert-box summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 0 16px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 550;
  list-style: none;
}
.alert-box summary::-webkit-details-marker { display: none; }
.alert-box summary::before {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 20px; height: 20px;
  margin-right: 8px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-weight: 500;
}
.alert-box[open] summary::before { content: "–"; }
.alert-box summary span:first-child { margin-right: auto; }
.summary-hint { color: var(--muted); font-weight: 400; font-size: 0.8rem; }
.alert-form { padding: 0 16px 16px; display: grid; gap: 8px; }
.hint { color: var(--muted); font-size: 0.79rem; line-height: 1.45; }
.form-msg { font-size: 0.84rem; min-height: 1.2em; }
.form-msg[data-tone="ok"] { color: var(--accent-deep); }
.form-msg[data-tone="warn"] { color: var(--danger); }

/* ---------- side history ---------- */

.stage-side {
  display: grid;
  gap: 18px;
  align-content: start;
}
.history-group h3 {
  font-size: 0.76rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.pill-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pill-wrap { display: flex; gap: 4px; align-items: stretch; }
.pill {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms, background 150ms;
}
.pill:hover { border-color: var(--accent); background: var(--accent-soft); }
.pill em { font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.8rem; }
.pill-x {
  width: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.pill-x:hover { border-color: var(--line); color: var(--danger); }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; margin: 16px auto; max-width: 720px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.data-table th, .data-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.data-table th { color: var(--muted); font-weight: 550; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.07em; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table td.num { font-variant-numeric: tabular-nums; }
.tag { display: inline-block; font-size: 0.68rem; letter-spacing: 0.06em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; }
.tag-best { background: var(--accent-soft); color: var(--accent-deep); }
.tag-worst { background: var(--ember-soft); color: var(--ember); }

/* ---------- pomodoro / interval extra ---------- */

.phase-strip { display: flex; gap: 4px; margin: 0 auto 16px; max-width: 720px; overflow-x: auto; padding-bottom: 4px; }
.phase-cell {
  flex: 1 0 auto;
  min-width: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 8px;
  background: var(--surface-2);
  text-align: center;
}
.phase-cell span { display: block; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.phase-cell em { font-style: normal; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.phase-cell.focus { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.phase-cell.long { border-color: color-mix(in srgb, var(--ember) 40%, var(--line)); }
.phase-cell.is-active { background: var(--accent-soft); border-color: var(--accent); }
.session-log { text-align: center; margin-top: 8px; }
.session-log h3 { font-size: 0.76rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }

.preset-inline { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-bottom: 16px; }
.round-line { text-align: center; color: var(--muted); font-size: 0.84rem; font-variant-numeric: tabular-nums; }

/* ---------- alarm wheels ---------- */

.alarm-display { display: grid; justify-items: center; gap: 10px; margin: 4px 0 18px; }
.wheel-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  perspective: 700px;
}
.wheel {
  height: 132px;
  width: 96px;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  -webkit-mask: linear-gradient(#0000, #000 26%, #000 74%, #0000);
          mask: linear-gradient(#0000, #000 26%, #000 74%, #0000);
  padding: 0;
  border-radius: 12px;
  scroll-behavior: smooth;
}
.wheel::-webkit-scrollbar { display: none; }
.wheel-pad { height: 44px; }
.wheel-item {
  display: block;
  width: 100%;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 1.42rem;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  scroll-snap-align: center;
  cursor: pointer;
  transform: rotateX(calc(var(--d, 0) * 7deg)) scale(calc(1 - var(--d, 0) * 0.055));
  opacity: calc(1 - var(--d, 0) * 0.24);
  transition: color 160ms, opacity 120ms;
}
.wheel-item.is-selected { color: var(--ink); font-weight: 650; }
.wheel-item:hover { color: var(--ink); }
.wheel-colon { font-size: 1.5rem; color: var(--muted); transform: translateY(-2px); }
.alarm-next { color: var(--muted); font-size: 0.84rem; text-align: center; }

.day-row { display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.day {
  min-width: 46px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 140ms, color 140ms, border-color 140ms;
}
.day.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.day:hover { border-color: var(--accent); }

.alarm-list { list-style: none; margin: 8px auto 0; padding: 0; max-width: 560px; display: grid; gap: 6px; }
.alarm-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 6px 6px 14px;
  background: var(--surface-2);
  font-size: 0.86rem;
}
.alarm-time { font-variant-numeric: tabular-nums; font-weight: 650; font-size: 1rem; }
.alarm-meta { color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.alarm-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, #050807 62%, transparent);
  backdrop-filter: blur(6px);
  padding: 20px;
}
.alarm-card {
  width: min(420px, 92vw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 30px 26px;
  text-align: center;
  box-shadow: var(--shadow-md);
  animation: alarm-in 420ms var(--ease-spring);
}
@keyframes alarm-in { from { transform: scale(0.94); opacity: 0; } to { transform: none; opacity: 1; } }
.alarm-kicker { font-size: 0.74rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.alarm-ring-time { font-size: 3.4rem; font-weight: 600; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; margin: 4px 0; }
.alarm-ring-label { color: var(--muted); margin-bottom: 20px; }

/* ---------- world ---------- */

.world-list { display: grid; gap: 4px; max-width: 760px; margin: 0 auto 14px; }
.world-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) auto auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 8px 10px 14px;
  border-bottom: 1px solid var(--line);
}
.world-row:last-child { border-bottom: 0; }
.world-city { display: grid; min-width: 0; }
.world-city strong { font-weight: 600; font-size: 0.96rem; }
.world-city span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.world-clock { display: grid; justify-items: end; }
.world-time { font-size: 1.32rem; font-variant-numeric: tabular-nums; font-weight: 550; letter-spacing: -0.02em; }
.world-state { display: flex; align-items: center; gap: 5px; color: var(--muted); text-transform: capitalize; }
.world-state .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.world-state[data-period="night"] .dot { background: #6b6fa8; }
.world-state[data-period="morning"] .dot { background: #d3a24a; }
.world-state[data-period="day"] .dot { background: var(--accent); }
.world-state[data-period="evening"] .dot { background: var(--ember); }

.overlap { max-width: 760px; margin: 18px auto 0; }
.overlap-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.overlap-head h3 { font-size: 0.76rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.overlap-strip { display: flex; gap: 2px; margin: 8px 0 4px; }
.overlap-cell {
  flex: 1;
  height: 34px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent) calc(var(--s) * 80%), var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  display: grid;
  place-items: end center;
}
.overlap-cell i { font-style: normal; font-size: 0.56rem; color: color-mix(in srgb, var(--ink) 55%, transparent); line-height: 1.4; }
.overlap-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.68rem; }

/* ---------- event ---------- */

.event-form { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: 10px; align-items: end; max-width: 760px; margin: 0 auto 24px; }
@media (max-width: 700px) { .event-form { grid-template-columns: 1fr; } }
.event-parts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  max-width: 700px;
  margin: 0 auto 12px;
}
.event-parts > div {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 8px;
  text-align: center;
}
.event-parts span { display: block; font-size: clamp(1.6rem, 5vw, 2.6rem); font-weight: 600; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.event-parts em { font-style: normal; font-size: 0.7rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.event-line { text-align: center; color: var(--muted); font-size: 0.88rem; margin-bottom: 18px; }

/* ---------- library ---------- */

.library { max-width: 1180px; margin: 0 auto; }
.lib-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.field-search { flex: 1 1 260px; max-width: 380px; }
.lib-controls .chips { justify-content: flex-start; margin: 0; }
.lib-count { margin-bottom: 14px; }
.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 12px;
}
.lib-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  animation: card-in 300ms var(--ease-out) both;
  transition: border-color 160ms, transform 220ms var(--ease-spring), box-shadow 160ms;
}
.lib-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); transform: translateY(-2px); box-shadow: var(--shadow-md); }
@keyframes card-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.lib-card header { display: grid; gap: 3px; }
.lib-card h3 { font-size: 1.02rem; }
.lib-cat { font-size: 0.66rem; letter-spacing: 0.11em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.lib-note { color: var(--muted); font-size: 0.83rem; line-height: 1.5; flex: 1; }
.lib-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.lib-duration { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 0.95rem; }
.lib-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.lib-link { font-family: var(--mono); font-size: 0.68rem; opacity: 0.65; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-empty { text-align: center; padding: 30px 0; }
.lib-saved { margin-top: 30px; }
.lib-saved h2 { font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.library .pill-list { max-width: 520px; }

/* ---------- about + footer ---------- */

.about { margin-top: 44px; padding-top: 26px; border-top: 1px solid var(--line); }
.about h2 { font-size: 1.05rem; margin-bottom: 14px; }
.about-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px 26px; }
.about-grid h3 { font-size: 0.9rem; margin-bottom: 5px; }
.about-grid p { color: var(--muted); font-size: 0.85rem; }

.foot {
  border-top: 1px solid var(--line);
  padding: 26px clamp(14px, 4vw, 40px) 34px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: baseline;
  justify-content: space-between;
}
.foot-links { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.foot-links a { color: var(--muted); font-size: 0.85rem; }
.foot-links a:hover { color: var(--ink); }
.foot-note { color: var(--muted); font-size: 0.78rem; max-width: 60ch; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  z-index: 90;
  max-width: min(92vw, 460px);
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.86rem;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms, transform 320ms var(--ease-spring);
}
.toast.is-open { opacity: 1; transform: translate(-50%, 0); }
.toast[data-tone="warn"] { background: var(--danger); color: #fff; }

/* ---------- prose / ops ---------- */

.notice { border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 14px 16px; color: var(--muted); }

.prose { max-width: 72ch; }
.prose h1 { margin-bottom: 10px; }
.prose h2 { font-size: 1.02rem; margin: 26px 0 8px; }
.prose p { color: var(--muted); margin-bottom: 10px; }
.prose .lede { font-size: 1.05rem; color: var(--ink); margin-bottom: 18px; }
.plain-list { color: var(--muted); font-size: 0.9rem; padding-left: 18px; display: grid; gap: 6px; margin: 8px 0 0; }
.kicker { font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.card h2 { font-size: 0.98rem; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.card p { color: var(--muted); font-size: 0.9rem; }
.health-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 10px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.ok { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }
.facts { display: grid; gap: 0; margin: 8px 0 0; }
.facts > div { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 0.86rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.grid-week { display: grid; grid-template-columns: 74px repeat(7, minmax(0, 1fr)); gap: 4px; margin: 12px 0 10px; font-size: 0.72rem; }
.grid-head { color: var(--muted); text-align: center; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.64rem; }
.grid-label { color: var(--muted); display: flex; align-items: center; }
.grid-week .cell { height: 26px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line); }
.grid-week .cell.exp { background: color-mix(in srgb, var(--accent) 22%, var(--surface-2)); border-color: color-mix(in srgb, var(--accent) 34%, var(--line)); }
.grid-week .cell.man { background: color-mix(in srgb, var(--accent) 45%, var(--surface)); color: var(--accent-ink); display: grid; place-items: center; font-size: 0.6rem; }
.grid-week .cell.ext { background: var(--surface-2); border-style: dashed; display: grid; place-items: center; color: var(--muted); font-size: 0.6rem; }
.legend { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); }
.legend .cell { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); font-size: 0.55rem; }
.legend .cell.exp { background: color-mix(in srgb, var(--accent) 22%, var(--surface-2)); }

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  .mode-rail { -webkit-mask-image: linear-gradient(to right, #000 88%, transparent 100%); mask-image: linear-gradient(to right, #000 88%, transparent 100%); }
  .top { flex-wrap: wrap; gap: 8px 12px; }
  .top-nav { order: 3; width: 100%; margin-left: 0; overflow-x: auto; padding-bottom: 2px; }
  .theme-btn { margin-left: auto; }
  .hero-line { padding: 10px 0 16px; }
  .mode-rail { margin-bottom: 14px; }
  .stage-panel { min-height: 0; padding: 18px 14px 22px; }
  .mode-head { flex-direction: column; gap: 6px; }
  .mode-head h2 { font-size: 1.05rem; }
  .mode-meta { padding-top: 0; }
  .dial-wrap { width: min(330px, 82vw); }
  .digits { font-size: clamp(2.6rem, 15vw, 4rem); }
  .actions .btn { flex: 1 1 auto; }
  .world-row { grid-template-columns: 1fr auto auto; }
  .world-row .world-state { display: none; }
  .event-parts { grid-template-columns: repeat(2, 1fr); }
  .about { margin-top: 30px; }
}

@media (max-width: 380px) {
  .mode-tab { padding: 0 11px; font-size: 0.86rem; }
  .btn-lg { padding: 0 18px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .stage-panel { opacity: 1; transform: none; }
  .lib-card { animation: none; }
  .dial-face, .digits { transition: none; }
}

@media (prefers-contrast: more) {
  :root { --muted: #3f4a43; --line: #b8b4a5; }
  [data-theme="dark"] { --muted: #c3d0c7; --line: #46564d; }
  .btn, .chip, input, select { border-width: 2px; }
}

/* ---------- hero composition ---------- */

.hero-grid { display: grid; gap: 4px; align-items: start; }
.hero-grid .dial-wrap { width: min(330px, 80vw); margin: 0 auto 10px; }
.hero-controls { min-width: 0; }
.hero-controls .inline-settings { margin-bottom: 8px; }

@media (min-width: 900px) {
  .hero-grid {
    grid-template-columns: minmax(280px, 0.95fr) minmax(0, 1.05fr);
    gap: 8px 30px;
    align-items: center;
    margin-bottom: 8px;
  }
  .hero-grid .dial-wrap { width: 100%; max-width: 320px; margin: 0; }
  .hero-controls .chips {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
    justify-content: stretch;
    margin-bottom: 12px;
  }
  .hero-controls .chip { padding: 0 6px; font-size: 0.8rem; white-space: nowrap; }
  .hero-controls .custom-row { justify-content: flex-start; flex-wrap: nowrap; margin: 0 0 14px; }
  .hero-controls .custom-row .field-inline { min-width: 0; flex: 1 1 auto; }
  .hero-controls .inline-settings { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: none; margin-bottom: 0; gap: 8px; }
  .hero-controls .field select { width: 100%; }
  .hero-actions { margin-top: 4px; }
}

/* The in-dial Start appears only on small screens, so the hero is usable
   without scrolling past the ring. */
.dial-start { display: none; }
@media (max-width: 760px) {
  .dial-start { display: inline-flex; }
  .hero-actions [data-start] { display: none; }
  .dial-actions { margin-top: 14px; }
}

/* ---------- optional video stage ---------- */

.video-stage {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  border-radius: 50%;
  background: #050807;
  pointer-events: none;
}
.event-stage .video-stage { border-radius: 0; }
.video-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 177.78%;
  aspect-ratio: 16 / 9;
  transform: translate(-50%, -50%);
}
.video-frame iframe,
.video-mount iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;
}
.video-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(circle at 50% 46%, rgba(4, 9, 7, 0.66), rgba(4, 9, 7, 0.78) 62%, rgba(4, 9, 7, 0.9));
}
.dial.has-video .digits {
  color: #fff;
  text-shadow: 0 2px 26px rgba(0, 0, 0, 0.7), 0 1px 3px rgba(0, 0, 0, 0.85);
}
.dial.has-video .dial-label,
.dial.has-video .dial-sub {
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.75);
}
.dial.has-video .ring-track { stroke: rgba(255, 255, 255, 0.28); }
.dial.has-video .ticks { opacity: 0.3; }

/* The gear stays on the overlay for as long as a video is attached. */
.video-gear {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 7;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(8, 13, 11, 0.66);
  color: #fff;
  cursor: pointer;
  -webkit-backdrop-filter: blur(5px);
          backdrop-filter: blur(5px);
  transition: background 150ms, transform 160ms var(--ease-spring);
}
.video-gear:hover { background: rgba(8, 13, 11, 0.86); }
.video-gear:active { transform: scale(0.94); }
.video-gear[hidden] { display: none; }
.video-gear:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.video-fallback {
  position: absolute;
  left: 50%;
  bottom: 7%;
  transform: translateX(-50%);
  z-index: 4;
  display: grid;
  justify-items: center;
  gap: 8px;
  width: max-content;
  max-width: 86%;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(6, 11, 9, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.22);
  text-align: center;
  pointer-events: auto;
}
.video-fallback[hidden] { display: none; }
.video-note { color: #fff; font-size: 0.78rem; line-height: 1.4; }
.video-fallback-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.video-fallback .btn { border-color: rgba(255, 255, 255, 0.4); }

/* Countdown (event) stage: the same video behind the big number blocks. */
.event-stage {
  position: relative;
  max-width: 700px;
  margin: 0 auto 12px;
  border-radius: 18px;
  overflow: hidden;
}
.event-stage .event-parts { position: relative; z-index: 2; margin: 0; padding: 18px 10px; }
.event-stage.has-video .event-parts > div {
  background: rgba(6, 11, 9, 0.5);
  border-color: rgba(255, 255, 255, 0.26);
}
.event-stage.has-video .event-parts span { color: #fff; text-shadow: 0 2px 18px rgba(0, 0, 0, 0.7); }
.event-stage.has-video .event-parts em { color: rgba(255, 255, 255, 0.86); }
.event-stage .video-gear { top: 8px; right: 8px; }

/* ---------- video options panel ---------- */

.media-box {
  max-width: 640px;
  margin: 18px auto 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  overflow: hidden;
}
.media-box summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 0 16px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 550;
  list-style: none;
}
.media-box summary::-webkit-details-marker { display: none; }
.media-box summary::before {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-right: 8px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-weight: 500;
}
.media-box[open] summary::before { content: "–"; }
.media-box summary span:first-child { margin-right: auto; }
.media-body { padding: 0 16px 16px; display: grid; gap: 10px; }
.media-url { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.media-url .field { flex: 1 1 240px; }
.media-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; }
@media (max-width: 620px) { .media-grid { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 0.84rem; color: var(--ink); }
.check input[type="checkbox"] { flex: none; width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
.check em { font-style: normal; color: var(--muted); font-size: 0.76em; }
.onend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
  margin: 0;
  padding: 8px 12px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  min-width: 0;
}
@media (max-width: 620px) { .onend { grid-template-columns: 1fr; } }
.onend legend {
  padding: 0 6px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.media-box input[type="range"] {
  width: 100%;
  min-height: 44px;
  accent-color: var(--accent);
  background: transparent;
}
.media-box [data-video-msg][data-tone="warn"] { color: var(--danger); }
.video-actions { display: flex; gap: 8px; flex-wrap: wrap; }
input[aria-invalid="true"] { border-color: var(--danger); }

/* ---------- 47 · tool above the fold ---------- */

body[data-page="app"] {
  --dial-size: clamp(170px, 40dvh, 340px);
}

/* A single-line identity: brand, compact total, theme. The site nav steps
   aside below 900px; the same links are in the footer. */
body[data-page="app"] .top {
  flex-wrap: nowrap;
  gap: 8px;
  padding: 3px clamp(10px, 3vw, 28px);
  min-height: 52px;
}
body[data-page="app"] .brand { min-height: 44px; }
body[data-page="app"] .brand-mark { width: 30px; height: 30px; }
body[data-page="app"] .brand-text { white-space: nowrap; }
body[data-page="app"] .top-nav { margin-left: auto; }
body[data-page="app"] .top-nav a { padding: 0 12px; }

.total-pill {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.total-pill:hover { color: var(--accent-deep); background: color-mix(in srgb, var(--accent) 22%, var(--surface)); }

body[data-page="app"] .hero-line {
  padding: 0 0 4px;
  gap: 8px 12px;
  align-items: center;
}
body[data-page="app"] .hero-line h1 { font-size: clamp(1rem, 1.6vw, 1.3rem); }
body[data-page="app"] .hero-line p { font-size: 0.8rem; }

body[data-page="app"] #stage { padding-top: 0; }
body[data-page="app"] .mode-rail { margin: 0 -4px 6px; padding: 2px 4px; }
body[data-page="app"] .mode-tab { padding: 0 12px; }
body[data-page="app"] .stage-panel {
  min-height: 0;
  padding: clamp(10px, 1.6vw, 22px);
}
body[data-page="app"] .stage-panel .mode-head { margin-bottom: 8px; }
body[data-page="app"] .stage-panel .mode-head h2 { font-size: 1.05rem; }

/* The ring is the stage: size it from the viewport, never a fixed 520px card. */
body[data-page="app"] .dial-wrap {
  width: min(var(--dial-size), 86vw);
  margin: 0 auto 8px;
}
body[data-page="app"] .dial { container-type: inline-size; }
body[data-page="app"] .digits { font-size: clamp(1.9rem, 18cqw, 4.2rem); }
body[data-page="app"] .dial-label { font-size: 0.72rem; }
body[data-page="app"] .dial-sub { font-size: 0.76rem; }

/* The core task: one row of presets, then Start/Pause and Reset. */
body[data-page="app"] .chips {
  flex-wrap: nowrap;
  overflow-x: auto;
  justify-content: flex-start;
  gap: 6px;
  margin: 0 auto 8px;
  padding: 0 2px 2px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
body[data-page="app"] .chips::-webkit-scrollbar { display: none; }
body[data-page="app"] .chips .chip { flex: none; }
body[data-page="app"] .core-actions { margin: 0 0 6px; }
body[data-page="app"] .core-actions .btn { min-width: 116px; }

body[data-page="app"] .secondary {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
}
body[data-page="app"] .secondary .custom-row,
body[data-page="app"] .secondary .inline-settings,
body[data-page="app"] .secondary .actions { margin-bottom: 0; }

@media (min-width: 900px) {
  body[data-page="app"] .chips {
    display: grid;
    grid-template-columns: repeat(11, minmax(0, 1fr));
    flex-wrap: nowrap;
    overflow: visible;
    justify-content: stretch;
  }
  body[data-page="app"] .chips .chip { padding: 0 4px; font-size: 0.8rem; white-space: nowrap; }
}

@media (max-width: 899px) {
  body[data-page="app"] .top-nav { display: none; }
  body[data-page="app"] .theme-btn { margin-left: auto; }
  body[data-page="app"] .total-pill { margin-left: auto; }
}

@media (max-width: 760px) {
  body[data-page="app"] .hero-line p { display: none; }
  body[data-page="app"] .hero-line { padding: 2px 0; }
  body[data-page="app"] .stage-panel .mode-head { display: none; }
  body[data-page="app"] .stage-panel { padding: 10px 10px 14px; }
  body[data-page="app"] .mode-rail { margin-bottom: 4px; }
  body[data-page="app"] .dial-wrap { margin-bottom: 6px; }
  body[data-page="app"] .actions .btn { flex: 1 1 auto; }
}

@media (max-width: 520px) {
  body[data-page="app"] .theme-btn { padding: 0 10px; }
  body[data-page="app"] .theme-btn [data-theme-value] { display: none; }
  .total-pill { padding: 0 10px; }
}

/* ---------- total time waited ---------- */

.waited {
  margin-top: 32px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.waited-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px 24px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.waited-head h2 { font-size: 1.05rem; margin-bottom: 4px; }
.waited-total {
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1;
}
.waited-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 12px 0;
}
.waited-card {
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 12px 14px;
}
.waited-card span {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.waited-card strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.waited-card em { font-style: normal; color: var(--muted); font-size: 0.78rem; }
.waited [data-totals-reset] { margin-top: 4px; }
.waited .hint { margin-top: 8px; }

/* ---------- user-supplied sound ---------- */

.sound-set {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px 12px;
  margin: 0;
  min-width: 0;
  display: grid;
  gap: 8px;
}
.sound-set legend {
  padding: 0 6px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.sound-set .hint { margin: 0; }
.sound-embed iframe,
.sound-embed video,
.sound-embed audio { width: 100%; border: 0; border-radius: 10px; display: block; }
.sound-embed iframe { aspect-ratio: 16 / 9; }
.sound-embed audio { min-height: 54px; }
.sound-embed[hidden] { display: none; }
.sound-element { width: 100%; }

