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

:root {
  --bg: #000000;
  --text: #ffffff;
  --text-secondary: #8e8e93;
  --green: #30d158;
  --green-dark: #0a3d1a;
  --red: #ff453a;
  --red-dark: #3d0f0c;
  --orange: #ff9f0a;
  --btn-bg: #1c1c1e;
  --btn-border: #38383a;
  --separator: #38383a;
  --lap-best: #30d158;
  --lap-worst: #ff453a;
  --accent-tint: color-mix(in srgb, var(--green) 12%, transparent);
  --accent-glow: color-mix(in srgb, var(--green) 22%, transparent);
  --accent-red-tint: color-mix(in srgb, var(--red) 12%, transparent);

  /* ── Design-system token foundation (Batch E-system) ───────────────────
     Scales below are color-scheme-independent → defined once here. Color
     tokens that differ by light/dark are mirrored in the prefers-color-scheme
     block; tokens that ALIAS an existing per-theme token (amber excepted) need
     no light variant because the referenced token already adapts. */
  /* Type scale */
  --fs-xs: 0.68rem;  --fs-sm: 0.8rem;  --fs-base: 0.9rem;  --fs-md: 1rem;
  --fs-lg: 1.25rem;  --fs-xl: 1.5rem;  --fs-display: clamp(3.2rem, 14vw, 5.5rem);
  /* Spacing scale (4px base) */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px;  --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px;
  /* Radius scale */
  --radius-sm: 8px; --radius-md: 10px; --radius-lg: 14px; --radius-pill: 999px;
  /* Motion */
  --dur-fast: 120ms; --dur-base: 180ms; --dur-slow: 300ms;
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  /* Z-index scale (named layers — see the z-index audit) */
  --z-base: 1; --z-dropdown: 10; --z-sticky: 20; --z-fab: 50;
  --z-overlay: 100; --z-modal: 200; --z-toast: 300; --z-max: 9999;
  /* Elevation */
  --shadow-1: 0 1px 3px rgba(0, 0, 0, 0.18);
  --shadow-2: 0 4px 12px rgba(0, 0, 0, 0.22);
  --shadow-3: 0 10px 28px rgba(0, 0, 0, 0.30);
  /* Amber — warning / partial-dose / BFRB / cap-notice. Themed (replaces the
     32 hardcoded #ff9f0a literals, which never picked up light mode). */
  --amber: #ff9f0a;
  --amber-tint: color-mix(in srgb, var(--amber) 14%, transparent);
  /* Phantom-token aliases (E1): the Rhythm pillar referenced these but they
     were defined NOWHERE — every reference silently used a hardcoded fallback
     and never re-themed. Aliasing to the existing per-theme tokens fixes Rhythm
     theming across all 6 themes + light with no edits to the Rhythm rules.
     (Alias targets match the old fallbacks: btn-bg≈#2c2c2e, text≈#f5f5f7,
     red=#ff453a, text-secondary≈the muted fallback.) */
  --surface: var(--btn-bg);
  --text-primary: var(--text);
  --text-muted: var(--text-secondary);
  --accent: var(--red);
  /* Categorical chart palette (Bold Data-Dense) — applied to Insights in
     E-polish. References themed tokens where sensible; literals get a light
     variant below. */
  --chart-1: #0a84ff; --chart-2: var(--green); --chart-3: var(--amber);
  --chart-4: var(--red); --chart-5: var(--text-secondary); --chart-6: #bf5af2;
  /* ── Life-OS Balance band colors (Home hub) ────────────────────────────
     One color per synthesis-record band. Aliased to the existing themed
     tokens so they re-theme across all 6 themes + light with no per-theme
     overrides. thriving=green, steady=blue, strained=amber, depleted=red,
     unknown=muted. The Home bubble fills + band chips reference ONLY these. */
  --home-band-thriving: var(--green);
  --home-band-steady: var(--chart-1);
  --home-band-strained: var(--amber);
  --home-band-depleted: var(--red);
  --home-band-unknown: var(--text-secondary);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2f2f7;
    --text: #000000;
    --text-secondary: #636366;
    --green: #34c759;
    --green-dark: #d4f5dc;
    --red: #ff3b30;
    --red-dark: #fdd;
    --orange: #ff9500;
    --btn-bg: #e5e5ea;
    --btn-border: #c7c7cc;
    --separator: #c7c7cc;
    --lap-best: #34c759;
    --lap-worst: #ff3b30;
    /* Light variants of the color tokens (Batch E-system). Scales + aliases
       carry over from :root unchanged. */
    --amber: #ff9500;
    --chart-1: #007aff;
    --chart-6: #af52de;
  }
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

#app {
  max-width: 420px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  min-height: 100dvh;
  position: relative;
}

/* Focus styles */
:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
input:focus:not(:focus-visible) {
  outline: none;
}

/* iOS focus-zoom guard.
   Mobile Safari / WKWebView auto-zooms whenever a focused form control has a
   computed font-size below 16px. Because our viewport intentionally permits
   user scaling (no maximum-scale / user-scalable=no — a deliberate a11y
   choice), iOS never zooms back out, leaving the page stuck zoomed-in until a
   relaunch (first reported on the Todoist API-token field). Enforce a 16px
   floor on every text-entry control on touch devices so focusing one never
   hijacks zoom. !important is required because per-control class rules
   (e.g. .tempo-todoist-input) out-specify a bare `input` selector. Desktop
   (fine pointer) keeps the existing compact sizing. */
@media (pointer: coarse) {
  input,
  textarea,
  select {
    font-size: 16px !important;
  }

  /* Controls intentionally sized above the 16px floor — keep them as-is
     (already ≥16px, so they never triggered the zoom). */
  .preset-save-icon-input { font-size: 1.5rem !important; }
  .offset-field input { font-size: 1.2rem !important; }
  .pomodoro-setting-row input { font-size: 1.1rem !important; }
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* D: the <main> content landmark must NOT generate a box — the pillars stay
   flex children of #app (their wrappers are display:contents too). The <main>
   role is preserved by modern browsers under display:contents. */
.tempo-main { display: contents; }

/* D: skip link — visually hidden until it receives focus, then it parks at the
   top-left so a keyboard user can jump straight into the content. */
.skip-link {
  position: absolute;
  left: 8px;
  top: -48px;
  z-index: var(--z-max, 9999);
  padding: 8px 14px;
  background: var(--btn-bg);
  color: var(--text);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-md, 10px);
  text-decoration: none;
  transition: top var(--dur-fast, 120ms) var(--ease-standard, ease);
}
.skip-link:focus {
  top: calc(8px + env(safe-area-inset-top, 0px));
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* Top Bar */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0 4px;
}

.mode-selector {
  display: flex;
  background: var(--btn-bg);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--btn-border);
}

.mode-tab {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-family: inherit;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.mode-tab-active {
  background: var(--green);
  color: #000;
  font-weight: 600;
}

.top-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.1rem;
  padding: 6px 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
  line-height: 1;
}

.icon-btn:active {
  opacity: 0.6;
}

/* Theme Picker */
.theme-picker {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 8px 0;
}

.theme-option {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--text);
  font-size: 0.8rem;
  padding: 6px 14px;
  border-radius: 16px;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s;
}

.theme-option-active {
  border-color: var(--green);
  color: var(--green);
}

/* Presets Quick Picks */
.presets-quick {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 4px 0;
  flex-wrap: wrap;
}

.presets-quick:empty {
  display: none;
}

.preset-quick-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 16px;
  color: var(--text);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s;
}

.preset-quick-chip:active {
  transform: scale(0.95);
}

.preset-quick-icon {
  font-size: 0.9rem;
  line-height: 1;
}

.preset-quick-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

/* Presets Drawer */
.presets-drawer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 300;
  display: flex;
  flex-direction: column;
  /* Reserve iOS safe-area — full-screen takeover; mirrors .focus-overlay (see
     .history-panel). Padded on the CONTAINER (not the shared .history-header) so
     the History panel's header is untouched. Inert where env()=0. */
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
           env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  overflow: hidden;
}

.presets-drawer-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 20px;
}

/* Preset Cards */
.presets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 0 8px;
}

@media (min-width: 500px) {
  .presets-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

.preset-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s;
  position: relative;
  overflow: hidden;
}

.preset-card:active {
  transform: scale(0.96);
}

.preset-card-add {
  border-style: dashed;
  color: var(--text-secondary);
}

.preset-card-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  line-height: 1;
}

.preset-card-add .preset-card-icon {
  font-size: 1.5rem;
  opacity: 0.5;
}

.preset-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  overflow: hidden;
}

.preset-card-name {
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preset-card-hint {
  font-size: 0.65rem;
  color: var(--text-secondary);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

.preset-card-mode {
  font-size: 0.55rem;
  font-weight: 700;
  color: #000;
  padding: 2px 5px;
  border-radius: 4px;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.preset-card-confirm {
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.preset-confirm-yes {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
}

.preset-confirm-no {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
}

/* Preset Save Form */
.preset-save-area {
  padding: 0 0 8px;
}

.preset-save-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.preset-auto-start-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.preset-save-icon-input {
  width: 44px;
  height: 44px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1.5rem;
  text-align: center;
  font-family: inherit;
}

.preset-save-name-input {
  width: 200px;
  height: 38px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.9rem;
  text-align: center;
  padding: 0 12px;
  font-family: inherit;
}

.preset-save-name-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.5;
}

/* Timer Display */
#timer-display {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 0 20px;
}

#timer-display.mode-fade-out {
  opacity: 0;
  transform: scale(0.97);
  transition: opacity 0.1s ease, transform 0.1s ease;
}

#timer-display.mode-fade-in {
  animation: mode-fade-in 0.15s ease;
}

@keyframes mode-fade-in {
  from { opacity: 0; transform: scale(1.02); }
  to { opacity: 1; transform: scale(1); }
}


#time {
  font-family: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Monaco, 'Cascadia Mono', monospace;
  font-size: clamp(3.2rem, 14vw, 5.5rem);
  font-weight: 250;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  white-space: nowrap;
  font-variation-settings: "wght" 250;
}

.centiseconds {
  display: inline-block;
  min-width: 1.6ch;
  font-size: 0.58em;
  opacity: 0.55;
  letter-spacing: -0.02em;
  margin-left: 0.08em;
  vertical-align: baseline;
}

/* Analog Display */
#analog-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.analog-svg {
  width: 220px;
  height: 220px;
}

@media (min-width: 500px) {
  .analog-svg {
    width: 280px;
    height: 280px;
  }
}

.analog-hand {
  stroke: var(--text);
  stroke-linecap: round;
}

.analog-hand-second {
  stroke: var(--green);
  stroke-width: 1.5;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.analog-hand-minute {
  stroke: var(--text);
  stroke-width: 2.5;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.4));
}

.analog-number {
  fill: var(--text-secondary);
  font-size: 10px;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
}

.analog-center {
  fill: var(--green);
}

.analog-tick {
  stroke: var(--text-secondary);
  stroke-width: 1;
}

.analog-tick-major {
  stroke: var(--text);
  stroke-width: 2;
}

.digital-small {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

#timer-display.mode-analog #time {
  display: none;
}

/* Mode Toggle */
.mode-toggle {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding-top: 12px;
}

.mode-dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: var(--btn-border);
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s;
}

/* Backlog #19: keep the visible dot at 8px (deliberate minimalist look on the
   flagship timer screen) but expand the *clickable* area via a transparent
   overlay so it's actually tappable. Horizontal reach is capped by the 8px
   .mode-toggle gap — each side extends 4px so the two hit areas meet at the
   midpoint and never overlap (no ambiguous taps); vertically there's no
   neighbor, so it grows to a full ~44px. Net target ~16×44px vs the old 8×8
   point. A true non-overlapping 44px-wide pair would need the dots spread
   apart, which would alter the hero screen — out of scope for this papercut. */
.mode-dot::after {
  content: '';
  position: absolute;
  top: -18px;
  bottom: -18px;
  left: -4px;
  right: -4px;
}

.mode-dot-active {
  background: var(--text);
}

