/* ==========================================================================
   ZenFlow design system
   --------------------------------------------------------------------------
   1. Tokens (dark default, light, liquid glass)
   2. Base
   3. Layout: sidebar, topbar, page
   4. Components: card, button, input, toggle, segmented, chip, badge, row,
      stepper, progress, empty state, dialog, toast, menu
   5. Pages
   6. Liquid glass surfaces
   7. Motion, input modality, responsive
   Rules of thumb: spacing from --space-*, radius from --radius-*, type from
   --text-*; colour by role, never by hue. Legacy variable names are aliases
   so inline styles rendered by app.js keep working.
   ========================================================================== */

/* 1. TOKENS ================================================================ */
:root {
  color-scheme: dark;

  /* spacing (4px grid) */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;

  /* radius */
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-full: 999px;

  /* type */
  --font-display: 'Syne', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'DM Mono', ui-monospace, monospace;
  --text-xs: 0.75rem;    /* 12 metadata, captions */
  --text-sm: 0.8125rem;  /* 13 labels, secondary */
  --text-md: 0.875rem;   /* 14 body, controls */
  --text-lg: 1rem;       /* 16 card titles */
  --text-xl: 1.25rem;    /* 20 dialog titles, stat values */
  --text-2xl: 1.625rem;  /* 26 page titles */
  --leading: 1.5;

  /* layout */
  --app-vh: 100vh;
  --sidebar-collapsed: 72px;
  --sidebar-expanded: 220px;
  --mobile-nav-height: 64px;
  --page-max: 1440px;

  /* colour: surfaces (dark) */
  --bg: #0b0b10;
  --surface-1: #121219;   /* cards */
  --surface-2: #181821;   /* rows inside cards */
  --surface-3: #20202b;   /* controls, inputs */
  --surface-4: #2a2a37;   /* tracks, hover */
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);

  /* colour: text */
  --text: #ececf3;
  --text-muted: #a6a6bb;
  --text-subtle: #8e8ea6;

  /* colour: semantic */
  --success: #4ade80; --success-soft: rgba(74,222,128,0.14);
  --warning: #fbbf24; --warning-soft: rgba(251,191,36,0.14);
  --danger:  #f87171; --danger-soft:  rgba(248,113,113,0.14);
  --info:    #22d3ee; --info-soft:    rgba(34,211,238,0.12);

  /* colour: accent (runtime-tuned by applyAccent for contrast) */
  --accent: #7c6af7;
  --accent-strong: #8f7ffa;
  --accent-soft: rgba(124,106,247,0.18);
  --accent-text: #a594ff;
  --on-accent: #0b0b10;

  /* elevation */
  --shadow-1: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-2: 0 16px 48px rgba(0,0,0,0.5);
  --focus-ring: 0 0 0 3px var(--accent-soft);

  /* motion */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --dur-fast: 120ms; --dur: 200ms;

}

/* Legacy aliases (used by markup/app.js inline styles). Declared on body as
   well as :root so they resolve against the active theme's tokens, which are
   overridden on body. */
:root, body {
  --bg2: var(--surface-1); --bg3: var(--surface-2); --bg4: var(--surface-3);
  --surface: var(--surface-3); --surface2: var(--surface-4);
  --border2: var(--border-strong);
  --text2: var(--text-muted); --text3: var(--text-subtle);
  --accent2: var(--accent-text); --accent-glow: var(--accent-soft);
  --green: var(--success); --green-dim: var(--success-soft);
  --red: var(--danger); --red-dim: var(--danger-soft);
  --orange: #fb923c; --orange-dim: rgba(251,146,60,0.14);
  --yellow: var(--warning); --yellow-dim: var(--warning-soft);
  --cyan: var(--info); --cyan-dim: var(--info-soft);
  --radius: var(--radius-md);
  --shadow: var(--shadow-1); --shadow-lg: var(--shadow-2);
}

body.bg-darker { --bg: #060608; --surface-1: #0d0d12; --surface-2: #13131a; }

body.theme-light {
  color-scheme: light;
  --bg: #f4f6fb;
  --surface-1: #ffffff;
  --surface-2: #f5f7fc;
  --surface-3: #eef1f8;
  --surface-4: #e2e7f2;
  --border: rgba(22,28,51,0.1);
  --border-strong: rgba(22,28,51,0.18);
  --text: #161c33;
  --text-muted: #424c6b;
  --text-subtle: #5a6482;
  --success: #127236; --success-soft: rgba(18,114,54,0.1);
  --warning: #a15c07; --warning-soft: rgba(161,92,7,0.1);
  --danger:  #c42b2b; --danger-soft:  rgba(196,43,43,0.09);
  --info:    #0e7490; --info-soft:    rgba(14,116,144,0.1);
  --orange: #b4530a; --orange-dim: rgba(180,83,10,0.1);
  --shadow-1: 0 1px 2px rgba(22,28,51,0.08);
  --shadow-2: 0 18px 48px rgba(22,28,51,0.18);
}

/* Liquid glass: dark-tinted frosted panels over an accent-tinted field. */
body.theme-glass {
  --bg: #0c0a1c;
  --glass-fill: rgba(24,21,44,0.52);
  --glass-fill-strong: rgba(20,18,38,0.82);
  --glass-edge: rgba(255,255,255,0.16);
  --glass-shine: rgba(255,255,255,0.24);
  --glass-blur: 22px;
  --surface-1: var(--glass-fill);
  --surface-2: rgba(255,255,255,0.05);
  --surface-3: rgba(255,255,255,0.08);
  --surface-4: rgba(255,255,255,0.13);
  --border: rgba(255,255,255,0.12);
  --border-strong: rgba(255,255,255,0.2);
  --text: #f3f2fc;
  --text-muted: #c4c4dc;
  --text-subtle: #a9a9c6;
  --shadow-1: 0 8px 28px rgba(5,3,20,0.35);
  --shadow-2: 0 24px 64px rgba(5,3,20,0.55);
}

/* 2. BASE ================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: var(--leading);
  min-height: var(--app-vh);
  overflow-x: hidden;
}
:where(button) { font: inherit; color: inherit; }
:where(button, [role="button"]) { cursor: pointer; }
:where(button:disabled) { cursor: not-allowed; }
img, svg { display: block; }
[hidden] { display: none !important; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-4); border-radius: var(--radius-full); border: 2px solid transparent; background-clip: padding-box; }

:where(button, a, select, summary, [tabindex]):focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
h1.page-title:focus, main:focus { outline: none; }

.skip-link { position: fixed; top: -100px; left: var(--space-3); z-index: 10001; padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm); background: var(--accent); color: var(--on-accent); font-weight: 600; text-decoration: none; }
.skip-link:focus { top: var(--space-3); }

/* 3. LAYOUT ================================================================ */
.app { display: flex; min-height: var(--app-vh); }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 100;
  width: var(--sidebar-collapsed); height: var(--app-vh);
  display: flex; flex-direction: column; align-items: center; gap: var(--space-1);
  padding: var(--space-5) 0;
  background: var(--surface-1); border-right: 1px solid var(--border);
  overflow: hidden auto; scrollbar-width: none;
  transition: width var(--dur) var(--ease);
}
.sidebar.expanded { width: var(--sidebar-expanded); }
.sidebar-logo {
  width: 44px; height: 44px; margin-bottom: var(--space-5); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface-2);
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.sidebar-logo:hover { border-color: var(--accent); }
.sidebar.expanded .sidebar-logo { width: 192px; justify-content: flex-start; gap: var(--space-3); padding: 0 var(--space-3); }
.sidebar-brand-mark, .brand-mark {
  width: 24px; height: 24px; border-radius: 7px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--on-accent);
  font-family: var(--font-display); font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
}
.sidebar-brand-copy { display: none; flex-direction: column; gap: 2px; min-width: 0; text-align: left; }
.sidebar.expanded .sidebar-brand-copy { display: flex; }
.sidebar-brand-name { font-family: var(--font-display); font-size: var(--text-md); font-weight: 600; line-height: 1.1; color: var(--text); }
.sidebar-brand-sub { font-size: var(--text-xs); line-height: 1.1; color: var(--text-subtle); }
.sidebar-toggle-glyph { display: none; width: 14px; height: 14px; margin-left: auto; stroke: var(--text-subtle); stroke-width: 2.2; fill: none; }
.sidebar.expanded .sidebar-toggle-glyph { display: block; }

