/* ==========================================================================
   رشد شخصی — design system «کاشی و بامداد»
   Plain CSS, no build step: tokens → base → layout → components → pages.
   Everything colour-related reads from the custom properties below, so light
   and dark mode are just two token sets.
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  color-scheme: light;
  /* Paper ground (cool, slightly blue — not cream, not neutral grey) */
  --bg: #eef3f4;
  --surface: #fbfdfd;
  --surface-2: #e3ecee;
  --line: #cfdcdf;
  --line-strong: #b4c6ca;
  --control: #6f8b92; /* borders of inputs/checkboxes: >= 3:1 (WCAG 1.4.11) */
  /* Ink */
  --ink: #12262b;
  --ink-2: #4b6269;
  --ink-3: #4f666d;
  /* Turquoise (primary) */
  --primary: #0b7a84;
  --primary-hover: #086670;
  --primary-ink: #ffffff;
  --primary-soft: #d5eef0;
  --primary-text: #085c64;
  /* Saffron (accent) */
  --accent: #e9a612;
  --accent-hover: #d99a0c;
  --accent-ink: #2b1c00;
  --accent-soft: #fbebc8;
  --accent-text: #7a4f00;
  /* Status */
  --ok: #1b7547;
  --ok-soft: #ddf1e5;
  --danger: #b5322a;
  --danger-soft: #fbe3e0;
  --danger-hover: #9a2820;
  /* Shape: two tiers only */
  --r-lg: 18px;
  --r-sm: 11px;
  /* Depth */
  --shadow-1: 0 1px 2px rgb(18 38 43 / .06), 0 1px 1px rgb(18 38 43 / .04);
  --shadow-2: 0 8px 24px -8px rgb(18 38 43 / .18), 0 2px 6px rgb(18 38 43 / .06);
  /* Motion */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --t-fast: 120ms;
  --t-base: 200ms;
  --t-slow: 420ms;
  /* Layout */
  --tabbar-h: 3.9rem;
  --font: "Vazirmatn", "Vazir", Tahoma, "Segoe UI", system-ui, sans-serif;
}

.dark {
  color-scheme: dark;
  --bg: #0b1a1d;
  --surface: #122428;
  --surface-2: #1a3035;
  --line: #254046;
  --line-strong: #35565d;
  --control: #5f8a91;
  --ink: #e6f1f2;
  --ink-2: #a5bcc0;
  --ink-3: #8ca5aa;
  --primary: #4cc3cc;
  --primary-hover: #6ad1d9;
  --primary-ink: #06262a;
  --primary-soft: #12383d;
  --primary-text: #7dd9e0;
  --accent: #f2b93b;
  --accent-hover: #f6c75e;
  --accent-ink: #2b1c00;
  --accent-soft: #3a2e10;
  --accent-text: #f2c768;
  --ok: #5fd197;
  --ok-soft: #12301f;
  --danger: #ff8a80;
  --danger-soft: #3a1a18;
  --danger-hover: #ffa399;
  --shadow-1: 0 1px 2px rgb(0 0 0 / .4);
  --shadow-2: 0 10px 28px -8px rgb(0 0 0 / .55), 0 2px 6px rgb(0 0 0 / .3);
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.75;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--t-base) var(--ease), color var(--t-base) var(--ease);
}
h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
h1, h2, h3 { line-height: 1.4; font-weight: 700; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; }
a { color: var(--primary-text); text-decoration-thickness: 1px; text-underline-offset: 4px; }
a:hover { color: var(--primary-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--primary-soft); color: var(--primary-text); }

.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;
}
.skip-link {
  position: fixed; top: .5rem; right: .5rem; z-index: 100;
  padding: .5rem 1rem; border-radius: var(--r-sm);
  background: var(--primary); color: var(--primary-ink); font-weight: 600;
  transform: translateY(-200%); transition: transform var(--t-base) var(--ease);
}
.skip-link:focus { transform: none; color: var(--primary-ink); }

/* Icons from the sprite in includes/icons.html */
.i { width: 1.25em; height: 1.25em; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 1em; height: 1em; }
.i-lg { width: 1.6em; height: 1.6em; }
.i-fill { fill: currentColor; stroke: none; }

/* ---------- 3. Layout ---------- */
.container { width: 100%; max-width: 46rem; margin-inline: auto; padding-inline: 1rem; }
.container-wide { width: 100%; max-width: 70rem; margin-inline: auto; padding-inline: 1.25rem; }
main.container { padding-block: 1.25rem 2rem; }
.stack > * + * { margin-top: 1rem; }
.stack-sm > * + * { margin-top: .5rem; }
.row { display: flex; align-items: center; gap: .75rem; }
.row-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1 1 0; min-width: 0; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .78rem; }
.text-center { text-align: center; }
.bold { font-weight: 700; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.nowrap { white-space: nowrap; }
.mt-1 { margin-top: .25rem; } .mt-2 { margin-top: .5rem; } .mt-3 { margin-top: .75rem; } .mt-4 { margin-top: 1rem; } .mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: .5rem; } .mb-3 { margin-bottom: .75rem; } .mb-4 { margin-bottom: 1rem; } .mb-6 { margin-bottom: 1.5rem; }
.tile-bg {
  background-image:
    radial-gradient(circle at 50% 50%, transparent 0 5px, var(--line) 5px 6px, transparent 6px),
    radial-gradient(circle at 0 0, var(--line) 0 1.5px, transparent 1.5px);
  background-size: 28px 28px;
}

/* ---------- 4. App bar, nav, tab bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.appbar-inner { display: flex; align-items: center; gap: 1rem; min-height: 3.5rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--ink); font-weight: 800; font-size: 1.05rem; text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand span { white-space: nowrap; }
@media (max-width: 419.98px) { .hide-xs { display: none !important; } }
.brand .i { width: 1.75rem; height: 1.75rem; stroke-width: 0; }
.nav { display: none; align-items: center; gap: .15rem; margin-inline-start: .5rem; }
.nav a {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .4rem .75rem; border-radius: 999px; font-size: .9rem; font-weight: 500;
  color: var(--ink-2); text-decoration: none;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary-text); font-weight: 700; }
.appbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: .25rem; }
.user-chip { display: none; font-size: .85rem; color: var(--ink-2); padding-inline: .5rem; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.5rem; height: 2.5rem; padding: 0; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--ink-2); text-decoration: none;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:active { transform: scale(.92); }
.icon-btn .i-moon { display: block; } .icon-btn .i-sun { display: none; }
.dark .icon-btn .i-moon { display: none; } .dark .icon-btn .i-sun { display: block; }

.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 45;
  display: grid; grid-template-columns: repeat(5, 1fr);
  min-height: var(--tabbar-h); padding-bottom: env(safe-area-inset-bottom, 0px);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a, .tabbar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem;
  border: 0; background: none; padding: .35rem 0; min-height: 3.5rem;
  font-size: .72rem; font-weight: 500; color: var(--ink-2); text-decoration: none; line-height: 1.4;
  transition: color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.tabbar .i { width: 1.5rem; height: 1.5rem; transition: transform var(--t-base) var(--ease); }
.tabbar a:active .i, .tabbar button:active .i { transform: scale(.88); }
.tabbar a[aria-current="page"] { color: var(--primary-text); font-weight: 700; }
.tabbar a[aria-current="page"] .i { transform: translateY(-1px); }
.tabbar a[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; width: 1.75rem; height: 3px; border-radius: 0 0 3px 3px; background: var(--primary);
}
.tabbar a { position: relative; }
body.has-tabbar { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + .5rem); }

@media (min-width: 768px) {
  .nav { display: flex; }
  .user-chip { display: inline; }
  .tabbar { display: none; }
  body.has-tabbar { padding-bottom: 0; }
  .appbar .only-desktop { display: inline-flex; }
}
@media (max-width: 767.98px) { .only-desktop { display: none !important; } }

/* ---------- 5. Buttons, fields, chips ---------- */
.btn {
  --_bg: var(--surface-2); --_fg: var(--ink); --_bd: transparent; --_hv: var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 2.75rem; padding: .5rem 1.15rem; border: 1px solid var(--_bd); border-radius: var(--r-sm);
  background: var(--_bg); color: var(--_fg); font-weight: 600; font-size: .95rem; line-height: 1.4;
  text-decoration: none; cursor: pointer; user-select: none; -webkit-user-select: none; white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-base) var(--ease), border-color var(--t-fast) var(--ease);
}
.btn:hover { background: var(--_hv); color: var(--_fg); }
.btn:active { transform: scale(.97); }
.btn-primary { --_bg: var(--primary); --_fg: var(--primary-ink); --_hv: var(--primary-hover); box-shadow: 0 1px 0 rgb(255 255 255 / .18) inset, var(--shadow-1); }
.btn-accent { --_bg: var(--accent); --_fg: var(--accent-ink); --_hv: var(--accent-hover); box-shadow: var(--shadow-1); }
.btn-ghost { --_bg: transparent; --_bd: var(--control); --_hv: var(--surface-2); }
.btn-danger { --_bg: var(--danger); --_fg: #fff; --_hv: var(--danger-hover); }
.dark .btn-danger { --_fg: #2a0a07; }
.btn-sm { min-height: 2.25rem; padding: .25rem .8rem; font-size: .85rem; }
.btn-lg { min-height: 3.1rem; padding: .6rem 1.6rem; font-size: 1.02rem; }
.btn-block { width: 100%; }
.btn.htmx-request, .btn[aria-busy="true"] { opacity: .65; pointer-events: none; }

.field {
  width: 100%; min-height: 2.75rem; padding: .55rem .85rem;
  border: 1px solid var(--control); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.field::placeholder { color: var(--ink-3); opacity: 1; }
.field:hover { border-color: var(--ink-3); }
.field:focus-visible { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 28%, transparent); outline: none; border-radius: var(--r-sm); }
.field[aria-invalid="true"] { border-color: var(--danger); }
textarea.field { min-height: 6rem; resize: vertical; line-height: 1.7; }
select.field { appearance: none; -webkit-appearance: none; padding-inline-end: 2.2rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: 1.1rem 52%, .8rem 52%; background-size: .3rem .3rem; background-repeat: no-repeat; }
.field[type="time"], .field[type="date"] { direction: ltr; text-align: right; }
.field-label { display: block; margin-bottom: .3rem; font-size: .9rem; font-weight: 600; }
.field-error { margin-top: .3rem; font-size: .85rem; color: var(--danger); display: flex; gap: .35rem; align-items: flex-start; }
.field-help { margin-top: .3rem; font-size: .8rem; color: var(--ink-2); }
.field-help ul { list-style: disc; padding-inline-start: 1.2rem; }
.form-row { margin-bottom: 1rem; }

.check-group { display: flex; flex-wrap: wrap; gap: .5rem; }
.check-group > div, .check-group li { display: contents; }
.check-pill { position: relative; }
.check-pill input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.check-pill label {
  display: inline-flex; align-items: center; gap: .4rem; min-height: 2.5rem; padding: .3rem .9rem;
  border: 1px solid var(--control); border-radius: 999px; background: var(--surface);
  font-size: .9rem; color: var(--ink-2); cursor: pointer; user-select: none;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.check-pill input:checked + label { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-text); font-weight: 700; }
.check-pill input:focus-visible + label { outline: 3px solid var(--primary); outline-offset: 2px; }
.check-pill input:active + label { transform: scale(.95); }

.switch-row { display: flex; align-items: center; gap: .6rem; }
.switch-row input[type="checkbox"] { width: 1.25rem; height: 1.25rem; accent-color: var(--primary); }

.chip {
  display: inline-flex; align-items: center; gap: .3rem; padding: .05rem .65rem;
  border-radius: 999px; font-size: .78rem; font-weight: 600; line-height: 1.7; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2);
}
.chip .i { width: .95em; height: .95em; }
.chip-primary { background: var(--primary-soft); color: var(--primary-text); }
.chip-accent { background: var(--accent-soft); color: var(--accent-text); }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }

/* Segmented control (goal tabs) */
.seg { display: inline-flex; padding: .25rem; gap: .15rem; background: var(--surface-2); border-radius: var(--r-sm); }
.seg a {
  padding: .3rem .95rem; border-radius: 8px; font-size: .9rem; font-weight: 500;
  color: var(--ink-2); text-decoration: none;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.seg a:hover { color: var(--ink); }
.seg a[aria-current="true"] { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: var(--shadow-1); }

/* ---------- 6. Cards, alerts, progress, empty states ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.1rem; box-shadow: var(--shadow-1); }
.card-link { display: block; color: inherit; text-decoration: none; transition: transform var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease), border-color var(--t-base) var(--ease); }
.card-link:hover { color: inherit; border-color: var(--line-strong); box-shadow: var(--shadow-2); transform: translateY(-2px); }
.card-link:active { transform: scale(.99); }
.card-title { font-size: 1rem; font-weight: 700; }
.card-accent { background: var(--accent-soft); border-color: transparent; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.1rem; }
.page-head h1 { display: flex; align-items: center; gap: .6rem; }
.page-sub { font-size: .9rem; color: var(--ink-2); margin-top: .15rem; }

.alert { display: flex; align-items: flex-start; gap: .6rem; padding: .7rem .9rem; border-radius: var(--r-sm); font-size: .92rem; background: var(--surface-2); color: var(--ink); animation: rise var(--t-slow) var(--ease) both; }
.alert-success { background: var(--ok-soft); color: var(--ok); }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert .i { margin-top: .2rem; }

.progress { height: .55rem; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; width: var(--w, 0%); border-radius: inherit; background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 70%, var(--accent))); transition: width var(--t-slow) var(--ease); animation: grow-x 700ms var(--ease) both; transform-origin: right; }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .35rem; padding: 2rem 1rem; }
.empty svg.illus { width: 9rem; height: auto; margin-bottom: .5rem; }
.empty h2, .empty h3 { font-size: 1.05rem; }
.empty p { color: var(--ink-2); font-size: .92rem; max-width: 24rem; }
.empty .btn { margin-top: .85rem; }
.empty-card { border: 1.5px dashed var(--line-strong); border-radius: var(--r-lg); background: transparent; }

/* ---------- 7. Today hero + progress ring ---------- */
.hero-today {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 1.1rem;
  padding: 1.25rem; border-radius: var(--r-lg); color: var(--ink);
  background: linear-gradient(135deg, var(--primary-soft), color-mix(in srgb, var(--primary-soft) 55%, var(--accent-soft)));
  border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--line));
}
.hero-today::after { /* tile motif, decorative */
  content: ""; position: absolute; inset: 0; opacity: .5; pointer-events: none;
  background-image: radial-gradient(circle at 50% 50%, transparent 0 6px, color-mix(in srgb, var(--primary) 22%, transparent) 6px 7px, transparent 7px);
  background-size: 30px 30px; mask-image: linear-gradient(to left, transparent 30%, #000 100%); -webkit-mask-image: linear-gradient(to left, transparent 30%, #000 100%);
}
.hero-today > * { position: relative; z-index: 1; }
.hero-text { min-width: 0; }
.hero-greet { font-size: 1.35rem; font-weight: 800; line-height: 1.4; }
.hero-date { font-size: .92rem; color: var(--ink-2); }
.hero-msg { margin-top: .35rem; font-size: .95rem; color: var(--primary-text); font-weight: 600; }
.ring { position: relative; width: 5.6rem; height: 5.6rem; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; }
.ring .track { stroke: color-mix(in srgb, var(--ink) 12%, transparent); }
.ring .bar { stroke: var(--primary); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--p, 0)); transition: stroke-dashoffset var(--t-slow) var(--ease), stroke var(--t-base) var(--ease); animation: ring-in 1s var(--ease) both; }
.ring.is-complete .bar { stroke: var(--ok); }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.2; }
.ring-label strong { font-size: 1.15rem; display: block; }
.ring-label span { font-size: .7rem; color: var(--ink-2); }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: 1.5rem 0 .6rem; }
.section-title h2 { display: flex; align-items: center; gap: .5rem; }

.deadline-list li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .5rem 0; }
.deadline-list li + li { border-top: 1px solid color-mix(in srgb, var(--accent-text) 18%, transparent); }
.deadline-list li { flex-direction: column; align-items: flex-start; gap: 0; }
.deadline-meta { color: var(--accent-text); }
@media (min-width: 560px) { .deadline-list li { flex-direction: row; align-items: center; gap: .75rem; } }
.deadline-list a { color: var(--ink); font-weight: 600; text-decoration: none; }
.deadline-list a:hover { text-decoration: underline; }

/* ---------- 8. Tasks ---------- */
.quick-add { margin-bottom: 1rem; padding: .75rem; }
.quick-add-main { display: flex; gap: .5rem; }
.quick-add details { margin-top: .6rem; }
.quick-add summary {
  display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; list-style: none;
  font-size: .85rem; color: var(--ink-2); padding: .2rem .4rem; border-radius: 8px;
}
.quick-add summary::-webkit-details-marker { display: none; }
.quick-add summary:hover { color: var(--ink); background: var(--surface-2); }
.quick-add summary .i { transition: transform var(--t-base) var(--ease); }
.quick-add details[open] summary .i { transform: rotate(180deg); }
.quick-add-extra { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: .6rem; }
.quick-add-extra .span-2 { grid-column: span 2; }
@media (min-width: 640px) { .quick-add-extra { grid-template-columns: 2fr 1fr 1fr 1fr; } .quick-add-extra .span-2 { grid-column: auto; } }