/* Offset Area */
#offset-area {
  text-align: center;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.offset-link {
  background: none;
  border: none;
  color: var(--green);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 8px 16px;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.offset-link:active {
  opacity: 0.6;
}

.offset-link-active {
  color: var(--green);
}

.offset-input {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  max-height: 500px;
  opacity: 1;
  transition: max-height 0.25s ease, opacity 0.2s ease, margin 0.25s ease;
}

.offset-input[data-collapsed] {
  max-height: 0;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}

.offset-fields {
  display: flex;
  align-items: center;
  gap: 6px;
}

.offset-field {
  display: flex;
  align-items: center;
  gap: 4px;
}

.offset-field input {
  width: 52px;
  height: 44px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1.2rem;
  text-align: center;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-variant-numeric: tabular-nums;
  -webkit-appearance: none;
  -moz-appearance: textfield;
}

.offset-field input::-webkit-inner-spin-button,
.offset-field input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.offset-field label {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.offset-buttons {
  display: flex;
  gap: 12px;
}

.offset-btn {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--text);
  padding: 8px 24px;
  border-radius: 10px;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.offset-btn:active {
  opacity: 0.6;
}

/* ── ±3 min Adjust Buttons (Timer, Pomodoro, Flow, Interval, Sequence) ── */
.time-adjust {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.time-adjust[hidden] { display: none; }

.adjust-btn {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--text);
  padding: 8px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  min-width: 84px;
  transition: opacity 0.12s, transform 0.08s;
}

.adjust-btn:active:not(:disabled) {
  opacity: 0.6;
  transform: scale(0.96);
}

.adjust-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Per-card adjust buttons inside cooking timers */
.cooking-adjust-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.cooking-adjust-btn {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  flex: 1;
  max-width: 96px;
  transition: opacity 0.12s, transform 0.08s;
}

.cooking-adjust-btn:active:not(:disabled) {
  opacity: 0.6;
  transform: scale(0.96);
}

.cooking-adjust-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Presets */
.preset-list {
  width: 100%;
  max-width: 280px;
}

.preset-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.preset-row:active {
  background: var(--btn-bg);
}

.preset-name {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preset-duration {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.preset-delete {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.preset-delete:hover,
.preset-delete:active {
  opacity: 1;
  color: var(--red);
}

.preset-name-input {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
}

.preset-name-input input[type="text"] {
  width: 200px;
  height: 40px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.95rem;
  text-align: center;
  padding: 0 12px;
  font-family: inherit;
}

.preset-name-input input[type="text"]::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

/* Controls */
#controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 10px;
}

.control-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.control-btn:active {
  transform: scale(0.92);
}

.control-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.btn-inner {
  position: relative;
  z-index: 1;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: opacity 0.08s ease, transform 0.08s ease;
}

.btn-transitioning .btn-inner {
  opacity: 0.4;
  transform: scale(0.85);
}

/* Button ring effect - outer ring via box-shadow */
.control-btn::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 2px solid transparent;
}

.btn-start {
  border-color: var(--green);
  background: var(--accent-tint);
  color: var(--green);
}

.btn-start::after {
  border-color: var(--green);
}

.btn-start:active {
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-stop {
  border-color: var(--red);
  background: var(--accent-red-tint);
  color: var(--red);
}

.btn-stop::after {
  border-color: var(--red);
}

.btn-stop:active {
  box-shadow: 0 0 20px color-mix(in srgb, var(--red) 30%, transparent);
}

.btn-lap {
  border-color: var(--btn-border);
  background: var(--btn-bg);
  color: var(--text);
}

.btn-reset {
  border-color: var(--btn-border);
  background: var(--btn-bg);
  color: var(--text);
}

/* Instance Cards */
.instance-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 4px;
}

.instance-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.instance-card:active {
  transform: scale(0.98);
}

.card-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-running {
  background: var(--green);
  box-shadow: 0 0 6px rgba(48, 209, 88, 0.5);
}

.status-paused {
  background: var(--amber);
}

.status-finished {
  background: var(--red);
}

.status-idle {
  background: var(--btn-border);
}

.card-name {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  outline: none;
  border-radius: 4px;
  padding: 2px 4px;
  transition: background 0.15s;
}

.card-name:focus {
  background: var(--bg);
  color: var(--text);
}

.card-time {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}

.card-compare {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  opacity: 0.4;
  transition: opacity 0.15s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.card-compare:active {
  opacity: 1;
  color: var(--green);
}

.card-delete {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.card-delete:hover,
.card-delete:active {
  opacity: 1;
  color: var(--red);
}

.instance-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: none;
  border: 1px dashed var(--btn-border);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.instance-add-btn:active {
  border-color: var(--green);
  color: var(--green);
}

.color-palette {
  position: absolute;
  top: 100%;
  left: 10px;
  display: flex;
  gap: 6px;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  -webkit-tap-highlight-color: transparent;
}

.color-swatch-active {
  border-color: var(--text);
}

.color-swatch-none {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--text-secondary);
}

/* Lap Stats */
.lap-stats {
  display: flex;
  justify-content: space-around;
  padding: 8px 4px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-variant-numeric: tabular-nums;
  border-bottom: 0.5px solid var(--separator);
}

/* Compare View */
.compare-view {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 4px;
  position: relative;
  z-index: 50;
}

.compare-columns {
  display: flex;
  gap: 1px;
}

.compare-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 4px;
}

.compare-divider {
  width: 1px;
  background: var(--separator);
  align-self: stretch;
}

.compare-name {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  outline: none;
  border-radius: 4px;
  padding: 2px 6px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compare-name:focus {
  background: var(--btn-bg);
  color: var(--text);
}

.compare-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-bottom: 6px;
}

.compare-time {
  font-family: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, monospace;
  font-size: clamp(1.5rem, 7vw, 2.5rem);
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  white-space: nowrap;
  margin-bottom: 12px;
  color: var(--text);
}

.compare-time .centiseconds {
  font-size: 0.6em;
  opacity: 0.85;
}

.compare-controls {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.compare-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--text);
  font-size: 0.8rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.1s ease;
}

.compare-btn:active {
  transform: scale(0.92);
}

.compare-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.compare-btn-start {
  border-color: var(--green);
  background: var(--accent-tint);
  color: var(--green);
}

.compare-btn-stop {
  border-color: var(--red);
  background: var(--accent-red-tint);
  color: var(--red);
}

.compare-exit {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: none;
  border: 1px solid var(--btn-border);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.compare-exit:active {
  border-color: var(--green);
  color: var(--green);
}

/* Lap Chart */
.lap-chart {
  padding: 8px 4px 4px;
}

.lap-chart svg {
  width: 100%;
  height: 80px;
  display: block;
}

.lap-chart-bar {
  fill: var(--text-secondary);
  opacity: 0.5;
  transition: opacity 0.15s;
}

.lap-chart-bar-best {
  fill: var(--lap-best);
  opacity: 0.8;
}

.lap-chart-bar-worst {
  fill: var(--lap-worst);
  opacity: 0.8;
}

/* Lap Section */
#lap-section {
  flex: 1 1 auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-top: 0.5px solid var(--separator);
}

#lap-list {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.lap-header {
  text-align: center;
  padding: 4px 0 2px;
}

.lap-header-toggle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.lap-header-toggle:active {
  opacity: 0.6;
}

.lap-row {
  position: relative;
  overflow: hidden;
  border-bottom: 0.5px solid var(--separator);
  font-size: 1rem;
}

.lap-row-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 4px;
  background: var(--bg);
  position: relative;
  z-index: 1;
  transition: transform 0.2s ease;
}

.lap-row-swiping .lap-row-inner {
  transition: none;
}

.lap-row-delete-bg {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 20px;
  background: var(--red);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
}

.lap-row-removing .lap-row-inner {
  transition: transform 0.2s ease, opacity 0.2s ease;
  opacity: 0;
}

.lap-label {
  color: var(--text);
}

.lap-time {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.lap-entering {
  animation: lap-enter 0.25s ease-out;
}

@keyframes lap-enter {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.lap-best .lap-label,
.lap-best .lap-time {
  color: var(--lap-best);
}

.lap-worst .lap-label,
.lap-worst .lap-time {
  color: var(--lap-worst);
}

/* Undo Toast */
.undo-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 12px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  color: var(--text);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
}

.undo-toast.undo-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Sync Toast (E-2 — first real cloud-sync visible toast surface).
   Mirrors .undo-toast byte-identical (class names swapped). Audit
   Risk #6 flagged a possible bottom: 90px tweak for overlap with
   undo-toast during simultaneous fire — deferred to a follow-up if
   Phase 4 SMOKE surfaces it. */
.sync-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 12px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  color: var(--text);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
}

.sync-toast.sync-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Toast action button (Phase 3 stress nudge — Toast.action). Rides inside the
   existing .sync-toast slot; `--amber` is an existing theme token. */
.sync-toast-action-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--amber);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0 0 0 12px;
  cursor: pointer;
  white-space: nowrap;
}

.undo-btn {
  background: none;
  border: none;
  color: var(--green);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

/* Timer Progress Bar */
.timer-progress {
  padding: 0 4px 8px;
}

.timer-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--btn-border);
  border-radius: 2px;
  overflow: hidden;
}

.timer-progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
  transition: width 0.1s linear;
}

#timer-display.timer-finished #time {
  animation: flash-red 0.5s ease-in-out 6 alternate;
}

@keyframes flash-red {
  from { color: var(--text); }
  to { color: var(--red); }
}

/* Countdown overshoot — steady amber once the brief flash-red animation
   has settled (~3s after zero crossing). The .overshoot class is added
   alongside (or after) the flash class by each countdown UI. */
#timer-display.overshoot #time {
  color: var(--orange);
}
#timer-display.overshoot.timer-finished #time {
  /* While the flash animation is still running, let it win — it animates
     between the text color and red. The amber takes over as the flash
     class is removed past 3s. */
  animation: flash-red 0.5s ease-in-out 6 alternate;
}

/* History list "+X over" badge. Hidden when overshootMs is 0/undefined
   via the JS guard (no class rendered). */
.history-overshoot {
  color: var(--orange);
  font-size: 12px;
  font-weight: 600;
  margin-left: 6px;
  white-space: nowrap;
}

/* Flow summary card — overshoot row reuses the amber. */
.flow-summary-overshoot {
  color: var(--orange);
  font-weight: 600;
}

/* Analytics overshoot card — visual language matches BFRB Trend so the
   dashboard reads consistently. */
.analytics-overshoot-numbers {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: baseline;
  margin-bottom: 12px;
}
.analytics-overshoot-primary {
  display: flex;
  flex-direction: column;
}
.analytics-overshoot-primary-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--orange);
  line-height: 1.1;
}
.analytics-overshoot-primary-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.analytics-overshoot-secondary {
  display: flex;
  flex-direction: column;
}
.analytics-overshoot-secondary-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.1;
}
.analytics-overshoot-secondary-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.analytics-overshoot-chart-wrap {
  margin: 8px 0;
}
.analytics-overshoot-chart {
  width: 100%;
  display: block;
}
.analytics-overshoot-foot {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* Vibration Interval */
.vibrate-area {
  text-align: center;
  margin-bottom: 4px;
}

.vibrate-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.vibrate-label select {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.8rem;
  padding: 4px 8px;
  /* >=44px touch target (mobile sweep B2): these Flow selects were ~25px tall. */
  min-height: 44px;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

/* Alert Area */
.alert-area {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.alert-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.alert-list:empty {
  display: none;
}

.alert-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--text);
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 14px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

.alert-chip-icon {
  font-style: normal;
  font-size: 0.75rem;
}

.alert-chip-fired {
  opacity: 0.45;
  border-style: dashed;
}

.alert-chip-fired .alert-chip-icon {
  color: var(--green);
}

.alert-chip-delete {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  opacity: 0.6;
  -webkit-tap-highlight-color: transparent;
}

.alert-chip-delete:active {
  opacity: 1;
  color: var(--red);
}

/* Pomodoro Area */
.pomodoro-area {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.pomodoro-phase-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.pomodoro-cycle {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-secondary);
}

.pomodoro-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.pomodoro-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--btn-border);
  transition: background 0.2s;
}

.pomodoro-dot-done {
  background: var(--green);
}

.pomodoro-dot-active {
  background: var(--green);
  box-shadow: 0 0 6px rgba(48, 209, 88, 0.5);
}

.pomodoro-setting-row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.pomodoro-setting-row label {
  width: 80px;
  text-align: right;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.pomodoro-setting-row input {
  width: 52px;
  height: 40px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1.1rem;
  text-align: center;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-variant-numeric: tabular-nums;
  -webkit-appearance: none;
  -moz-appearance: textfield;
}

.pomodoro-setting-row input::-webkit-inner-spin-button,
.pomodoro-setting-row input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.pomodoro-setting-row span {
  font-size: 0.85rem;
  color: var(--text-secondary);
  width: 24px;
}

/* Pomodoro Action Links */
.pomo-action-links {
  display: flex;
  gap: 4px;
  justify-content: center;
}
/* Five links (Stats / Settings / Actions / Auto / Tasks) must share one
   phone-width row without wrapping into the fixed bottom tab bar. Keep each
   on a single line and trim the footprint; overflow-x scrolls as a safety on
   very narrow screens rather than wrapping to a second (clipped) row. */
.pomo-action-links {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.pomo-action-links::-webkit-scrollbar { display: none; }
.pomo-action-links .offset-link {
  white-space: nowrap;
  flex: 0 0 auto;
  font-size: 0.82rem;
  padding: 8px 9px;
}

/* Pomodoro Stats Panel */
.pomo-stats-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 300;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pomo-stats-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.pomo-stat-cards {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
}

.pomo-stat-card {
  flex: 1;
  max-width: 120px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
}

.pomo-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--green);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}

.pomo-stat-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.pomo-stat-chart-title {
  font-size: 0.8rem;
  /* E-polish follow-up: brighten dim chart heading (text-secondary → text @ 0.82). */
  color: var(--text);
  opacity: 0.82;
  font-weight: 600;
  text-align: center;
  margin-bottom: 8px;
}

.pomo-stat-chart {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: flex-end;
  height: 100px;
  padding: 0 10px;
}

.pomo-stat-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.pomo-stat-bar {
  width: 100%;
  max-width: 30px;
  background: var(--green);
  border-radius: 3px 3px 0 0;
  min-height: 0;
  transition: height 0.3s ease;
}

.pomo-stat-bar-label {
  font-size: 0.65rem;
  color: var(--text-secondary);
}