.nav-item {
  position: relative; flex-shrink: 0;
  width: 44px; height: 44px; border: 0; border-radius: var(--radius-sm); background: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-subtle);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); }
.sidebar:not(.expanded) .nav-item.active::before { content: ''; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar.expanded .nav-item { width: 192px; justify-content: flex-start; gap: var(--space-3); padding: 0 var(--space-3); }
.nav-label { font-size: var(--text-md); font-weight: 500; white-space: nowrap; overflow: hidden; max-width: 0; opacity: 0; transition: max-width var(--dur) var(--ease), opacity var(--dur); }
.sidebar.expanded .nav-label { max-width: 140px; opacity: 1; }
.nav-short { display: none; }
.nav-divider { width: 32px; height: 1px; margin: var(--space-2) 0; flex-shrink: 0; background: var(--border); }
.sidebar.expanded .nav-divider { width: 192px; }
.sidebar-bottom { margin-top: auto; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-collapsed); transition: margin-left var(--dur) var(--ease); }
.sidebar.expanded ~ .main { margin-left: var(--sidebar-expanded); }

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-3) var(--space-8);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.topbar-right { gap: var(--space-2); }
.brand { display: flex; align-items: center; gap: var(--space-2); }
.brand-word { font-family: var(--font-display); font-size: var(--text-md); font-weight: 600; }
.topbar-time { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--text-muted); }
.topbar-date { font-size: var(--text-sm); color: var(--text-subtle); }

.page { display: none; width: 100%; max-width: var(--page-max); margin: 0 auto; padding: var(--space-8); }
.page.active { display: block; animation: pageIn var(--dur) var(--ease); }
@keyframes pageIn { from { opacity: 0; } to { opacity: 1; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-6); }
.page-title { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 700; letter-spacing: -0.4px; line-height: 1.15; }
.page-subtitle { margin-top: var(--space-1); font-size: var(--text-md); color: var(--text-muted); }
.page-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* Today at a glance (Focus page) */
.stat-strip { display: flex; gap: var(--space-2); }
.stat-strip-item { min-width: 88px; padding: var(--space-2) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-1); }
.stat-strip-item dt { font-size: var(--text-xs); color: var(--text-subtle); }
.stat-strip-item dd { font-family: var(--font-mono); font-size: var(--text-lg); font-weight: 500; line-height: 1.3; }

/* 4. COMPONENTS ============================================================ */

/* Card */
.card, .settings-section, .stat-card, .timer-display, .sw-display, .tracker-bar {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.card { padding: var(--space-6); }
.card-sm { padding: var(--space-4) var(--space-5); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); min-height: 32px; }
.card-title, h3 { font-family: var(--font-body); font-size: var(--text-lg); font-weight: 600; line-height: 1.3; }
.section-label, .label { display: block; margin-bottom: var(--space-2); font-family: var(--font-body); font-size: var(--text-sm); font-weight: 600; color: var(--text-muted); }

/* Button */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 38px; padding: 0 var(--space-4);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: var(--text-md); font-weight: 500; line-height: 1; white-space: nowrap;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast), transform var(--dur-fast);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover:not(:disabled) { border-color: var(--danger); }
.btn-success { background: var(--success-soft); color: var(--success); }
.btn-success:hover:not(:disabled) { border-color: var(--success); }
.btn-link { min-height: 0; padding: var(--space-1) 0; border: 0; background: none; color: var(--accent-text); font-weight: 500; }
.btn-link:hover { text-decoration: underline; }
.btn-icon { width: 36px; min-height: 36px; padding: 0; }
.btn-lg { min-height: 46px; padding: 0 var(--space-6); font-size: var(--text-lg); border-radius: var(--radius-md); }
.btn-xl { min-height: 52px; padding: 0 var(--space-6); font-size: var(--text-lg); border-radius: var(--radius-md); }
.btn-xl svg { width: 18px; height: 18px; }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--text-muted) transparent var(--text-muted) transparent; animation: spin 0.8s linear infinite; }
.btn-primary.is-busy::after { border-color: var(--on-accent) transparent var(--on-accent) transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Input */
.input {
  width: 100%; min-height: 38px; padding: var(--space-2) var(--space-3);
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: var(--text-md);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.input:hover { border-color: color-mix(in srgb, var(--text-subtle) 45%, transparent); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
.input::placeholder { color: var(--text-subtle); opacity: 1; }
.input[aria-invalid="true"] { border-color: var(--danger); }
select.input { cursor: pointer; }
option { background: var(--surface-1); color: var(--text); }
textarea.input { line-height: var(--leading); }
.field-error { display: flex; gap: var(--space-1); margin-top: var(--space-1); font-size: var(--text-sm); color: var(--danger); }
.form-group { margin-bottom: var(--space-4); }
.form-label { display: block; margin-bottom: var(--space-1); font-size: var(--text-sm); font-weight: 500; color: var(--text-muted); }
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.form-hint { margin-top: var(--space-1); font-size: var(--text-xs); color: var(--text-subtle); }

/* Toggle switch */
.toggle { position: relative; width: 40px; height: 22px; flex-shrink: 0; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.toggle-slider { position: absolute; inset: 0; border-radius: var(--radius-full); background: var(--surface-4); transition: background var(--dur); pointer-events: none; }
.toggle-slider::before { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-subtle); transition: transform var(--dur) var(--ease), background var(--dur); }
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); background: var(--on-accent); }
.toggle input:focus-visible + .toggle-slider { outline: 2px solid var(--accent-text); outline-offset: 2px; }

/* Segmented control (pomodoro modes, login/sign-up) */
.pomo-tabs, .auth-mode-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-md); background: var(--surface-2); border: 1px solid var(--border); }
.auth-mode-switch { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: var(--space-4); }
.pomo-tab, .auth-mode-btn {
  min-height: 34px; padding: 0 var(--space-4); border: 0; border-radius: 9px; background: none;
  font-size: var(--text-sm); font-weight: 500; color: var(--text-muted); white-space: nowrap;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.pomo-tab:hover, .auth-mode-btn:hover { color: var(--text); }
.pomo-tab.active, .auth-mode-btn.active { background: var(--surface-4); color: var(--text); box-shadow: var(--shadow-1); }

/* Chip / tag / priority (one pill family) */
.chip, .prio-btn, .tag {
  display: inline-flex; align-items: center; gap: var(--space-1);
  min-height: 30px; padding: 0 var(--space-3);
  border: 1px solid var(--border-strong); border-radius: var(--radius-full); background: transparent;
  font-size: var(--text-sm); font-weight: 500; color: var(--text-muted); white-space: nowrap;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}
.chip:hover, .prio-btn:hover { background: var(--surface-3); color: var(--text); }
.chip.active, .chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.filter-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.priority-select { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.prio-btn.high.active   { background: var(--danger-soft);  border-color: var(--danger);  color: var(--danger); }
.prio-btn.medium.active { background: var(--orange-dim);   border-color: var(--orange);  color: var(--orange); }
.prio-btn.low.active    { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.prio-btn.none.active   { background: var(--surface-4);    border-color: var(--border-strong); color: var(--text); }
.tag { min-height: 26px; padding: 0 var(--space-2); font-size: var(--text-xs); border-color: transparent; }
.tag:hover { border-color: var(--border-strong); }
.tag.selected { border-color: currentColor; }

/* Badge */
.badge { display: inline-flex; align-items: center; gap: var(--space-1); padding: 2px var(--space-2); border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: 500; line-height: 1.5; white-space: nowrap; }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.badge-green  { background: var(--success-soft); color: var(--success); }
.badge-red    { background: var(--danger-soft);  color: var(--danger); }
.badge-orange { background: var(--orange-dim);   color: var(--orange); }
.badge-cyan   { background: var(--info-soft);    color: var(--info); }
.badge-yellow { background: var(--warning-soft); color: var(--warning); }

/* Row (one list-item surface for settings, tasks, entries, presets, logs, laps) */
.setting-row, .todo-item, .entry-item, .preset-item, .log-entry, .lap-item, .achievement {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md);
  transition: border-color var(--dur-fast), background var(--dur-fast);
}

/* Number stepper */
.number-input { display: flex; align-items: center; gap: var(--space-2); }
.num-btn { width: 30px; height: 30px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-3); color: var(--text-muted); display: flex; align-items: center; justify-content: center; font-size: var(--text-lg); line-height: 1; transition: background var(--dur-fast), color var(--dur-fast); }
.num-btn:hover:not(:disabled) { background: var(--surface-4); color: var(--text); }
.num-btn:disabled { opacity: 0.4; }
.num-val { min-width: 44px; text-align: center; font-family: var(--font-mono); font-size: var(--text-md); font-weight: 500; }
.num-val small { margin-left: 2px; font-family: var(--font-body); font-size: var(--text-xs); color: var(--text-subtle); }

/* Progress */
.progress-bar { height: 6px; border-radius: var(--radius-full); background: var(--surface-4); overflow: hidden; }
.progress-fill { height: 100%; border-radius: inherit; transition: width 400ms var(--ease); }

/* Empty state */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2); padding: var(--space-10) var(--space-5); text-align: center; color: var(--text-muted); }
.empty-state-icon { font-size: 32px; line-height: 1; opacity: 0.7; }
.empty-state-text { font-size: var(--text-md); font-weight: 600; color: var(--text); }
.empty-state-sub { max-width: 36ch; font-size: var(--text-sm); color: var(--text-muted); }

