/* ============================================================
   CandleBeep — stylesheet
   Light theme is the default; [data-theme="dark"] on <html> flips it.
   ============================================================ */

:root {
  --bg:        #f4f6f9;
  --bg-grad:   radial-gradient(1100px 600px at 50% -12%, #e7ecf5 0%, transparent 70%);
  --card:      #ffffff;
  --card-2:    #f8fafc;
  --line:      #e3e8ef;
  --line-soft: #eef2f7;
  --text:      #10151f;
  --text-2:    #5b6675;
  --text-3:    #8b95a5;
  --accent:    #2563eb;
  --accent-ink:#ffffff;
  --accent-soft:#e8effe;
  --up:        #14a058;
  --down:      #e0304a;
  --warn:      #b45309;
  --warn-soft: #fdf3e3;
  --live:      #14a058;
  --shadow:    0 1px 2px rgba(16,21,31,.05), 0 8px 24px -12px rgba(16,21,31,.14);
  --shadow-lg: 0 2px 4px rgba(16,21,31,.06), 0 24px 48px -20px rgba(16,21,31,.22);
  --r:   14px;
  --r-sm: 10px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg:        #0b0f16;
  --bg-grad:   radial-gradient(1100px 600px at 50% -12%, #16202f 0%, transparent 70%);
  --card:      #141a24;
  --card-2:    #1b222e;
  --line:      #26303e;
  --line-soft: #1e2632;
  --text:      #e9eef6;
  --text-2:    #9fadbe;
  --text-3:    #6b7889;
  --accent:    #5b8cff;
  --accent-ink:#0b0f16;
  --accent-soft:#1c2740;
  --up:        #2ecc71;
  --down:      #ff5a72;
  --warn:      #f0b429;
  --warn-soft: #2c2410;
  --live:      #2ecc71;
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
  --shadow-lg: 0 2px 4px rgba(0,0,0,.5), 0 24px 48px -20px rgba(0,0,0,.8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: hidden;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
p  { margin: 0; }

svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------------- top bar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  /* track the same 1240px column the content uses, so the brand lines up
     with the cards instead of hugging the window edge */
  padding: 10px max(12px, env(safe-area-inset-right), calc((100% - 1240px) / 2 + 20px))
           10px max(12px, env(safe-area-inset-left),  calc((100% - 1240px) / 2 + 20px));
  padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.brand {
  display: flex; align-items: center; gap: 11px; min-width: 0;
  text-decoration: none; color: inherit;
  border-radius: 8px;
}
.brand:hover .brand-text strong { color: var(--accent); }
.brand:hover .brand-text .tld { color: var(--accent); opacity: .7; }
.brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.brand-text strong, .brand-text .tld { transition: color .15s; }
.brand-mark { width: 34px; height: 34px; flex: none; stroke-width: 2; }
.bm-red    { fill: var(--down); stroke: none; }
.bm-red-l  { stroke: var(--down); stroke-width: 2; }
.bm-green  { fill: var(--up); stroke: none; }
.bm-green-l{ stroke: var(--up); stroke-width: 2; }
.bm-wave   { stroke: var(--warn); stroke-width: 2; }
/* Name and tagline sit on ONE baseline-aligned row, so the wordmark can use
   the full height of the bar instead of being squeezed into a stacked pair. */
.brand-text { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.brand-text strong {
  font-size: 21px; font-weight: 680; letter-spacing: -.025em;
  line-height: 1.1; white-space: nowrap;
}
.brand-text .tld { font-weight: 500; color: var(--text-3); }
.brand-text .tagline {
  font-size: 12px; color: var(--text-3); white-space: nowrap;
  padding-left: 10px; border-left: 1px solid var(--line);
  min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
/* the bar gets tight once the action buttons are in — name only */
@media (max-width: 640px) {
  .brand-text .tagline { display: none; }
  .brand-text strong { font-size: 19px; }
  .brand-mark { width: 30px; height: 30px; }
}

.topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--text-2);
  font-size: 13px; font-weight: 550;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-3); }
.icon-btn svg { width: 17px; height: 17px; flex: none; }
#installBtn { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: var(--accent-soft); }

.ico-moon { display: none; }
[data-theme="dark"] .ico-sun  { display: none; }
[data-theme="dark"] .ico-moon { display: block; }

/* ---------------- layout ----------------
   Mobile: one column, edge-to-edge with minimal gutters.
   ≥900px: hero parks in a sticky left rail, everything else fills the right.
   ------------------------------------------------------------------------ */
.wrap {
  --page: 1240px;
  --gutter: 12px;
  max-width: var(--page);
  margin: 0 auto;
  padding: 14px max(var(--gutter), env(safe-area-inset-left)) 40px max(var(--gutter), env(safe-area-inset-right));
  display: flex; flex-direction: column; gap: 12px;
}
.col-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

@media (min-width: 900px) {
  .wrap { --gutter: 20px; gap: 16px; }
  .col-main { gap: 16px; }
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-sub { font-size: 12.5px; color: var(--text-3); margin-top: 4px; line-height: 1.5; }
.card-sub em { font-style: italic; color: var(--text-2); }
.head-actions { display: flex; gap: 6px; }

/* ---------------- hero ---------------- */
.hero { padding: 18px 16px 16px; text-align: center; position: relative; overflow: hidden; }
/* Equal-width outer columns so the middle label is centred on the CARD, not
   merely between a wide pill and a narrow clock. */
.hero-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}
.hero-top > .pill { justify-self: start; }
.hero-top > .hero-clock { justify-self: end; }

/* Three items won't fit across a phone — drop the label to its own centred
   row rather than letting it collide with the status pill. */
@media (max-width: 620px) {
  .hero-top {
    grid-template-columns: auto auto;
    grid-template-areas: "pill clock" "label label";
    justify-content: space-between;
    row-gap: 5px;
  }
  .hero-top > .pill       { grid-area: pill; }
  .hero-top > .hero-clock { grid-area: clock; }
  .hero-top > .count-label{ grid-area: label; justify-self: center; }
  .hero-count { margin-top: 2px; }
}

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 11px 4px 9px;
  border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--line);
  font-size: 11.5px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-2);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.pill[data-state="live"]  { color: var(--live); border-color: color-mix(in srgb, var(--live) 35%, var(--line)); background: color-mix(in srgb, var(--live) 10%, transparent); }
.pill[data-state="live"] .dot { background: var(--live); animation: blip 2s ease-in-out infinite; }
.pill[data-state="pre"]   { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); background: var(--warn-soft); }
.pill[data-state="pre"] .dot { background: var(--warn); }
.pill[data-state="break"] { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); background: var(--warn-soft); }
.pill[data-state="break"] .dot { background: var(--warn); }
.pill[data-state="muted"] { color: var(--down); border-color: color-mix(in srgb, var(--down) 45%, var(--line)); background: color-mix(in srgb, var(--down) 12%, transparent); }
.pill[data-state="muted"] .dot { background: var(--down); animation: blip 1.1s ease-in-out infinite; }