.task-list { display: grid; gap: .6rem; }
.task {
  display: grid; grid-template-columns: auto 1fr; gap: .25rem .8rem; align-items: start;
  padding: .85rem .9rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  transition: opacity var(--t-base) var(--ease), transform var(--t-base) var(--ease), border-color var(--t-base) var(--ease), background-color var(--t-base) var(--ease);
}
.task.is-new { animation: rise var(--t-slow) var(--ease) both; }
.task.htmx-swapping { opacity: 0; transform: translateX(-24px) scale(.98); }
.task[data-priority="high"] { border-inline-start: 4px solid var(--danger); }
.task[data-priority="low"] { border-inline-start: 4px solid var(--primary); }
.task[data-status="done"] { background: color-mix(in srgb, var(--ok-soft) 55%, var(--surface)); }
.task[data-status="done"] .task-title { color: var(--ink-3); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.task[data-status="failed"] { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.task[data-status="moved"] { opacity: .85; }

.check {
  position: relative; display: grid; place-items: center; width: 2.5rem; height: 2.5rem; margin: -.15rem -.2rem; padding: 0;
  border: 0; background: none; border-radius: 50%; color: var(--ink-3); flex: none;
}
.check::before { /* the visible circle is smaller than the 40px hit area */
  content: ""; position: absolute; width: 1.65rem; height: 1.65rem; border-radius: 50%;
  border: 2px solid var(--control); background: var(--surface);
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.check:hover::before { border-color: var(--primary); }
.check:active::before { transform: scale(.88); }
.check .i { position: relative; width: 1rem; height: 1rem; stroke-width: 3; color: var(--primary-ink); opacity: 0; }
.task[data-status="done"] .check::before { background: var(--ok); border-color: var(--ok); }
.dark .task[data-status="done"] .check .i { color: #06231a; }
.task[data-status="done"] .check .i { opacity: 1; }
.task[data-status="in_progress"] .check::before { border-color: var(--accent); background: var(--accent-soft); }
.task[data-status="failed"] .check::before { border-color: var(--danger); background: var(--danger-soft); }
.task.is-new[data-status="done"] .check::before { animation: pop 420ms var(--ease); }
.check.htmx-request { opacity: .6; }

.task-body { min-width: 0; }
.task-title { font-weight: 600; line-height: 1.6; overflow-wrap: anywhere; }
.task-meta { display: flex; flex-wrap: wrap; gap: .35rem .5rem; margin-top: .25rem; }
.task-fail { margin-top: .35rem; font-size: .85rem; color: var(--danger); }
.task-actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: .15rem; margin-top: .35rem; margin-inline-start: -.5rem; }
.task-actions .icon-btn { width: 2.5rem; height: 2.5rem; }
.task-actions .act-start:hover { color: var(--accent-text); background: var(--accent-soft); }
.task-actions .act-fail:hover, .task-actions .act-delete:hover { color: var(--danger); background: var(--danger-soft); }
.task-actions .act-move:hover { color: var(--primary-text); background: var(--primary-soft); }
.task-actions .locked { display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; color: var(--ink-3); }
.task-fail-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; grid-column: 1 / -1; }
.task-fail-form .field { flex: 1 1 12rem; }
.task-list .empty-state { display: block; }
.task-list:has(.task) .empty-state { display: none; }

/* Mood picker */
.mood { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem; }
.mood .check-pill label { padding-inline: .7rem; }
.mood .i { width: 1.35rem; height: 1.35rem; }
.mood .check-pill input:checked + label { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
/* "no mood" option: always readable text, sits after the five faces */
.mood .check-pill.is-none { order: 9; flex-basis: 100%; }
.mood .check-pill.is-none label { min-height: 2rem; padding-block: .1rem; font-size: .8rem; border-style: dashed; }
@media (max-width: 479.98px) {
  /* five faces share one row; only the chosen one shows its word */
  .mood .check-pill:not(.is-none) { flex: 1 1 0; min-width: 0; }
  .mood .check-pill:not(.is-none) label { width: 100%; justify-content: center; padding-inline: .3rem; }
  .mood .check-pill:not(.is-none) label span { display: none; }
  .mood .check-pill:not(.is-none) input:checked + label span { display: inline; }
}
.saved-flag { display: inline-flex; align-items: center; gap: .3rem; font-size: .85rem; color: var(--ok); font-weight: 600; animation: rise var(--t-slow) var(--ease) both; }

/* ---------- 9. Goals & habits ---------- */
.item-card + .item-card { margin-top: .75rem; }
.item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
.item-title { font-weight: 700; overflow-wrap: anywhere; }
.item-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .75rem; flex-wrap: wrap; }
.item-actions { display: flex; align-items: center; gap: .15rem; margin-inline-start: -.4rem; }
.item-actions form { display: inline; }
.item-actions .icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.filters { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.search-form { display: flex; gap: .5rem; flex: 1 1 14rem; max-width: 22rem; }
.dim { opacity: .62; }
.streak { color: var(--accent-text); background: var(--accent-soft); }
.weekday-dots { display: flex; gap: .2rem; }
.weekday-dots span { width: 1.45rem; height: 1.45rem; display: grid; place-items: center; border-radius: 50%; font-size: .7rem; background: var(--surface-2); color: var(--ink-3); }
.weekday-dots span.on { background: var(--primary-soft); color: var(--primary-text); font-weight: 700; }

/* ---------- 10. Calendar & timeline ---------- */
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: .9rem; }
.cal-nav h1 { font-size: 1.25rem; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .3rem; }
.cal-dow { text-align: center; font-size: .78rem; color: var(--ink-2); padding-block: .3rem; font-weight: 600; }
.cal-dow abbr { text-decoration: none; }
.cal-dow .full { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.cal-dow { position: relative; }
.cal-dow.fri { color: var(--danger); }
.cal-day {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: .2rem;
  min-height: 3.4rem; padding: .35rem .1rem; border-radius: var(--r-sm); text-decoration: none; font-weight: 600; font-size: .95rem;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  transition: background-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.cal-day:hover { background: var(--primary-soft); color: var(--ink); border-color: var(--primary); }
.cal-day:active { transform: scale(.94); }
.cal-day.is-out { background: transparent; border-color: transparent; color: var(--ink-3); font-weight: 400; opacity: .55; }
.cal-day.is-holiday { color: var(--danger); }
.cal-day.is-today { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.cal-day.is-today:hover { background: var(--primary-hover); color: var(--primary-ink); }
.dots { display: flex; gap: 3px; min-height: 6px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); }
.dot-done { background: var(--ok); }
.dot-in_progress { background: var(--accent); }
.dot-todo { background: var(--ink-3); }
.dot-moved { background: var(--line-strong); }
.dot-failed { background: var(--danger); }
.cal-day.is-today .dot { box-shadow: 0 0 0 1.5px var(--primary-ink); }
.legend { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin-top: 1rem; font-size: .8rem; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
@media (min-width: 640px) { .cal { gap: .4rem; } .cal-day { min-height: 4.4rem; font-size: 1.02rem; } .cal-dow .full { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; white-space: normal; } .cal-dow .short { display: none; } }

.tl-wrap { overflow: hidden; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); }
.tl { position: relative; display: flex; height: 1440px; }
.tl-hours { width: 3.6rem; flex: none; font-size: .72rem; color: var(--ink-3); }
.tl-hours div { height: 60px; padding: .1rem .5rem 0 0; border-top: 1px solid var(--line); text-align: left; }
.tl-hours div:first-child { border-top-color: transparent; }
.tl-grid { position: relative; flex: 1; border-inline-start: 1px solid var(--line); }
.tl-line { position: absolute; inset-inline: 0; border-top: 1px solid var(--line); }
.tl-event {
  position: absolute; inset-inline: .35rem; overflow: hidden; padding: .2rem .55rem; border-radius: 9px; font-size: .8rem; line-height: 1.5;
  background: var(--primary-soft); color: var(--ink); border-inline-start: 4px solid var(--primary); box-shadow: var(--shadow-1);
}
.tl-event.is-done { background: var(--ok-soft); border-color: var(--ok); color: var(--ink-3); text-decoration: line-through; }
.tl-event.is-failed { background: var(--danger-soft); border-color: var(--danger); }
.tl-event .t { color: var(--ink-2); font-size: .72rem; display: block; }
.tl-now { position: absolute; inset-inline: 0; height: 0; border-top: 2px solid var(--danger); z-index: 3; }
.tl-now::before { content: ""; position: absolute; inset-inline-start: -5px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.untimed { padding: .75rem; background: var(--surface-2); border-radius: var(--r-lg); margin-bottom: 1rem; }
.untimed ul { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.untimed li { padding: .15rem .8rem; border-radius: 999px; background: var(--surface); font-size: .88rem; box-shadow: var(--shadow-1); }
.untimed li.is-done { color: var(--ink-3); text-decoration: line-through; }

/* ---------- 11. Stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
.stat { padding: 1rem; }
.stat-top { display: flex; align-items: center; gap: .5rem; color: var(--ink-2); font-size: .85rem; }
.stat-top .i { color: var(--primary); }
.stat-top .i.accent { color: var(--accent-text); }
.stat-value { margin-top: .35rem; font-size: 1.9rem; font-weight: 800; line-height: 1.2; }
.stat-value small { font-size: .9rem; font-weight: 500; color: var(--ink-2); }
.stat-wide { grid-column: span 2; }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } .stat-wide { grid-column: auto; } }
.bars { display: flex; align-items: flex-end; justify-content: space-between; gap: .5rem; height: 9rem; margin-top: 1rem; }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; gap: .35rem; min-width: 0; }
.bar-track { flex: 1; width: 100%; max-width: 2.6rem; display: flex; align-items: flex-end; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.bar-fill { width: 100%; min-height: 4px; border-radius: 8px; background: linear-gradient(to top, var(--primary), color-mix(in srgb, var(--primary) 65%, var(--accent))); transform-origin: bottom; animation: grow-y 700ms var(--ease) both; }
.bar-fill.is-empty { background: var(--line-strong); }
.bar-label { font-size: .75rem; color: var(--ink-2); }
.bar-val { font-size: .7rem; color: var(--ink-3); }
.seg-bar { display: flex; height: .7rem; border-radius: 999px; overflow: hidden; background: var(--surface-2); gap: 2px; }
.seg-bar span { display: block; height: 100%; }
.legend-list { display: grid; gap: .5rem; margin-top: .9rem; }
.legend-list li { display: flex; align-items: center; justify-content: space-between; font-size: .92rem; }
.legend-list .sw { display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; margin-inline-end: .5rem; }

/* ---------- 12. Auth pages ---------- */
.auth { max-width: 26rem; margin: 1rem auto 0; }
.auth-head { text-align: center; margin-bottom: 1.1rem; }
.auth-head .mark { width: 3.4rem; height: 3.4rem; margin: 0 auto .6rem; }
.auth-card { padding: 1.4rem; }
.auth-foot { margin-top: 1rem; text-align: center; font-size: .92rem; color: var(--ink-2); }
.auth-foot a { font-weight: 600; }
.status-icon { display: grid; place-items: center; width: 3.4rem; height: 3.4rem; margin: 0 auto .75rem; border-radius: 50%; background: var(--primary-soft); color: var(--primary-text); }
.status-icon.danger { background: var(--danger-soft); color: var(--danger); }
.status-icon.ok { background: var(--ok-soft); color: var(--ok); }
.status-icon .i { width: 1.6rem; height: 1.6rem; }
.settings-section { display: grid; grid-template-columns: auto 1fr; gap: .25rem .9rem; align-items: start; }
.settings-section .status-icon { margin: 0; width: 2.6rem; height: 2.6rem; }
.settings-section .status-icon .i { width: 1.3rem; height: 1.3rem; }
.settings-section > .body { min-width: 0; }
.settings-section.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }

/* ---------- 13. Toasts, confetti ---------- */
.toasts {
  position: fixed; inset-inline: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + .75rem); z-index: 90;
  display: flex; flex-direction: column; align-items: center; gap: .5rem; padding-inline: 1rem; pointer-events: none;
}
@media (min-width: 768px) { .toasts { bottom: 1.5rem; } }
.toast {
  display: inline-flex; align-items: center; gap: .55rem; max-width: 100%; padding: .65rem 1rem; border-radius: var(--r-sm);
  background: var(--ink); color: var(--bg); font-size: .92rem; box-shadow: var(--shadow-2);
  animation: toast-in var(--t-slow) var(--ease) both;
}
.toast.is-error { background: var(--danger); color: #fff; }
.dark .toast.is-error { color: #2a0a07; }
.toast.is-leaving { animation: toast-out var(--t-base) var(--ease) both; }
.confetti { position: fixed; inset: 0; z-index: 95; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; opacity: 0;
  animation: confetti-fall var(--d, 1.8s) var(--ease) var(--delay, 0s) forwards;
}

/* ---------- 14. Keyframes ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes ring-in { from { stroke-dashoffset: 100; } }
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes grow-y { from { transform: scaleY(0); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.96); } }
@keyframes confetti-fall {
  0% { opacity: 1; transform: translate3d(0, 0, 0) rotate(0); }
  100% { opacity: 0; transform: translate3d(var(--x, 0), 105vh, 0) rotate(var(--r, 540deg)); }
}
.reveal { animation: rise 600ms var(--ease) both; animation-delay: var(--delay, 0s); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .confetti { display: none; }
}

/* ---------- 15. Landing page ---------- */
.landing-nav { display: flex; align-items: center; gap: .5rem; }
.hero { padding-block: 2.5rem 1rem; display: grid; gap: 2rem; align-items: center; }
.hero h1 { font-size: clamp(1.9rem, 6.5vw, 3.1rem); line-height: 1.35; font-weight: 800; letter-spacing: -.01em; }
.hero h1 em { font-style: normal; color: var(--primary-text); background: linear-gradient(transparent 62%, color-mix(in srgb, var(--accent) 55%, transparent) 62%); padding-inline: .15em; }
.hero .lead { margin-top: 1rem; font-size: 1.08rem; color: var(--ink-2); max-width: 34rem; }
.hero-cta { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; }
.hero-cta .btn { flex: 1 1 auto; }
@media (min-width: 480px) { .hero-cta .btn { flex: 0 0 auto; } }
.hero-proof { margin-top: 1.25rem; display: flex; flex-wrap: wrap; gap: .5rem 1.1rem; font-size: .85rem; color: var(--ink-2); }
.hero-proof span { display: inline-flex; align-items: center; gap: .35rem; }
.hero-proof .i { color: var(--ok); width: 1.05em; height: 1.05em; }
@media (min-width: 900px) { .hero { grid-template-columns: 1.1fr .9fr; padding-block: 4rem 2rem; gap: 3rem; } }

/* Illustrative app preview (not live data) */
.mock { position: relative; max-width: 22rem; margin-inline: auto; }
.mock::before { content: ""; position: absolute; inset: 8% 2% -4% 12%; border-radius: 32px; background: var(--accent-soft); transform: rotate(-3deg); z-index: 0; }
.mock-phone { position: relative; z-index: 1; padding: .9rem; border-radius: 28px; background: var(--bg); border: 1px solid var(--line-strong); box-shadow: var(--shadow-2); }
.mock .hero-today { padding: .9rem; gap: .8rem; }
.mock .ring { width: 4.4rem; height: 4.4rem; }
.mock .hero-greet { font-size: 1.05rem; }
.mock .task { padding: .55rem .7rem; box-shadow: none; }
.mock .task-title { font-size: .9rem; }
.mock-caption { text-align: center; font-size: .75rem; color: var(--ink-3); margin-top: .75rem; position: relative; z-index: 1; }

.lsection { padding-block: 3rem; }
.lsection-head { text-align: center; max-width: 36rem; margin: 0 auto 2rem; }
.lsection-head h2 { font-size: clamp(1.4rem, 4.5vw, 2rem); font-weight: 800; }
.lsection-head p { margin-top: .5rem; color: var(--ink-2); }
.features { display: grid; gap: .9rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .features { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .features { grid-template-columns: repeat(3, 1fr); } }
.feature { padding: 1.25rem; }
.feature .status-icon { margin: 0 0 .8rem; border-radius: var(--r-sm); }
.feature h3 { font-size: 1.05rem; margin-bottom: .3rem; }
.feature p { color: var(--ink-2); font-size: .94rem; }
.steps { display: grid; gap: 1rem; }
@media (min-width: 768px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.step { position: relative; padding: 1.25rem 1.25rem 1.25rem 1.25rem; }
.step .num { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; margin-bottom: .7rem; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 800; }
.step h3 { margin-bottom: .25rem; }
.step p { color: var(--ink-2); font-size: .94rem; }
.band { background: var(--surface); border-block: 1px solid var(--line); }
.cta-final { text-align: center; padding: 2.5rem 1.25rem; border-radius: var(--r-lg); background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 70%, #000)); color: var(--primary-ink); }
.dark .cta-final { background: linear-gradient(135deg, var(--primary-soft), color-mix(in srgb, var(--primary-soft) 70%, var(--accent-soft))); color: var(--ink); }
.cta-final h2 { font-size: clamp(1.4rem, 4.5vw, 2rem); font-weight: 800; }
.cta-final p { margin: .5rem auto 1.4rem; max-width: 30rem; opacity: .92; }
.cta-final .btn-accent { box-shadow: var(--shadow-2); }
.site-footer { padding-block: 2rem 2.5rem; font-size: .88rem; color: var(--ink-2); }
.site-footer .row { justify-content: space-between; flex-wrap: wrap; }

/* ---------- 16. Error pages (shared by 404/500 which inline the essentials) ---------- */
.error-page { min-height: 70vh; display: grid; place-items: center; text-align: center; }
.error-code { font-size: 4.5rem; font-weight: 800; line-height: 1; color: var(--primary); }

@media print {
  .appbar, .tabbar, .toasts, .skip-link { display: none !important; }
  body { background: #fff; }
}


/* ==========================================================================
   Round 2 — hamburger drawer, command palette, richer hover/motion, new pages
   ========================================================================== */

/* ---------- Hamburger button ---------- */
.burger { margin-inline-end: -.25rem; }
.burger-lines { position: relative; width: 1.35rem; height: 1rem; display: block; }
.burger-lines i {
  position: absolute; inset-inline: 0; height: 2px; border-radius: 2px; background: currentColor;
  transition: transform var(--t-slow) var(--ease), opacity var(--t-fast) var(--ease), width var(--t-base) var(--ease);
}
.burger-lines i:nth-child(1) { top: 0; }
.burger-lines i:nth-child(2) { top: 50%; margin-top: -1px; width: 70%; inset-inline-start: auto; }
.burger-lines i:nth-child(3) { bottom: 0; }
.burger:hover .burger-lines i:nth-child(2) { width: 100%; }
.burger.is-open .burger-lines i:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger.is-open .burger-lines i:nth-child(2) { opacity: 0; transform: scaleX(0); }
.burger.is-open .burger-lines i:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Drawer ---------- */
.no-scroll { overflow: hidden; }
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 60; background: rgb(8 20 23 / .45);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  opacity: 0; transition: opacity var(--t-base) var(--ease);
}
.drawer-backdrop.is-open { opacity: 1; }
.drawer {
  position: fixed; top: 0; bottom: 0; inset-inline-start: 0; z-index: 65;
  width: min(21.5rem, 88vw); display: flex; flex-direction: column;
  background: var(--surface); border-inline-end: 1px solid var(--line);
  box-shadow: var(--shadow-2); overflow-y: auto; overscroll-behavior: contain;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transform: translateX(105%); transition: transform var(--t-slow) var(--ease);
}
.drawer.is-open { transform: none; }
.drawer-head {
  display: flex; align-items: center; gap: .8rem; padding: 1rem 1rem .9rem;
  background: linear-gradient(135deg, var(--primary-soft), color-mix(in srgb, var(--primary-soft) 50%, var(--accent-soft)));
  border-bottom: 1px solid var(--line);
}
.avatar {
  display: grid; place-items: center; width: 2.8rem; height: 2.8rem; flex: none; border-radius: 50%;
  background: var(--primary); color: var(--primary-ink); font-weight: 800; font-size: 1.15rem;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent);
}
.drawer-nav { padding: .5rem .6rem; flex: 1; }
.drawer-group { margin: .9rem .6rem .3rem; font-size: .74rem; font-weight: 700; letter-spacing: .02em; color: var(--ink-3); }
.drawer-item {
  position: relative; display: flex; align-items: center; gap: .85rem; width: 100%;
  padding: .6rem .7rem; border: 0; border-radius: var(--r-sm); background: none; text-align: start;
  color: var(--ink); text-decoration: none; cursor: pointer; overflow: hidden;
  transition: background-color var(--t-fast) var(--ease), transform var(--t-base) var(--ease);
}
.drawer-item .i { color: var(--ink-2); transition: transform var(--t-base) var(--ease), color var(--t-fast) var(--ease); }
.drawer-item b { display: block; font-weight: 600; font-size: .95rem; line-height: 1.5; }
.drawer-item small { display: block; font-size: .76rem; color: var(--ink-2); line-height: 1.5; }
.drawer-item:hover { background: var(--surface-2); color: var(--ink); transform: translateX(-3px); }
.drawer-item:hover .i { color: var(--primary); transform: scale(1.18) rotate(-6deg); }
.drawer-item:active { transform: scale(.98); }
.drawer-item[aria-current="page"] { background: var(--primary-soft); }
.drawer-item[aria-current="page"] b, .drawer-item[aria-current="page"] .i { color: var(--primary-text); }
.drawer-item[aria-current="page"]::before { content: ""; position: absolute; inset-block: .55rem; inset-inline-start: 0; width: 3px; border-radius: 3px; background: var(--primary); }
.drawer-item.is-danger, .drawer-item.is-danger .i { color: var(--danger); }
.drawer-item.is-danger:hover { background: var(--danger-soft); }
.drawer-item.is-danger:hover .i { color: var(--danger); }
.drawer.is-open .drawer-nav .drawer-item { animation: drawer-in 480ms var(--ease) both; animation-delay: calc(80ms + var(--i, 0) * 35ms); }
@keyframes drawer-in { from { opacity: 0; transform: translateX(26px); } }
.drawer-foot { padding: .5rem .6rem 1rem; border-top: 1px solid var(--line); display: grid; gap: .1rem; }
.drawer-foot form { display: contents; }
.drawer-foot .drawer-item .i-moon, .drawer-foot .drawer-item .i-sun { margin: 0; }
.drawer-foot .drawer-item .i-moon { display: block; } .drawer-foot .drawer-item .i-sun { display: none; }
.dark .drawer-foot .drawer-item .i-moon { display: none; } .dark .drawer-foot .drawer-item .i-sun { display: block; }
.switch { margin-inline-start: auto; position: relative; width: 2.4rem; height: 1.4rem; border-radius: 999px; background: var(--line-strong); transition: background-color var(--t-base) var(--ease); flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: calc(1.4rem - 6px); height: calc(1.4rem - 6px); border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform var(--t-base) var(--ease); }
[data-theme-toggle][aria-pressed="true"] .switch { background: var(--primary); }
[data-theme-toggle][aria-pressed="true"] .switch::after { transform: translateX(-1rem); }

/* ---------- Command palette ---------- */
.palette { position: fixed; inset: 0; z-index: 80; display: grid; place-items: start center; padding: 12vh 1rem 1rem; }
.palette-backdrop { position: absolute; inset: 0; background: rgb(8 20 23 / .5); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); opacity: 0; transition: opacity var(--t-base) var(--ease); }
.palette.is-open .palette-backdrop { opacity: 1; }
.palette-box {
  position: relative; width: min(34rem, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-2); overflow: hidden; opacity: 0; transform: translateY(-10px) scale(.97);
  transition: opacity var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}
.palette.is-open .palette-box { opacity: 1; transform: none; }
.palette-input { width: 100%; padding: 1rem 1.1rem; border: 0; border-bottom: 1px solid var(--line); background: transparent; font-size: 1.05rem; color: var(--ink); }
.palette-input:focus-visible { outline: none; box-shadow: inset 0 -2px 0 var(--primary); border-radius: 0; }
.palette-list { max-height: 55vh; overflow-y: auto; padding: .4rem; }
.palette-list li { display: flex; align-items: center; gap: .8rem; padding: .6rem .75rem; border-radius: var(--r-sm); cursor: pointer; }
.palette-list li .i { color: var(--ink-2); }
.palette-list li b { display: block; font-weight: 600; font-size: .95rem; }
.palette-list li small { display: block; color: var(--ink-2); font-size: .76rem; }
.palette-list li.is-active { background: var(--primary-soft); }
.palette-list li.is-active .i, .palette-list li.is-active b { color: var(--primary-text); }
.palette-none { padding: 1.2rem; text-align: center; color: var(--ink-2); cursor: default; }
.palette-foot { display: flex; gap: 1rem; justify-content: center; padding: .55rem; border-top: 1px solid var(--line); font-size: .74rem; color: var(--ink-3); background: var(--surface-2); }

/* ---------- Richer hover + motion ---------- */
.appbar { transition: box-shadow var(--t-base) var(--ease); }
.nav a { position: relative; }
.nav a::after { content: ""; position: absolute; inset-inline: 22%; bottom: 3px; height: 2px; border-radius: 2px; background: var(--primary); transform: scaleX(0); transition: transform var(--t-base) var(--ease); }
.nav a:hover::after { transform: scaleX(1); }
.nav a[aria-current="page"]::after { transform: scaleX(1); }
.brand .i { transition: transform var(--t-slow) var(--ease); }
.brand:hover .i { transform: rotate(-12deg) scale(1.08); }

/* primary/accent buttons: a soft light sweep on hover */
.btn-primary, .btn-accent { position: relative; overflow: hidden; isolation: isolate; }
.btn-primary::after, .btn-accent::after {
  content: ""; position: absolute; inset: 0; z-index: -1; transform: translateX(110%);
  background: linear-gradient(100deg, transparent 20%, rgb(255 255 255 / .28) 50%, transparent 80%);
  transition: transform 650ms var(--ease);
}
.btn-primary:hover::after, .btn-accent:hover::after { transform: translateX(-110%); }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.97); }
.btn .i { transition: transform var(--t-base) var(--ease); }
.btn:hover .i { transform: scale(1.12); }
.icon-btn:hover .i { transform: scale(1.12); }
.icon-btn .i { transition: transform var(--t-base) var(--ease); }

/* cards lift; "spot" cards also follow the pointer with a soft glow */
.card { transition: transform var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease), border-color var(--t-base) var(--ease); }
.item-card:hover, .stat:hover, .feature:hover, .step:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.spot { position: relative; --mx: 50%; --my: 50%; }
.spot::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0;
  background: radial-gradient(18rem circle at var(--mx) var(--my), color-mix(in srgb, var(--primary) 16%, transparent), transparent 70%);
  transition: opacity var(--t-base) var(--ease);
}
.spot:hover::before { opacity: 1; }

/* tasks: lift on hover; secondary actions fade in on pointer devices, always there on touch */
.task:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.task-actions .icon-btn { transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.task-actions .icon-btn:hover { transform: translateY(-2px); }
.task-actions .act-focus:hover { color: var(--primary-text); background: var(--primary-soft); }
@media (hover: hover) and (pointer: fine) {
  .task .task-actions { opacity: .35; transition: opacity var(--t-base) var(--ease); }
  .task:hover .task-actions, .task:focus-within .task-actions { opacity: 1; }
}
.check:hover::before { transform: scale(1.12); }
.check:active::before { transform: scale(.88); }
.check::after { /* ripple on completion */
  content: ""; position: absolute; width: 1.65rem; height: 1.65rem; border-radius: 50%; border: 2px solid var(--ok); opacity: 0; pointer-events: none;
}
.task.is-new[data-status="done"] .check::after { animation: ripple 650ms var(--ease) both; }
@keyframes ripple { from { opacity: .8; transform: scale(1); } to { opacity: 0; transform: scale(2.4); } }

/* lists enter with a gentle stagger on page load */
.task-list > .task, .item-card, .stat-grid > .card { animation: rise 520ms var(--ease) both; }
.task-list > .task:nth-child(1), .item-card:nth-child(1) { animation-delay: 40ms; }
.task-list > .task:nth-child(2), .item-card:nth-child(2) { animation-delay: 90ms; }
.task-list > .task:nth-child(3), .item-card:nth-child(3) { animation-delay: 140ms; }
.task-list > .task:nth-child(4), .item-card:nth-child(4) { animation-delay: 190ms; }
.task-list > .task:nth-child(n+5), .item-card:nth-child(n+5) { animation-delay: 230ms; }
.task.is-new { animation: rise var(--t-slow) var(--ease) both; animation-delay: 0ms; }

/* ring: a calm pulse when everything is done */
.ring.is-complete { animation: ring-pulse 2.4s var(--ease) 1; }
@keyframes ring-pulse { 0%, 100% { filter: none; } 40% { filter: drop-shadow(0 0 14px color-mix(in srgb, var(--ok) 55%, transparent)); } }

/* calendar days */
.cal-day:hover { transform: translateY(-2px) scale(1.04); z-index: 1; box-shadow: var(--shadow-1); }
.cal-day:active { transform: scale(.94); }
.cal > .cal-day { animation: rise 420ms var(--ease) both; }
.cal > .cal-day:nth-child(7n+8) { animation-delay: 20ms; } .cal > .cal-day:nth-child(7n+9) { animation-delay: 40ms; } .cal > .cal-day:nth-child(7n+10) { animation-delay: 60ms; }
.cal > .cal-day:nth-child(7n+11) { animation-delay: 80ms; } .cal > .cal-day:nth-child(7n+12) { animation-delay: 100ms; } .cal > .cal-day:nth-child(7n+13) { animation-delay: 120ms; } .cal > .cal-day:nth-child(7n+14) { animation-delay: 140ms; }

/* bars on hover */
.bar-col:hover .bar-fill { filter: brightness(1.12) saturate(1.1); }
.bar-col:hover .bar-label { color: var(--ink); }

/* smooth cross-page fades where the browser supports it */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 220ms; }

/* ---------- Activity heatmap ---------- */
.heat-scroll { overflow-x: auto; padding-block: .75rem .25rem; }
.heat { display: grid; grid-template-columns: repeat(14, minmax(1rem, 1fr)); gap: 4px; max-width: 36rem; margin-inline: auto; direction: rtl; }
.heat-col { display: grid; grid-template-rows: auto repeat(7, auto); gap: 4px; }
.heat-month { height: 1.1rem; font-size: .68rem; color: var(--ink-2); white-space: nowrap; overflow: visible; }
.heat-cell { position: relative; display: block; aspect-ratio: 1; width: 100%; border-radius: 5px; background: var(--surface-2); }
.heat-cell.lv1 { background: color-mix(in srgb, var(--primary) 28%, var(--surface-2)); }
.heat-cell.lv2 { background: color-mix(in srgb, var(--primary) 52%, var(--surface-2)); }
.heat-cell.lv3 { background: color-mix(in srgb, var(--primary) 76%, var(--surface-2)); }
.heat-cell.lv4 { background: var(--primary); }
.heat-cell.is-future { background: transparent; border: 1px dashed var(--line); }
.heat .heat-cell:not(.is-future) { animation: pop-in 420ms var(--ease) both; animation-delay: calc(var(--c, 0) * 28ms); }
.heat-col { --d: 0ms; }
@keyframes pop-in { from { opacity: 0; transform: scale(.4); } }
.heat .heat-cell:not(.is-future):hover { transform: scale(1.35); z-index: 3; box-shadow: var(--shadow-1); transition: transform var(--t-fast) var(--ease); }
.heat .heat-cell[data-tip]:hover::after, .heat .heat-cell[data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); inset-inline-start: 50%; transform: translateX(50%);
  padding: .3rem .6rem; border-radius: 8px; background: var(--ink); color: var(--bg); font-size: .75rem; white-space: nowrap; z-index: 5; pointer-events: none;
}
.heat-legend { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: .6rem; font-size: .72rem; color: var(--ink-2); }
.heat-legend .heat-cell { width: .85rem; border-radius: 3px; }
.heat-legend span:first-child { margin-inline-end: .3rem; } .heat-legend span:last-child { margin-inline-start: .3rem; }

/* ---------- Focus page ---------- */
.focus { text-align: center; padding-block: 1.4rem; }
.focus-modes { margin-bottom: 1.2rem; max-width: 100%; }
.focus-modes button {
  border: 0; background: none; padding: .35rem .9rem; border-radius: 8px; font-size: .88rem; font-weight: 500; color: var(--ink-2);
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.focus-modes button:hover { color: var(--ink); }
.focus-modes button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: var(--shadow-1); }
.focus-ring { position: relative; width: min(17rem, 70vw); aspect-ratio: 1; margin: 0 auto; }
.focus-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.focus-ring circle { fill: none; stroke-width: 6; }
.focus-ring .track { stroke: var(--surface-2); }
.focus-ring .bar { stroke: var(--primary); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--p, 0)); transition: stroke-dashoffset 400ms linear, stroke var(--t-base) var(--ease); }
.focus[data-mode="short"] .focus-ring .bar, .focus[data-mode="long"] .focus-ring .bar { stroke: var(--accent); }
.focus-readout { position: absolute; inset: 0; display: grid; place-content: center; gap: .1rem; }
.focus-time { font-size: clamp(2.6rem, 14vw, 3.6rem); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.focus-state { font-size: .92rem; color: var(--ink-2); }
.focus.is-running .focus-ring { animation: breathe 4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.025); } }
.focus.is-running .focus-ring::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--primary); opacity: 0; animation: focus-halo 2.4s var(--ease) infinite; }
@keyframes focus-halo { from { opacity: .5; transform: scale(.96); } to { opacity: 0; transform: scale(1.12); } }
.focus-adjust { display: flex; align-items: center; justify-content: center; gap: .5rem; margin-top: .6rem; }
.focus-controls { display: flex; justify-content: center; gap: .6rem; margin-top: 1rem; }
.focus-controls .btn-primary { min-width: 9rem; }
.focus-dots { display: flex; flex-wrap: wrap; gap: .35rem; }
.focus-dots i { width: .9rem; height: .9rem; border-radius: 50%; background: var(--primary); animation: pop-in 420ms var(--ease) both; animation-delay: calc(var(--i, 0) * 50ms); }