/* Pomodoro Checklist */
.pomo-checklist {
  width: 100%;
  max-width: 280px;
  margin: 4px auto;
}

.pomo-checklist-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 4px 4px;
}

.pomo-checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 0.5px solid var(--separator);
}

.pomo-drag-handle {
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: grab;
  padding: 0 2px;
  opacity: 0.35;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
}

.pomo-drag-handle:active {
  opacity: 0.7;
  cursor: grabbing;
}

.pomo-dragging {
  position: fixed;
  z-index: 100;
  opacity: 0.85;
  background: var(--bg);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

.pomo-drag-placeholder {
  background: var(--btn-bg);
  border-radius: 6px;
  opacity: 0.4;
}

.pomo-checklist-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
  flex-shrink: 0;
  cursor: pointer;
}

.pomo-checklist-item-text {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pomo-checklist-item-done .pomo-checklist-item-text {
  text-decoration: line-through;
  color: var(--text-secondary);
  opacity: 0.6;
}

.pomo-checklist-item-delete {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.4;
  -webkit-tap-highlight-color: transparent;
}

.pomo-checklist-item-delete:active {
  opacity: 1;
  color: var(--red);
}

.pomo-checklist-add {
  padding: 6px 0;
}

.pomo-checklist-add input {
  width: 100%;
  height: 32px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  padding: 0 10px;
  font-family: inherit;
  outline: none;
}

.pomo-checklist-add input:focus {
  border-color: var(--green);
}

.pomo-checklist-add input::placeholder {
  color: var(--text-secondary);
  opacity: 0.5;
}

/* Bullet list items (no checkbox) */
.pomo-bullet-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 0.5px solid var(--separator);
}

.pomo-bullet-marker {
  color: var(--text-secondary);
  font-size: 0.6rem;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}

/* Actions drawer */
.pomo-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px 0;
}

.pomo-action-btn {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.8rem;
  padding: 10px 4px;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.pomo-action-btn:active {
  opacity: 0.6;
}

.pomo-checklist-item-save {
  background: none;
  border: none;
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0 2px;
  opacity: 0.35;
  -webkit-tap-highlight-color: transparent;
}

.pomo-checklist-item-save:active {
  opacity: 0.8;
}

.pomo-saved-task-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 4px;
  border-bottom: 0.5px solid var(--separator);
}

/* todoist-pomo-rename: inline click-to-edit affordance, scoped to saved-task
   rows only (the rename behavior is wired exclusively on these spans). */
.pomo-saved-task-item .pomo-checklist-item-text {
  cursor: text;
  border-radius: 4px;
  padding: 1px 3px;
  margin: -1px -3px;
}

.pomo-saved-task-item .pomo-checklist-item-text[contenteditable="true"] {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  background: var(--btn-bg);
  outline: 1.5px solid var(--green);
  cursor: text;
}

.pomo-saved-task-add,
.pomo-saved-task-add-break {
  background: none;
  border: 1px solid var(--btn-border);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 0.65rem;
  padding: 2px 6px;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.pomo-saved-task-add:active,
.pomo-saved-task-add-break:active {
  color: var(--green);
  border-color: var(--green);
}

/* Timeline */
.pomo-timeline {
  width: 100%;
  max-width: 320px;
  margin: 6px auto 2px;
}

.pomo-timeline-bar {
  display: flex;
  height: 18px;
  border-radius: 4px;
  overflow: hidden;
  gap: 1px;
}

.pomo-tl-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
}

.pomo-tl-work {
  background: rgba(48, 209, 88, 0.25);
  color: var(--green);
}

.pomo-tl-break {
  background: rgba(10, 199, 232, 0.2);
  color: var(--text-secondary);
}

.pomo-tl-done {
  opacity: 0.35;
}

.pomo-tl-active {
  outline: 2px solid var(--green);
  outline-offset: -1px;
}

.pomo-tl-label {
  font-size: 0.55rem;
  font-weight: 600;
  white-space: nowrap;
}

.pomo-timeline-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--text-secondary);
  padding: 2px 2px 0;
}

/* Distraction Log */
.pomo-distraction-btn {
  background: none;
  border: 1px solid var(--red);
  border-radius: 8px;
  color: var(--red);
  font-size: 0.75rem;
  padding: 4px 12px;
  cursor: pointer;
  font-family: inherit;
  margin-top: 4px;
  -webkit-tap-highlight-color: transparent;
}

.pomo-distraction-btn:active {
  opacity: 0.6;
}

.pomo-distraction-picker {
  margin-top: 6px;
  text-align: center;
}

.pomo-distraction-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 6px;
}

.pomo-distraction-cat {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.75rem;
  padding: 4px 10px;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.pomo-distraction-cat:active {
  border-color: var(--red);
  color: var(--red);
}

.pomo-distraction-picker input {
  width: 200px;
  max-width: 80%;
  height: 28px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.8rem;
  padding: 0 8px;
  font-family: inherit;
  outline: none;
}

.pomo-distraction-picker input:focus {
  border-color: var(--red);
}

/* Flow running action row — side-by-side Distraction + End early buttons. */
.flow-run-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 4px;
}

.flow-run-actions .pomo-distraction-btn {
  margin-top: 0;
}

/* End early — subtle secondary action. Muted border so it doesn't compete
   with Distraction or the main Pause button. */
.flow-end-early-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted, var(--text));
  opacity: 0.78;
  font-size: 0.75rem;
  padding: 4px 12px;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.12s ease, border-color 0.12s ease;
}

.flow-end-early-btn:hover,
.flow-end-early-btn:focus-visible {
  opacity: 1;
  border-color: var(--text);
  outline: none;
}

.flow-end-early-btn:active {
  opacity: 0.6;
}

/* ── Wellness › Recovery ── */
.recovery-container {
  display: block;
  padding: 0;
}

.recovery-surface {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px;
}

.recovery-status-card {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.recovery-status-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 0.85rem;
}

.recovery-status-label {
  color: var(--text-muted, var(--text));
  opacity: 0.72;
}

.recovery-status-value {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.recovery-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.recovery-section-title {
  font-size: 0.78rem;
  /* E-polish follow-up: crisp dashboard heading — opacity 0.72 → 0.82, weight
     600 → 700 (matches .analytics-card-header). */
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  opacity: 0.82;
  margin: 0;
}

.recovery-sleep-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 12px;
  padding: 14px 16px;
}

.recovery-sleep-input-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--text);
  opacity: 0.82;
}

.recovery-sleep-input-label input {
  background: var(--bg);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  width: 100%;
  max-width: 180px;
}

.recovery-sleep-input-label input:focus {
  outline: 2px solid var(--green);
  outline-offset: 1px;
}

.recovery-sleep-quality {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recovery-sleep-quality-label {
  font-size: 0.78rem;
  color: var(--text);
  opacity: 0.82;
}

.recovery-sleep-quality-buttons {
  display: flex;
  gap: 6px;
}

.recovery-quality-btn {
  flex: 0 0 auto;
  /* >=44px touch target (mobile sweep B2): was 36x36. */
  width: 44px;
  height: 44px;
  border-radius: 22px;
  border: 1px solid var(--btn-border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.recovery-quality-btn.is-selected {
  background: color-mix(in srgb, var(--green) 22%, transparent);
  border-color: var(--green);
  color: var(--green);
}

.recovery-sleep-submit-row {
  display: flex;
  justify-content: flex-end;
}

.recovery-primary-btn {
  background: var(--green);
  border: 1px solid var(--green);
  border-radius: 8px;
  color: var(--bg);
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.12s ease;
}

.recovery-primary-btn:active { opacity: 0.7; }

.recovery-link-btn {
  background: none;
  border: none;
  color: var(--green);
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  padding: 4px 6px;
}

.recovery-link-btn.recovery-link-muted {
  color: var(--text);
  opacity: 0.55;
}

.recovery-link-btn:hover { text-decoration: underline; }

.recovery-sleep-logged {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 12px;
  padding: 12px 16px;
}

.recovery-sleep-value {
  font-size: 1rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.recovery-sleep-value strong {
  font-size: 1.3rem;
  color: var(--green);
}

.recovery-sleep-actions {
  display: flex;
  gap: 4px;
}

.recovery-nap-presets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

@media (min-width: 520px) {
  .recovery-nap-presets {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.recovery-preset-btn {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 10px;
  color: var(--text);
  padding: 14px 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.recovery-preset-btn:hover {
  border-color: var(--green);
  color: var(--green);
}

.recovery-preset-btn:active { opacity: 0.7; }

.recovery-nap-running {
  background: var(--btn-bg);
  border: 1px solid var(--green);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recovery-nap-countdown {
  font-size: 2.5rem;
  font-weight: 300;
  color: var(--green);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.recovery-nap-sub {
  font-size: 0.8rem;
  color: var(--text);
  opacity: 0.7;
}

.recovery-nap-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 6px;
}

.recovery-trend-list {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 12px;
  overflow: hidden;
}

.recovery-trend-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  font-size: 0.85rem;
  border-top: 1px solid var(--btn-border);
}

.recovery-trend-row:first-child { border-top: none; }

.recovery-trend-label {
  color: var(--text);
  opacity: 0.8;
}

.recovery-trend-value {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.recovery-trend-empty {
  background: var(--btn-bg);
  border: 1px dashed var(--btn-border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text);
  opacity: 0.6;
}

/* BFRB tally button (Flow & Pomodoro) */
.log-btn-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.bfrb-btn {
  background: none;
  border: 1px solid var(--amber);
  border-radius: 8px;
  color: var(--amber);
  font-size: 0.75rem;
  padding: 4px 12px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}

.bfrb-btn:active {
  opacity: 0.6;
}

.bfrb-btn.bfrb-pulse {
  transform: scale(1.12);
  background: color-mix(in srgb, var(--amber) 16%, transparent);
}

/* Recovery countdown: button fills with an amber bar that drains from 100%
   (fresh catch) to 0% (1 min elapsed). The --bfrb-recovery-progress custom
   property is updated by JS every 250ms while the routine runs. */
.bfrb-btn.bfrb-recovery-active {
  position: relative;
  overflow: hidden;
  --bfrb-recovery-progress: 1;
  min-width: 60px;
  font-variant-numeric: tabular-nums;
}

.bfrb-btn.bfrb-recovery-active::before {
  content: '';
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--amber) 22%, transparent);
  transform-origin: left;
  transform: scaleX(var(--bfrb-recovery-progress, 1));
  transition: transform 0.25s linear;
  pointer-events: none;
  z-index: 0;
}

.bfrb-btn.bfrb-recovery-active {
  /* Push text above the fill */
  color: var(--amber);
}

.bfrb-btn.bfrb-recovery-active > * {
  position: relative;
  z-index: 1;
}

/* Global floating BFRB FAB — fixed bottom-right, always on top. Circular
   enough to feel like a distinct action, big enough to hit reliably.
   Bottom offset clears the mobile tempo tabbar (56px + safe area); on
   desktop the tabbar is a sidebar, so the regular offset applies. */
.global-bfrb-fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--tempo-tabbar-h, 56px) + env(safe-area-inset-bottom, 0px) + 16px);
  z-index: 2000;
  padding: 0;
  min-width: 52px;
  height: 52px;
  border-radius: 26px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--bg);
  border: 2px solid var(--amber);
  color: var(--amber);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  user-select: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.global-bfrb-fab:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--amber) 35%, transparent);
}

.global-bfrb-fab:active {
  transform: translateY(0);
  opacity: 0.85;
}

.global-bfrb-fab:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--amber) 60%, transparent);
  outline-offset: 2px;
}

/* When recovery is running on the FAB, the progress fill ::before from
   .bfrb-recovery-active above kicks in. Override its origin so the drain
   looks centered on the round shape, and make the countdown text big. */