/* ---- "sound is blocked" banner — deliberately hard to ignore ---- */
.audio-alert {
  display: flex; align-items: center; gap: 12px;
  margin-top: 14px; padding: 12px 14px;
  text-align: left;
  border: 1.5px solid color-mix(in srgb, var(--down) 55%, transparent);
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--down) 11%, var(--card));
  animation: audioPulse 2.4s ease-in-out infinite;
}
.audio-alert[hidden] { display: none; }
.audio-alert > svg { width: 22px; height: 22px; flex: none; color: var(--down); stroke-width: 2; }
.audio-alert-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.audio-alert-text strong { font-size: 13.5px; color: var(--down); }
.audio-alert-text span { font-size: 11.5px; color: var(--text-2); line-height: 1.45; }
.audio-alert .mini-btn { flex: none; height: 36px; padding: 0 15px; }
@keyframes audioPulse {
  0%, 100% { border-color: color-mix(in srgb, var(--down) 55%, transparent); }
  50%      { border-color: color-mix(in srgb, var(--down) 95%, transparent); }
}
@media (max-width: 520px) {
  .audio-alert { flex-wrap: wrap; }
  .audio-alert .mini-btn { width: 100%; }
}
@keyframes blip { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.8); } }

.hero-clock { font-family: var(--mono); font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.hero-count { margin: 6px 0 14px; }
/* shares the status row with the pill and the clock to save vertical space */
.count-label {
  flex: 1; min-width: 0; text-align: center;
  font-size: 12.5px; color: var(--text-2); font-weight: 550;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.count-value {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: clamp(52px, 17vw, 82px);
  font-weight: 620; letter-spacing: -.045em; line-height: 1.02;
  margin: 2px 0 4px;
}
.count-value.urgent { color: var(--down); }
.count-sub { font-size: 12.5px; color: var(--text-3); min-height: 19px; font-variant-numeric: tabular-nums; }

/* ---- hero footer: flash toggle | session bar | volume, all on one line ---- */
.hero-foot {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; margin-top: 14px;
}
/* Centre each pill on the 5px progress track itself, not on the whole
   track+legend block. Negative offset keeps the row height unchanged. */
.hero-foot .flash-wrap,
.hero-foot .vol-wrap { margin-top: calc((5px - 28px) / 2); }
/* no track to line up with in 24x7 mode — sit normally */
.hero-foot.no-bar { align-items: center; }
.hero-foot.no-bar .flash-wrap,
.hero-foot.no-bar .vol-wrap { margin-top: 0; }
.vol-wrap { position: relative; flex: none; }

.vol-btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 10px 0 8px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card-2); color: var(--text-2);
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  transition: color .15s, border-color .15s, background .15s;
}
.vol-btn:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.vol-btn.is-muted { color: var(--down); border-color: color-mix(in srgb, var(--down) 40%, var(--line)); }
.vol-btn svg { width: 15px; height: 15px; stroke-width: 1.9; }
.vol-btn .vol-body { fill: currentColor; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.vol-btn .vol-x { display: none; }
#volIcon.low .vol-w2 { display: none; }
#volIcon.muted .vol-w1, #volIcon.muted .vol-w2 { display: none; }
#volIcon.muted .vol-x { display: block; }

/* the `hidden` attribute must beat the display rule below */
.vol-pop[hidden] { display: none; }
.vol-pop {
  position: absolute; z-index: 30;
  bottom: calc(100% + 8px); right: 0;
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); box-shadow: var(--shadow-lg);
  width: 244px; max-width: calc(100vw - 44px);
}
.vol-pop input[type="range"] { flex: 1; min-width: 0; }
.vol-pop-val {
  font-family: var(--mono); font-size: 11.5px; color: var(--text-3);
  font-variant-numeric: tabular-nums; width: 34px; text-align: right; flex: none;
}
.vol-mute {
  flex: none; width: 26px; height: 26px; padding: 0;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--card-2); color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
}
.vol-mute:hover { color: var(--down); border-color: var(--down); }
.vol-mute svg { width: 14px; height: 14px; }