/* ---------- Landing: reveal, float, drifting glow ---------- */
.js [data-reveal] { opacity: 0; transform: translateY(18px); transition: opacity 700ms var(--ease), transform 700ms var(--ease); transition-delay: var(--delay, 0s); }
.js [data-reveal].is-in { opacity: 1; transform: none; }
.mock-phone { animation: float 7s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-8px) rotate(.4deg); } }
.hero { position: relative; }
.hero::before {
  content: ""; position: absolute; z-index: -1; inset-inline-end: 4%; top: 6%; width: 22rem; height: 22rem; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--primary) 20%, transparent), transparent 68%);
  filter: blur(8px); animation: drift 14s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate(-3rem, 2rem) scale(1.15); } }
.hero h1 em { background-size: 0 100%; background-repeat: no-repeat; background-position: right bottom; background-image: linear-gradient(color-mix(in srgb, var(--accent) 55%, transparent), color-mix(in srgb, var(--accent) 55%, transparent)); background-color: transparent; animation: underline-in 900ms var(--ease) 500ms forwards; }
@keyframes underline-in { to { background-size: 100% 38%; } }

@media (prefers-reduced-motion: reduce) {
  .js [data-reveal] { opacity: 1; transform: none; }
  .mock-phone, .hero::before, .focus.is-running .focus-ring, .focus.is-running .focus-ring::after { animation: none !important; }
}