/* Dialog */
dialog.modal {
  margin: auto; width: calc(100% - 32px); max-width: 480px; max-height: min(90vh, calc(var(--app-vh) - 32px)); overflow-y: auto;
  padding: var(--space-6); color: var(--text);
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-2);
}
dialog.modal[open] { animation: modalIn var(--dur) var(--ease); }
dialog.modal::backdrop { background: rgba(4,4,10,0.6); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-5); }
.modal-title { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 600; line-height: 1.25; }
.modal-close { width: 32px; height: 32px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: transparent; color: var(--text-muted); transition: background var(--dur-fast), color var(--dur-fast); }
.modal-close:hover { background: var(--surface-3); color: var(--text); }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-5); }
.confirm-message { font-size: var(--text-md); line-height: 1.6; color: var(--text-muted); white-space: pre-line; }

/* Toast */
.toasts { position: fixed; right: var(--space-6); bottom: var(--space-6); z-index: 9999; display: flex; flex-direction: column; gap: var(--space-2); pointer-events: none; }
.toasts[popover] { inset: auto var(--space-6) var(--space-6) auto; margin: 0; padding: 0; border: 0; background: transparent; overflow: visible; color: var(--text); }
.toasts[popover]:popover-open { display: flex; }
.toast {
  display: flex; align-items: center; gap: var(--space-3); pointer-events: auto;
  max-width: min(420px, calc(100vw - 32px)); padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  background: var(--surface-3); border: 1px solid var(--border-strong); border-left-width: 3px; border-radius: var(--radius-md); box-shadow: var(--shadow-2);
  font-size: var(--text-md); animation: toastIn var(--dur) var(--ease);
}
body.theme-light .toast { background: var(--surface-1); }
.toast.leaving { animation: toastOut var(--dur) var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }
.toast-success { border-left-color: var(--success); }
.toast-error   { border-left-color: var(--danger); }
.toast-info    { border-left-color: var(--accent); }
.toast-icon { font-size: var(--text-lg); line-height: 1; }
.toast-msg { flex: 1; line-height: 1.4; }
.toast-action { min-height: 30px; padding: 0 var(--space-3); border: 0; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-text); font-size: var(--text-sm); font-weight: 600; white-space: nowrap; }
.toast-action:hover { background: var(--accent); color: var(--on-accent); }
.toast-close { width: 28px; height: 28px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-subtle); }
.toast-close:hover { background: var(--surface-4); color: var(--text); }

/* Menu */
.ctx-menu { position: fixed; z-index: 2000; min-width: 190px; padding: var(--space-1); background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: var(--radius-md); box-shadow: var(--shadow-2); }
.ctx-item { width: 100%; min-height: 36px; display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-3); border: 0; border-radius: var(--radius-sm); background: none; text-align: left; font-size: var(--text-md); color: var(--text); }
.ctx-item:hover, .ctx-item:focus-visible, .ctx-item.active { background: var(--surface-3); }
.ctx-item.danger { color: var(--danger); }
.ctx-divider { height: 1px; margin: var(--space-1) 0; background: var(--border); }

/* Top-bar controls */
.ambient-badge { display: flex; align-items: center; gap: var(--space-2); min-height: 32px; padding: 0 var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius-full); background: var(--surface-2); font-size: var(--text-sm); color: var(--text-muted); transition: border-color var(--dur-fast), color var(--dur-fast); }
.ambient-badge:hover { color: var(--text); }
.ambient-badge.playing { color: var(--accent-text); border-color: var(--accent); }
.ambient-wave { display: flex; align-items: center; gap: 2px; }
.ambient-wave span { width: 3px; border-radius: 2px; background: currentColor; animation: wave 1.2s ease-in-out infinite; }
.ambient-wave span:nth-child(1) { height: 6px; }
.ambient-wave span:nth-child(2) { height: 10px; animation-delay: 0.15s; }
.ambient-wave span:nth-child(3) { height: 7px; animation-delay: 0.3s; }
.ambient-wave span:nth-child(4) { height: 12px; animation-delay: 0.1s; }
.ambient-wave span:nth-child(5) { height: 8px; animation-delay: 0.2s; }
@keyframes wave { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(0.35); } }
.auth-corner-btn { max-width: 220px; gap: var(--space-2); padding: 0 var(--space-3); border-color: transparent; }
.auth-corner-btn.auth-on { background: var(--accent-soft); color: var(--accent-text); }
.auth-corner-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--text-subtle); }
.auth-corner-btn.auth-on .auth-corner-dot { background: var(--success); }
.auth-corner-avatar { width: 22px; height: 22px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--surface-4); font-size: var(--text-xs); font-weight: 600; color: var(--text-muted); }
.auth-corner-btn.auth-on .auth-corner-avatar { background: var(--accent); color: var(--on-accent); }
.auth-corner-text { max-width: 145px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-sm); }
.auth-helper { margin-bottom: var(--space-4); font-size: var(--text-sm); line-height: 1.5; color: var(--text-muted); }
.auth-status { margin-top: var(--space-3); font-size: var(--text-sm); color: var(--text-muted); }
.auth-form-note { margin-top: var(--space-2); font-size: var(--text-xs); color: var(--text-subtle); }
.auth-sync-card { padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); }