.global-bfrb-fab.bfrb-recovery-active {
  /* Override .bfrb-btn.bfrb-recovery-active which sets position: relative.
     Fixed positioning is already a containing block for abs-positioned
     descendants, so the ::before fill still anchors inside the button. */
  position: fixed;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.global-bfrb-fab.bfrb-recovery-active::before {
  border-radius: inherit;
}

@media (max-width: 480px) {
  .global-bfrb-fab {
    right: 12px;
    bottom: calc(var(--tempo-tabbar-h, 56px) + env(safe-area-inset-bottom, 0px) + 12px);
    min-width: 48px;
    height: 48px;
    border-radius: 24px;
  }
}

/* Desktop: tempo tabbar becomes a sidebar, so FAB returns to standard
   bottom-right offset. */
@media (min-width: 768px) {
  .global-bfrb-fab {
    bottom: 16px;
  }
}

/* Hide the FAB when Focus Mode is on — Focus mode intentionally strips
   chrome. Catches still have keyboard shortcut. */
body.focus-mode .global-bfrb-fab {
  display: none;
}

/* Also hide the FAB while a full-screen takeover panel is open — it otherwise
   floats over the panel's bottom-right actions (notably History's destructive
   "Clear All"). These panels toggle .hidden, so :not(.hidden) = open. :has()
   matches the #176 idiom; engines without :has() just keep the FAB visible
   (harmless fallback). */
body:has(#history-panel:not(.hidden)) .global-bfrb-fab,
body:has(#analytics-panel:not(.hidden)) .global-bfrb-fab,
body:has(#presets-drawer:not(.hidden)) .global-bfrb-fab,
body:has(#log-past-panel:not(.hidden)) .global-bfrb-fab {
  display: none;
}

/* Backlog #18: the FAB also floats over the Recovery surface's bottom-right
   "Log sleep" button on #/wellness/recovery (a normal route, not a takeover
   panel — so the rule above doesn't catch it). Hide the FAB while that surface
   is visible, same idiom. Wellness sub-surfaces toggle the native [hidden]
   attribute (js/tempo-nav.js), so :not([hidden]) = recovery is the active sub.
   Catches still have keyboard shortcut B. */
body:has([data-wellness-sub="recovery"]:not([hidden])) .global-bfrb-fab {
  display: none;
}

/* BFRB Closed Loop Slice B: the if-then competing-response plan banner.
   Anchored just above the FAB (bottom-right) so the plan reminder sits with the
   countdown it relates to. It is shown only AFTER the antecedent-capture popover
   dismisses (js/global-bfrb.js commitPending → BFRBRecovery.showPlan), so the two
   right-aligned surfaces never overlap on a narrow viewport — the separation is
   temporal, not spatial (tagging happens first, the competing-response window
   after). A gentle reminder of the user's own replacement-behavior plan. */
.bfrb-recovery-plan {
  position: fixed;
  right: 16px;
  bottom: calc(var(--tempo-tabbar-h, 56px) + env(safe-area-inset-bottom, 0px) + 16px + 60px);
  z-index: 2000;
  max-width: min(280px, calc(100vw - 32px));
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--amber);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: bfrb-plan-in 0.18s ease;
}

.bfrb-recovery-plan[hidden] {
  display: none;
}

.bfrb-recovery-plan-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber);
}

.bfrb-recovery-plan-text {
  font-size: 0.85rem;
  line-height: 1.3;
  color: var(--text);
}

@keyframes bfrb-plan-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
  .bfrb-recovery-plan {
    right: 12px;
    bottom: calc(var(--tempo-tabbar-h, 56px) + env(safe-area-inset-bottom, 0px) + 12px + 56px);
  }
}

@media (min-width: 768px) {
  .bfrb-recovery-plan {
    bottom: calc(16px + 60px);
  }
}

body.focus-mode .bfrb-recovery-plan {
  display: none;
}

/* ── BFRB antecedent capture popover (E-1g) ──────────────────────────────
   Optional 1-2 tap urge + trigger picker that floats above the FAB after a
   catch. Chips are dismissible: the catch is already logged via the deferred
   commit, so one-tap-and-ignore still records it field-less. */
.bfrb-capture {
  position: fixed;
  right: 16px;
  bottom: calc(var(--tempo-tabbar-h, 56px) + env(safe-area-inset-bottom, 0px) + 78px);
  z-index: 2001;
  width: min(260px, calc(100vw - 32px));
  padding: 12px 14px 10px;
  background: var(--bg);
  border: 1px solid var(--btn-border);
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
  animation: bfrb-capture-in 0.14s ease;
}

@keyframes bfrb-capture-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bfrb-capture[hidden] { display: none; }

.bfrb-capture-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.bfrb-capture-sub { font-weight: 400; opacity: 0.6; }

.bfrb-capture-grouplabel {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.55;
  margin: 4px 0;
}

.bfrb-capture-row { display: flex; flex-wrap: wrap; gap: 6px; }

.bfrb-chip {
  appearance: none;
  border: 1px solid var(--btn-border);
  background: transparent;
  color: var(--text);
  font-size: 0.76rem;
  padding: 5px 10px;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.1s ease, border-color 0.1s ease, color 0.1s ease;
}

.bfrb-chip:hover { border-color: var(--amber); }

.bfrb-chip.is-selected {
  background: var(--amber);
  border-color: var(--amber);
  color: #1a1a1a;
  font-weight: 600;
}

.bfrb-capture-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.bfrb-capture-done {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--amber);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 6px;
  cursor: pointer;
}

.bfrb-capture-done:hover { text-decoration: underline; }

body.focus-mode .bfrb-capture { display: none; }

/* ── Mood capture popover (Life-OS Phase 3) ──────────────────────────────
   Topbar-anchored sibling of the BFRB capture popover. Reuses the
   position-independent .bfrb-chip / .bfrb-capture-* classes for the innards;
   ONLY the positioning differs (.bfrb-capture is bottom-anchored above the
   FAB — the mood icon lives in the topbar, so this anchors below it,
   right-aligned). Visual tokens (border, background, radius, shadow,
   animation) mirror .bfrb-capture exactly. */
.mood-capture {
  position: fixed;
  right: 16px;
  top: calc(var(--tempo-topbar-h, 52px) + 8px);
  z-index: 2001;
  width: min(280px, calc(100vw - 32px));
  padding: 12px 14px 10px;
  background: var(--bg);
  border: 1px solid var(--btn-border);
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
  animation: mood-capture-in 0.14s ease;
}

/* Drop-in mirror of bfrb-capture-in, inverted (slides DOWN from the topbar
   instead of up from the FAB). */
@keyframes mood-capture-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mood-capture[hidden] { display: none; }

/* "+ note" reveal toggle — quiet text affordance, matches .bfrb-capture-done
   styling but left-aligned with the chip rows. */
.mood-note-toggle {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--amber);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 4px 0;
  margin-top: 6px;
  cursor: pointer;
}

.mood-note-toggle:hover { text-decoration: underline; }

.mood-note-toggle[hidden] { display: none; }

/* Optional ≤280-char note. Theme-token styled to match the chips. */
.mood-note-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-top: 6px;
  padding: 6px 8px;
  background: transparent;
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  resize: none;
}

.mood-note-input:focus { outline: none; border-color: var(--amber); }

.mood-note-input[hidden] { display: none; }

/* Focus / ambient mode hides every floating affordance (mirrors the
   body.focus-mode .bfrb-capture rule). */
body.focus-mode .mood-capture { display: none; }

/* BFRB chime volume slider in the settings drawer. */
.tempo-settings-slider {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px 12px;
}

.tempo-settings-slider .tempo-settings-item-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.tempo-settings-slider input[type="range"] {
  width: 100%;
  accent-color: var(--amber);
}

/* ── Cloud Sync (B-2) — settings drawer section ── */
.tempo-cloud-sync-section,
/* tempo-coach-daily-loop: same column spacing + separator as Cloud Sync so
   the Tempo Coach toggle rows align with the rest of the drawer. Reuses the
   shared .tempo-cloud-sync-toggle / .tempo-cloud-sync-row / -heading markup. */
.tempo-coach-section,
/* BFRB Closed Loop Slice B: same column layout for the BFRB support section
   (pace-nudge toggle + if-then plan input). */
.bfrb-support-section {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--separator);
  margin-top: 4px;
}

/* BFRB support — the if-then competing-response plan input row (stacked label
   over a full-width text field). */
.bfrb-support-plan-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.bfrb-support-plan-row .tempo-settings-item-label {
  font-size: 0.9rem;
  color: var(--text);
}

.bfrb-support-plan-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}

.bfrb-support-plan-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.8;
}

.bfrb-support-plan-input:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--amber) 60%, transparent);
  outline-offset: 1px;
  border-color: var(--amber);
}

.tempo-cloud-sync-heading {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 2px 0;
}

.tempo-cloud-sync-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

/* The bare `hidden` attribute should win over `display: flex` above. */
.tempo-cloud-sync-row[hidden],
.tempo-cloud-sync-photo[hidden] {
  display: none;
}

.tempo-cloud-sync-row .tempo-settings-item-label {
  flex: 1 1 auto;
  font-size: 0.9rem;
  color: var(--text);
}

/* iOS-style toggle switch (no extra deps). */
.tempo-cloud-sync-toggle {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex: 0 0 auto;
}

.tempo-cloud-sync-toggle-track {
  display: inline-block;
  width: 38px;
  height: 22px;
  background: var(--btn-border);
  border-radius: 11px;
  position: relative;
  transition: background-color 150ms ease;
}

.tempo-cloud-sync-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 150ms ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.tempo-cloud-sync-toggle[aria-checked="true"] .tempo-cloud-sync-toggle-track {
  background: var(--green);
}

.tempo-cloud-sync-toggle[aria-checked="true"] .tempo-cloud-sync-toggle-thumb {
  transform: translateX(16px);
}

.tempo-cloud-sync-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}

/* ── Live Activities (iOS) — settings drawer section ──
   Mirrors the Cloud Sync section styles above. Reuses the
   .tempo-cloud-sync-toggle* classes for the iOS-style switch so the two
   sections render identically. */
.tempo-live-activities-section {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--separator);
  margin-top: 4px;
}

.tempo-live-activities-heading {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 2px 0;
}

.tempo-live-activities-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.tempo-live-activities-row .tempo-settings-item-label {
  flex: 1 1 auto;
  font-size: 0.9rem;
  color: var(--text);
}

.tempo-cloud-sync-photo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--btn-bg);
  flex: 0 0 auto;
  object-fit: cover;
}

.tempo-cloud-sync-user-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.tempo-cloud-sync-name {
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.tempo-cloud-sync-email {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.tempo-cloud-sync-link {
  background: none;
  border: none;
  padding: 4px 6px;
  color: var(--green);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex: 0 0 auto;
}

.tempo-cloud-sync-link:hover { filter: brightness(1.15); }

.tempo-cloud-sync-primary {
  background: var(--green);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
}

.tempo-cloud-sync-primary:hover { filter: brightness(1.1); }

/* B-3: button-in-flight (mid-push) state. The `disabled` attribute and
   aria-disabled="true" are both applied by tempo-nav.js. */
.tempo-cloud-sync-primary:disabled,
.tempo-cloud-sync-primary[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

.tempo-cloud-sync-status {
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 2px 0;
}

.tempo-cloud-sync-status[data-error] {
  color: var(--red);
}

/* B-3: push-to-cloud progress states. data-progress mirrors the audit's
   enum: backup | checking-cloud | uploading | done | stage-d-handoff |
   error. Reuses the existing color tokens — no new design vars. */
.tempo-cloud-sync-status[data-progress="backup"],
.tempo-cloud-sync-status[data-progress="checking-cloud"],
.tempo-cloud-sync-status[data-progress="uploading"] {
  color: var(--text-secondary);
}

.tempo-cloud-sync-status[data-progress="done"] {
  color: var(--green);
}

.tempo-cloud-sync-status[data-progress="error"] {
  color: var(--red);
}

/* Stage D handoff is informational (cloud already has data) — use the
   productivity-pillar blue to signal "next step lives elsewhere" rather
   than "something failed". */
.tempo-cloud-sync-status[data-progress="stage-d-handoff"] {
  color: #007aff;
}

/* C-1: hydrate progress states for the settings drawer status row.
   The four per-store stages and the per-store progress messages
   ("Loading meds…") use the muted secondary text color; hydrate-done
   uses --green to match the existing 'done' state from push. */
.tempo-cloud-sync-status[data-progress="hydrate-checking-local"],
.tempo-cloud-sync-status[data-progress="hydrate-rest_log"],
.tempo-cloud-sync-status[data-progress="hydrate-meds"],
.tempo-cloud-sync-status[data-progress="hydrate-presets"],
.tempo-cloud-sync-status[data-progress="hydrate-history"] {
  color: var(--text-secondary);
}

.tempo-cloud-sync-status[data-progress="hydrate-done"] {
  color: var(--green);
}

/* ── C-1: Boot-time hydrate overlay ──
   Full-screen blocking modal shown while SyncEngine.hydrateFromCloud()
   pulls Device A's state for the first time on Device B. The blocking
   approach (vs render-then-replace) prevents every engine's render loop
   from racing the privileged-write replace path. Auto-dismisses on
   success; reveals retry/skip on error. Matches the .focus-overlay
   pattern (fixed inset:0, z-index:9999, background: var(--bg)). */
.tempo-hydrate-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.tempo-hydrate-overlay[hidden] {
  display: none;
}

.tempo-hydrate-overlay-content {
  max-width: 420px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.tempo-hydrate-overlay-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--btn-bg);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: tempo-hydrate-spin 1s linear infinite;
}

@keyframes tempo-hydrate-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .tempo-hydrate-overlay-spinner {
    animation: tempo-hydrate-pulse 1.5s ease-in-out infinite;
  }
  @keyframes tempo-hydrate-pulse {
    0%, 100% { opacity: 0.5; }
    50%      { opacity: 1; }
  }
}

.tempo-hydrate-overlay-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.tempo-hydrate-overlay-detail,
.tempo-hydrate-overlay-progress {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.4;
}

.tempo-hydrate-overlay-progress {
  font-weight: 500;
  color: var(--text);
  min-height: 1.4em;
}

.tempo-hydrate-overlay-error {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  width: 100%;
  margin-top: 8px;
}

.tempo-hydrate-overlay-error[hidden] {
  display: none;
}

.tempo-hydrate-overlay-error-message {
  font-size: 0.875rem;
  color: var(--red);
  margin: 0;
  line-height: 1.4;
}

.tempo-hydrate-overlay-retry,
.tempo-hydrate-overlay-dismiss {
  font: inherit;
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
  min-width: 160px;
}

.tempo-hydrate-overlay-retry {
  background: var(--green);
  color: var(--bg);
  border: 1px solid var(--green);
  font-weight: 600;
}

.tempo-hydrate-overlay-retry:hover {
  filter: brightness(1.1);
}

.tempo-hydrate-overlay-dismiss {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--btn-border);
}