/* keep theme + sign-out reachable however short the screen is */
.drawer-foot { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); }

/* ==========================================================================
   v3 — dashboard layout, week board, journal archive, achievements, polish
   ========================================================================== */

/* Ambient background: two soft colour washes behind everything */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60rem 38rem at 92% -12%, color-mix(in srgb, var(--primary) 15%, transparent), transparent 62%),
    radial-gradient(48rem 34rem at -6% 112%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 62%);
}

/* Cards get a hairline top highlight so they read as slightly raised glass */
.card { box-shadow: var(--shadow-1), inset 0 1px 0 rgb(255 255 255 / .55); }
.dark .card { box-shadow: var(--shadow-1), inset 0 1px 0 rgb(255 255 255 / .05); }

/* Buttons: sheen on hover, ripple on press, arrow nudge */
.btn { position: relative; overflow: hidden; }
.btn-primary::after, .btn-accent::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg, transparent 30%, rgb(255 255 255 / .28) 50%, transparent 70%);
  transform: translateX(120%); transition: transform 650ms var(--ease);
}
.btn-primary:hover::after, .btn-accent:hover::after { transform: translateX(-120%); }
.btn .i { transition: transform var(--t-base) var(--ease); }
.btn:hover .i { transform: scale(1.12); }
.ripple { position: absolute; border-radius: 50%; background: currentColor; opacity: .2; transform: scale(0); animation: ripple 620ms ease-out forwards; pointer-events: none; }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }
.icon-btn:hover .i { animation: wiggle 520ms var(--ease); }
@keyframes wiggle { 20% { transform: rotate(-12deg) scale(1.1); } 50% { transform: rotate(9deg) scale(1.1); } 80% { transform: rotate(-4deg); } }

/* Header links: underline grows in */
.nav a { position: relative; }
.nav a::after {
  content: ""; position: absolute; inset-inline: .8rem; bottom: .15rem; height: 2px; border-radius: 2px;
  background: var(--primary); transform: scaleX(0); transition: transform 260ms var(--ease);
}
.nav a:hover::after, .nav a[aria-current="page"]::after { transform: scaleX(1); }