kbd { font-family: var(--font-mono); font-size: 11px; padding: 1px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface-3); color: var(--text-muted); }
.divider { height: 1px; margin: var(--space-4) 0; background: var(--border); }

/* 5. PAGES ================================================================= */

/* Focus */
.pomodoro-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--space-6); align-items: start; }
.timer-card { padding: var(--space-8) var(--space-6); }
.pomo-center { display: flex; flex-direction: column; align-items: center; }
.pomo-tabs { margin-bottom: var(--space-8); }
.ring-container { position: relative; width: 280px; height: 280px; margin-bottom: var(--space-6); }
.ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--surface-4); stroke-width: 8; }
.ring-progress { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 600ms var(--ease), stroke 300ms; }
.ring-work { stroke: var(--accent); }
.ring-short-break { stroke: var(--success); }
.ring-long-break { stroke: var(--info); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-1); }
.ring-time { font-family: var(--font-mono); font-size: 56px; font-weight: 500; letter-spacing: -2px; line-height: 1; font-variant-numeric: tabular-nums; }
.ring-label { font-size: var(--text-sm); font-weight: 500; color: var(--text-muted); }
.ring-session { font-size: var(--text-xs); color: var(--text-subtle); }
.pomo-dots { display: flex; gap: var(--space-2); margin-bottom: var(--space-6); }
.pomo-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-4); transition: background var(--dur), transform var(--dur); }
.pomo-dot.done { background: var(--accent); }
.pomo-dot.current { background: var(--accent-text); transform: scale(1.25); }
.pomo-task-input { width: 100%; max-width: 440px; min-height: 42px; padding: 0 var(--space-4); border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface-2); color: var(--text); font-family: var(--font-body); font-size: var(--text-md); text-align: center; transition: border-color var(--dur-fast), box-shadow var(--dur-fast); }
.pomo-task-input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
.pomo-task-input::placeholder { color: var(--text-subtle); }
.pomo-controls { display: flex; align-items: center; gap: var(--space-4); margin-top: var(--space-5); }
.pomo-btn-main { width: 72px; height: 72px; border: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: background var(--dur-fast), transform var(--dur-fast); }
.pomo-btn-main svg { width: 24px; height: 24px; fill: currentColor; }
.pomo-btn-main.play { background: var(--accent); color: var(--on-accent); box-shadow: 0 8px 24px var(--accent-soft); }
.pomo-btn-main.play:hover { background: var(--accent-strong); }
.pomo-btn-main.pause { background: var(--surface-4); color: var(--text); }
.pomo-btn-main:active { transform: scale(0.96); }
.pomo-btn-side { width: 48px; height: 48px; border: 1px solid var(--border-strong); border-radius: 50%; background: transparent; color: var(--text-muted); display: flex; align-items: center; justify-content: center; transition: background var(--dur-fast), color var(--dur-fast); }
.pomo-btn-side:hover { background: var(--surface-3); color: var(--text); }
.pomo-btn-side svg { width: 18px; height: 18px; }
.shortcut-hint { margin-top: var(--space-4); font-size: var(--text-xs); color: var(--text-subtle); }

.pomo-settings { display: flex; flex-direction: column; gap: var(--space-4); }
.stepper-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.stepper { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); }
.stepper-label { font-size: var(--text-sm); color: var(--text-muted); }
.stepper .number-input { justify-content: space-between; }
.toggle-list { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-3); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 48px; padding: var(--space-2) var(--space-3) var(--space-2) var(--space-4); }
.setting-label { font-size: var(--text-md); color: var(--text); }
.card-footer-link { margin-top: var(--space-3); }

.pomo-log { display: flex; flex-direction: column; gap: var(--space-2); max-height: 280px; overflow-y: auto; }
.log-entry { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-left: 3px solid transparent; }
.log-entry.work { border-left-color: var(--accent); }
.log-entry.short-break { border-left-color: var(--success); }
.log-entry.long-break { border-left-color: var(--info); }
.log-entry-label { flex: 1; font-size: var(--text-md); }
.log-entry-task { margin-top: 1px; font-size: var(--text-xs); color: var(--text-subtle); }
.log-entry-time { font-size: var(--text-xs); color: var(--text-subtle); font-variant-numeric: tabular-nums; }

/* Tasks */
.todo-layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: var(--space-6); align-items: start; }
.todo-sidebar { display: flex; flex-direction: column; gap: 2px; }
.todo-list-item { width: 100%; min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: 0 var(--space-3); border: 1px solid transparent; border-radius: var(--radius-sm); background: none; text-align: left; font-size: var(--text-md); color: var(--text-muted); transition: background var(--dur-fast), color var(--dur-fast); }
.todo-list-item:hover { background: var(--surface-2); color: var(--text); }
.todo-list-item.active { background: var(--accent-soft); color: var(--accent-text); }
.todo-list-count { min-width: 22px; padding: 1px 6px; border-radius: var(--radius-full); background: var(--surface-3); font-size: var(--text-xs); text-align: center; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.todo-main { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }
.todo-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.todo-add-row { display: flex; gap: var(--space-2); }
#todoItems { display: flex; flex-direction: column; gap: var(--space-2); }
.todo-item { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4); }
.todo-item:hover { border-color: var(--border-strong); }
.todo-item.completed .todo-text { text-decoration: line-through; color: var(--text-subtle); }
.todo-item.completed { background: transparent; }
.todo-priority { width: 8px; height: 8px; margin-top: 7px; flex-shrink: 0; border-radius: 50%; }
.todo-checkbox { width: 20px; height: 20px; margin-top: 1px; flex-shrink: 0; padding: 0; display: flex; align-items: center; justify-content: center; border: 2px solid var(--border-strong); border-radius: 6px; background: transparent; transition: background var(--dur-fast), border-color var(--dur-fast); }
.todo-checkbox:hover { border-color: var(--accent); }
.todo-checkbox.checked { background: var(--accent); border-color: var(--accent); }
.todo-checkbox svg { width: 12px; height: 12px; fill: none; stroke: var(--on-accent); stroke-width: 3; opacity: 0; transition: opacity var(--dur-fast); }
.todo-checkbox.checked svg { opacity: 1; }
.todo-content { flex: 1; min-width: 0; }
.todo-text { font-size: var(--text-md); line-height: 1.45; word-break: break-word; }
.todo-note { margin-top: 2px; font-size: var(--text-sm); line-height: 1.4; color: var(--text-muted); }
.todo-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-2); }
.todo-meta:empty { display: none; }
.todo-actions { display: flex; gap: 2px; opacity: 0; transition: opacity var(--dur-fast); }
.todo-item:hover .todo-actions, .todo-item:focus-within .todo-actions { opacity: 1; }
.todo-actions .btn-icon { width: 32px; min-height: 32px; }
.tag-input { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); min-height: 38px; padding: var(--space-1) var(--space-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-3); cursor: text; }
.tag-input:focus-within { border-color: var(--accent); box-shadow: var(--focus-ring); }
.tag-input-field { flex: 1; min-width: 100px; min-height: 28px; border: 0; background: transparent; color: var(--text); font-family: var(--font-body); font-size: var(--text-md); outline: none; }
.tag-input-field::placeholder { color: var(--text-subtle); }