.tempo-hydrate-overlay-dismiss:hover {
  background: var(--btn-bg);
  color: var(--text);
}

/* ── bl-2-todoist: Todoist settings drawer panel ──
   Lives inside #tempo-settings-drawer immediately below the Cloud Sync
   section. Spacing matches `.tempo-cloud-sync-section` so the two panels
   sit visually flush. No hardcoded colors — only theme tokens. */
.tempo-todoist-section {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--separator);
  margin-top: 4px;
}

.tempo-todoist-subhead {
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 2px 0;
}

.tempo-todoist-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.tempo-todoist-label {
  flex: 0 0 auto;
  font-size: 0.85rem;
  color: var(--text);
  min-width: 110px;
}

.tempo-todoist-input {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 0.85rem;
  -webkit-appearance: none;
  appearance: none;
}

.tempo-todoist-input:focus {
  outline: none;
  border-color: var(--green);
}

.tempo-todoist-help {
  font-size: 0.7rem;
  color: var(--text-secondary);
  padding: 0 2px;
}

.tempo-todoist-help a {
  color: var(--green);
  text-decoration: none;
}

.tempo-todoist-help a:hover {
  text-decoration: underline;
}

/* Secondary button used both for "Test connection" + the "Import from
   Todoist" surface on the Saved Tasks panel + the picker modal's Cancel.
   Matches the visual weight of `.pomo-action-btn` (transparent fill,
   outlined). */
.tempo-todoist-secondary {
  background: transparent;
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 8px 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  align-self: flex-start;
}

.tempo-todoist-secondary:hover {
  border-color: var(--green);
  color: var(--green);
}

.tempo-todoist-secondary:active {
  opacity: 0.7;
}

.tempo-todoist-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tempo-todoist-status {
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 2px 0;
}

.tempo-todoist-status[data-error] {
  color: var(--red);
}

.todoist-pending-count {
  font-style: italic;
}

.todoist-pending-count[hidden] {
  display: none;
}

/* The Import button on the Saved Tasks panel should fit in line with
   the other Pomodoro inline buttons rather than sit flush-left. */
#pomo-import-todoist {
  align-self: stretch;
  margin: 6px 0;
}

/* ── bl-2-todoist: shared picker modal ──
   Open via `TodoistUI.openPicker({ onImport })`. Single backdrop +
   centered card. The list scrolls inside the body so the header / footer
   stay visible. Z-index above settings drawer (which is z-index 200ish);
   we use 1000 to also clear the global BFRB FAB. */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.todoist-picker-modal {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.todoist-picker-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--separator);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.todoist-picker-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.modal-subhead {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.todoist-picker-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 12px;
  min-height: 80px;
}

.todoist-picker-status {
  padding: 16px 8px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.todoist-picker-status[data-error] {
  color: var(--red);
}

.todoist-picker-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.todoist-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  cursor: pointer;
  border-radius: 6px;
  -webkit-tap-highlight-color: transparent;
}

.todoist-picker-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.todoist-picker-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
  flex-shrink: 0;
  cursor: pointer;
}

.todoist-picker-task-content {
  flex: 1 1 auto;
  font-size: 0.9rem;
  color: var(--text);
  word-break: break-word;
}

.todoist-picker-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--separator);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Flow Block Mode ── */
.flow-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding: 0 4px;
}

.flow-setup {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.flow-duration-toggle {
  display: flex;
  gap: 8px;
}

.flow-dur-btn {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 8px 18px;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, color 0.15s;
}

.flow-dur-btn.flow-dur-active {
  border-color: var(--green);
  color: var(--green);
}

.flow-dur-btn:active {
  opacity: 0.7;
}

/* tempo-coach-daily-loop: the one-line descriptive "why" under the duration
   buttons when a readiness-sized default is pre-selected. Observational copy
   only — no pillar-color hardcoding (inherits the green accent var). */
.flow-readiness-why {
  margin: 6px 0 0;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--text-secondary);
}

.flow-readiness-why.hidden {
  display: none;
}

.flow-goal-input {
  width: 100%;
  max-width: 340px;
  height: 36px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  padding: 0 12px;
  font-family: inherit;
  outline: none;
  text-align: center;
}

.flow-goal-input:focus {
  border-color: var(--green);
}

.flow-goal-input::placeholder {
  color: var(--text-secondary);
}

.flow-checklist {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 10px;
}

.flow-checklist-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.flow-check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}

.flow-check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
  cursor: pointer;
}

#flow-skip-checklist {
  align-self: center;
  margin-top: 4px;
  font-size: 0.75rem;
}

/* todoist-flow-tasks: user-editable "Tasks for this block" list. Reuses the
   .flow-checklist container styling; adds row + add-input + import-button
   layout. The .tempo-todoist-secondary button class is shipped (V1). */
.flow-user-tasks {
  margin-top: 8px;
}

.flow-user-task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.flow-user-task-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
  cursor: pointer;
  flex-shrink: 0;
}

.flow-user-task-text {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-user-task-done .flow-user-task-text {
  text-decoration: line-through;
  color: var(--text-secondary);
  opacity: 0.6;
}

.flow-user-task-del {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.4;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.flow-user-task-del:active {
  opacity: 1;
  color: var(--red);
}

.flow-user-tasks-add {
  padding: 4px 0;
}

.flow-user-tasks-add input {
  width: 100%;
  height: 32px;
  background: var(--bg);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  padding: 0 10px;
  font-family: inherit;
  outline: none;
}

.flow-user-tasks-add input:focus {
  border-color: var(--green);
}

.flow-user-tasks-add input::placeholder {
  color: var(--text-secondary);
  opacity: 0.5;
}

/* todoist-flow-tasks: in-session running view — live count + checkable
   mirror. The count hides itself (empty text) when the list is empty. */
.flow-running-tasks {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.flow-running-tasks-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
}

.flow-running-tasks-count:empty {
  display: none;
}

#flow-running-tasks-items:empty {
  display: none;
}

.flow-running {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.flow-phase-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.flow-goal-display {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-secondary);
  text-align: center;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-summary {
  width: 100%;
  max-width: 360px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.flow-summary-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--green);
  text-align: center;
}

.flow-summary-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flow-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 0.85rem;
}

.flow-summary-label {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.flow-summary-value {
  color: var(--text);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flow-summary-sub {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.flow-summary-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.flow-action-btn {
  flex: 1;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  padding: 10px 12px;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.flow-action-btn.flow-action-primary {
  border-color: var(--green);
  color: var(--green);
}

.flow-action-btn:active {
  opacity: 0.6;
}

.flow-recovery {
  width: 100%;
  max-width: 360px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: center;
}

.flow-recovery-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.flow-recovery-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.history-flow-goal {
  font-size: 0.85rem;
  color: var(--text);
  padding: 2px 0;
}

/* Task Templates */
.pomo-template-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 4px;
  border-bottom: 0.5px solid var(--separator);
}

.pomo-template-save-row {
  display: flex;
  gap: 6px;
  padding: 8px 0 4px;
}

.pomo-template-save-row input {
  flex: 1;
  height: 32px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  padding: 0 10px;
  font-family: inherit;
  outline: none;
}

.pomo-template-save-row input:focus {
  border-color: var(--green);
}

.pomo-saved-empty {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: center;
  padding: 8px 0;
  opacity: 0.5;
}

.pomo-action-btn-primary {
  color: var(--green);
  border-color: var(--green);
}

/* Interval Area */
.interval-area {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.interval-templates {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 6px;
}

.interval-tpl-btn {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--text);
  font-size: 0.75rem;
  padding: 5px 12px;
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s;
}

.interval-tpl-btn:active {
  border-color: var(--green);
  color: var(--green);
}

.interval-phase-list {
  width: 100%;
  max-width: 280px;
}

.interval-phase-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 0.5px solid var(--separator);
}

.interval-phase-color {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.interval-phase-label {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text);
  text-align: left;
}

.interval-phase-dur {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.interval-phase-del {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.5;
  -webkit-tap-highlight-color: transparent;
}

.interval-phase-del:active {
  opacity: 1;
  color: var(--red);
}

.interval-empty {
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 12px 0;
}

.interval-add-row {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  padding: 6px 0;
}

.interval-input-name {
  width: 100px;
  height: 32px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.8rem;
  padding: 0 8px;
  font-family: inherit;
}

.interval-input-sec {
  width: 50px;
  height: 32px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  text-align: center;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  -webkit-appearance: none;
  -moz-appearance: textfield;
}

.interval-sec-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.interval-add-btn {
  width: 32px;
  height: 32px;
  background: var(--accent-tint);
  border: 1px solid var(--green);
  border-radius: 8px;
  color: var(--green);
  font-size: 1.2rem;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.interval-config-row {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  padding: 4px 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.interval-input-small {
  width: 44px;
  height: 30px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  text-align: center;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  -webkit-appearance: none;
  -moz-appearance: textfield;
}

.interval-input-small::-webkit-inner-spin-button,
.interval-input-small::-webkit-outer-spin-button,
.interval-input-sec::-webkit-inner-spin-button,
.interval-input-sec::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

/* Interval Running Info */
.interval-run-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.interval-current-phase {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--green);
}

.interval-next-phase {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.interval-round-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}

/* Cooking Mode */
.cooking-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cooking-timer-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cooking-timer-card {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cooking-running {
  border-color: var(--green);
}

.cooking-finished {
  border-color: var(--red);
}

.cooking-paused {
  border-color: var(--amber);
}

.cooking-timer-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cooking-timer-name {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 1px solid var(--btn-border);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  padding: 2px 0;
  outline: none;
}

.cooking-timer-name:focus {
  border-bottom-color: var(--green);
}

.cooking-timer-delete {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 2px 6px;
  opacity: 0.5;
  -webkit-tap-highlight-color: transparent;
}

.cooking-timer-delete:active {
  opacity: 1;
  color: var(--red);
}

.cooking-timer-time {
  font-family: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, monospace;
  font-size: clamp(2rem, 10vw, 3.5rem);
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--text);
  letter-spacing: -0.02em;
}

.cooking-finished .cooking-timer-time {
  color: var(--red);
}

.cooking-quick-btns {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
}

.cooking-quick-btn {
  background: var(--bg);
  border: 1px solid var(--btn-border);
  color: var(--text);
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 12px;
  cursor: pointer;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  -webkit-tap-highlight-color: transparent;
}

.cooking-quick-btn:active {
  border-color: var(--green);
  color: var(--green);
}

.cooking-timer-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.cooking-ctrl-btn {
  flex: 1;
  max-width: 120px;
  height: 36px;
  border-radius: 18px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cooking-ctrl-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.cooking-ctrl-start {
  border-color: var(--green);
  background: var(--accent-tint);
  color: var(--green);
}

.cooking-ctrl-stop {
  border-color: var(--red);
  background: var(--accent-red-tint);
  color: var(--red);
}

.cooking-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: none;
  border: 1px dashed var(--btn-border);
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cooking-add-btn:active {
  border-color: var(--green);
  color: var(--green);
}

.cooking-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 20px 0;
  font-size: 0.9rem;
}

#pomodoro-settings {
  max-height: 350px;
}

#timer-display.pomodoro-break #time {
  color: var(--green);
}

#timer-display.pomodoro-phase-complete #time {
  animation: flash-red 0.5s ease-in-out 6 alternate;
}

/* Focus / Ambient Mode */
.focus-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
  /* F-pwa: this overlay is meant to be left on-screen, so safe-area insets
     matter most here — keep the centered time + bottom hint clear of the
     notch and home indicator on iOS standalone. */
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
           env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

.focus-overlay.focus-visible {
  opacity: 1;
}

.focus-time {
  font-size: min(20vw, 200px);
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: -0.02em;
}

.focus-status {
  font-size: 1.2rem;
  color: var(--green);
  margin-top: 8px;
  min-height: 1.5em;
}

.focus-hint {
  position: absolute;
  /* F-pwa: lift above the home indicator on iOS standalone. */
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  font-size: 0.7rem;
  color: var(--text-secondary);
  opacity: 0.4;
}

.auto-advance-overlay {
  position: absolute;
  bottom: 4px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--green);
  font-weight: 600;
  pointer-events: none;
}

/* Export Area */
.export-area {
  text-align: center;
  padding: 2px 0;
}

/* History Panel */
.history-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 300;
  display: flex;
  flex-direction: column;
  /* Reserve iOS safe-area: this full-screen fixed takeover paints over the tabbar
     and escapes #app's padding, so it must inset its own header (title + close) off
     the notch and its footer actions off the home indicator on notched iOS
     standalone. Mirrors .focus-overlay; inert (no visual change) where env()=0. */
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
           env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  overflow: hidden;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 0.5px solid var(--separator);
}

.history-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 20px;
}

/* Analytics Dashboard */
.analytics-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  top: 0;
  background: var(--bg);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  /* Reserve iOS safe-area — full-screen takeover; mirrors .focus-overlay (see
     .history-panel). Panel is the scroll container, so padding insets the scroll
     content off the notch/home-indicator. Inert where env()=0. */
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
           env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.analytics-content {
  padding: 12px 20px 40px;
}

.analytics-loading {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 0;
}