/* Request progress bar */
.topbar { position: fixed; top: 0; inset-inline: 0; height: 3px; z-index: 200; opacity: 0; pointer-events: none;
  background: linear-gradient(90deg, var(--primary), var(--accent)); transform-origin: right; transform: scaleX(0); transition: opacity 200ms; }
.topbar.is-on { opacity: 1; animation: topbar 1.4s var(--ease) infinite; }
@keyframes topbar { 0% { transform: scaleX(0); } 70% { transform: scaleX(.85); } 100% { transform: scaleX(.96); } }

/* Hover-capable devices: tasks lift, actions fade in */
@media (hover: hover) {
  .task:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
  .task-actions { opacity: .55; transition: opacity var(--t-base) var(--ease); }
  .task:hover .task-actions, .task:focus-within .task-actions { opacity: 1; }
}
.eyebrow { display: flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 700; color: var(--accent-text); }

/* ---- Today dashboard ---- */
.container-dash { max-width: 72rem; }
.dash { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }
.dash-side { display: contents; }
.dash-main { min-width: 0; }
@media (min-width: 1024px) {
  .dash { display: grid; grid-template-columns: minmax(0, 1fr) 21.5rem; gap: 1.5rem; align-items: start; }
  .dash-side { display: flex; flex-direction: column; gap: 1rem; order: 3; position: sticky; top: 4.75rem; }
}
.nextup { background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.nextup-title { font-size: 1.12rem; line-height: 1.5; overflow-wrap: anywhere; }
.steps-list li + li { margin-top: .15rem; }
.steps-list a { display: flex; align-items: center; gap: .7rem; padding: .5rem .45rem; border-radius: var(--r-sm); color: inherit; text-decoration: none; transition: background-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.steps-list a:hover { background: var(--surface-2); transform: translateX(-3px); }
.steps-list b { display: block; font-size: .92rem; }
.steps-list small { display: block; font-size: .78rem; color: var(--ink-2); }
.step-mark { flex: none; display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--primary-soft); color: var(--primary-text); }
.step-mark .i { width: 1rem; height: 1rem; }
.steps-list .is-done .step-mark { background: var(--ok); color: #fff; }
.dark .steps-list .is-done .step-mark { color: #06231a; }
.steps-list .is-done b { color: var(--ink-3); text-decoration: line-through; }

/* ---- Week board ---- */
.week-page { padding-block: 1.25rem 2rem; }
.week-hint { display: flex; align-items: center; gap: .4rem; }
.week { display: grid; grid-auto-flow: column; grid-auto-columns: 86%; gap: .75rem; overflow-x: auto; padding: .15rem .15rem .9rem; scroll-snap-type: x proximity; overscroll-behavior-x: contain; }
@media (min-width: 700px) { .week { grid-auto-columns: minmax(16.5rem, 1fr); } }
.wday {
  scroll-snap-align: center; display: flex; flex-direction: column; gap: .6rem; min-width: 0; padding: .7rem;
  background: color-mix(in srgb, var(--surface) 70%, transparent); border: 1px solid var(--line); border-radius: var(--r-lg);
  animation: rise var(--t-slow) var(--ease) both; animation-delay: calc(var(--i, 0) * 55ms);
  transition: background-color var(--t-base) var(--ease), border-color var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease);
}
.wday.is-today { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); background: var(--surface); }
.wday.is-friday h2 { color: var(--danger); }
.wday.drop-hover { background: var(--primary-soft); border-color: var(--primary); border-style: dashed; }
.wday-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.wday-head h2 { font-size: 1rem; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.wday-date { font-size: .82rem; color: var(--ink-2); text-decoration: none; }
.wday-date:hover { color: var(--primary-text); text-decoration: underline; }
.wlist { min-height: 4.5rem; align-content: start; }
.wempty { display: none; }
.wlist:not(:has(.task)) .wempty { display: block; padding: 1rem .5rem; border: 1.5px dashed var(--line-strong); border-radius: var(--r-sm); text-align: center; font-size: .8rem; color: var(--ink-3); }
.week .task { padding: .6rem .65rem; gap: .15rem .55rem; border-radius: var(--r-sm); }
.week .task-title { font-size: .9rem; line-height: 1.55; }
.week .task-actions .icon-btn, .week .task-actions .locked { width: 2.1rem; height: 2.1rem; }
.week .task-actions { margin-inline-start: -.35rem; }
.week .task[draggable="true"] { cursor: grab; }
.task.is-dragging { opacity: .4; transform: rotate(-2deg) scale(.97); }
.wadd .field { min-height: 2.4rem; font-size: .88rem; border-style: dashed; background: transparent; }
.wadd .field:focus-visible { border-style: solid; background: var(--surface); }

/* ---- Journal archive ---- */
.strip { display: flex; align-items: flex-end; gap: 3px; height: 5.5rem; margin-top: 1rem; }
.strip-col { flex: 1; height: 100%; display: flex; align-items: flex-end; min-width: 0; }
.strip-bar { display: block; width: 100%; height: calc(var(--h) * 20%); min-height: 4px; border-radius: 4px; transform-origin: bottom;
  background: linear-gradient(to top, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--primary)));
  animation: grow-y 650ms var(--ease) both; animation-delay: calc(var(--n) * 18ms); }
.strip-bar.is-empty { height: 4px; background: var(--surface-2); }
.note-card { transition: transform var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease); }
.note-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.note-text { white-space: normal; overflow-wrap: anywhere; color: var(--ink); }

/* ---- Stats: sparkline + achievements ---- */
.spark { width: 100%; height: 1.7rem; margin-top: .4rem; overflow: visible; }
.spark polyline { fill: none; stroke: var(--primary); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.3s var(--ease) .25s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.badges { display: grid; gap: .7rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .badges { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .badges { grid-template-columns: repeat(3, 1fr); } }
.badge { display: flex; gap: .8rem; padding: .85rem; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); transition: transform var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease); }
.badge:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.badge b { display: block; }
.badge small { display: block; font-size: .8rem; color: var(--ink-2); }
.badge-icon { flex: none; display: grid; place-items: center; width: 2.7rem; height: 2.7rem; border-radius: 13px; background: var(--surface-2); color: var(--ink-3); }
.badge-icon .i { width: 1.35rem; height: 1.35rem; }
.badge:not(.is-earned) .badge-icon { filter: grayscale(.4); }
.badge.is-earned { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: linear-gradient(135deg, var(--accent-soft), var(--surface) 75%); }
.badge.is-earned .badge-icon { background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #fff)); color: var(--accent-ink); box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent); animation: pop 600ms var(--ease) both; }

/* ==========================================================================
   v4 — goal & habit pages, interactive cards, keyboard help, richer motion
   ========================================================================== */

/* Cursor-aware cards: gentle 3D tilt and a soft spotlight that follows the pointer */
.tilt, .glow { position: relative; isolation: isolate; }
.tilt { transform: perspective(760px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform 280ms var(--ease), box-shadow var(--t-base) var(--ease); will-change: transform; }
.tilt:hover { transition: transform 80ms linear, box-shadow var(--t-base) var(--ease); box-shadow: var(--shadow-2); }
.tilt::before, .glow::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity 300ms var(--ease);
  background: radial-gradient(16rem circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--primary) 17%, transparent), transparent 62%);
}
.tilt:hover::before, .glow:hover::before { opacity: 1; }

/* Links that look like titles */
.item-link { color: inherit; text-decoration: none; background: linear-gradient(var(--primary), var(--primary)) right bottom / 0 2px no-repeat; transition: background-size 320ms var(--ease), color var(--t-fast) var(--ease); padding-bottom: 1px; }
.item-link:hover { color: var(--primary-text); background-size: 100% 2px; }
a.chip { transition: transform var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease); }
a.chip:hover { transform: translateY(-1px); }

/* Goal / habit cards in lists */
.item-card { transition: transform var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease), border-color var(--t-base) var(--ease); }
@media (hover: hover) { .item-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: var(--line-strong); } }
.progress > span { position: relative; overflow: hidden; }
.progress > span::after { content: ""; position: absolute; inset: 0; transform: translateX(120%); background: linear-gradient(110deg, transparent 30%, rgb(255 255 255 / .38) 50%, transparent 70%); }
@media (hover: hover) { .item-card:hover .progress > span::after, .badge:hover .progress > span::after { animation: shimmer 1.1s var(--ease); } }
@keyframes shimmer { to { transform: translateX(-120%); } }

/* Detail pages */
.crumbs { margin-bottom: .75rem; font-size: .9rem; }
.crumbs a { display: inline-flex; align-items: center; gap: .2rem; color: var(--ink-2); text-decoration: none; transition: color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.crumbs a:hover { color: var(--primary-text); transform: translateX(3px); }
.goal-hero {
  position: relative; display: flex; gap: 1.25rem; align-items: center; justify-content: space-between; padding: 1.25rem;
  border-radius: var(--r-lg); border: 1px solid var(--line); box-shadow: var(--shadow-2); overflow: hidden;
  background: linear-gradient(135deg, var(--surface), color-mix(in srgb, var(--primary-soft) 60%, var(--surface)));
  animation: rise var(--t-slow) var(--ease) both;
}
.goal-hero-main { min-width: 0; display: flex; flex-direction: column; gap: .6rem; }
.goal-title { font-size: 1.6rem; line-height: 1.4; overflow-wrap: anywhere; }
.goal-desc { font-size: .95rem; }
.goal-deadline { font-weight: 600; font-size: .95rem; }
.goal-deadline.is-late { color: var(--danger); }
.goal-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .35rem; }
.goal-actions form { display: inline; }
.goal-ring .ring { width: 8rem; height: 8rem; }
.goal-ring .ring-label strong { font-size: 1.5rem; }
@media (max-width: 639.98px) { .goal-hero { flex-direction: column-reverse; align-items: stretch; } .goal-ring { align-self: center; } .goal-title { font-size: 1.35rem; } }
.goal-day { margin-top: 1rem; }
.goal-day-title { display: flex; align-items: center; gap: .5rem; font-size: .95rem; margin-bottom: .5rem; color: var(--ink-2); }
.done-details summary { display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; }
.done-details summary::-webkit-details-marker { display: none; }
.done-details[open] summary { margin-bottom: .25rem; }
.done-list li { display: flex; align-items: center; gap: .5rem; padding: .4rem 0; border-top: 1px solid var(--line); font-size: .92rem; }

/* Streak flame */
.flame-wrap { display: grid; place-items: center; }
.flame { width: 6.5rem; height: 6.5rem; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-3); }
.flame .i { width: 3.2rem; height: 3.2rem; }
.flame.is-lit {
  color: var(--accent-ink); animation: flicker 2.4s ease-in-out infinite;
  background: radial-gradient(circle at 50% 72%, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--danger)));
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 22%, transparent), 0 12px 32px -8px color-mix(in srgb, var(--accent) 75%, transparent);
}
@keyframes flicker { 0%, 100% { transform: scale(1) rotate(0); } 30% { transform: scale(1.05) rotate(-2deg); } 62% { transform: scale(.98) rotate(2deg); } }
.streak .i { transform-origin: 50% 90%; animation: flicker-sm 2.2s ease-in-out infinite; }
@keyframes flicker-sm { 50% { transform: scale(1.18) rotate(-7deg); } }