/* Timer */
.timer-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--space-6); align-items: start; }
.timer-display { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2); min-height: 360px; padding: var(--space-10) var(--space-6); }
.timer-time-big { font-family: var(--font-mono); font-size: clamp(48px, 7vw, 84px); font-weight: 300; letter-spacing: -3px; line-height: 1; font-variant-numeric: tabular-nums; }
.timer-time-big.running { color: var(--accent-text); }
.timer-time-big.done { color: var(--success); }
.timer-label-big { font-size: var(--text-md); color: var(--text-muted); }
.custom-time-input { display: flex; align-items: flex-start; gap: var(--space-2); }
.time-field { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); font-size: var(--text-xs); color: var(--text-subtle); }
.time-seg { width: 92px; min-height: 76px; padding: 0; text-align: center; font-family: var(--font-mono); font-size: 40px; font-weight: 300; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; }
.time-seg::-webkit-outer-spin-button, .time-seg::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.time-colon { margin-top: 18px; font-family: var(--font-mono); font-size: 32px; color: var(--text-subtle); }
.timer-display[data-state="idle"] .timer-time-big { display: none; }
.timer-display:not([data-state="idle"]) .custom-time-input { display: none; }
.timer-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-3); margin-top: var(--space-6); }
.timer-laps { display: flex; flex-direction: column; gap: var(--space-1); width: 100%; max-width: 360px; max-height: 200px; margin-top: var(--space-4); overflow-y: auto; }
.timer-laps:empty { display: none; }
.timer-presets { display: flex; flex-direction: column; gap: var(--space-2); }
.preset-item { display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-2) 0 0; }
.preset-item:hover { border-color: var(--border-strong); }
.preset-item.active { border-color: var(--accent); background: var(--accent-soft); }
.preset-apply { flex: 1; min-width: 0; min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 0 var(--space-2) 0 var(--space-4); border: 0; background: none; text-align: left; }
.preset-name { font-size: var(--text-md); font-weight: 500; }
.preset-duration { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--text-muted); }
.recent-timer { width: 100%; min-height: 38px; border: 1px solid var(--border) !important; color: var(--text); }
.recent-timer:hover { border-color: var(--border-strong) !important; }

/* Stopwatch */
.sw-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--space-6); align-items: start; }
.sw-display { display: flex; flex-direction: column; align-items: center; gap: var(--space-6); padding: var(--space-10) var(--space-6); min-width: 0; }
.sw-time { font-family: var(--font-mono); font-size: clamp(40px, 5.2vw, 72px); font-weight: 300; letter-spacing: -2px; line-height: 1; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sw-time.running { color: var(--info); }
.sw-ms { font-size: 0.5em; color: var(--text-subtle); }
.sw-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-3); }
.laps-container { display: flex; flex-direction: column; gap: var(--space-1); max-height: 400px; overflow-y: auto; }
.lap-item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); font-family: var(--font-mono); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.lap-num { min-width: 32px; color: var(--text-subtle); }
.lap-time { flex: 1; }
.lap-split { color: var(--text-subtle); }
.lap-item.best .lap-time, .lap-item.best .lap-split { color: var(--success); }
.lap-item.worst .lap-time, .lap-item.worst .lap-split { color: var(--danger); }

/* Time log */
.tracker-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-6); }
.tracker-pulse { width: 10px; height: 10px; flex-shrink: 0; border-radius: 50%; background: var(--surface-4); }
.tracker-pulse.active { background: var(--danger); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 3px var(--danger-soft); } 50% { box-shadow: 0 0 0 7px transparent; } }
.tracker-time { min-width: 104px; font-family: var(--font-mono); font-size: var(--text-xl); font-weight: 500; font-variant-numeric: tabular-nums; }
.tracker-time.running { color: var(--danger); }
.tracker-desc { flex: 1 1 240px; }
.tracker-project { flex: 0 1 180px; }
#trackerPriority { flex: 0 1 130px; width: auto !important; }
#trackerProject { width: auto !important; }
.tracking-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--space-6); align-items: start; }
.tracking-side { display: flex; flex-direction: column; gap: var(--space-4); }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.section-head .section-label { margin: 0; }
#trackingEntries { display: flex; flex-direction: column; gap: var(--space-2); }
.date-header { padding: var(--space-3) var(--space-1) 0; font-size: var(--text-sm); font-weight: 600; color: var(--text-muted); }
.entry-item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4); }
.entry-item:hover { border-color: var(--border-strong); }
.entry-dot { width: 10px; height: 10px; flex-shrink: 0; border-radius: 50%; }
.entry-desc { font-size: var(--text-md); }
.entry-project { font-size: var(--text-xs); color: var(--text-muted); }
.entry-time { font-size: var(--text-xs); color: var(--text-subtle); white-space: nowrap; font-variant-numeric: tabular-nums; }
.entry-duration { min-width: 56px; text-align: right; font-family: var(--font-mono); font-size: var(--text-md); font-weight: 500; color: var(--text); }
.entry-actions { display: flex; gap: 2px; opacity: 0; transition: opacity var(--dur-fast); }
.entry-item:hover .entry-actions, .entry-item:focus-within .entry-actions { opacity: 1; }
.proj-dot-0 { background: #7c6af7; } .proj-dot-1 { background: #4ade80; } .proj-dot-2 { background: #f87171; } .proj-dot-3 { background: #22d3ee; }
.proj-dot-4 { background: #fbbf24; } .proj-dot-5 { background: #f472b6; } .proj-dot-6 { background: #fb923c; } .proj-dot-7 { background: #a78bfa; }

/* Stats */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stat-card { display: flex; flex-direction: column; gap: 2px; padding: var(--space-4) var(--space-5); }
.stat-value { font-family: var(--font-mono); font-size: 28px; font-weight: 500; letter-spacing: -1px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-card.is-primary .stat-value { color: var(--accent-text); }
.stat-label { font-size: var(--text-sm); font-weight: 500; color: var(--text-muted); }
.stat-sub { font-size: var(--text-xs); color: var(--text-subtle); }
.garden-scroll { overflow-x: auto; }
.garden-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: var(--space-3); padding: var(--space-2) 0; }
.tree-item { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); }
.tree-emoji { font-size: 32px; line-height: 1; }
.tree-mins { font-size: var(--text-xs); color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.tree-dead .tree-emoji { filter: grayscale(1); opacity: 0.45; }
.card-caption { margin-top: var(--space-3); font-size: var(--text-xs); color: var(--text-subtle); }
.streak-display { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-2) 0 var(--space-4); }
.streak-fire { font-size: 36px; line-height: 1; }
.streak-num { font-family: var(--font-mono); font-size: 52px; font-weight: 500; letter-spacing: -2px; line-height: 1; color: var(--orange); }
.streak-info { display: flex; flex-direction: column; gap: 2px; }
.streak-label { font-size: var(--text-md); font-weight: 600; }
.streak-sub { font-size: var(--text-sm); color: var(--text-muted); }
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--space-2); }
.week-day { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); }
.week-day-label { font-size: var(--text-xs); font-weight: 500; color: var(--text-subtle); }
.week-day-num { font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.week-day-bar { position: relative; width: 100%; height: 64px; overflow: hidden; border-radius: var(--radius-sm); background: var(--surface-3); }
.week-day-fill { position: absolute; inset: auto 0 0 0; border-radius: inherit; transition: height 500ms var(--ease); }
.week-day-val { min-height: 1.2em; font-size: var(--text-xs); color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.week-day.today .week-day-num, .week-day.today .week-day-label { color: var(--accent-text); font-weight: 600; }
.week-day.future .week-day-bar { background: transparent; border: 1px dashed var(--border-strong); }
.week-day.future .week-day-num { color: var(--text-subtle); }
.heatmap-months { display: flex; margin-bottom: var(--space-1); font-size: 10px; color: var(--text-subtle); }
.heatmap-grid { display: grid; grid-template-columns: repeat(53, minmax(0, 1fr)); grid-auto-flow: column; grid-template-rows: repeat(7, auto); gap: 3px; }
.heatmap-cell { aspect-ratio: 1; border-radius: 2px; }
.heatmap-0 { background: var(--surface-3); }
.heatmap-1 { background: color-mix(in srgb, var(--accent) 25%, var(--surface-3)); }
.heatmap-2 { background: color-mix(in srgb, var(--accent) 45%, var(--surface-3)); }
.heatmap-3 { background: color-mix(in srgb, var(--accent) 65%, var(--surface-3)); }
.heatmap-4 { background: color-mix(in srgb, var(--accent) 85%, var(--surface-3)); }
.heatmap-5 { background: var(--accent-text); }
.heatmap-legend { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-1); margin-top: var(--space-3); font-size: var(--text-xs); color: var(--text-subtle); }
.heatmap-legend .heatmap-cell { width: 12px; aspect-ratio: 1; }
.bar-chart { display: flex; align-items: flex-end; gap: var(--space-2); height: 168px; }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; gap: var(--space-1); }
.bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.bar { width: 100%; min-height: 4px; border-radius: 4px 4px 0 0; transition: height 500ms var(--ease); }
.bar-label, .bar-val { font-size: var(--text-xs); color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.focus-score-ring { position: relative; width: 120px; height: 120px; margin: 0 auto var(--space-4); }
.focus-score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.focus-score-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.focus-score-num { font-family: var(--font-mono); font-size: 28px; font-weight: 500; line-height: 1; }
.focus-score-label { font-size: var(--text-xs); color: var(--text-subtle); }
.achievements-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-2); }
.achievement { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
.achievement.unlocked { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-soft); }
.ach-icon { font-size: 24px; line-height: 1; }
.ach-title { font-size: var(--text-md); font-weight: 600; }
.ach-desc { font-size: var(--text-xs); color: var(--text-muted); }
.achievement.locked .ach-icon { filter: grayscale(1); opacity: 0.4; }
.achievement.locked .ach-title { color: var(--text-muted); }
.report-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); }
.report-cell { padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--surface-2); border: 1px solid var(--border); }
.report-cell-label { font-size: var(--text-xs); color: var(--text-subtle); }
.report-cell-value { margin-top: 2px; font-family: var(--font-mono); font-size: var(--text-xl); font-weight: 500; font-variant-numeric: tabular-nums; }