.analytics-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

/* Shared card chrome. Every analytics section renders via renderCard()
   which outputs this structure; per-card rules below only override what
   differs (gap, padding). */
.analytics-card {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-lg, 14px);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* E-polish: crisp aligned figures across every data card. */
  font-variant-numeric: tabular-nums;
}

.analytics-card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.analytics-card-header {
  /* E-polish (Bold Data-Dense): uppercase, tracked, and brighter. The old
     text-secondary @ opacity 0.6 compounded into a barely-legible label; data
     panels deserve a crisp dashboard heading. */
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  opacity: 0.82;
  font-weight: 700;
}

.analytics-card-aside {
  font-size: 0.66rem;
  color: var(--text);
  opacity: 0.55;
  letter-spacing: 0.1em;
}

/* Focus streak hero card — slightly taller top padding */
.analytics-streak-card {
  padding: 18px 20px 16px;
}

.analytics-streak-hero {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.analytics-streak-number {
  font-size: 3rem;
  font-weight: 600;
  line-height: 1;
  color: var(--green);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.analytics-streak-hero-label {
  font-size: 1rem;
  color: var(--text);
  opacity: 0.8;
}

.analytics-streak-sub {
  font-size: 0.82rem;
  color: var(--text);
  opacity: 0.72;
}

.analytics-streak-dots {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-top: 6px;
}

.analytics-streak-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--btn-border);
  flex: 0 0 auto;
  transition: background 0.12s ease, transform 0.12s ease;
}

.analytics-streak-dot-on {
  background: var(--green);
}

.analytics-streak-dot-today {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--green) 45%, transparent);
  transform: scale(1.12);
}

.analytics-streak-dot-today.analytics-streak-dot-on {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--green) 70%, transparent);
}

/* Flow completion rate card — slightly wider gap between body + foot */
.analytics-flow-card {
  gap: 12px;
}

.analytics-flow-body {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.analytics-flow-donut-wrap {
  flex: 0 0 auto;
}

.analytics-flow-donut {
  display: block;
}

.analytics-flow-donut-label {
  font-family: inherit;
  font-size: 18px;
  font-weight: 600;
  fill: var(--green);
}

.analytics-flow-stats {
  margin: 0;
  padding: 0;
  flex: 1 1 180px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.analytics-flow-stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
}

.analytics-flow-stat-row dt {
  color: var(--text);
  opacity: 0.72;
  margin: 0;
}

.analytics-flow-stat-row dd {
  color: var(--text);
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.analytics-flow-foot {
  font-size: 0.78rem;
  color: var(--text);
  opacity: 0.6;
}

/* Distraction patterns card (leaderboard + hour-of-day heat strip) */
/* Distraction card uses shared chrome — see .analytics-card. */

.analytics-distraction-subtitle {
  font-size: 0.78rem;
  color: var(--text);
  opacity: 0.68;
  margin-bottom: 2px;
}

.analytics-distraction-leaderboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.analytics-distraction-row {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text);
}

.analytics-distraction-label {
  opacity: 0.82;
}

.analytics-distraction-bar {
  height: 10px;
  background: var(--btn-border);
  border-radius: 5px;
  overflow: hidden;
  display: flex;
}

.analytics-distraction-bar-flow {
  height: 100%;
  /* E-polish follow-up (E20): pillar token (centralizes the productivity hue). */
  background: var(--productivity-accent);
}

.analytics-distraction-bar-pomo {
  height: 100%;
  background: #ff6b6b;
}

.analytics-distraction-count {
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  opacity: 0.82;
  white-space: nowrap;
}

.analytics-distraction-split {
  opacity: 0.55;
  font-size: 0.72rem;
  margin-left: 4px;
}

.analytics-distraction-legend {
  display: flex;
  gap: 12px;
  font-size: 0.72rem;
  color: var(--text);
  opacity: 0.7;
  margin-top: 2px;
}

.analytics-distraction-legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.analytics-distraction-legend-dot.is-flow { background: var(--productivity-accent); }
.analytics-distraction-legend-dot.is-pomo { background: #ff6b6b; }

.analytics-distraction-hour-title {
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  color: var(--text);
  opacity: 0.55;
  margin-top: 10px;
  font-weight: 600;
}

.analytics-distraction-hour-strip {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 2px;
  height: 22px;
}

.analytics-distraction-hour {
  border-radius: 2px;
  min-width: 0;
}

.analytics-distraction-hour-axis {
  display: flex;
  justify-content: space-between;
  font-size: 0.66rem;
  color: var(--text);
  opacity: 0.55;
  padding: 0 2px;
  margin-top: -2px;
}

.analytics-distraction-peak {
  font-size: 0.76rem;
  color: var(--text);
  opacity: 0.6;
}

/* BFRB trend card — line chart with 14/30/90 window toggle */
/* BFRB trend card uses shared chrome — see .analytics-card. */

.analytics-bfrb-toggle {
  display: inline-flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  padding: 2px;
}

.analytics-bfrb-window {
  background: none;
  border: none;
  color: var(--text);
  opacity: 0.7;
  font-size: 0.75rem;
  font-family: inherit;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background 0.12s ease, opacity 0.12s ease;
}

.analytics-bfrb-window:hover {
  opacity: 1;
}

.analytics-bfrb-window-active {
  background: color-mix(in srgb, var(--amber) 18%, transparent);
  color: var(--amber);
  opacity: 1;
}

.analytics-bfrb-numbers {
  display: flex;
  align-items: baseline;
  gap: 20px;
  flex-wrap: wrap;
}

.analytics-bfrb-primary {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.analytics-bfrb-primary-value {
  font-size: 2rem;
  font-weight: 600;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
}

.analytics-bfrb-primary-label {
  font-size: 0.78rem;
  color: var(--text);
  opacity: 0.7;
}

.analytics-bfrb-secondary {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.analytics-bfrb-secondary-value {
  font-size: 1.1rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.analytics-bfrb-secondary-label {
  font-size: 0.78rem;
  color: var(--text);
  opacity: 0.6;
}

.analytics-bfrb-chart-wrap {
  position: relative;
  margin-top: 2px;
}

.analytics-bfrb-chart {
  display: block;
  width: 100%;
}

.analytics-bfrb-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--text);
  opacity: 0.55;
  pointer-events: none;
}

.analytics-bfrb-axis {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text);
  opacity: 0.55;
}

.analytics-bfrb-foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.76rem;
  color: var(--text);
  opacity: 0.6;
}

.analytics-bfrb-trend-note {
  font-weight: 600;
  opacity: 0.85;
}

/* BFRB trend sub-sections (hour-of-day + by-source) */
.analytics-bfrb-sub-title {
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  color: var(--text);
  opacity: 0.55;
  margin-top: 10px;
  font-weight: 600;
}

.analytics-bfrb-hour-strip {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 2px;
  height: 20px;
}

.analytics-bfrb-hour {
  border-radius: 2px;
  min-width: 0;
}

.analytics-bfrb-hour-axis {
  display: flex;
  justify-content: space-between;
  font-size: 0.66rem;
  color: var(--text);
  opacity: 0.55;
  padding: 0 2px;
  margin-top: -2px;
}

.analytics-bfrb-hour-peak-wrap {
  font-size: 0.74rem;
  color: var(--text);
  opacity: 0.6;
}

.analytics-bfrb-source-bar {
  display: flex;
  height: 12px;
  background: var(--btn-border);
  border-radius: 4px;
  overflow: hidden;
}

.analytics-bfrb-source-seg {
  height: 100%;
  transition: width 0.2s ease;
}

.analytics-bfrb-source-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  font-size: 0.74rem;
  color: var(--text);
  opacity: 0.75;
}

.analytics-bfrb-source-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.analytics-bfrb-source-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.analytics-bfrb-source-count {
  opacity: 0.65;
  font-variant-numeric: tabular-nums;
}

/* Med adherence 30-day dot row per med */
/* Med adherence card uses shared chrome — see .analytics-card. */

.analytics-adherence-legend {
  display: flex;
  gap: 14px;
  font-size: 0.7rem;
  color: var(--text);
  opacity: 0.65;
  align-items: center;
}

.analytics-adherence-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.analytics-adherence-legend .adherence-dot {
  width: 8px;
  height: 8px;
}

.analytics-adherence-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.adherence-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.adherence-row-header {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "name pct"
    "meta pct";
  gap: 0 12px;
  align-items: baseline;
}

.adherence-name {
  grid-area: name;
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 600;
}

.adherence-meta {
  grid-area: meta;
  font-size: 0.76rem;
  color: var(--text);
  opacity: 0.65;
}

.adherence-pct {
  grid-area: pct;
  font-size: 1.3rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  align-self: center;
}

.adherence-pct-high { color: var(--green); }
.adherence-pct-mid { color: var(--amber); }
.adherence-pct-low { color: #ff6b6b; }

.adherence-dots {
  display: grid;
  grid-template-columns: repeat(30, 1fr);
  gap: 3px;
  align-items: center;
}

.adherence-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: inline-block;
}

.adherence-dot-full {
  background: var(--green);
}

.adherence-dot-partial {
  background: linear-gradient(
    90deg,
    var(--green) 0%,
    var(--green) 50%,
    var(--btn-border) 50%,
    var(--btn-border) 100%
  );
}

.adherence-dot-missed {
  background: var(--btn-border);
}

/* Actual-work log (top-10 Pomodoro actualWork entries in window) */
/* Actual-work card — tighter vertical rhythm than default */
.analytics-aw-card {
  gap: 8px;
}

.analytics-aw-meta {
  font-size: 0.78rem;
  color: var(--text);
  opacity: 0.65;
}

.analytics-aw-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  counter-reset: aw;
}

.analytics-aw-row {
  counter-increment: aw;
  display: grid;
  grid-template-columns: 20px 1fr auto;
  gap: 10px;
  align-items: baseline;
  padding: 6px 0;
  border-top: 1px solid var(--btn-border);
  font-size: 0.87rem;
  color: var(--text);
}

.analytics-aw-row:first-child {
  border-top: none;
}

.analytics-aw-row::before {
  content: counter(aw) ".";
  color: var(--text);
  opacity: 0.45;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.analytics-aw-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-aw-count {
  font-size: 0.76rem;
  color: var(--text);
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--green) 16%, transparent);
  border-radius: 10px;
  padding: 2px 8px;
  min-width: 20px;
  text-align: center;
}

/* Phase restarts card — small summary of Pomodoro phaseLog[].restarted */
/* Phase-restarts card — tighter vertical rhythm than default */
.analytics-pr-card {
  gap: 8px;
}

.analytics-pr-number-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}

.analytics-pr-number {
  font-size: 2rem;
  font-weight: 600;
  color: #ff6b6b;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
}

.analytics-pr-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  font-size: 0.85rem;
  color: var(--text);
  opacity: 0.82;
}

.analytics-pr-count {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  margin-right: 2px;
}

.analytics-pr-sep {
  opacity: 0.4;
}

.analytics-pr-tone {
  font-size: 0.78rem;
  color: var(--text);
  opacity: 0.6;
}

.analytics-section-title {
  font-size: 0.75rem;
  /* E-polish follow-up: crisp dashboard heading (matches .analytics-card-header). */
  color: var(--text);
  opacity: 0.82;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 12px 0 6px;
}

.analytics-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 120px;
  padding: 4px 0;
}

.analytics-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.analytics-bar-stack {
  width: 100%;
  display: flex;
  flex-direction: column-reverse;
  border-radius: 3px 3px 0 0;
  overflow: hidden;
  min-height: 2px;
}

.analytics-bar-segment {
  width: 100%;
  min-height: 1px;
}

.analytics-bar-label {
  font-size: 0.6rem;
  color: var(--text-secondary);
  margin-top: 4px;
  white-space: nowrap;
}

.analytics-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0 8px;
}

.analytics-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.analytics-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.analytics-heatmap {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  grid-auto-flow: column;
  gap: 2px;
  padding: 4px 0;
}

.heatmap-cell {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 2px;
  background: var(--btn-bg);
  min-width: 6px;
}

.history-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 12px 20px;
  border-top: 0.5px solid var(--separator);
}

.history-danger {
  color: var(--red) !important;
}

.log-past-panel {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  /* Reserve iOS safe-area — full-screen takeover; mirrors .focus-overlay (see
     .history-panel). Header (title + close) clears the notch; .log-past-form keeps
     its 40px bottom for breathing room above this inset. Inert where env()=0. */
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
           env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.log-past-form {
  padding: 12px 20px 40px;
}

.log-past-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  text-align: center;
}

.log-past-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
}

.log-past-row label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  flex-shrink: 0;
  min-width: 90px;
}

.log-past-row input,
.log-past-row select {
  flex: 1;
  height: 32px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  padding: 0 10px;
  font-family: inherit;
  outline: none;
  max-width: 180px;
}

.log-past-row input:focus,
.log-past-row select:focus {
  border-color: var(--green);
}

.log-past-row select {
  -webkit-appearance: none;
  appearance: none;
}

.log-past-list-row {
  padding: 6px 0;
}

.log-past-list-row label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.log-past-list-row input {
  width: 100%;
  height: 32px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  padding: 0 10px;
  font-family: inherit;
  outline: none;
  margin-top: 4px;
}

.log-past-list-row input:focus {
  border-color: var(--green);
}