/* ---- master flash toggle, mirroring the volume pill on the left ---- */
.flash-wrap { position: relative; flex: none; }
.flash-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 28px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card-2); color: var(--text-3);
  transition: color .15s, border-color .15s, background .15s;
}
.flash-btn svg { width: 14px; height: 14px; fill: currentColor; stroke: none; }
.flash-btn .mini-track {
  position: relative; width: 26px; height: 15px; border-radius: 999px;
  background: var(--line); transition: background .18s;
}
.flash-btn .mini-track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 11px; height: 11px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3);
  transition: transform .18s cubic-bezier(.3,1.4,.5,1);
}
.flash-btn.on { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.flash-btn.on .mini-track { background: var(--accent); }
.flash-btn.on .mini-track::after { transform: translateX(11px); }

@media (max-width: 420px) { .hero-foot { gap: 9px; } }

.arm-btn {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  height: 52px; border-radius: 12px; border: 1px solid transparent;
  background: var(--accent); color: var(--accent-ink);
  font-size: 16px; font-weight: 650; letter-spacing: -.01em;
  transition: filter .15s, background .15s, transform .06s;
}
.arm-btn:hover { filter: brightness(1.07); }
.arm-btn:active { transform: scale(.988); }
.arm-btn svg { width: 19px; height: 19px; stroke-width: 2.1; }
.arm-btn.on { background: color-mix(in srgb, var(--down) 12%, var(--card)); color: var(--down); border-color: color-mix(in srgb, var(--down) 42%, transparent); }
/* inline flow, so the info icon hugs the end of the sentence instead of
   dropping to a line of its own when the text wraps */
.arm-hint { font-size: 11.5px; color: var(--text-3); margin-top: 9px; }
.arm-hint.warn { color: var(--warn); font-weight: 600; }
.info-btn {
  width: 18px; height: 18px; padding: 0; margin-left: 2px;
  border: 0; background: none; color: inherit; opacity: .65;
  display: inline-flex; align-items: center; justify-content: center;
  /* inline-flex sits on the text baseline by default, which reads low next to
     an 11.5px line — pull it onto the text's optical centre instead */
  vertical-align: middle;
  position: relative; top: -1px;
  transition: opacity .15s, color .15s;
}
.info-btn:hover { opacity: 1; color: var(--accent); }
.info-btn svg { width: 15px; height: 15px; stroke-width: 1.9; }

/* Stays centred at every width — the countdown reads best dead centre with the
   arm button directly beneath it. On wide screens the inner content is capped
   rather than stretched edge to edge. */
@media (min-width: 720px) {
  .hero-actions { max-width: 400px; margin-left: auto; margin-right: auto; }
  .session-bar  { max-width: 760px; margin-left: auto; margin-right: auto; }
  .count-value  { font-size: clamp(64px, 7vw, 92px); }
}

.session-bar { flex: 1; min-width: 0; }
.session-track { height: 5px; border-radius: 999px; background: var(--line); overflow: hidden; }
.session-fill  { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--live)); transition: width .5s linear; }
.session-legend {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 8px; margin-top: 6px;
  font-family: var(--mono); font-size: 11px; color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.session-legend > span { overflow: hidden; text-overflow: ellipsis; }
/* the bar is narrow once the two pills flank it — shrink rather than wrap */
@media (max-width: 620px) {
  .session-legend { font-size: 10px; gap: 5px; }
}
@media (max-width: 430px) {
  .session-legend #sbElapsed { display: none; }
}

/* ---------------- timeframe grid ---------------- */
.tf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 9px; margin-top: 13px; }
/* roomier cards once there's space, so sound names stop truncating */
@media (min-width: 860px) { .tf-grid { grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 10px; } }