/* Habit history states (reuse the heatmap grid) */
.heat-12 { grid-template-columns: repeat(12, minmax(1rem, 1fr)); }
.heat-12 .heat-col { grid-template-rows: repeat(7, auto); }
.heat-cell.hs-done { background: var(--ok); }
.heat-cell.hs-missed { background: color-mix(in srgb, var(--danger) 48%, var(--surface-2)); }
.heat-cell.hs-pending { background: var(--accent); }
.heat-cell.hs-none { background: var(--surface-2); }
.heat-cell.hs-future { background: transparent; border: 1px dashed var(--line); }
.heat-legend { gap: .4rem; }
.wk-list li { display: flex; align-items: center; gap: .7rem; }
.wk-list li + li { margin-top: .6rem; }
.wk-name { width: 4.8rem; flex: none; font-size: .9rem; }
.wk-val { width: 3.2rem; flex: none; text-align: left; color: var(--ink-2); }

/* Focus + insights */
.stat-grid.focus-stats { grid-template-columns: repeat(2, 1fr); }
.stat-mini { display: flex; flex-direction: column; padding: .7rem .9rem; background: var(--surface-2); border-radius: var(--r-sm); transition: transform var(--t-base) var(--ease); }
.stat-mini:hover { transform: translateY(-2px); }
.stat-mini b { font-size: 1.1rem; }
.insights { display: grid; gap: .6rem; }
.insight { display: flex; gap: .8rem; padding: .85rem; border-radius: var(--r-sm); background: var(--surface-2); transition: transform var(--t-base) var(--ease), background-color var(--t-base) var(--ease); }
.insight:hover { transform: translateX(-4px); background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface-2)); }
.insight p { color: var(--ink-2); font-size: .92rem; margin-top: .15rem; }
.insight .badge-icon { background: var(--accent-soft); color: var(--accent-text); }

/* Animated edge on the "next up" card */
@property --angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.nextup { position: relative; }
.nextup::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1.5px; pointer-events: none;
  background: conic-gradient(from var(--angle), transparent 0 68%, var(--accent) 84%, var(--primary) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  animation: spin-angle 5s linear infinite;
}
@keyframes spin-angle { to { --angle: 360deg; } }

/* Keyboard help */
kbd { display: inline-grid; place-items: center; min-width: 1.6rem; padding: .05rem .4rem; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px; background: var(--surface); font: inherit; font-size: .78rem; direction: ltr; }
.help-pop { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 1rem; }
.help-backdrop { position: absolute; inset: 0; background: rgb(8 20 23 / .55); animation: help-fade 200ms var(--ease) both; }
.help-card { position: relative; width: min(28rem, 100%); max-height: 85vh; overflow: auto; padding: 1rem 1.1rem 1.1rem; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-2); animation: help-in 320ms var(--ease) both; }
.help-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-top: 1px solid var(--line); font-size: .95rem; }
.chord-hint { position: fixed; inset-inline: 0; bottom: calc(var(--tabbar-h) + 1rem); margin-inline: auto; width: max-content; z-index: 110; padding: .45rem .9rem; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: .9rem; box-shadow: var(--shadow-2); animation: help-in 220ms var(--ease) both; }
.chord-hint kbd { background: transparent; border-color: color-mix(in srgb, var(--bg) 40%, transparent); color: inherit; }
@keyframes help-fade { from { opacity: 0; } }
@keyframes help-in { from { opacity: 0; transform: translateY(12px) scale(.97); } }

@media (prefers-reduced-motion: reduce) {
  .tilt { transform: none !important; }
  .flame.is-lit, .streak .i, .nextup::after { animation: none !important; }
}
.tilt.reveal, .tilt[data-reveal] { animation-fill-mode: backwards; }

.heat-legend-states { justify-content: center; flex-wrap: wrap; gap: .5rem 1rem; }
.heat-legend-states .lg { display: inline-flex; align-items: center; gap: .35rem; margin: 0; }
.heat-legend-states .heat-cell { width: .85rem; flex: none; }
.heat-12 { max-width: 30rem; }
/* sunset */
[data-palette="sunset"] {
  --bg: #f7f3f0;
  --surface: #fdfcfc;
  --surface-2: #eee7e2;
  --line: #e0d4cc;
  --line-strong: #ccbaae;
  --control: #a08b7e;
  --ink: #201813;
  --ink-2: #746358;
  --ink-3: #72645a;
  --primary: #a23a1a;
  --primary-hover: #8c3217;
  --primary-ink: #ffffff;
  --primary-soft: #f8ded6;
  --primary-text: #913418;
  --accent: #f2b02c;
  --accent-hover: #f0a919;
  --accent-ink: #251c09;
  --accent-soft: #feedcb;
  --accent-text: #865c09;
}
.dark[data-palette="sunset"] {
  --bg: #18110b;
  --surface: #261a13;
  --surface-2: #37261b;
  --line: #493527;
  --line-strong: #684d3b;
  --control: #8a7160;
  --ink: #f0edea;
  --ink-2: #c2b6ae;
  --ink-3: #aa9c92;
  --primary: #f09275;
  --primary-hover: #f3a891;
  --primary-ink: #22110b;
  --primary-soft: #4d2519;
  --primary-text: #f6b6a2;
  --accent: #f7bc45;
  --accent-hover: #f8c662;
  --accent-ink: #251c09;
  --accent-soft: #4e3a13;
  --accent-text: #fad180;
}

/* forest */
[data-palette="forest"] {
  --bg: #f2f5f3;
  --surface: #fcfdfc;
  --surface-2: #e4ece7;
  --line: #d0dcd4;
  --line-strong: #b4c5ba;
  --control: #759981;
  --ink: #132017;
  --ink-2: #536e5c;
  --ink-3: #586f5f;
  --primary: #20794d;
  --primary-hover: #1b6540;
  --primary-ink: #ffffff;
  --primary-soft: #d6f7e7;
  --primary-text: #1c6942;
  --accent: #e6b237;
  --accent-hover: #e4ab25;
  --accent-ink: #251c09;
  --accent-soft: #fbedcd;
  --accent-text: #7f5e10;
}
.dark[data-palette="forest"] {
  --bg: #0e1610;
  --surface: #16221a;
  --surface-2: #203226;
  --line: #2d4334;
  --line-strong: #43604d;
  --control: #608a6e;
  --ink: #eaf0ec;
  --ink-2: #aec2b4;
  --ink-3: #92aa9a;
  --primary: #80e5b3;
  --primary-hover: #99eac2;
  --primary-ink: #0b2217;
  --primary-soft: #194d33;
  --primary-text: #a9efcc;
  --accent: #eebe4f;
  --accent-hover: #f0c86a;
  --accent-ink: #251c09;
  --accent-soft: #4e3c13;
  --accent-text: #f4d385;
}

/* ocean */
[data-palette="ocean"] {
  --bg: #f1f3f6;
  --surface: #fcfcfd;
  --surface-2: #e3e7ed;
  --line: #ced5de;
  --line-strong: #b1bbc8;
  --control: #7e8da0;
  --ink: #131920;
  --ink-2: #586474;
  --ink-3: #5a6472;
  --primary: #1f58ad;
  --primary-hover: #1b4d98;
  --primary-ink: #ffffff;
  --primary-soft: #d6e3f8;
  --primary-text: #1c4f9c;
  --accent: #40c8dd;
  --accent-hover: #2fc3da;
  --accent-ink: #092125;
  --accent-soft: #cff4f9;
  --accent-text: #156c79;
}
.dark[data-palette="ocean"] {
  --bg: #0c1117;
  --surface: #141b24;
  --surface-2: #1d2734;
  --line: #2a3647;
  --line-strong: #3e4f65;
  --control: #60728a;
  --ink: #eaedf0;
  --ink-2: #aeb6c2;
  --ink-3: #929daa;
  --primary: #77a7ee;
  --primary-hover: #92b8f2;
  --primary-ink: #0b1522;
  --primary-soft: #192e4d;
  --primary-text: #a3c4f5;
  --accent: #56d3e6;
  --accent-hover: #71daea;
  --accent-ink: #092125;
  --accent-soft: #13464e;
  --accent-text: #8ae2ef;
}

/* orchid */
[data-palette="orchid"] {
  --bg: #f4f1f6;
  --surface: #fdfcfd;
  --surface-2: #e9e3ed;
  --line: #d8cfde;
  --line-strong: #bfb2c7;
  --control: #927ea0;
  --ink: #1b1320;
  --ink-2: #695874;
  --ink-3: #685a72;
  --primary: #7339a2;
  --primary-hover: #66328f;
  --primary-ink: #ffffff;
  --primary-soft: #e8d9f5;
  --primary-text: #683493;
  --accent: #e43a89;
  --accent-hover: #e2287e;
  --accent-ink: #250916;
  --accent-soft: #fbcee3;
  --accent-text: #7e1144;
}
.dark[data-palette="orchid"] {
  --bg: #130d17;
  --surface: #1e1523;
  --surface-2: #2b1e33;
  --line: #3b2b46;
  --line-strong: #554064;
  --control: #7a608a;
  --ink: #eeeaf0;
  --ink-2: #baaec2;
  --ink-3: #a092aa;
  --primary: #b788dd;
  --primary-hover: #c5a0e4;
  --primary-ink: #180b22;
  --primary-soft: #351b4b;
  --primary-text: #cfaeea;
  --accent: #ec5199;
  --accent-hover: #ef6ca9;
  --accent-ink: #250916;
  --accent-soft: #4e132f;
  --accent-text: #f386b9;
}

/* saffron */
[data-palette="saffron"] {
  --bg: #f7f5f0;
  --surface: #fdfdfc;
  --surface-2: #efeae1;
  --line: #e1dacb;
  --line-strong: #cdc2ad;
  --control: #9b9078;
  --ink: #201c13;
  --ink-2: #6e6553;
  --ink-3: #6f6758;
  --primary: #9e5e0a;
  --primary-hover: #865009;
  --primary-ink: #ffffff;
  --primary-soft: #f8e9d6;
  --primary-text: #8b5309;
  --accent: #40cedd;
  --accent-hover: #2fc9da;
  --accent-ink: #092225;
  --accent-soft: #cff5f9;
  --accent-text: #156f79;
}
.dark[data-palette="saffron"] {
  --bg: #19140b;
  --surface: #261f13;
  --surface-2: #372d1b;
  --line: #493e27;
  --line-strong: #68593b;
  --control: #8a7c60;
  --ink: #f0eeea;
  --ink-2: #c2bbae;
  --ink-3: #aaa292;
  --primary: #f0bb75;
  --primary-hover: #f3c891;
  --primary-ink: #22180b;
  --primary-soft: #4d3619;
  --primary-text: #f7d2a1;
  --accent: #56d7e6;
  --accent-hover: #71deea;
  --accent-ink: #092225;
  --accent-soft: #13484e;
  --accent-text: #8ae5ef;
}