.log-past-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.8rem;
  color: var(--text);
  border-bottom: 0.5px solid var(--separator);
}

.log-past-list-item button {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.5;
}

.log-past-list-item button:active {
  opacity: 1;
  color: var(--red);
}

.history-row {
  padding: 12px 0;
  border-bottom: 0.5px solid var(--separator);
}

.history-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.history-type {
  font-size: 0.8rem;
  color: var(--green);
  font-weight: 600;
  text-transform: uppercase;
}

.history-dur {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
}

.history-date {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.history-row-bottom {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.history-laps {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.history-tasks {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 0.5px solid var(--separator);
}

.history-task-section {
  margin-bottom: 4px;
}

.history-task-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.history-task-list {
  margin: 2px 0 0 0;
  padding-left: 18px;
  font-size: 0.8rem;
  color: var(--text);
}

.history-task-list li {
  margin-bottom: 1px;
}

.history-timing {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 0.5px solid var(--separator);
}

.history-phase-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
  font-size: 0.8rem;
}

.history-phase-name {
  color: var(--text);
}

.history-phase-time {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.history-note {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-style: italic;
  cursor: pointer;
}

.history-note:active {
  opacity: 0.6;
}

.history-add-note {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  opacity: 0.5;
  -webkit-tap-highlight-color: transparent;
}

.history-add-note:active {
  opacity: 1;
  color: var(--green);
}

.note-input {
  width: 100%;
  max-width: 200px;
  height: 24px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.8rem;
  padding: 0 8px;
  font-family: inherit;
  font-style: italic;
  outline: none;
}

.note-input:focus {
  border-color: var(--green);
}

/* History Filter Bar */
.history-filter {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 20px;
}

.history-filter:empty {
  display: none;
}

.date-filter-bar,
.tag-filter-bar {
  display: flex;
  gap: 6px;
  padding: 4px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.filter-chip {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, color 0.15s;
}

.filter-chip-active {
  border-color: var(--green);
  color: var(--green);
}

/* History Tags */
.history-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--text-secondary);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
}

.tag-chip-delete {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  opacity: 0.6;
  -webkit-tap-highlight-color: transparent;
}

.tag-chip-delete:active {
  opacity: 1;
  color: var(--red);
}

.tag-add-btn {
  background: none;
  border: 1px dashed var(--btn-border);
  color: var(--text-secondary);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.tag-add-btn:active {
  border-color: var(--green);
  color: var(--green);
}

/* D-1: "Imported (pre-sync)" chip on history-session rows whose bucket
   is 'imported'. Visually distinct from .tag-chip so it doesn't look
   user-editable — slightly smaller text, dashed-outline border (matches
   .tag-add-btn idiom but in a non-interactive shape), and no hover/active
   affordance. pointer-events: none seals it as read-only. */
.history-tag-imported {
  display: inline-flex;
  align-items: center;
  border: 1px dashed var(--btn-border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: 10px;
  pointer-events: none;
  white-space: nowrap;
}

/* D-1: imported-filter-bar wraps the single "Hide imported" /
   "Show imported" filter chip into its own row so it doesn't crowd the
   date or tag chips on narrow viewports. Mirrors .date-filter-bar /
   .tag-filter-bar layout — no new tokens. */
.imported-filter-bar {
  display: flex;
  gap: 6px;
  padding: 4px 0;
}

.tag-input {
  width: 80px;
  height: 22px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.7rem;
  padding: 0 8px;
  font-family: inherit;
  outline: none;
}

.tag-input:focus {
  border-color: var(--green);
}

.history-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 0;
  font-size: 0.9rem;
}

/* Install Banner */
.install-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 12px;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--text);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.install-banner.install-visible {
  opacity: 1;
  transform: translateY(0);
}

.install-btn {
  background: var(--green);
  color: #000;
  border: none;
  border-radius: 8px;
  padding: 5px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}

.install-dismiss {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  font-family: inherit;
}

/* Utility */
.hidden {
  display: none !important;
}

/* Desktop layout — wider container, side-by-side timer + laps */
@media (min-width: 768px) {
  #app {
    max-width: 720px;
  }

  .top-bar {
    padding: 16px 0 8px;
  }

  #timer-display {
    padding: 40px 0 16px;
  }

  #controls {
    padding: 16px 40px;
  }

  #lap-section {
    max-height: 400px;
  }
}

/* Reduced motion: suppress lap-entering slide */
@media (prefers-reduced-motion: reduce) {
  .lap-entering {
    animation: none;
  }
}

/* Safe area for notched devices */
@supports (padding-top: env(safe-area-inset-top)) {
  #timer-display {
    padding-top: calc(60px + env(safe-area-inset-top));
  }
  #app {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ── Rhythm pillar — daily timeline ── */