.tf {
  position: relative;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--card-2);
  padding: 10px 11px 11px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.tf.on {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 6%, var(--card));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
}
.tf.ringing { animation: tfRing .55s ease-out; }
@keyframes tfRing {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 65%, transparent); }
  100% { box-shadow: 0 0 0 13px transparent; }
}

.tf-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tf-name { display: flex; align-items: baseline; cursor: pointer; user-select: none; min-width: 0; }
.tf-name b {
  font-size: 16.5px; font-weight: 650; letter-spacing: -.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* clock face marks a fixed-time alert apart from a candle length at a glance.
   align-self, because .tf-name aligns on the baseline and an svg has none. */
.tf-kind {
  width: 13px; height: 13px; flex: none; align-self: center;
  margin-right: 5px; color: var(--text-3); stroke-width: 2.1;
}
.tf.on .tf-kind { color: var(--accent); }

.tf-del {
  position: absolute; top: -7px; right: -7px;
  width: 21px; height: 21px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--text-3);
  display: none; align-items: center; justify-content: center; padding: 0;
  box-shadow: var(--shadow);
}
.tf-del svg { width: 11px; height: 11px; stroke-width: 2.4; }
.tf:hover .tf-del { display: flex; }
.tf-del:hover { color: var(--down); border-color: var(--down); }

/* toggle */
/* .tgl is a <label>, not a <span>, on purpose. Safari keeps a native checkbox's
   real hit-box (and pointer cursor) at its intrinsic ~16px on the LEFT even when
   CSS stretches the visual to 38x22 — so on Safari the switch only enabled, and
   only showed the hand cursor, when you clicked the left edge. Chrome stretches
   the hit-box, hiding the bug. A <label> toggles the input by association from a
   click anywhere on it, and cursor:pointer here makes the hand span the whole
   control. (Separate from the v14 consent-bar overlap fix — both were real.) */