/* Settings */
.settings-sections { display: flex; flex-direction: column; gap: var(--space-5); max-width: 720px; }
.settings-section { overflow: hidden; }
.settings-section-title { padding: var(--space-4) var(--space-6) var(--space-2); font-family: var(--font-body); font-size: var(--text-lg); font-weight: 600; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border); }
.settings-row-label { font-size: var(--text-md); font-weight: 500; }
.settings-row-sub { margin-top: 2px; font-size: var(--text-sm); color: var(--text-muted); }
.settings-row-sub.text-red { color: var(--danger); }
.settings-row .input { width: 180px !important; flex-shrink: 0; }
.settings-control { display: flex; align-items: center; gap: var(--space-3); flex-shrink: 0; }
.status-pill { font-size: var(--text-xs); font-weight: 600; padding: 2px var(--space-2); border-radius: var(--radius-full); background: var(--surface-3); color: var(--text-muted); }
.status-pill.on { background: var(--success-soft); color: var(--success); }
.status-pill.blocked { background: var(--danger-soft); color: var(--danger); }
.color-options { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.color-opt { width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15); transition: transform var(--dur-fast), border-color var(--dur-fast); }
.color-opt:hover { transform: scale(1.08); }
.color-opt[aria-pressed="true"], .color-opt.selected { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg) inset; }
input[type="range"] { accent-color: var(--accent); width: 180px; }

/* Focus mode */
.focus-mode { position: fixed; inset: 0; z-index: 500; display: none; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-5); background: var(--bg); }
.focus-mode.active { display: flex; }
.focus-mode-exit { position: absolute; top: var(--space-6); right: var(--space-6); }

/* Utilities (kept small; prefer components) */
.section-gap { display: flex; flex-direction: column; gap: var(--space-3); }
.flex-row { display: flex; align-items: center; gap: var(--space-3); }
.flex-col { display: flex; flex-direction: column; gap: var(--space-2); }
.spacer { flex: 1; }
.text-sm { font-size: var(--text-sm); color: var(--text-muted); }
.text-xs { font-size: var(--text-xs); color: var(--text-subtle); }
.text-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.text-accent { color: var(--accent-text); } .text-green { color: var(--success); } .text-red { color: var(--danger); } .text-orange { color: var(--orange); }
.fw-bold { font-weight: 600; }
.mt-4 { margin-top: var(--space-1); } .mt-8 { margin-top: var(--space-2); } .mt-16 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-1); } .mb-8 { margin-bottom: var(--space-2); } .mb-16 { margin-bottom: var(--space-4); }
.w-full { width: 100%; } .flex-wrap { flex-wrap: wrap; } .justify-between { justify-content: space-between; } .align-center { align-items: center; }
.pomodoro-layout > *, .todo-layout > *, .timer-layout > *, .tracking-layout > *, .sw-layout > *, .grid-2 > *, .grid-3 > *, .grid-4 > * { min-width: 0; }