.rhythm-root {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px 16px 80px;
}
.rhythm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.rhythm-nav-btn {
  background: var(--surface, #2c2c2e);
  color: var(--text-primary, #f5f5f7);
  border: 0.5px solid var(--separator, #38383a);
  border-radius: 12px;
  width: 40px;
  height: 40px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.1s ease;
}
.rhythm-nav-btn:active {
  transform: scale(0.92);
}
.rhythm-day-label {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary, #f5f5f7);
  letter-spacing: 0.01em;
}
.rhythm-status {
  font-size: 13px;
  color: var(--text-secondary, #8e8e93);
  text-align: center;
  margin-bottom: 16px;
  min-height: 18px;
}
.rhythm-timeline {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 0.5px solid var(--separator, #38383a);
  padding-top: 12px;
}
.rhythm-empty {
  font-size: 14px;
  color: var(--text-secondary, #8e8e93);
  text-align: center;
  padding: 32px 0;
}
.rhythm-entry {
  display: grid;
  grid-template-columns: 64px 20px 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  border-radius: 8px;
  font-size: 14px;
  transition: background 0.1s ease;
}
.rhythm-entry:hover {
  background: var(--surface, rgba(255, 255, 255, 0.03));
}
.rhythm-time {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text-secondary, #8e8e93);
}
.rhythm-dot {
  font-size: 14px;
  text-align: center;
  line-height: 1;
}
.rhythm-summary {
  color: var(--text-primary, #f5f5f7);
}
/* E-polish follow-up (E20): centralize the pillar hue in the pillar tokens
   (the bare hex duplicated the token value). --productivity/--wellness-accent
   are :root brand constants (same hue across all themes), so this is
   consolidation — not a re-theming change. */
.rhythm-entry--productivity .rhythm-dot { color: var(--productivity-accent); }
.rhythm-entry--wellness .rhythm-dot { color: var(--wellness-accent); }
.rhythm-entry--session-end .rhythm-dot { opacity: 0.55; }
.rhythm-now-line {
  position: relative;
  height: 1px;
  background: var(--accent, #ff453a);
  margin: 12px 0;
}
.rhythm-now-label {
  position: absolute;
  top: -10px;
  left: 0;
  background: var(--bg, #1c1c1e);
  color: var(--accent, #ff453a);
  font-size: 11px;
  font-weight: 600;
  padding: 0 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.rhythm-readiness-band {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 12px;
  font-size: 13px;
  background: var(--surface, #2c2c2e);
  border: 0.5px solid var(--separator, #38383a);
  color: var(--text-primary, #f5f5f7);
  line-height: 1.3;
}
.rhythm-readiness-band[hidden] {
  display: none;
}
.rhythm-readiness-emoji {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}
.rhythm-readiness-label {
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.rhythm-readiness-detail {
  color: var(--text-secondary, #8e8e93);
  font-variant-numeric: tabular-nums;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* E-polish follow-up: themed tokens for the readiness rails where one exists.
   --green/--red track light/dark; neutral (yellow #ffd60a) and insufficient
   (grey border) have no clean token, kept literal. */
.rhythm-readiness-band--well_recovered { border-left: 3px solid var(--green); }
.rhythm-readiness-band--neutral { border-left: 3px solid #ffd60a; }
.rhythm-readiness-band--strained { border-left: 3px solid var(--red); }
.rhythm-readiness-band--insufficient_data { border-left: 3px solid #8e8e93; }

@media (prefers-color-scheme: light) {
  .rhythm-nav-btn { background: #fff; }
  .rhythm-now-label { background: var(--bg, #f5f5f7); }
  .rhythm-readiness-band {
    background: #fff;
    border-color: #e5e5ea;
  }
}

/* ── Rhythm Insights dashboard (#12) ───────────────────────────────────
   Panels reuse the .analytics-card* chrome; these classes cover the
   insights surface, shared building blocks, the Meds-vs-Sleep panel, and
   the #11 bedtime/wake-time inputs. Theme vars keep light/dark in sync. */

.rhythm-insights-surface {
  /* E-polish (Bold Data-Dense): a 2-up dashboard grid on wider viewports,
     single column on phones. The Today briefing pins full-width atop as the
     hero (rule below). */
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 4px 0 24px;
  align-items: start;
}
@media (min-width: 520px) {
  .rhythm-insights-surface { grid-template-columns: 1fr 1fr; }
}
/* Today briefing = full-width hero with a pillar-accent rail so it reads as the
   headline, not just another card in the grid. */
.rhythm-insights-surface [data-insight-panel="today"] {
  grid-column: 1 / -1;
  border-left: 3px solid var(--chart-1);
}

.rhythm-insights-loading,
.rhythm-insight-empty {
  color: var(--text-secondary, #8e8e93);
  font-size: 0.82rem;
  text-align: center;
  padding: 18px 8px;
}

.rhythm-insight-card { gap: 10px; margin-bottom: 0; } /* grid gap handles spacing */

/* ── BFRB Triggers panel (order 45) ──────────────────────────────────────
   Forgiving clean-streak (reuses .analytics-streak-*; catch days get an amber
   dot) + trigger leaderboard (reuses .analytics-distraction-*) + urge mix. */
.bfrb-streak { margin-bottom: 6px; }

.bfrb-streak-dot-catch { background: var(--amber); }

.bfrb-triggers-subtitle {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.55;
  margin: 10px 0 6px;
}

.bfrb-trigger-bar-fill { height: 100%; background: var(--amber); }

.bfrb-trigger-bar-untagged {
  background: var(--text-secondary, #8a8a8e);
  opacity: 0.5;
}

.bfrb-urge { margin-top: 4px; }

.bfrb-urge-bar {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--btn-border);
}

.bfrb-urge-seg { height: 100%; }
.bfrb-urge-seg-1 { background: var(--green); }
.bfrb-urge-seg-2 { background: var(--amber); }
.bfrb-urge-seg-3 { background: var(--red); }

.bfrb-urge-legend {
  display: flex;
  gap: 12px;
  font-size: 0.72rem;
  opacity: 0.75;
  margin-top: 6px;
}

.bfrb-urge-legend-item { display: inline-flex; align-items: center; gap: 4px; }

.bfrb-urge-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.bfrb-urge-dot-1 { background: var(--green); }
.bfrb-urge-dot-2 { background: var(--amber); }
.bfrb-urge-dot-3 { background: var(--red); }

/* Segmented toggles + selectors (aside controls / med picker) */
.rhythm-ms-toggle,
.rhythm-ms-meds {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
}
.rhythm-ms-meds { margin-top: 2px; }

.rhythm-ms-toggle button,
.rhythm-ms-med {
  font: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary, #8e8e93);
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
  line-height: 1.4;
}

.rhythm-ms-toggle button.is-active,
.rhythm-ms-med.is-active {
  color: #fff;
  background: var(--active-accent, #007aff);
  border-color: var(--active-accent, #007aff);
}

.rhythm-ms-subtitle {
  font-size: 0.78rem;
  color: var(--text);
  opacity: 0.7;
}

.rhythm-ms-chart { display: block; width: 100%; margin-top: 4px; }

.rhythm-ms-axis {
  display: flex;
  justify-content: space-between;
  font-size: 0.66rem;
  color: var(--text-secondary, #8e8e93);
  margin-top: 2px;
}

.rhythm-ms-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.66rem;
  color: var(--text-secondary, #8e8e93);
  margin-top: 4px;
}
.rhythm-ms-legend i {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.rhythm-ms-legend-note { margin-left: auto; opacity: 0.7; }

/* Generic insight building blocks (reused by recovery/event/correlation panels) */
.rhythm-spark { display: block; width: 100%; }

.rhythm-spark-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  align-items: center;
  font-size: 0.78rem;
}
.rhythm-spark-row + .rhythm-spark-row { margin-top: 8px; }
.rhythm-spark-label { color: var(--text-secondary, #8e8e93); font-weight: 600; }
.rhythm-spark-value { color: var(--text); font-variant-numeric: tabular-nums; }

.rhythm-callout-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rhythm-callout {
  font-size: 0.84rem;
  color: var(--text);
  line-height: 1.4;
  padding-left: 16px;
  position: relative;
}
.rhythm-callout::before {
  content: "•";
  position: absolute;
  left: 2px;
  color: var(--active-accent, #007aff);
}

/* event-zoom panel: 14-day condensed activity strip. Per-segment height +
   background are set inline in the panel JS; these are the structural rules. */
.rhythm-zoom-strip {
  display: flex;
  flex-direction: row;
  gap: 3px;
  align-items: flex-end;
}
.rhythm-zoom-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.rhythm-zoom-bar {
  width: 100%;
  height: 60px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
}
.rhythm-zoom-segment { width: 100%; }
.rhythm-zoom-label {
  margin-top: 4px;
  font-size: 9px;
  line-height: 1;
  text-align: center;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* #11: bedtime / wake-time inputs on the Recovery sleep form */
.recovery-sleep-times {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}
.recovery-sleep-time-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--text-secondary, #8e8e93);
  flex: 1 1 0;
}
.recovery-sleep-time-label input[type="time"] {
  font: inherit;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--text);
}
.recovery-sleep-times-display {
  font-size: 0.8rem;
  color: var(--text-secondary, #8e8e93);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

/* Shared axis + gridline chrome for the SVG insight panels (RI.gridlines /
   RI.xAxis / RI.yAxis). Set as CSS so they track light/dark themes. */
.rhythm-gridline {
  stroke: var(--btn-border);
  stroke-width: 1;
  opacity: 0.35;
}
.rhythm-axis-line {
  stroke: var(--btn-border);
  stroke-width: 1;
}
.rhythm-axis-text {
  fill: var(--text-secondary, #8e8e93);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

/* Cross-panel day highlight: hovering any element with data-day="YYYY-MM-DD"
   emphasizes every element sharing that day across all panels. HTML bars get an
   outline; SVG dots get a contrasting stroke. */
.rhythm-day-hi {
  outline: 2px solid var(--active-accent, #007aff);
  outline-offset: 1px;
  border-radius: 3px;
}
circle.rhythm-day-hi,
rect.rhythm-day-hi {
  outline: none;
  stroke: var(--text);
  stroke-width: 1.5;
  paint-order: stroke;
}

/* Shared custom hover tooltip: a single <div> on <body> that follows the
   cursor (positioned inline by JS). pointer-events:none so it never eats the
   hover it describes. */
.rhythm-tooltip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1000;
  pointer-events: none;
  max-width: 220px;
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--btn-bg, #1c1c1e);
  color: var(--text, #fff);
  border: 1px solid var(--btn-border);
  font-size: 0.72rem;
  line-height: 1.35;
  white-space: pre-line;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
}
.rhythm-tooltip[hidden] {
  display: none;
}

/* ── Accessibility: global reduced-motion reset (Batch D) ──────────────────
   The codebase only had a handful of targeted reduced-motion blocks, leaving
   the flash-red countdown, BFRB pulse, mode-fade, breathing glow, and analog
   hand transitions uncovered. This honors the OS setting app-wide by collapsing
   all animation/transition durations. (Inline JS-set transitions — e.g. the
   Mindful breathing circle — can't be reached by CSS and are gated in JS via
   matchMedia in mindful-ui.js.) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Accessibility: ≥44px touch targets for icon/chip-delete controls (D) ──
   The tag/checklist/alert/phase/card/preset delete glyphs and icon buttons had
   ~16-24px effective hit areas — below the 44px iOS/WCAG minimum on a phone-
   first PWA. Keep the small visual glyph; expand the HIT area via a centered
   flex box + min size. Applied to the existing per-component selectors so no
   markup changes are needed. */
.tag-chip-delete,
.pomo-checklist-item-delete,
.alert-chip-delete,
.interval-phase-del,
.card-delete,
.card-compare,
.preset-delete,
.cooking-timer-delete,
.icon-btn,
.tempo-iconbtn,
[data-seq-del],
[data-log-del] {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Life-OS Home hub (Phase 1) ──────────────────────────────────────────
   The default-landing dashboard: bubble map + synthesis cards + 3 moves.
   Themed entirely via design-system vars + the --home-band-* tokens; no
   hardcoded hex outside those band vars (defined in :root). */
.home-pillar-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4) var(--space-8);
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

/* Shared card chrome — reuses the surface/radius/shadow token language. */
.home-card {
  background: var(--surface);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-1);
}

/* ── Bubble map ── */
.home-bubblemap {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.home-lens-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.home-lens-btn {
  flex: 1 1 auto;
  min-height: 36px;
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-standard),
              background var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard);
}
.home-lens-btn:hover {
  color: var(--text-primary);
}
.home-lens-btn.is-active {
  color: var(--text-primary);
  background: var(--accent-tint);
  border-color: var(--accent);
}
.home-bubblemap-figure {
  width: 100%;
}
.home-bubblemap-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}
.home-bubble-circle {
  transition: r var(--dur-base) var(--ease-standard);
  opacity: 0.9;
}
.home-bubble-label {
  fill: var(--text-secondary);
  font-size: 9px;
  font-weight: 600;
}

/* ── Band chips ── */
.home-band-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  font-size: var(--fs-xs);
  font-weight: 700;
  border-radius: var(--radius-pill);
  color: var(--bg);
  white-space: nowrap;
}
.home-band-chip[data-band="thriving"] { background: var(--home-band-thriving); }
.home-band-chip[data-band="steady"]   { background: var(--home-band-steady); }
.home-band-chip[data-band="strained"] { background: var(--home-band-strained); }
.home-band-chip[data-band="depleted"] { background: var(--home-band-depleted); }
.home-band-chip[data-band="unknown"]  { background: var(--home-band-unknown); }

/* ── Hero card ── */
.home-hero-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.home-hero-kicker {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.home-hero-headline {
  margin-top: var(--space-3);
  font-size: var(--fs-lg);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

/* ── Per-pillar cards ── */
.home-pillar-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.home-pillar-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.home-pillar-card-title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text-primary);
}
.home-pillar-card-headline {
  margin-top: var(--space-2);
  font-size: var(--fs-base);
  line-height: 1.35;
  color: var(--text-primary);
}
.home-pillar-card-signal {
  margin-top: var(--space-1);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

/* ── This week's 3 moves ── */
.home-moves-title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}
.home-moves-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  counter-reset: home-move;
}
.home-move-row {
  position: relative;
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-8);
  font-size: var(--fs-base);
  line-height: 1.35;
  color: var(--text-primary);
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-md);
  counter-increment: home-move;
}
.home-move-row::before {
  content: counter(home-move);
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--bg);
  background: var(--accent);
  border-radius: var(--radius-pill);
}

/* ── Empty state (the DEFAULT path) ── */
.home-empty {
  text-align: center;
  padding: var(--space-8) var(--space-4);
}
.home-empty-mark {
  font-size: 2rem;
  color: var(--text-secondary);
  line-height: 1;
}
.home-empty-title {
  margin-top: var(--space-3);
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text-primary);
}
.home-empty-body {
  margin-top: var(--space-2);
  font-size: var(--fs-base);
  color: var(--text-secondary);
}

/* ── Life-OS Physicals hub (Phase 2) ─────────────────────────────────────
   The dedicated Physicals pillar: a composite hero + four Area cards
   (Recovery / Sleep / Meds / Training load) + this week's moves. Reuses the
   Home hub's .home-card chrome, .home-band-chip primitive, --home-band-*
   tokens and .home-moves* list — only the layout + text classes are new. */
.physicals-pillar-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4) var(--space-8);
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

/* ── Hero (the composite Physicals read) ── */
.physicals-hero-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.physicals-hero-kicker {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.physicals-hero-headline {
  margin-top: var(--space-3);
  font-size: var(--fs-lg);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

/* ── Area cards ── */
.physicals-areas {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.physicals-area-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.physicals-area-card-title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text-primary);
}
.physicals-area-card-signal {
  margin-top: var(--space-1);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

/* ── Empty state (the DEFAULT path) ── */
.physicals-empty {
  text-align: center;
  padding: var(--space-8) var(--space-4);
}
.physicals-empty-mark {
  font-size: 2rem;
  color: var(--text-secondary);
  line-height: 1;
}
.physicals-empty-title {
  margin-top: var(--space-3);
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text-primary);
}
.physicals-empty-body {
  margin-top: var(--space-2);
  font-size: var(--fs-base);
  color: var(--text-secondary);
}

/* ── Life-OS Chickens hub (Phase 3) ──────────────────────────────────────
   The dedicated Chickens pillar: a composite hero + five Area cards
   (Mood / Mindfulness / BFRB regulation / Focus engagement / Stress load) +
   this week's moves. Mirrors the Physicals hub exactly — reuses the Home
   hub's .home-card chrome, .home-band-chip primitive, --home-band-* tokens
   and .home-moves* list; only the layout + text classes are new. */
.chickens-pillar-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4) var(--space-8);
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

/* ── Hero (the composite Chickens read) ── */
.chickens-hero-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.chickens-hero-kicker {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.chickens-hero-headline {
  margin-top: var(--space-3);
  font-size: var(--fs-lg);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

/* ── Area cards ── */
.chickens-areas {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.chickens-area-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.chickens-area-card-title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text-primary);
}
.chickens-area-card-signal {
  margin-top: var(--space-1);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

/* ── Empty state (the DEFAULT path) ── */
.chickens-empty {
  text-align: center;
  padding: var(--space-8) var(--space-4);
}
.chickens-empty-mark {
  font-size: 2rem;
  color: var(--text-secondary);
  line-height: 1;
}
.chickens-empty-title {
  margin-top: var(--space-3);
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text-primary);
}
.chickens-empty-body {
  margin-top: var(--space-2);
  font-size: var(--fs-base);
  color: var(--text-secondary);
}

/* Display-only mood trend line on the Mood Area card (local stream). */
.chickens-mood-delta {
  margin: 4px 0 0;
  font-size: 0.74rem;
  color: var(--text-secondary);
}

/* ── Life-OS Life Building hub (Phase 5) ──────────────────────────────────
   The dedicated Life Building pillar: a composite hero + Finances Area card
   (council verdict + local raw numbers) + this week's moves + the monthly
   finance capture form. Mirrors the Physicals/Chickens hubs for the verdict
   side; mirrors recovery-ui's form for the write path. Reuses the Home
   hub's .home-card chrome, .home-band-chip primitive, --home-band-* tokens
   and .home-moves* list — only the layout + text classes are new. */
.life-building-pillar-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4) var(--space-8);
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

/* ── Hero (the composite Life Building read) ── */
.life-building-hero-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.life-building-hero-kicker {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.life-building-hero-headline {
  margin-top: var(--space-3);
  font-size: var(--fs-lg);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

/* ── Area cards ── */
.life-building-areas {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.life-building-area-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.life-building-area-card-title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text-primary);
}
.life-building-area-card-signal {
  margin-top: var(--space-1);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

/* ── Raw numbers breakdown (per-metric mini-status on the Finances Area card) ── */
.life-building-raw-numbers {
  margin-top: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.life-building-raw-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.life-building-raw-label {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}
.life-building-raw-value {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* ── Empty state (the DEFAULT path) ── */
.life-building-empty {
  text-align: center;
  padding: var(--space-8) var(--space-4);
}
.life-building-empty-mark {
  font-size: 2rem;
  color: var(--text-secondary);
  line-height: 1;
}
.life-building-empty-title {
  margin-top: var(--space-3);
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text-primary);
}
.life-building-empty-body {
  margin-top: var(--space-2);
  font-size: var(--fs-base);
  color: var(--text-secondary);
}

/* ── Capture form ("Update this month's numbers") ── */
.life-building-capture {
  padding: var(--space-4);
}
.life-building-capture-title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}
.life-building-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.life-building-form-label {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.life-building-form-label-text {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
}
.life-building-form-input {
  font-size: 1rem;
  padding: 8px 12px;
  border: 1px solid var(--border-color, #d1d5db);
  border-radius: 8px;
  background: var(--bg-primary, #fff);
  color: var(--text-primary);
  -webkit-appearance: none;
  appearance: none;
  min-height: 44px; /* ≥44px tap target (#17) */
}
.life-building-form-input:focus {
  outline: 2px solid var(--accent, #3b82f6);
  outline-offset: 2px;
}
/* Prevent iOS zoom on focus (sub-16px inputs) */
@media (pointer: coarse) {
  .life-building-form-input {
    font-size: 1rem; /* 16px floor — same as recovery-ui + #21 fix */
  }
}
.life-building-form-submit-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-1);
}
.life-building-form-save-btn {
  padding: 10px 24px;
  background: var(--accent, #3b82f6);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: var(--fs-base);
  font-weight: 600;
  cursor: pointer;
  min-height: 44px; /* ≥44px tap target (#17) */
}
.life-building-form-save-btn:active {
  opacity: 0.85;
}
.life-building-form-saved-msg {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

/* ── 8-tab tabbar fallback (Phase 5) ─────────────────────────────────────
   With Life Building the phone tabbar holds 8 tabs. We continue the
   Phase 3 icon-only pattern at ≤374px — the existing rule already hides
   span text, so no change needed there. This comment tracks the addition. */

/* ── 7-tab tabbar fallback (Phase 3) ─────────────────────────────────────
   With Chickens the phone tabbar holds 7 tabs; at ≤374px each gets ~45px
   and the longest labels ("Analytics") risk truncation. Ratified fallback:
   icon-only on very small phones. The .tempo-tabbar prefix is load-bearing:
   tempo-shell.css loads AFTER this file, so its base .tempo-tab rule (equal
   specificity, later source order) would otherwise win the cascade and the
   gap/padding override would never apply. Desktop sidebar unaffected. */
@media (max-width: 374px) {
  .tempo-tabbar .tempo-tab span { display: none; }
  .tempo-tabbar .tempo-tab { gap: 0; padding: 10px 2px; }
}