.tgl { position: relative; width: 38px; height: 22px; flex: none; cursor: pointer; }
.tgl input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 2; }
.tgl span {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--line); transition: background .18s;
}
.tgl span::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.28);
  transition: transform .18s cubic-bezier(.3,1.4,.5,1);
}
.tgl input:checked + span { background: var(--accent); }
.tgl input:checked + span::after { transform: translateX(16px); }
.tgl input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.tf-next {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 12px; color: var(--text-3);
  margin: 7px 0 8px; display: flex; justify-content: space-between; gap: 6px;
}
.tf.on .tf-next { color: var(--text-2); }
.tf-next b { font-weight: 600; color: var(--text); }
.tf:not(.on) .tf-next b { color: var(--text-3); font-weight: 500; }

.tf-sound { display: flex; gap: 6px; }
.tf-sound select { flex: 1; min-width: 0; height: 32px; font-size: 12px; padding: 0 22px 0 8px; background-position: right 6px center; background-size: 14px; }

/* per-timeframe lead time ("beep N seconds before the close") */
.tf-lead { position: relative; margin-top: 6px; }
.tf-lead::before {
  content: ""; position: absolute; left: 9px; top: 50%; width: 13px; height: 13px;
  transform: translateY(-50%); pointer-events: none; opacity: .75;
  background: currentColor; color: var(--text-3);
  -webkit-mask: var(--clock-ico) center / contain no-repeat;
          mask: var(--clock-ico) center / contain no-repeat;
}
.tf.on .tf-lead::before { color: var(--accent); }
.tf-lead select {
  width: 100%; height: 32px; font-size: 12.5px;
  padding: 0 26px 0 27px;
  background-color: var(--card);
}
.tf.on .tf-lead select { border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }

/* per-timeframe screen flash — the swatch shows the chosen colour */
.tf-flash { position: relative; margin-top: 6px; }
.tf-flash::before {
  content: ""; position: absolute; left: 9px; top: 50%;
  width: 12px; height: 12px; border-radius: 50%;
  transform: translateY(-50%); pointer-events: none;
  background: var(--sw, transparent);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .12) inset;
}
.tf-flash.none::before {
  background: transparent;
  border: 1.5px dashed var(--text-3);
  opacity: .5;
  box-shadow: none;
}
.tf-flash select {
  width: 100%; height: 32px; font-size: 12.5px;
  padding: 0 26px 0 27px;
  background-color: var(--card);
}
.tf.on .tf-flash select { border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
:root { --clock-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.5V12l3 2'/%3E%3C/svg%3E"); }
.play-btn {
  width: 32px; height: 32px; flex: none; padding: 0;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
}
.play-btn:hover { color: var(--accent); border-color: var(--accent); }
.play-btn svg { width: 14px; height: 14px; }

/* ---------------- form controls ---------------- */
.field { margin-top: 13px; }
.field > label {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 12px; font-weight: 600; color: var(--text-2);
  margin-bottom: 5px; letter-spacing: .005em;
}
.field .val { font-family: var(--mono); font-weight: 500; color: var(--text-3); }

input[type="time"], input[type="number"], select, textarea {
  width: 100%; height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--card-2); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  font-size: 14.5px;
}
textarea { height: auto; padding: 9px 11px; resize: vertical; font-size: 13.5px; font-family: var(--mono); line-height: 1.5; }
input[type="time"] { font-family: var(--mono); font-variant-numeric: tabular-nums; }
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b95a5' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 15px;
}
[data-theme="dark"] select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7889' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
:is(input, select, textarea):focus-visible {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.grid-2 .field { margin-top: 13px; }

/* session settings pair up once there's room, instead of stacking full-width */
@media (min-width: 700px) {
  .fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; align-items: start; }
  .fields > .field, .fields > .grid-2 { min-width: 0; }
}
.sub-block { margin-left: 50px; }
@media (max-width: 460px) { .sub-block { margin-left: 0; } }

.hint { font-size: 11.5px; color: var(--text-3); margin-top: 5px; line-height: 1.45; }
.hint code { font-family: var(--mono); font-size: 11px; background: var(--card-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; }

.inline-input { display: flex; align-items: center; gap: 8px; }
.inline-input input { flex: 1; min-width: 0; }
.unit { font-size: 12.5px; color: var(--text-3); white-space: nowrap; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; background: transparent; padding: 0; border: 0;
}
input[type="range"]::-webkit-slider-runnable-track { height: 5px; border-radius: 999px; background: var(--line); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 19px; height: 19px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--card); margin-top: -7px;
  box-shadow: 0 1px 4px rgba(0,0,0,.28);
}
input[type="range"]::-moz-range-track { height: 5px; border-radius: 999px; background: var(--line); }
input[type="range"]::-moz-range-thumb {
  width: 19px; height: 19px; border-radius: 50%; border: 3px solid var(--card);
  background: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.28);
}