/* rose */
[data-palette="rose"] {
  --bg: #f6f1f3;
  --surface: #fdfcfc;
  --surface-2: #ede3e6;
  --line: #deced4;
  --line-strong: #c8b1b9;
  --control: #a07e89;
  --ink: #201317;
  --ink-2: #745861;
  --ink-3: #725a62;
  --primary: #ab2657;
  --primary-hover: #97214c;
  --primary-ink: #ffffff;
  --primary-soft: #f8d6e2;
  --primary-text: #9b224e;
  --accent: #efa22e;
  --accent-hover: #ee9a1b;
  --accent-ink: #251a09;
  --accent-soft: #fde9cb;
  --accent-text: #85540a;
}
.dark[data-palette="rose"] {
  --bg: #170c10;
  --surface: #241419;
  --surface-2: #341d25;
  --line: #472a33;
  --line-strong: #653e4b;
  --control: #8a606e;
  --ink: #f0eaec;
  --ink-2: #c2aeb4;
  --ink-3: #aa929a;
  --primary: #ea7ba4;
  --primary-hover: #ee96b6;
  --primary-ink: #220b14;
  --primary-soft: #4d192c;
  --primary-text: #f2a6c2;
  --accent: #f5b047;
  --accent-hover: #f7bc64;
  --accent-ink: #251a09;
  --accent-soft: #4e3613;
  --accent-text: #fac980;
}

/* graphite */
[data-palette="graphite"] {
  --bg: #f3f4f4;
  --surface: #fcfcfd;
  --surface-2: #e7e8e9;
  --line: #d4d6d8;
  --line-strong: #babdc0;
  --control: #7e8fa0;
  --ink: #131920;
  --ink-2: #586674;
  --ink-3: #5a6672;
  --primary: #323d48;
  --primary-hover: #283039;
  --primary-ink: #ffffff;
  --primary-soft: #e0e7ee;
  --primary-text: #2a333c;
  --accent: #bedd40;
  --accent-hover: #b8da2f;
  --accent-ink: #1f2509;
  --accent-soft: #f1f9cf;
  --accent-text: #627515;
}
.dark[data-palette="graphite"] {
  --bg: #0f1214;
  --surface: #191c1f;
  --surface-2: #24292e;
  --line: #32383e;
  --line-strong: #4b5258;
  --control: #60758a;
  --ink: #eaedf0;
  --ink-2: #aeb8c2;
  --ink-3: #929eaa;
  --primary: #9fb2c6;
  --primary-hover: #b2c2d2;
  --primary-ink: #0b1722;
  --primary-soft: #2a333c;
  --primary-text: #beccda;
  --accent: #c9e656;
  --accent-hover: #d2ea71;
  --accent-ink: #1f2509;
  --accent-soft: #424e13;
  --accent-text: #dbef8a;
}

/* ==========================================================================
   v5 — English / left-to-right, appearance panel, richer motion
   ========================================================================== */

/* ---- LTR counterparts of every direction-dependent rule above ---- */
html[dir="ltr"] .skip-link { right: auto; left: .5rem; }
html[dir="ltr"] select.field { background-position: calc(100% - 1.1rem) 52%, calc(100% - .8rem) 52%; }
html[dir="ltr"] .field[type="time"], html[dir="ltr"] .field[type="date"] { text-align: left; }
html[dir="ltr"] .progress > span, html[dir="ltr"] .topbar { transform-origin: left; }
html[dir="ltr"] .hero-today::after { mask-image: linear-gradient(to right, transparent 30%, #000 100%); -webkit-mask-image: linear-gradient(to right, transparent 30%, #000 100%); }
html[dir="ltr"] .drawer { transform: translateX(-105%); }
html[dir="ltr"] .drawer.is-open { transform: none; }
html[dir="ltr"] .drawer-item:hover { transform: translateX(3px); }
html[dir="ltr"] .drawer.is-open .drawer-nav .drawer-item { animation-name: drawer-in-ltr; }
@keyframes drawer-in-ltr { from { opacity: 0; transform: translateX(-26px); } }
html[dir="ltr"] [data-theme-toggle][aria-pressed="true"] .switch::after { transform: translateX(1rem); }
html[dir="ltr"] .btn-primary::after, html[dir="ltr"] .btn-accent::after { transform: translateX(-120%); }
html[dir="ltr"] .btn-primary:hover::after, html[dir="ltr"] .btn-accent:hover::after { transform: translateX(120%); }
html[dir="ltr"] .heat { direction: ltr; }
html[dir="ltr"] .heat .heat-cell[data-tip]:hover::after, html[dir="ltr"] .heat .heat-cell[data-tip]:focus-visible::after { transform: translateX(-50%); }
html[dir="ltr"] .hero h1 em { background-position: left bottom; }
html[dir="ltr"] .item-link { background-position: left bottom; }
html[dir="ltr"] .steps-list a:hover { transform: translateX(3px); }
html[dir="ltr"] .insight:hover { transform: translateX(4px); }
html[dir="ltr"] .crumbs a:hover { transform: translateX(-3px); }
html[dir="ltr"] .progress > span::after { transform: translateX(-120%); }
html[dir="ltr"] .item-card:hover .progress > span::after, html[dir="ltr"] .badge:hover .progress > span::after { animation-name: shimmer-ltr; }
@keyframes shimmer-ltr { to { transform: translateX(120%); } }
html[dir="ltr"] .mock::before { inset: 8% 12% -4% 2%; transform: rotate(3deg); }

/* ---- Palette-aware extras ---- */
.brand .i use { color: inherit; }
body::before { animation: aurora 38s ease-in-out infinite alternate; background-size: 140% 140%; }
@keyframes aurora { from { background-position: 0% 0%, 100% 100%; } to { background-position: 18% 12%, 82% 88%; } }

/* ---- Appearance panel (colour palette, light/dark/auto, language) ---- */
.ap-popover { position: fixed; z-index: 130; inset-block-start: 3.6rem; inset-inline-end: .75rem; width: min(22rem, calc(100vw - 1.5rem));
  max-height: calc(100vh - 5rem); overflow: auto; padding: 1rem; border-radius: var(--r-lg); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-2); transform-origin: top; animation: ap-in 260ms var(--ease) both; }
.ap-backdrop { position: fixed; inset: 0; z-index: 125; background: rgb(8 20 23 / .28); animation: help-fade 200ms var(--ease) both; }
@keyframes ap-in { from { opacity: 0; transform: translateY(-10px) scale(.97); } }
.ap-title { font-size: .82rem; font-weight: 700; color: var(--ink-2); margin: 0 0 .5rem; }
.ap-group + .ap-group { margin-top: 1rem; }
.seg-pills { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .25rem; padding: .25rem; border-radius: var(--r-sm); background: var(--surface-2); }
.seg-pills button, .seg-pills a {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 2.4rem; padding: .25rem .5rem;
  border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font-size: .88rem; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-base) var(--ease);
}
.seg-pills button:hover, .seg-pills a:hover { color: var(--ink); }
.seg-pills button:active, .seg-pills a:active { transform: scale(.96); }
.seg-pills [aria-pressed="true"], .seg-pills [aria-current="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.swatch {
  display: grid; justify-items: center; gap: .3rem; padding: .55rem .2rem .45rem; border: 2px solid transparent; border-radius: var(--r-sm);
  background: transparent; color: var(--ink-2); font-size: .72rem; cursor: pointer;
  transition: transform var(--t-base) var(--ease), background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.swatch:hover { transform: translateY(-3px); background: var(--surface-2); }
.swatch:active { transform: scale(.94); }
.sw-dots { position: relative; width: 2.3rem; height: 2.3rem; border-radius: 50%; overflow: hidden; box-shadow: 0 2px 8px -2px rgb(0 0 0 / .25), inset 0 0 0 1px rgb(255 255 255 / .35);
  background: linear-gradient(135deg, var(--primary) 0 52%, var(--accent) 52% 100%); transition: transform var(--t-base) var(--ease); }
.swatch:hover .sw-dots { transform: rotate(18deg) scale(1.08); }
.swatch[aria-checked="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); font-weight: 700; }
.swatch[aria-checked="true"] .sw-dots::after { content: ""; position: absolute; inset: 0; margin: auto; width: .7rem; height: .4rem; border: solid #fff; border-width: 0 0 2.5px 2.5px; transform: rotate(-45deg) translate(1px, -1px); filter: drop-shadow(0 0 2px rgb(0 0 0 / .45)); }
.sw-name { line-height: 1.3; text-align: center; }
.appearance-inline { padding: 0; }
.lang-flag { font-weight: 800; letter-spacing: .02em; }

/* Circular reveal when the theme or palette changes (View Transitions API, with an instant fallback) */
html.vt-theme::view-transition-old(root), html.vt-theme::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
html.vt-theme::view-transition-old(root) { z-index: 1; }
html.vt-theme::view-transition-new(root) { z-index: 2; }

/* Page-to-page crossfade in browsers that support cross-document view transitions */
@view-transition { navigation: auto; }
.appbar { view-transition-name: appbar; }
.tabbar { view-transition-name: tabbar; }
::view-transition-old(root) { animation: 160ms var(--ease) both vt-out; }
::view-transition-new(root) { animation: 260ms var(--ease) both vt-in; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { body::before { animation: none; } ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; } }

/* ---- Welcome tour ---- */
.tour { position: fixed; inset: 0; z-index: 150; }
.tour-spot { position: fixed; border-radius: 14px; box-shadow: 0 0 0 9999px rgb(8 20 23 / .62), 0 0 0 3px var(--accent); pointer-events: none; transition: top 320ms var(--ease), left 320ms var(--ease), width 320ms var(--ease), height 320ms var(--ease); }
.tour-card { position: fixed; padding: 1rem 1.1rem; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-2); border: 1px solid var(--line); transition: top 320ms var(--ease), left 320ms var(--ease); }
.tour-card.is-in { animation: help-in 320ms var(--ease) both; }
.tour-step { font-size: .78rem; color: var(--ink-2); font-weight: 600; }
.tour-title { font-size: 1.1rem; margin-top: .15rem; }
.tour-text { margin-top: .3rem; font-size: .93rem; color: var(--ink-2); }
.tour-dots { display: flex; gap: .3rem; margin-top: .7rem; }
.tour-dots i { width: .45rem; height: .45rem; border-radius: 50%; background: var(--line-strong); transition: width var(--t-base) var(--ease), background-color var(--t-base) var(--ease); }
.tour-dots i.on { width: 1.3rem; border-radius: 4px; background: var(--primary); }
.tour-actions { display: flex; align-items: center; gap: .4rem; margin-top: .85rem; }

.style-demo { max-width: 34rem; margin-inline: auto; padding: 1.25rem; }
.mock-phone .task { transition: background-color 400ms var(--ease), border-color 400ms var(--ease); }

/* The header stays on one line on phones: the light/dark switch lives in the appearance panel there. */
@media (max-width: 479.98px) { .appbar-actions .hide-sm { display: none !important; } .appbar-inner { gap: .5rem; } }
@media (max-width: 399.98px) {
  .appbar .container-wide { padding-inline: .9rem; }
  .appbar .icon-btn { width: 2.25rem; }
  .appbar .btn-sm { padding-inline: .65rem; }
  .brand { font-size: .95rem; gap: .4rem; }
}
