/* ============ tokens ============ */
/* The four theme colours are registered so a theme change can fade instead of snapping. */
@property --bg { syntax: '<color>'; inherits: true; initial-value: #000000; }
@property --card { syntax: '<color>'; inherits: true; initial-value: #121212; }
@property --digit { syntax: '<color>'; inherits: true; initial-value: #b3b3b3; }
@property --accent { syntax: '<color>'; inherits: true; initial-value: #d4e157; }
html.theme-anim { transition: --bg .45s ease, --card .45s ease, --digit .45s ease, --accent .45s ease; }

:root {
  --bg: #000;
  --card: #121212;
  --digit: #b3b3b3;
  --accent: #d4e157;
  --on-accent: #111;
  --glow: .6;
  --danger: #ff6b6b;
  --ui-font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --digit-font: 'Barlow Semi Condensed', system-ui, sans-serif;
  --digit-weight: 700;
  --ls: 0em;
  color-scheme: dark;
}
/* Derived colours. Re-declared on .themed so a template preview can carry its own theme. */
:root, .themed {
  --text: var(--digit);
  --muted: color-mix(in srgb, var(--digit) 70%, var(--bg));
  --faint: color-mix(in srgb, var(--digit) 32%, var(--bg));
  --line: color-mix(in srgb, var(--digit) 14%, transparent);
  --surface: var(--card);
  --surface-2: color-mix(in srgb, var(--card) 88%, var(--digit));
  --sheet: color-mix(in srgb, var(--card) 96%, var(--digit));
}
:root[data-scheme='light'] {
  color-scheme: light;
  --danger: #c62828;
  --surface-2: color-mix(in srgb, var(--card) 90%, var(--digit));
  --sheet: var(--card);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 var(--ui-font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
input, textarea, select { -webkit-user-select: text; user-select: text; font: inherit; color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .3; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg.i { width: 22px; height: 22px; display: block; flex: none; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ============ main layout: a grid of content + navigation ============ */
:root { --g: 12px; } /* the grid gutter used everywhere */
.app {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "main" "nav";
}
.app.landscape {
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "nav main";
}
.views { grid-area: main; position: relative; min-width: 0; min-height: 0; }
.tabbar { grid-area: nav; }
.view { position: absolute; inset: 0; display: flex; flex-direction: column; }
.view-clock {
  gap: 10px;
  padding:
    calc(env(safe-area-inset-top) + 10px)
    calc(env(safe-area-inset-right) + 14px)
    10px
    14px;
}
.app:not(.landscape) .view-clock { padding-left: calc(env(safe-area-inset-left) + 14px); }
.view-home, .view-stats {
  display: block;
  container-type: inline-size;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--digit) 22%, transparent) transparent;
  padding:
    calc(env(safe-area-inset-top) + 14px)
    calc(env(safe-area-inset-right) + 16px)
    28px
    16px;
}
.app:not(.landscape) .view-home, .app:not(.landscape) .view-stats { padding-left: calc(env(safe-area-inset-left) + 16px); }

.chrome, .controls { transition: opacity .45s ease; }
.app.chrome-hidden .chrome, .app.chrome-hidden .view-clock .controls { opacity: 0; pointer-events: none; }
.app.chrome-hidden { cursor: none; }

/* Full-screen clock: the face covers the screen and the controls float over it
   (tap to show, like a video player). Nothing underneath moves. */
.app.immersive .tabbar { display: none; }
.app.immersive .view-clock {
  gap: 0;
  padding:
    calc(env(safe-area-inset-top) + 8px)
    calc(env(safe-area-inset-right) + 8px)
    calc(env(safe-area-inset-bottom) + 8px)
    calc(env(safe-area-inset-left) + 8px);
}
.app.immersive .stage { gap: 0; }
.app.immersive .view-clock .topbar {
  position: absolute; z-index: 6; top: 0; left: 0; right: 0;
  padding: calc(env(safe-area-inset-top) + 10px) calc(env(safe-area-inset-right) + 14px) 36px calc(env(safe-area-inset-left) + 14px);
  background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 88%, transparent), transparent);
}
.app.immersive .view-clock .topbar .icon-btn { background: color-mix(in srgb, var(--card) 80%, transparent); color: var(--text); }
.app.immersive .view-clock .controls {
  position: absolute; z-index: 6; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 18px);
  flex-direction: row;
  gap: 10px; padding: 8px;
  border-radius: 26px;
  background: color-mix(in srgb, var(--card) 86%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5), inset 0 0 0 1px var(--line);
  transform: translateX(-50%);
  transition: opacity .3s ease, transform .3s ease;
}
.app.immersive .view-clock .controls .ctl { background: var(--surface-2); }
.app.immersive .view-clock .controls .ctl-play { order: 0; background: var(--accent); color: var(--on-accent); }
.app.immersive .view-clock .info {
  position: absolute; z-index: 5; left: 0; right: 0; bottom: 0;
  padding: 60px 20px calc(env(safe-area-inset-bottom) + 100px);
  background: linear-gradient(to top, color-mix(in srgb, var(--bg) 90%, transparent) 45%, transparent);
  pointer-events: none;
}
.app.immersive .view-clock .info .progress { display: none; }
.app.immersive .view-clock .info-row { justify-content: center; gap: 20px; color: var(--text); }
.app.immersive:not(.overlay-on) .view-clock :is(.topbar, .info, .controls) { opacity: 0; pointer-events: none; }
.app.immersive:not(.overlay-on) .view-clock .controls { transform: translate(-50%, 16px); }
.app.immersive:not(.overlay-on) { cursor: none; }


/* bottom tab bar (a side rail when the phone is sideways) */
.tabbar {
  flex: none;
  display: flex;
  justify-content: space-around;
  gap: 2px;
  padding: 6px calc(env(safe-area-inset-right) + 4px) calc(env(safe-area-inset-bottom) + 6px) calc(env(safe-area-inset-left) + 4px);
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.landscape .tabbar {
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 6px calc(env(safe-area-inset-bottom) + 8px) calc(env(safe-area-inset-left) + 6px);
  border-top: 0;
  border-right: 1px solid var(--line);
}
.tab {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  max-width: 96px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 3px 0 2px;
  color: var(--muted);
  font-size: 11px; font-weight: 600;
  transition: color .2s;
}
.landscape .tab { flex: none; width: auto; min-width: 72px; padding-left: 6px; padding-right: 6px; }
/* Phones held sideways: an icon-only rail keeps things tidy (labels stay for screen readers). */
@media (max-height: 540px) {
  .landscape .tab { min-width: 0; width: 60px; padding: 0; }
  .landscape .tab-ic { width: 48px; height: 42px; border-radius: 14px; }
  .landscape .tab-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .landscape .tab.live::after, .landscape .tab.paused::after { top: 0; left: calc(50% + 14px); }
  .landscape .tabbar { gap: 10px; }
}
.tab-ic { display: grid; place-items: center; width: 54px; height: 30px; border-radius: 15px; transition: background .25s; }
.tab-ic svg.i { width: 22px; height: 22px; }
.tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab[aria-selected='true'] { color: var(--text); }
.tab[aria-selected='true'] .tab-ic { background: color-mix(in srgb, var(--accent) 22%, var(--card)); color: var(--text); }
.tab.live::after, .tab.paused::after {
  content: '';
  position: absolute; top: 2px; left: calc(50% + 12px);
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--bg);
}
.tab.live::after { animation: pulse 1.6s ease-in-out infinite; }
.tab.paused::after { background: var(--bg); box-shadow: inset 0 0 0 2px var(--accent), 0 0 0 2px var(--bg); }
@keyframes pulse { 50% { opacity: .35; } }

/* top bar */
.topbar { display: grid; align-items: center; gap: 10px; grid-template-columns: 1fr auto 1fr; }
.topbar .pill { justify-self: center; }
.topbar > :first-child { justify-self: start; }
.topbar-right { justify-self: end; display: flex; gap: 2px; }

.icon-btn {
  width: 44px; height: 44px;
  display: inline-grid; place-items: center;
  border-radius: 14px;
  color: var(--muted);
  transition: background .2s, color .2s;
}
.icon-btn:hover:not(:disabled) { color: var(--text); background: var(--surface); }
.icon-btn:active:not(:disabled) { background: var(--surface-2); }

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; max-width: 100%;
  padding: 0 10px 0 14px;
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px; font-weight: 600;
}
.pill .dot { width: 11px; height: 11px; }
.pill-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw; }
.pill svg.i { width: 16px; height: 16px; color: var(--muted); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--c, var(--accent)); }

/* segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 13px; background: var(--surface); max-width: 100%; }
.seg > button {
  height: 30px; padding: 0 12px;
  border-radius: 10px;
  font-size: 13px; font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: background .2s, color .2s;
}
.seg > button:hover { color: var(--text); }
.seg > button[aria-checked='true'], .seg > button[aria-selected='true'] { background: var(--surface-2); color: var(--text); }

/* stage */
.stage { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; gap: 16px; }
.layout-row .stage { flex-direction: row; gap: 18px; }
.clock {
  flex: 1 1 0; min-width: 0; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--gap, 12px);
  cursor: pointer;
}
.layout-row .clock { flex-direction: row; }

.controls { flex: none; display: flex; align-items: center; justify-content: center; gap: 14px; }
.layout-row .controls { flex-direction: column; }
.layout-row .ctl-play { order: -1; }
.ctl {
  --s: clamp(52px, 5vmin + 30px, 66px);
  width: var(--s); height: var(--s);
  border-radius: calc(var(--s) * .3);
  background: var(--card);
  color: var(--digit);
  display: grid; place-items: center;
  transition: transform .12s ease, background .2s;
}
.ctl svg.i { width: 42%; height: 42%; }
.ctl:hover { background: var(--surface-2); }
.ctl:active { transform: scale(.92); }

/* info footer */
.info { flex: none; display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.info-row { display: flex; justify-content: space-between; gap: 12px; min-height: 18px; }
.info-row span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { height: 3px; border-radius: 2px; background: var(--surface); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .6s ease; }

/* ============ flip cards ============ */
.card {
  position: relative;
  flex: none;
  width: var(--cw, 200px);
  height: var(--ch, 200px);
  border-radius: var(--r, 18px);
  perspective: calc(var(--ch, 200px) * 3.2);
  font-family: var(--digit-font);
  font-weight: var(--digit-weight);
  font-size: var(--fs, 120px);
  letter-spacing: var(--ls);
  color: var(--digit);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  transition: color .4s;
}
.half, .leaf { position: absolute; left: 0; right: 0; height: 50%; overflow: hidden; background: var(--card); }
.upper, .leaf-up { top: 0; border-radius: var(--r) var(--r) 0 0; }
.lower, .leaf-down { bottom: 0; border-radius: 0 0 var(--r) var(--r); }
.num {
  position: absolute; left: 0; right: 0;
  height: var(--ch);
  line-height: var(--ch);
  text-align: center;
  white-space: nowrap;
  transform: translate(calc(var(--ls) / 2), var(--dy, 0px));
}
.upper .num, .leaf-up .num { top: 0; }
.lower .num, .leaf-down .num { bottom: 0; }
.card.wide .num { font-size: var(--fs3); transform: translate(calc(var(--ls) / 2), var(--dy3, 0px)); }
.leaf { visibility: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; will-change: transform; z-index: 2; }
.leaf-up { transform-origin: 50% 100%; }
.leaf-down { transform-origin: 50% 0; }
.card.flipping .leaf { visibility: visible; }
.shade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; }
.card::after {
  content: '';
  position: absolute; left: 0; right: 0; top: 50%;
  height: var(--hinge, 3px);
  transform: translateY(-50%);
  background: var(--bg);
  z-index: 3;
}
.no-hinge .card::after { display: none; }