/* trading days */
.days { display: flex; gap: 5px; }
.day {
  flex: 1 1 0; min-width: 0; padding: 0 2px;
  height: 36px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--card-2);
  color: var(--text-3); font-size: 12px; font-weight: 600;
  transition: all .15s;
}
.day.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 50%, transparent); color: var(--accent); }

/* switches */
.switch {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 0; cursor: pointer;
  border-top: 1px solid var(--line-soft);
  margin-top: 13px;
}
.switch:first-of-type { }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  position: relative; width: 38px; height: 22px; flex: none; margin-top: 1px;
  border-radius: 999px; background: var(--line); transition: background .18s;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.28);
  transition: transform .18s cubic-bezier(.3,1.4,.5,1);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.switch-text strong { font-size: 13.5px; font-weight: 600; }
.switch-text em { font-style: normal; font-size: 11.5px; color: var(--text-3); line-height: 1.4; }

/* "add timeframe" tile — sits in the grid as one more box */
.tf-add {
  border: 1.5px dashed var(--line);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-3);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 5px;
  padding: 14px 10px;
  text-align: center;
  transition: border-color .15s, color .15s, background .15s;
}
.tf-add:hover {
  border-color: var(--accent); color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}
.tf-add svg { width: 22px; height: 22px; stroke-width: 2; }
.tf-add span { font-size: 13px; font-weight: 650; }
.tf-add em { font-style: normal; font-size: 10.5px; opacity: .8; line-height: 1.3; }

.mini-btn {
  height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card-2); color: var(--text-2);
  font-size: 12.5px; font-weight: 600;
  transition: all .15s;
}
.mini-btn:hover { color: var(--text); border-color: var(--text-3); }
.mini-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.mini-btn.primary:hover { filter: brightness(1.08); color: var(--accent-ink); }
.mini-btn.danger { color: var(--down); border-color: color-mix(in srgb, var(--down) 35%, var(--line)); margin-top: 16px; width: 100%; height: 38px; }
.mini-btn.danger:hover { background: color-mix(in srgb, var(--down) 10%, transparent); border-color: var(--down); color: var(--down); }

.tz-chip {
  font-family: var(--mono); font-size: 11px; color: var(--text-3);
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 9px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 55%;
}

/* details */
details summary {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; list-style: none; gap: 8px;
}
details summary::-webkit-details-marker { display: none; }
.chev { width: 9px; height: 9px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(45deg); transition: transform .2s; margin-right: 3px; margin-bottom: 3px; }
details[open] .chev { transform: rotate(-135deg); margin-bottom: -2px; }
.details-body { margin-top: 4px; }

/* log */
.log-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.log-tab {
  height: 28px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card-2); color: var(--text-2);
  font-size: 12px; font-weight: 600; white-space: nowrap;
  transition: background .14s, color .14s, border-color .14s;
}
.log-tab:hover { color: var(--text); border-color: var(--text-3); }
.log-tab.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.log-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.log { list-style: none; margin: 11px 0 0; padding: 0; max-height: 232px; overflow-y: auto; }
.log li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 2px; border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.log li:last-child { border-bottom: 0; }
.log-time { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 12.5px; }
.log-tf {
  font-family: var(--mono); font-size: 11px; font-weight: 650;
  padding: 2px 7px; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent);
  white-space: nowrap;
}
/* clock alerts get a neutral chip so a 3:10 PM row can't be mistaken for a
   candle length at a glance */
.log-tf.is-time {
  background: var(--card-2); color: var(--text-2);
  box-shadow: 0 0 0 1px var(--line) inset;
}
.log-sound { color: var(--text-2); font-size: 12px; }
.log-sound.muted { color: var(--warn); font-style: italic; }
.log-note { color: var(--text-3); font-size: 12px; margin-left: auto; }
.log-empty { color: var(--text-3); font-size: 12.5px; justify-content: center; border: 0 !important; }