/* Calendar ------------------------------------------------------------------ */
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: var(--space-5); align-items: start; }
.cal-main { padding: var(--space-4); min-width: 0; }
.cal-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.cal-nav { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.cal-title { margin-left: var(--space-2); font-family: var(--font-display); font-size: var(--text-xl); font-weight: 600; white-space: nowrap; }
.cal-side { display: flex; flex-direction: column; gap: var(--space-5); }
.cal-list { display: flex; flex-direction: column; gap: 2px; }
.cal-list-item { display: flex; align-items: center; gap: var(--space-2); min-height: 34px; padding: 0 var(--space-2); border-radius: var(--radius-sm); font-size: var(--text-md); cursor: pointer; }
.cal-list-item:hover { background: var(--surface-2); }
.cal-list-item input { width: 16px; height: 16px; accent-color: var(--accent); }
.cal-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.cal-src { margin-left: auto; font-size: var(--text-xs); color: var(--text-subtle); }
.cal-upcoming { list-style: none; display: flex; flex-direction: column; gap: var(--space-2); }
.cal-upcoming li { display: flex; flex-direction: column; padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.cal-up-when { font-size: var(--text-xs); color: var(--text-subtle); }
.cal-up-title { font-size: var(--text-md); }

/* Month */
.cal-month-head, .cal-month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-weekday { padding: var(--space-1) var(--space-2) var(--space-2); font-size: var(--text-xs); font-weight: 600; color: var(--text-subtle); }
.cal-month-grid { border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.cal-cell { min-height: 108px; padding: var(--space-1); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; cursor: pointer; min-width: 0; }
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.is-outside { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
.cal-cell.is-outside .cal-daynum { color: var(--text-subtle); }
.cal-daynum { align-self: flex-start; min-width: 28px; height: 28px; padding: 0 6px; border: 0; border-radius: var(--radius-full); background: none; font-size: var(--text-sm); font-weight: 500; font-variant-numeric: tabular-nums; }
.cal-daynum:hover { background: var(--surface-4); }
.cal-cell.is-today .cal-daynum { background: var(--accent); color: var(--on-accent); }
.cal-chips { display: flex; flex-direction: column; gap: 2px; min-width: 0; pointer-events: none; }
.cal-chips > * { pointer-events: auto; }
.cal-chip { display: flex; align-items: center; gap: 4px; width: 100%; min-width: 0; min-height: 22px; padding: 0 6px; border: 0; border-radius: 6px; background: color-mix(in srgb, var(--chip) 16%, transparent); color: var(--text); font-size: var(--text-xs); text-align: left; }
.cal-chip:hover { background: color-mix(in srgb, var(--chip) 28%, transparent); }
.cal-chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--chip); flex-shrink: 0; }
.cal-chip.is-allday { background: var(--chip); color: #fff; font-weight: 500; }
.cal-chip.is-allday::before { display: none; }
.cal-chip-time { color: var(--text-muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.cal-chip-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-more { align-self: flex-start; padding: 0 6px; border: 0; background: none; font-size: var(--text-xs); font-weight: 600; color: var(--accent-text); }

/* Week / day */
.cal-week { --gutter: 52px; display: flex; flex-direction: column; min-width: 0; }
.cal-wk-headrow, .cal-wk-alldayrow { display: grid; grid-template-columns: var(--gutter) repeat(var(--days), minmax(0, 1fr)); }
.cal-wk-head { display: flex; justify-content: center; padding-bottom: var(--space-2); }
.cal-wk-head .cal-daynum { display: flex; flex-direction: column; align-items: center; height: auto; padding: var(--space-1) var(--space-2); border-radius: var(--radius-md); gap: 0; }
.cal-wk-head .cal-daynum span { font-size: var(--text-xs); color: var(--text-subtle); }
.cal-wk-head .cal-daynum strong { font-size: var(--text-lg); font-weight: 600; }
.cal-wk-head.is-today .cal-daynum { background: var(--accent-soft); color: var(--accent-text); }
.cal-wk-alldayrow { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.cal-gutter-label { align-self: center; font-size: var(--text-xs); color: var(--text-subtle); }
.cal-wk-allday { min-height: 30px; padding: 3px; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.cal-wk-scroll { position: relative; max-height: 560px; overflow-y: auto; }
.cal-wk-body { position: relative; display: grid; grid-template-columns: var(--gutter) repeat(var(--days), minmax(0, 1fr)); }
.cal-hours { grid-row: 1; grid-column: 1; }
.cal-hour { height: 44px; position: relative; }
.cal-hour span { position: absolute; top: -7px; right: 8px; font-size: 10px; color: var(--text-subtle); white-space: nowrap; }
.cal-wk-col { position: relative; grid-row: 1; border-left: 1px solid var(--border); cursor: pointer;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 43px, var(--border) 43px, var(--border) 44px); }
.cal-wk-col.is-today { background-color: color-mix(in srgb, var(--accent) 5%, transparent); }
.cal-block { position: absolute; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; overflow: hidden; padding: 3px 6px; border: 0; border-left: 3px solid var(--chip); border-radius: 6px;
  background: color-mix(in srgb, var(--chip) 22%, var(--surface-1)); color: var(--text); text-align: left; font-size: var(--text-xs); line-height: 1.3; }
.cal-block:hover { background: color-mix(in srgb, var(--chip) 34%, var(--surface-1)); z-index: 2; }
.cal-block-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.cal-block-time { color: var(--text-muted); white-space: nowrap; }
.cal-block.is-short { flex-direction: row; gap: 6px; align-items: center; padding-top: 1px; padding-bottom: 1px; }
.cal-block.is-short .cal-block-time { display: none; }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 3; pointer-events: none; }
.cal-now::before { content: ''; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

/* Agenda */
.cal-agenda { display: flex; flex-direction: column; gap: var(--space-4); }
.cal-agenda-date { margin-bottom: var(--space-2); font-family: var(--font-body); font-size: var(--text-sm); font-weight: 600; color: var(--text-muted); }
.cal-agenda-day.is-today .cal-agenda-date { color: var(--accent-text); }
.cal-agenda-item { width: 100%; display: grid; grid-template-columns: 132px minmax(0, 1fr) auto; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-1);
  border: 1px solid var(--border); border-left: 3px solid var(--chip); border-radius: var(--radius-md); background: var(--surface-2); text-align: left; }
.cal-agenda-item:hover { border-color: var(--border-strong); border-left-color: var(--chip); }
.cal-agenda-time { font-size: var(--text-sm); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.cal-agenda-main { display: flex; flex-direction: column; min-width: 0; }
.cal-agenda-title { font-size: var(--text-md); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-agenda-sub { font-size: var(--text-xs); color: var(--text-subtle); }

/* Event editor, alarm, more sheet */
dialog.modal-wide { max-width: 560px; }
.ev-kind { display: flex; width: 100%; }
.ev-kind .pomo-tab { flex: 1; }
.ev-repeat { display: flex; flex-direction: column; gap: var(--space-3); margin: calc(-1 * var(--space-2)) 0 var(--space-4); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); }
.ev-dow[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.ev-rem-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: var(--space-2); align-items: center; }
.ev-rem-row .btn-icon { width: 36px; }
.spacer { flex: 1; }
.alarm-dialog { max-width: 400px; text-align: center; }
.alarm-icon { font-size: 44px; line-height: 1; animation: ring 1s ease-in-out infinite; }
@keyframes ring { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-12deg); } 40% { transform: rotate(12deg); } 60% { transform: rotate(-8deg); } 80% { transform: rotate(8deg); } }
.alarm-time { margin: var(--space-2) 0; font-family: var(--font-mono); font-size: 40px; font-weight: 300; font-variant-numeric: tabular-nums; }
.alarm-actions { justify-content: center; }
.nav-more { display: none; }
.more-list { display: flex; flex-direction: column; gap: var(--space-1); }
.more-item { width: 100%; min-height: 48px; padding: 0 var(--space-4); border: 0; border-radius: var(--radius-md); background: none; text-align: left; font-size: var(--text-lg); }
.more-item:hover, .more-item[aria-current] { background: var(--accent-soft); color: var(--accent-text); }

@media (max-width: 1200px) {
  .cal-layout { grid-template-columns: minmax(0, 1fr); }
  .cal-side { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
}
@media (max-width: 780px) {
  .app .sidebar { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .sidebar .nav-item[data-page="timer"], .sidebar .nav-item[data-page="stopwatch"], .sidebar .nav-item[data-page="forest"], .sidebar .nav-item[data-page="settings"] { display: none; }
  .nav-more { display: flex; }
  .nav-more.is-current { background: var(--accent-soft); color: var(--accent-text); }
  dialog.sheet { margin: auto 0 0; width: 100%; max-width: none; border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom)); }
  .cal-main { padding: var(--space-3); }
  .cal-title { font-size: var(--text-lg); margin-left: var(--space-1); }
  .cal-toolbar { gap: var(--space-2); }
  .cal-cell { min-height: 64px; padding: 2px; }
  .cal-chip-time, .cal-chip-title { display: none; }
  .cal-chip { min-height: 6px; height: 6px; padding: 0; }
  .cal-chip::before { display: none; }
  .cal-chip:not(.is-allday) { background: var(--chip); }
  .cal-more { font-size: 10px; padding: 0 2px; }
  .cal-agenda-item { grid-template-columns: 84px minmax(0, 1fr) auto; padding: var(--space-3); }
  .cal-wk-scroll { max-height: 60vh; }
  .ev-rem-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .page-actions { width: 100%; }
  .page-actions .btn-primary { flex: 1; }
}

/* 6. LIQUID GLASS ========================================================== */
body.theme-glass {
  background:
    radial-gradient(55% 45% at 12% 8%, color-mix(in srgb, var(--accent) 50%, transparent), transparent 70%),
    radial-gradient(45% 40% at 88% 18%, rgba(34,211,238,0.26), transparent 70%),
    radial-gradient(50% 45% at 62% 96%, rgba(244,114,182,0.24), transparent 70%),
    radial-gradient(40% 35% at 30% 70%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}
/* Frosted panels: translucent fill, blur of what's behind, a bright top edge
   and a soft sheen. Blur is only on large containers (performance). */
body.theme-glass :is(.card, .settings-section, .stat-card, .timer-display, .sw-display, .tracker-bar, .stat-strip-item, .ctx-menu, .toast) {
  background: linear-gradient(145deg, rgba(255,255,255,0.1), rgba(255,255,255,0.02) 45%), var(--glass-fill);
  border: 1px solid var(--glass-edge);
  box-shadow: inset 0 1px 0 var(--glass-shine), inset 0 -1px 0 rgba(255,255,255,0.03), var(--shadow-1);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(170%);
  backdrop-filter: blur(var(--glass-blur)) saturate(170%);
}
body.theme-glass :is(.sidebar, .topbar) {
  background: rgba(16,14,32,0.5);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  backdrop-filter: blur(24px) saturate(170%);
  border-color: var(--glass-edge);
}
/* Dialogs host the toast stack, and a backdrop-filter would trap its fixed
   positioning, so they use a denser fill with the blur on ::backdrop. */
body.theme-glass dialog.modal {
  background: linear-gradient(145deg, rgba(255,255,255,0.08), rgba(255,255,255,0.01) 50%), var(--glass-fill-strong);
  border-color: var(--glass-edge);
  box-shadow: inset 0 1px 0 var(--glass-shine), var(--shadow-2);
}
body.theme-glass dialog.modal::backdrop { background: rgba(6,4,20,0.45); -webkit-backdrop-filter: blur(12px) saturate(140%); backdrop-filter: blur(12px) saturate(140%); }
body.theme-glass .focus-mode { background: transparent; -webkit-backdrop-filter: blur(40px) saturate(160%); backdrop-filter: blur(40px) saturate(160%); }
body.theme-glass :is(.btn-primary, .pomo-btn-main.play) { box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 8px 24px color-mix(in srgb, var(--accent) 35%, transparent); }
body.theme-glass :is(.pomo-tab.active, .auth-mode-btn.active) { background: rgba(255,255,255,0.14); box-shadow: inset 0 1px 0 rgba(255,255,255,0.2); }
body.theme-glass .toast { background: linear-gradient(145deg, rgba(255,255,255,0.1), rgba(255,255,255,0.02) 45%), var(--glass-fill-strong); }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  body.theme-glass { --glass-fill: rgba(22,19,40,0.94); }
}
/* Respect people who need solid, higher-contrast surfaces. */
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  body.theme-glass { --glass-fill: #17152b; --glass-fill-strong: #17152b; --surface-2: #1f1c36; --surface-3: #27243f; }
  body.theme-glass :is(.card, .settings-section, .stat-card, .timer-display, .sw-display, .tracker-bar, .stat-strip-item, .ctx-menu, .toast, .sidebar, .topbar, .focus-mode, dialog.modal::backdrop) {
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  body.theme-glass :is(.sidebar, .topbar) { background: #120f25; }
}

/* 7. MOTION, INPUT MODALITY, RESPONSIVE ==================================== */
@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; }
}
@media (hover: none) {
  .todo-actions, .entry-actions { opacity: 1; }
  .shortcut-hint { display: none; }
}
/* Comfortable touch targets. */
@media (pointer: coarse) {
  .num-btn { width: 40px; height: 40px; }
  .btn-icon, .todo-actions .btn-icon { width: 40px; min-height: 40px; }
  .color-opt { width: 36px; height: 36px; }
  .chip, .prio-btn { min-height: 36px; }
  .toast-close { width: 36px; height: 36px; }
  .btn { min-height: 42px; }
}

@media (max-width: 1200px) {
  .pomodoro-layout, .timer-layout, .tracking-layout { grid-template-columns: minmax(0, 1fr); }
  .pomo-settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .tracking-side { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .timer-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .timer-presets > .section-label, .timer-presets > .btn, .timer-presets > #timerPresetList, .timer-presets > #recentTimers { grid-column: 1 / -1; }
  #timerPresetList { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-2); }
  .grid-4, .report-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page { padding: var(--space-6); }
}
@media (max-width: 980px) {
  .todo-layout { grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
  .todo-sidebar { flex-direction: row; overflow-x: auto; gap: var(--space-2); padding-bottom: var(--space-1); scrollbar-width: none; }
  .todo-list-item { width: auto; flex-shrink: 0; white-space: nowrap; border-color: var(--border-strong); }
  .todo-lists-col .divider { display: none; }
  .sw-layout { grid-template-columns: minmax(0, 1fr); }
  .topbar { padding: var(--space-3) var(--space-5); }
  .page-head { align-items: flex-start; }
}
@media (max-width: 780px) {
  /* Bottom navigation: all seven destinations, labelled, above the home bar. */
  .sidebar {
    inset: auto 0 0 0; width: 100%; height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
    display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px;
    padding: var(--space-1) var(--space-1) calc(var(--space-1) + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--border); overflow: hidden;
  }
  .sidebar.expanded { width: 100%; }
  .sidebar-logo, .nav-divider { display: none; }
  .sidebar-bottom { display: contents; }
  .nav-item, .sidebar.expanded .nav-item { width: 100%; height: 100%; min-width: 0; padding: 0 2px; flex-direction: column; gap: 3px; border-radius: var(--radius-md); justify-content: center; }
  .nav-item.active::before { display: none; }
  .nav-item svg { width: 20px; height: 20px; }
  .nav-label, .sidebar.expanded .nav-label { display: none; }
  .nav-short { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; font-weight: 500; line-height: 1; }
  .main, .sidebar.expanded ~ .main { margin-left: 0; padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom)); }
  .toasts, .toasts[popover] { inset: auto var(--space-3) calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + var(--space-3)) var(--space-3); align-items: stretch; }
  .toast { max-width: none; }
  .topbar { padding: var(--space-2) var(--space-3); }
  .topbar-date, .topbar-right .btn-icon { display: none; }
  .ambient-badge #ambientLabel { max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .auth-corner-text { max-width: 80px; }
  .page { padding: var(--space-5) var(--space-4); }
  .pomo-settings, .tracking-side { grid-template-columns: minmax(0, 1fr); }
  .settings-row { flex-wrap: wrap; padding: var(--space-4); }
  .settings-section-title { padding: var(--space-4) var(--space-4) var(--space-2); }
}
@media (max-width: 600px) {
  .page-title { font-size: 1.375rem; }
  .page-head { margin-bottom: var(--space-4); }
  .stat-strip { width: 100%; }
  .stat-strip-item { flex: 1; min-width: 0; padding: var(--space-2) var(--space-3); }
  .timer-card { padding: var(--space-6) var(--space-4); }
  .pomo-tabs { margin-bottom: var(--space-6); }
  .ring-container { width: 240px; height: 240px; }
  .ring-time { font-size: 46px; }
  .grid-2, .grid-3, .grid-4, .form-row { grid-template-columns: minmax(0, 1fr); }
  .report-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar-time { display: none; }
  .auth-corner-text { display: none; }
  .tracker-desc, .tracker-project { flex-basis: 100%; }
  .tracker-bar .btn { flex: 1; }
  .time-seg { width: 72px; min-height: 64px; font-size: 32px; }
  .time-colon { font-size: 26px; margin-top: 14px; }
  .timer-display { min-height: 0; padding: var(--space-8) var(--space-4); }
  .sw-display { padding: var(--space-8) var(--space-4); }
  .sw-time { font-size: clamp(34px, 11vw, 56px); }
  .stepper-grid { grid-template-columns: 1fr 1fr; }
  .entry-time { display: none; }
  .settings-row .input, input[type="range"] { width: 100% !important; }
  .settings-control { width: 100%; justify-content: space-between; }
}
@media (max-width: 420px) {
  .nav-short { font-size: 9px; }
  .ambient-badge #ambientLabel { max-width: 56px; }
  .brand-word { display: none; }
}