.clock.done :is(.num, .mn, .led, .nx, .rg-time) { animation: blink 1.1s steps(1, end) infinite; }
@keyframes blink { 50% { opacity: .25; } }
.view-clock.is-break .clock { --ink: color-mix(in srgb, var(--accent) 75%, var(--digit)); }
.card { color: var(--ink, var(--digit)); }

/* ============ other clock faces ============ */
@keyframes sepblink { 50% { opacity: .2; } }

/* Minimal */
.mn {
  display: flex; align-items: center; justify-content: center;
  color: var(--ink, var(--digit));
  font-family: var(--digit-font); font-weight: var(--digit-weight);
  font-size: var(--mfs, 80px); line-height: var(--mlh, 1);
  letter-spacing: var(--ls);
  font-variant-numeric: tabular-nums; font-feature-settings: 'tnum';
}
.mn.col { flex-direction: column; }
.mn.col .mn-sep { display: none; }
.mn-g { display: flex; transform: translateY(var(--mdy, 0px)); }
.mn-d { display: inline-block; }
.mn-sep { color: var(--faint); padding: 0 .05em; transform: translateY(calc(var(--mdy, 0px) - .05em)); }
.mn.running .mn-sep { animation: sepblink 1s steps(1, end) infinite; }

/* LED seven-segment */
.led {
  display: flex; align-items: center; justify-content: center;
  gap: calc(var(--lh, 60px) * .12);
  padding: calc(var(--lh, 60px) * .16) calc(var(--lh, 60px) * .22);
  border-radius: calc(var(--lh, 60px) * .16);
  background: color-mix(in srgb, var(--card) 80%, #000);
  box-shadow: inset 0 0 0 1px var(--line), inset 0 calc(var(--lh, 60px) * .05) calc(var(--lh, 60px) * .25) rgba(0, 0, 0, .55);
}
.led.col { flex-direction: column; }
.led.col .led-sep { display: none; }
.led { --ledc: var(--face, var(--accent)); }
.led-g {
  height: var(--lh, 60px); width: auto; overflow: visible;
  filter: drop-shadow(0 0 calc(var(--lh, 60px) * .06 * var(--glow, .6)) color-mix(in srgb, var(--ledc) 70%, transparent));
}
.led .s { fill: color-mix(in srgb, var(--ledc) 8%, transparent); transition: fill .08s; }
.led .s.on { fill: var(--ledc); }
.no-ghost .led .s:not(.on) { fill: transparent; }
.led-sep { display: flex; flex-direction: column; gap: calc(var(--lh, 60px) * .26); }
.led-sep i { width: calc(var(--lh, 60px) * .1); height: calc(var(--lh, 60px) * .1); border-radius: 2px; background: var(--ledc); box-shadow: 0 0 calc(var(--lh, 60px) * .1 * var(--glow, .6)) var(--ledc); }
.led.running .led-sep { animation: sepblink 1s steps(1, end) infinite; }

/* Nixie tubes (warm orange by default, like the real thing) */
.nx { --nxc: var(--face, #ff8a1e); display: flex; align-items: center; justify-content: center; gap: calc(var(--tw, 40px) * .28); }
.nx.col { flex-direction: column; gap: calc(var(--tw, 40px) * .2); }
.nx.col .nx-sep { display: none; }
.nx-g { display: flex; gap: calc(var(--tw, 40px) * .1); }
.nx-t {
  position: relative;
  width: var(--tw, 40px); height: var(--th, 66px);
  border-radius: calc(var(--tw, 40px) * .5) calc(var(--tw, 40px) * .5) calc(var(--tw, 40px) * .16) calc(var(--tw, 40px) * .16);
  background:
    repeating-linear-gradient(90deg, color-mix(in srgb, var(--nxc) 6%, transparent) 0 1px, transparent 1px calc(var(--tw, 40px) * .08)),
    repeating-linear-gradient(0deg, color-mix(in srgb, var(--nxc) 6%, transparent) 0 1px, transparent 1px calc(var(--tw, 40px) * .08)),
    radial-gradient(120% 70% at 50% 40%, color-mix(in srgb, var(--nxc) 15%, transparent), transparent 65%),
    linear-gradient(90deg, rgba(255, 255, 255, .07), transparent 22% 78%, rgba(255, 255, 255, .05)),
    color-mix(in srgb, var(--nxc) 5%, #070707);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--nxc) 18%, transparent), inset 0 calc(var(--th, 66px) * -.07) calc(var(--th, 66px) * .1) rgba(0, 0, 0, .7), 0 calc(var(--th, 66px) * .03) 0 #1b1b1b;
  font-family: 'Barlow Semi Condensed', system-ui, sans-serif; font-weight: 300;
  font-size: calc(var(--th, 66px) * .68); line-height: var(--th, 66px);
}
.nx-t span { position: absolute; inset: 0; text-align: center; color: color-mix(in srgb, var(--nxc) 9%, transparent); }
.no-ghost .nx-t span:not(.on) { color: transparent; }
.nx-t span.on {
  color: color-mix(in srgb, var(--nxc) 40%, #fff);
  text-shadow: 0 0 .02em #fff8, 0 0 calc(.08em * var(--glow, .6)) var(--nxc), 0 0 calc(.24em * var(--glow, .6)) var(--nxc), 0 0 calc(.6em * var(--glow, .6)) color-mix(in srgb, var(--nxc) 55%, transparent);
}
.nx-sep { display: flex; flex-direction: column; gap: calc(var(--th, 66px) * .22); }
.nx-sep i { width: calc(var(--tw, 40px) * .11); height: calc(var(--tw, 40px) * .11); border-radius: 50%; background: color-mix(in srgb, var(--nxc) 55%, #fff); box-shadow: 0 0 calc(var(--tw, 40px) * .12 * var(--glow, .6)) var(--nxc), 0 0 calc(var(--tw, 40px) * .3 * var(--glow, .6)) color-mix(in srgb, var(--nxc) 60%, transparent); }
.nx.running .nx-sep { animation: sepblink 1s steps(1, end) infinite; }

/* Ring */
.rg { position: relative; width: var(--rd, 200px); height: var(--rd, 200px); flex: none; }
.rg-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.rg-ticks line { stroke: var(--faint); stroke-width: .8; stroke-linecap: round; }
.rg-ticks line.major { stroke: var(--muted); stroke-width: 1.6; }
.rg-track { fill: none; stroke: var(--card); stroke-width: 7; }
.rg-arc { fill: none; stroke: var(--face, var(--accent)); stroke-width: 7; stroke-linecap: round; transition: stroke-dasharray .16s linear; }
.rg-dot { fill: var(--face, var(--accent)); filter: drop-shadow(0 0 4px var(--face, var(--accent))); transition: cx .16s linear, cy .16s linear; }
.no-ticks .rg-ticks { display: none; }
.rg.jump .rg-arc, .rg.jump .rg-dot { transition: none; }
.rg.empty .rg-dot { opacity: 0; }
.rg-mid { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.rg-time {
  font-family: var(--digit-font); font-weight: var(--digit-weight);
  font-size: var(--rfs, 40px); line-height: 1; letter-spacing: var(--ls);
  color: var(--ink, var(--digit));
  font-variant-numeric: tabular-nums; font-feature-settings: 'tnum';
}
.rg-label { margin-top: calc(var(--rd, 200px) * .035); font-size: var(--rls, 12px); color: var(--muted); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============ overlays ============ */
.overlay { position: fixed; inset: 0; z-index: 50; }
.backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); opacity: 0; transition: opacity .28s ease; }
.overlay.open .backdrop { opacity: 1; }
.overlay.closing { pointer-events: none; }

.panel { position: absolute; display: flex; flex-direction: column; background: var(--sheet); color: var(--text); }
.panel-head { display: flex; align-items: center; gap: 6px; padding: 10px 10px 6px 18px; flex: none; }
.panel-head h2 { flex: 1; margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.panel-body { overflow-y: auto; overscroll-behavior: contain; padding: 4px 18px 22px; -webkit-overflow-scrolling: touch; }

/* bottom sheet */
.sheet .panel {
  left: 0; right: 0; bottom: 0;
  margin: 0 auto;
  max-width: 560px;
  max-height: min(90dvh, 900px);
  border-radius: 24px 24px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  transform: translateY(100%);
  transition: transform .34s cubic-bezier(.2, .8, .2, 1);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .35);
}
.sheet.open .panel { transform: none; }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--faint); margin: 8px auto 0; flex: none; }
@media (min-width: 700px) and (min-height: 560px) {
  .sheet .panel { bottom: 50%; border-radius: 24px; transform: translateY(calc(50% + 40px)); opacity: 0; transition: transform .3s cubic-bezier(.2, .8, .2, 1), opacity .2s; }
  .sheet.open .panel { transform: translateY(50%); opacity: 1; }
  .grabber { display: none; }
}

/* full page */
.page .panel {
  inset: 0;
  background: var(--bg);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  transform: translateY(24px);
  opacity: 0;
  transition: transform .3s cubic-bezier(.2, .8, .2, 1), opacity .22s ease;
}
.page.open .panel { transform: none; opacity: 1; }
.page .panel-head { padding: 8px 12px 4px 6px; max-width: 1132px; width: 100%; margin: 0 auto; }
.page .panel-body {
  flex: 1;
  container-type: inline-size;
  padding: 6px 16px calc(env(safe-area-inset-bottom) + 32px);
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--digit) 22%, transparent) transparent;
}
.page .panel-body > * { max-width: 688px; margin-left: auto; margin-right: auto; }
.page .panel-body > .settings { max-width: 1100px; }
/* Settings: one column on phones, two balanced columns on wide screens */
.set-sec { break-inside: avoid; display: flow-root; }
@container (min-width: 760px) {
  .settings { column-count: 2; column-gap: 20px; }
  .settings .preview, .settings .footnote { column-span: all; }
  .settings .set-sec:first-of-type .group-title { margin-top: 18px; }
}

/* dialog */
.dialog .panel {
  left: 50%; top: 50%;
  width: min(360px, calc(100% - 40px));
  padding: 22px 20px 18px;
  border-radius: 22px;
  transform: translate(-50%, -50%) scale(.94);
  opacity: 0;
  transition: transform .22s cubic-bezier(.2, .8, .2, 1), opacity .18s;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.dialog.open .panel { transform: translate(-50%, -50%); opacity: 1; }
.dialog h3 { margin: 0 0 6px; font-size: 19px; font-weight: 700; }
.dialog p { margin: 0 0 4px; color: var(--muted); }
.dialog-actions { display: flex; gap: 10px; margin-top: 18px; }
.dialog-actions .btn { flex: 1; }

/* ============ controls in sheets ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 18px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px; font-weight: 600;
  white-space: nowrap;
  transition: filter .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn svg.i { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--danger); }
.btn.danger-fill { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px dashed var(--line); }
.btn.block { display: flex; width: 100%; margin-top: 12px; }
.btn.sm { height: 34px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 20px; }
.sheet-actions > * { flex: 1; }
.sheet-actions > span { flex: 0; }

.hint { color: var(--muted); margin: 0 0 12px; }
.hint.small { font-size: 13px; margin: 10px 0 0; }
.field { display: block; margin: 0 0 16px; }
.field-label { display: block; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; min-width: 0; }
.input, .select {
  width: 100%; height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.input:focus, .select:focus { border-color: var(--accent); }
.select { width: auto; min-width: 120px; height: 38px; padding: 0 10px; }
input[type='range'] { width: min(180px, 40vw); accent-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.center { justify-content: center; margin-top: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border-radius: 18px;
  background: var(--surface-2);
  font-size: 14px; font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.chip[aria-checked='true'] { background: var(--accent); color: var(--on-accent); }
.chip:active { transform: scale(.96); }

/* wheels */
.wheels { position: relative; display: flex; justify-content: center; gap: 4px; padding: 4px 0; }
.wheels::before {
  content: '';
  position: absolute; left: 0; right: 0; top: 50%;
  height: 42px; transform: translateY(-50%);
  border-radius: 12px;
  background: var(--surface-2);
  pointer-events: none;
}
.wheel { position: relative; display: flex; align-items: center; }
.wheel-scroll {
  height: 200px; width: 62px;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(transparent, #000 32%, #000 68%, transparent);
  mask-image: linear-gradient(transparent, #000 32%, #000 68%, transparent);
  overscroll-behavior: contain;
}
.wheel-scroll::-webkit-scrollbar { display: none; }
.wheel-pad { height: 80px; }
.wheel-item {
  height: 40px; line-height: 40px;
  text-align: center;
  scroll-snap-align: center;
  font-size: 24px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--faint);
  cursor: pointer;
  transition: color .15s;
}
.wheel-item.sel { color: var(--text); }
.wheel-label { width: 22px; font-size: 15px; font-weight: 600; color: var(--muted); }

/* switch */
.switch { position: relative; width: 50px; height: 30px; border-radius: 15px; background: var(--surface-2); transition: background .2s; flex: none; }
.switch i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s cubic-bezier(.3, .7, .4, 1); }
.switch[aria-checked='true'] { background: var(--accent); }
.switch[aria-checked='true'] i { transform: translateX(20px); }

/* stepper */
.stepper { display: inline-flex; align-items: center; border-radius: 12px; background: var(--surface-2); height: 36px; }
.stepper button { width: 38px; height: 36px; font-size: 20px; font-weight: 500; color: var(--text); border-radius: 12px; }
.stepper button:active { background: var(--line); }
.stepper output { min-width: 66px; text-align: center; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* settings-style groups */
.group-title { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 26px 4px 8px; }
.group { background: var(--card); border-radius: 18px; overflow: hidden; }
.group.pad { padding: 14px; }
.sheet .group { background: var(--surface); margin-top: 14px; }
.row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 14px; min-height: 54px; padding: 9px 14px; }
.row + .row { border-top: 1px solid var(--line); }
.row-label { flex: 1 1 140px; font-weight: 500; }
.row-label small { display: block; color: var(--muted); font-size: 12.5px; font-weight: 400; margin-top: 1px; }
.row-ctl { margin-left: auto; display: flex; align-items: center; }
.inline { display: flex; align-items: center; gap: 6px; }

/* ============ categories ============ */
.cat-list { display: flex; flex-direction: column; gap: 6px; }
.cat-row { display: flex; align-items: center; gap: 4px; border-radius: 16px; background: var(--surface); padding-right: 4px; }
.cat-row.sel { box-shadow: inset 0 0 0 1.5px var(--accent); }
.cat-pick { flex: 1; display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 8px 0 16px; text-align: left; min-width: 0; }
.cat-pick .dot { width: 12px; height: 12px; }
.cat-name { flex: 1; font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-meta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cat-check { color: var(--accent); width: 18px; height: 18px; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; width: 38px; height: 38px; border-radius: 50%; background: var(--c); }
.swatch[aria-pressed='true']::after, .swatch.custom:focus-within::after {
  content: ''; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--text);
}
.swatch.custom { background: conic-gradient(#f87171, #fbbf24, #4ade80, #22d3ee, #818cf8, #f472b6, #f87171); overflow: visible; cursor: pointer; }
.swatch.custom::before { content: ''; position: absolute; inset: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px var(--sheet); }
.swatch.custom input, .color-in input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }

/* ============ settings ============ */
.preview { display: flex; justify-content: center; padding: 10px 0 2px; }
.preview-clock { flex: none; flex-direction: row; cursor: default; }
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 10px; }
.theme-tile {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 12px 6px 9px;
  border-radius: 14px;
  background: var(--tb);
  border: 2px solid color-mix(in srgb, var(--td) 12%, transparent);
}
.theme-tile[aria-pressed='true'] { border-color: var(--accent); }
.tt-card { position: relative; padding: 2px 10px; border-radius: 8px; background: var(--tc); color: var(--td); font: 700 26px/1.2 var(--digit-font); }
.tt-card::after { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px; background: var(--tb); }
.tt-card::before { content: ''; position: absolute; top: -3px; right: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--ta); }
.tt-name { font-size: 12px; font-weight: 600; color: var(--td); opacity: .85; }
.color-in { position: relative; display: block; width: 44px; height: 30px; border-radius: 9px; background: var(--c); box-shadow: inset 0 0 0 1px var(--line); }
.face-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.face-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 8px 8px; border-radius: 14px; background: var(--surface-2); border: 2px solid transparent; min-width: 0; }
.face-tile[aria-pressed='true'] { border-color: var(--accent); }
.face-tile .face-mini { flex: none; width: 100%; height: 58px; cursor: inherit; pointer-events: none; overflow: hidden; contain: strict; }
.fonts { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.font-tile { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px 8px; border-radius: 14px; background: var(--surface-2); border: 2px solid transparent; }
.font-tile[aria-pressed='true'] { border-color: var(--accent); }
.ft-num { font-size: 34px; line-height: 1.15; color: var(--digit); }
.ft-name { font-size: 12px; color: var(--muted); font-weight: 600; }
.data-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.footnote { text-align: center; color: var(--faint); font-size: 12px; margin: 26px 0 0; }

/* ============ statistics ============ */
.view-head { display: flex; align-items: center; justify-content: space-between; max-width: 1200px; margin: 0 auto 14px; }
.view-head h1 { margin: 0; font-size: 28px; font-weight: 750; letter-spacing: -.02em; }
.view-stats .stats { max-width: 1200px; margin: 0 auto; }
.stats { padding-top: 4px; }
.hero-card { background: var(--card); border-radius: 20px; padding: 18px 18px 16px; }
.hero-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.hero { font-size: 48px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; margin: 2px 0 12px; }
.meter { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .3s ease; }
.hero-sub { color: var(--muted); font-size: 13px; margin-top: 8px; }
.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.hero-stats > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hero-stats span {
  font-size: 12px;
  color: var(--muted);
}
.hero-stats b {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.hero-stats small {
  font-size: 11px;
  color: var(--muted);
}
.stat-goal-tile {
  transition: opacity .15s ease, transform .15s ease;
}
.stat-goal-tile:hover {
  opacity: .9;
  transform: translateY(-1px);
}
.stat-goal-tile b {
  color: var(--accent);
}
.week-progress-box {
  margin: 6px 0 14px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 14px;
  border: 1px solid var(--line);
  transition: border-color .15s ease, background .15s ease;
}
.week-progress-box:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}
.week-progress-head, .hpb-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13.5px;
  margin-bottom: 7px;
}
.week-progress-head b, .hpb-head b {
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.wph-pct, .hpb-head b:last-child {
  color: var(--accent);
  font-weight: 700;
}
.wph-hint {
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}
.week-progress-sub, .hpb-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.hero-progress-box {
  margin: 10px 0 14px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 14px;
  border: 1px solid var(--line);
  transition: border-color .15s ease;
}
.hero-progress-box:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}
.chips.filter { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; padding-bottom: 2px; }
.chips.filter .chip { flex: none; }
.range-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.range-nav { display: flex; align-items: center; gap: 2px; }
.range-title { min-width: 120px; text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--g); }
.tile { background: var(--card); border-radius: 16px; padding: 13px 14px; }
.tile-label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.tile-value { font-size: 21px; font-weight: 650; margin-top: 2px; }
.tile-sub { color: var(--muted); font-size: 12px; }
.chart-card { background: var(--card); border-radius: 20px; padding: 12px 10px 12px; }
.chart { position: relative; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart text { font-family: var(--ui-font); font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .xtick.today { fill: var(--text); font-weight: 700; }
.chart .xtick.selected { fill: var(--accent); font-weight: 700; }
.chart .goal { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 4; opacity: .9; }
.chart .goal-label { font-weight: 600; fill: var(--muted); }
.chart .goal-line-wrap { cursor: pointer; }
.chart .goal-line-wrap:hover .goal { stroke-width: 2.2; opacity: 1; }
.chart .goal-line-wrap:hover .goal-label { fill: var(--text); }
.chart .gap { fill: var(--card); }
.chart .sel-band {
  fill: color-mix(in srgb, var(--accent) 8%, transparent);
  stroke: color-mix(in srgb, var(--accent) 26%, transparent);
  stroke-width: 1px;
}
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit.future { cursor: default; }
.tip {
  position: absolute; left: 0; top: 0;
  min-width: 120px; max-width: 220px;
  padding: 9px 11px;
  border-radius: 12px;
  background: var(--surface-2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  pointer-events: none;
  font-size: 12.5px;
  z-index: 2;
}
.tip-title { color: var(--muted); font-weight: 600; }
.tip-total { font-size: 16px; font-weight: 700; margin: 1px 0 3px; }
.tip-row { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.tip-row b { margin-left: auto; padding-left: 10px; font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 8px 6px 0; font-size: 12.5px; color: var(--muted); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.table-view { margin: 8px 6px 0; font-size: 13px; color: var(--muted); }
.table-view summary { cursor: pointer; padding: 4px 0; }
.table-view table { width: 100%; border-collapse: collapse; margin-top: 6px; font-variant-numeric: tabular-nums; }
.table-view th, .table-view td { text-align: left; padding: 5px 4px; border-bottom: 1px solid var(--line); }
.table-view td:last-child, .table-view th:last-child { text-align: right; }
.sec-title { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 26px 4px 10px; }
.breakdown { background: var(--card); border-radius: 20px; padding: 16px 16px 6px; }
.breakdown .card-head { margin-bottom: 2px; }
.bd-row { display: grid; grid-template-columns: auto 1fr auto 44px; grid-template-rows: auto auto; align-items: center; column-gap: 10px; padding: 10px 0; }
.bd-row + .bd-row { border-top: 1px solid var(--line); }
.bd-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.bd-pct { color: var(--muted); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.bd-bar { grid-column: 2 / -1; height: 4px; border-radius: 2px; background: var(--surface-2); margin-top: 7px; overflow: hidden; }
.bd-bar i { display: block; height: 100%; border-radius: inherit; }
.day-head { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 4px 10px; }
.day-head .sec-title { margin: 0; }
.day.dash-card .day-head { margin: 0; padding: 16px 16px 6px; }
.day.dash-card .empty { padding: 14px 16px 2px; }
.day.dash-card .btn.block { width: calc(100% - 32px); margin: 10px 16px 16px; }
.day-total { font-weight: 700; font-variant-numeric: tabular-nums; }
.sess-list { background: var(--card); border-radius: 18px; overflow: hidden; }
.sess { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; text-align: left; }
.sess + .sess { border-top: 1px solid var(--line); }
.sess:active { background: var(--surface-2); }
.sess-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sess-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sess-note { font-weight: 400; color: var(--muted); }
.sess-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.sess-sub svg.i { width: 13px; height: 13px; margin-right: 3px; display: inline-block; vertical-align: -2px; }
.sess-sub em { font-style: normal; color: var(--accent); }
.sess-time { display: inline-flex; align-items: center; }
.sess-mode { color: var(--muted); font-size: 11.5px; }
.sess-break { color: var(--faint); font-size: 11px; }
.sess-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  background: var(--line);
  color: var(--muted);
}
.sess-pill-edited {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
}
.sess-pill-manual {
  background: color-mix(in srgb, var(--digit) 14%, transparent);
  color: var(--text);
}
.sess-detail-card {
  background: var(--surface-2);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sess-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  gap: 12px;
}
.sess-detail-label {
  color: var(--muted);
  flex-shrink: 0;
}
.sess-detail-val {
  font-weight: 600;
  color: var(--text);
  text-align: right;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sess-detail-highlight {
  color: var(--accent);
}
.sess-dur { font-weight: 650; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); text-align: center; padding: 18px 0 4px; margin: 0; }

/* ============ card grid ("bento") shared by Home and Stats ============
   4 columns on phones, 8 on tablets, 12 on wide screens.
   Cards default to the full row; .g-m is half a row, .g-s a quarter (half on phones). */
.bento {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--g);
  max-width: 1200px;
  margin: 0 auto;
  align-items: stretch;
}
.bento > * { grid-column: 1 / -1; min-width: 0; margin: 0; }
.bento > .g-s { grid-column: span 2; }
@container (min-width: 600px) {
  .bento { grid-template-columns: repeat(8, minmax(0, 1fr)); --g: 14px; }
  .bento > .g-s { grid-column: span 2; }
  .bento > .g-m { grid-column: span 4; }
}
@container (min-width: 960px) {
  .bento { grid-template-columns: repeat(12, minmax(0, 1fr)); --g: 16px; }
  .bento > .g-s { grid-column: span 3; }
  .bento > .g-m { grid-column: span 6; }
}

/* ============ home ============ */
.home-hero { display: flex; flex-direction: column; gap: 10px; max-width: 1200px; margin: 0 auto; min-height: 240px; }
.hero-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: none; }
.hero-when { display: flex; flex-direction: column; min-width: 0; }
.greet { color: var(--muted); font-size: 13px; font-weight: 600; }
.home-date { font-size: 18px; font-weight: 700; letter-spacing: -.01em; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-clock { flex: 1 1 0; min-height: 0; cursor: default; }
.home-clock-sub { flex: none; display: flex; justify-content: center; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.home-bento { margin-top: 18px; }
.live-slot:empty { display: none; }
.chart-slot { min-width: 0; }

.live-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px 12px 14px;
  border-radius: 20px;
  background: var(--card);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
}
.live-card.on { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 70%, transparent); }
.live-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; background: var(--surface-2); color: var(--text); flex: none; }
.live-card.on .live-ic { background: var(--accent); color: var(--on-accent); }
.live-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.live-label { display: flex; align-items: center; gap: 7px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-state { color: var(--muted); font-size: 12.5px; }
.live-card.on .live-state { color: var(--accent); }
.live-time { font: var(--digit-weight) 26px/1 var(--digit-font); font-variant-numeric: tabular-nums; letter-spacing: var(--ls); }
.live-btn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--surface-2); color: var(--text); flex: none; }
.live-btn svg.i { width: 20px; height: 20px; }

.dash-card { background: var(--card); border-radius: 20px; padding: 16px; }
.dash-card.flush { padding: 0; overflow: hidden; }
.dash-card.flush .sess-list { border-radius: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head.pad { padding: 16px 16px 0; margin-bottom: 4px; }
.card-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.card-head > span { color: var(--muted); font-size: 12.5px; }
.card-kicker { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.card-kicker svg.i { width: 16px; height: 16px; }

.rings-card { display: flex; align-items: center; gap: 18px; }
.rings { flex: none; }
.rings svg { display: block; }
.ring-center { font: 700 20px var(--ui-font); fill: var(--text); }
.rings-info { flex: 1; min-width: 0; }
.rings-total { font-size: 34px; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; margin-top: 2px; }
.rings-sub { color: var(--muted); font-size: 13px; }
.ring-rows { margin-top: 10px; display: flex; flex-direction: column; gap: 5px; }
.ring-row { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.rr-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rr-val { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.tile2 { display: flex; flex-direction: column; }
.tile2-value { font-size: 24px; font-weight: 700; margin-top: 4px; letter-spacing: -.01em; }
.tile2-sub { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.tile2-sub.up { color: var(--text); }

.mini-chart, .heatmap { display: block; overflow: visible; }
.mini-chart .grid { stroke: var(--line); stroke-width: 1; }
.mini-chart .goal { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 4; opacity: .8; }
.mini-chart .wbar { fill: color-mix(in srgb, var(--accent) 55%, var(--card)); }
.mini-chart .wbar.today { fill: var(--accent); }
.mini-chart text { font: 11px var(--ui-font); fill: var(--muted); }
.mini-chart .xtick.today { fill: var(--text); font-weight: 700; }
.mini-chart .wval { fill: var(--text); font-weight: 700; font-size: 11.5px; }
.legend-goal { display: inline-flex; align-items: center; gap: 6px; }
.legend-goal i { width: 14px; border-top: 1.5px dashed var(--accent); }
.heatmap .hm-label { font: 10px var(--ui-font); fill: var(--muted); }
.heatmap .hm-today { stroke: var(--text); stroke-width: 1.5; }
.hm-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-top: 10px; color: var(--muted); font-size: 11.5px; }
.hm-legend i { width: 12px; height: 12px; border-radius: 3px; }
.hm-legend span { margin: 0 3px; }
.hm-note { margin-left: 2px !important; }

.empty-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 24px 18px; color: var(--muted); }
.empty-card > svg.i { width: 34px; height: 34px; color: var(--faint); }
.empty-card p { margin: 0; max-width: 320px; }

/* ============ toast ============ */
.toast {
  position: fixed; z-index: 100;
  left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 84px);
  margin: 0 auto;
  width: fit-content;
  display: flex; align-items: center; gap: 14px;
  max-width: min(480px, calc(100% - 32px));
  padding: 12px 12px 12px 18px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--card) 78%, var(--digit));
  border: 1px solid var(--line);
  color: color-mix(in srgb, var(--digit) 80%, #fff);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  font-size: 14px; font-weight: 500;
  transform: translateY(160%);
  opacity: 0;
  transition: transform .3s cubic-bezier(.2, .8, .2, 1), opacity .25s;
  pointer-events: none;
}
:root[data-scheme='light'] .toast { background: var(--digit); color: var(--bg); }
body:has(.app.landscape) .toast { bottom: calc(env(safe-area-inset-bottom) + 20px); }
.toast.show { transform: none; opacity: 1; pointer-events: auto; }
.toast:not(:has(button)) { padding-right: 18px; }
.toast button { padding: 7px 12px; border-radius: 10px; font-weight: 700; color: var(--accent); background: rgba(0, 0, 0, .18); }

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

a.btn { text-decoration: none; }

/* ============ account & cloud sync ============ */
.account-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  flex-wrap: wrap;
}
.account-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.account-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 18%, var(--card));
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.account-icon.muted {
  background: var(--surface);
  color: var(--muted);
}
.account-icon svg.i {
  width: 22px;
  height: 22px;
}
.account-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-meta {
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.account-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.sync-dot.synced { background: #22c55e; }
.sync-dot.syncing {
  background: #eab308;
  animation: pulse-sync 1.2s infinite ease-in-out;
}
.sync-dot.error { background: #ef4444; }
.sync-dot.offline { background: var(--muted); }
@keyframes pulse-sync {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .4; transform: scale(.85); }
}

.auth-tabs {
  display: flex;
  background: var(--surface);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin-bottom: 16px;
}
.auth-tab {
  flex: 1;
  text-align: center;
  padding: 8px 12px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 9px;
  cursor: pointer;
  color: var(--muted);
  transition: background .15s, color .15s;
  user-select: none;
}
.auth-tab.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .14);
}
.auth-err {
  padding: 10px 14px;
  border-radius: 10px;
  background: color-mix(in srgb, #ef4444 14%, var(--card));
  border: 1px solid color-mix(in srgb, #ef4444 35%, transparent);
  color: #ef4444;
  font-size: 13px;
  margin-bottom: 14px;
  line-height: 1.4;
}
.setup-guide {
  margin-top: 18px;
  padding: 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}
.setup-guide ol {
  margin: 8px 0 12px 18px;
  padding: 0;
}
.setup-guide li {
  margin-bottom: 4px;
}
.sql-box {
  margin: 10px 0;
  padding: 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .32);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11.5px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.45;
  border: 1px solid var(--line);
}
.center { text-align: center; }