/* footer */
.foot { text-align: center; font-size: 11.5px; color: var(--text-3); line-height: 1.6; padding: 4px 6px 0; }
.foot-warn { margin-top: 5px; opacity: .8; }
.foot-links {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 8px 16px; margin-top: 14px; padding-top: 13px;
  border-top: 1px solid var(--line-soft);
}
.foot-links a {
  color: var(--text-2); text-decoration: none; font-size: 12.5px; font-weight: 550;
  border-radius: 5px; transition: color .15s;
}
.foot-links a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.foot-links a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.foot-copy { margin-top: 11px; font-size: 11.5px; opacity: .85; }

/* ---------------- static content pages ---------------- */
.prose { max-width: 760px; margin: 0 auto; }
.prose .card { padding: 22px; }
@media (max-width: 480px) { .prose .card { padding: 16px; } }
.prose h1 { font-size: 25px; font-weight: 680; letter-spacing: -.02em; margin-bottom: 4px; }
.prose .lede { font-size: 14px; color: var(--text-2); line-height: 1.6; margin-bottom: 4px; }
.prose h2 {
  font-size: 15.5px; margin-top: 26px; margin-bottom: 7px;
  padding-top: 18px; border-top: 1px solid var(--line-soft);
}
.prose h2:first-of-type { border-top: 0; padding-top: 0; margin-top: 20px; }
.prose p, .prose li { font-size: 14px; color: var(--text-2); line-height: 1.7; }
.prose p { margin-bottom: 11px; }
.prose ul { margin: 8px 0 13px; padding-left: 20px; }
.prose li { margin-bottom: 6px; }
.prose strong { color: var(--text); font-weight: 620; }
.prose a { color: var(--accent); text-decoration: none; }
.prose a:hover { text-decoration: underline; text-underline-offset: 3px; }
.prose .updated { font-size: 12px; color: var(--text-3); margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  text-decoration: none; margin-bottom: 14px;
}
.back-link:hover { color: var(--accent); }
.back-link svg { width: 15px; height: 15px; }

/* flash overlay */
.flash {
  position: fixed; inset: 0; z-index: 90; pointer-events: none;
  background: var(--accent); opacity: 0;
}
.flash.go { animation: flashPulse .95s ease-out; }
/* three distinct pulses — one blink is easy to miss out of the corner of an eye */
@keyframes flashPulse {
  0%   { opacity: .32; }
  13%  { opacity: 0;   }
  26%  { opacity: .32; }
  39%  { opacity: 0;   }
  52%  { opacity: .32; }
  70%  { opacity: 0;   }
  100% { opacity: 0;   }
}

/* dialog */
.dlg {
  width: min(560px, calc(100vw - 28px));
  max-height: min(78vh, 700px);
  padding: 0; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--card); color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.dlg::backdrop { background: rgba(8,12,18,.5); backdrop-filter: blur(3px); }
.dlg-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--card);
}
.dlg-head h2 { font-size: 16px; }
.dlg-head .icon-btn { padding: 0; width: 32px; height: 32px; justify-content: center; }
.dlg-sm { width: min(400px, calc(100vw - 28px)); }
.dlg-body { padding: 6px 16px 18px; overflow-y: auto; max-height: calc(78vh - 60px); }
.dlg-lead { font-size: 13.5px; color: var(--text-2); margin: 10px 0 12px; line-height: 1.55; }

/* segmented control — candle length vs clock time in the add dialog */
.seg {
  display: flex; gap: 4px; margin-top: 12px; padding: 4px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card-2);
}
.seg-btn {
  flex: 1 1 0; min-width: 0; height: 36px; padding: 0 8px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 7px; background: transparent;
  color: var(--text-3); font-size: 12.5px; font-weight: 600;
  white-space: nowrap; transition: background .15s, color .15s, box-shadow .15s;
}
.seg-btn svg { width: 14px; height: 14px; flex: none; stroke-width: 2; }
.seg-btn:hover { color: var(--text-2); }
.seg-btn.on {
  background: var(--card); color: var(--accent);
  box-shadow: 0 1px 2px rgba(8, 12, 18, .12);
}
.seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (max-width: 380px) {
  .seg-btn { font-size: 11.5px; gap: 4px; }
  .seg-btn svg { width: 13px; height: 13px; }
}

.add-row { display: flex; gap: 9px; }
.add-row input { flex: 1 1 auto; min-width: 0; height: 46px; font-size: 19px; font-family: var(--mono); text-align: center; }
.add-row select { flex: 0 0 128px; height: 46px; }
/* a lone time field would stretch the full width and read as a text box */
#addTimePane .add-row input { max-width: 190px; margin-inline: auto; }
.sub-hint { margin-top: 8px; }
#addPreview { min-height: 32px; margin-top: 9px; }
#addPreview.bad { color: var(--down); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.dlg-actions .mini-btn { height: 38px; padding: 0 16px; }
.dlg-actions .mini-btn[disabled] { opacity: .45; pointer-events: none; }
/* the shared .mini-btn.danger is full-width for the reset button; inside a
   dialog's action row it must be an inline, filled destructive button */
.dlg-actions .mini-btn.danger {
  width: auto; margin-top: 0;
  background: var(--down); border-color: var(--down); color: #fff;
}
.dlg-actions .mini-btn.danger:hover { filter: brightness(1.06); background: var(--down); color: #fff; }
.dlg-body h3 { margin-top: 16px; margin-bottom: 6px; color: var(--text); }
.dlg-body p, .dlg-body li { font-size: 13.5px; color: var(--text-2); line-height: 1.6; }
.dlg-body p { margin-bottom: 6px; }
.dlg-body ul { margin: 4px 0; padding-left: 19px; }
.dlg-body li { margin-bottom: 5px; }
.dlg-body em { font-style: normal; font-weight: 600; color: var(--text); }
.ios-share { font-family: var(--sans); }

/* ---- cookie consent bar (EEA/UK only) ---- */
/* Dims the page behind the consent bar so a first-time visitor answers it
   before touching the app. Without it the fixed bar covered the timeframe
   toggles and ate the taps — a real "the switch does nothing" bug for EEA/UK
   users and anyone in a private window. z-index sits just under .consent-bar. */
.consent-backdrop {
  position: fixed; inset: 0; z-index: 94;
  background: rgba(8, 12, 18, .38);
  animation: consentFade .2s ease-out;
}
@keyframes consentFade { from { opacity: 0; } to { opacity: 1; } }
[data-theme="dark"] .consent-backdrop { background: rgba(0, 0, 0, .55); }
.consent-bar {
  position: fixed; z-index: 95;
  left: 50%; transform: translateX(-50%);
  bottom: max(14px, env(safe-area-inset-bottom));
  width: min(680px, calc(100vw - 24px));
  display: flex; align-items: center; gap: 16px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  animation: consentIn .28s ease-out;
}
@keyframes consentIn {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.consent-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.consent-text strong { font-size: 13.5px; color: var(--text); }
.consent-text span { font-size: 12px; color: var(--text-2); line-height: 1.5; }
.consent-text a { color: var(--accent); text-decoration: none; }
.consent-text a:hover { text-decoration: underline; text-underline-offset: 2px; }
.consent-actions { display: flex; gap: 8px; flex: none; }
.consent-actions .mini-btn { height: 36px; padding: 0 15px; }
@media (max-width: 560px) {
  .consent-bar { flex-direction: column; align-items: stretch; gap: 12px; }
  .consent-actions .mini-btn { flex: 1; }
}

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  z-index: 100; pointer-events: none;
  max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: 999px;
  background: var(--text); color: var(--card);
  font-size: 13px; font-weight: 550;
  box-shadow: var(--shadow-lg);
  opacity: 0; transition: opacity .22s, transform .22s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* claw back gutter space on small phones */
@media (max-width: 420px) {
  .wrap { --gutter: 9px; }
  .card { padding: 13px; }
  .hero { padding: 15px 13px 13px; }
  .tf-grid { gap: 8px; }
  /* two cards per row here, so shave the controls to stop labels clipping */
  .tf { padding: 9px 9px 10px; }
  .tf-sound { gap: 5px; }
  .tf-sound select, .tf-lead select, .tf-flash select { font-size: 11.5px; }
  .play-btn { width: 30px; }
  .tf-lead select, .tf-flash select { padding-left: 25px; }
}

@media (min-width: 620px) {
  body { font-size: 15px; }
  .card { padding: 18px; }
  .hero { padding: 22px 20px 18px; }
}

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