/* ============================================================
   ADHD Habit Tracker — layout and components.
   Colours come only from the tokens in themes.css.
   Sizes are rem so the Text size setting (--font-scale) scales everything.
   ============================================================ */

:root {
  --font-scale: 1;
  --font-body: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'DM Serif Display', Georgia, serif;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(40, 30, 35, .04), 0 1px 3px rgba(40, 30, 35, .05);
  --shadow: 0 6px 20px rgba(40, 30, 35, .07), 0 2px 6px rgba(40, 30, 35, .04);
  --sidebar-w: 248px;
  --bottom-h: 66px;
  --gap: 16px;
}
[data-theme="dark"] {
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: calc(100% * var(--font-scale)); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button, a, [role="button"], input, select, label { touch-action: manipulation; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
h1, h2, h3, h4 { color: var(--heading); margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-family: var(--font-display); font-weight: 400; font-size: 1.85rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { max-width: 100%; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: 6px; }
/* Headings get focus after navigation (for screen readers), not a visible ring. */
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; }
.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; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .78rem; }
.text-lg { font-size: 1.125rem; }
.center { text-align: center; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 14px; } .mb-4 { margin-bottom: 20px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 14px; } .mt-4 { margin-top: 20px; }
.hidden, [hidden] { display: none !important; }
html.is-demo .demo-hide { display: none !important; }
.serif { font-family: var(--font-display); font-weight: 400; }
.nowrap { white-space: nowrap; }

/* ---------- splash ---------- */
#app-splash {
  position: fixed; inset: 0; z-index: 400; display: flex; flex-direction: column; gap: 10px;
  align-items: center; justify-content: center; background: var(--bg); color: var(--accent-2-deep);
}
#app-splash p { color: var(--text-muted); font-size: .95rem; }

/* ---------- update banner / demo bar ---------- */
#update-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 500;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--btn-primary-bg); color: var(--btn-primary-text); font-size: .9rem;
  box-shadow: var(--shadow);
}
#update-banner small { opacity: .85; margin-left: 6px; }
#update-banner .update-actions { display: flex; gap: 8px; }
#update-banner button {
  padding: 6px 14px; border-radius: 8px; border: 2px solid currentColor; background: transparent;
  color: inherit; font-weight: 600; font-size: .85rem; min-height: 36px;
}
.demo-bar {
  position: sticky; top: 0; z-index: 60; display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 14px; background: var(--callout-bg); border-bottom: 1px solid var(--callout-border); font-size: .9rem; color: var(--text);
}

/* ---------- app shell ---------- */
#app-root { display: block; }
#app-main { padding: 18px 16px calc(var(--bottom-h) + 28px + env(safe-area-inset-bottom)); max-width: 1120px; margin: 0 auto; outline: none; }
.sidebar { display: none; }
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--nav-bg); border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px;
  font-size: .72rem; font-weight: 600; color: var(--nav-text); text-decoration: none; border-radius: 12px; min-height: 48px;
}
.bottom-nav a .icon { color: var(--nav-icon); }
.bottom-nav a.active { background: var(--nav-active-bg); color: var(--nav-active-text); box-shadow: inset 0 3px 0 var(--accent-1-deep); }
.bottom-nav a.active .icon { color: var(--nav-active-text); }

@media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
  .sidebar {
    display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; width: var(--sidebar-w);
    background: var(--nav-bg); border-right: 1px solid var(--border); z-index: 40; overflow-y: auto;
  }
  .bottom-nav { display: none; }
  #app-main { margin-left: var(--sidebar-w); padding: 28px 40px 60px; max-width: calc(1120px + var(--sidebar-w)); }
  body.has-banner .sidebar { top: var(--banner-h, 0px); }
}
.brand-stripe { height: 6px; background: var(--brand-stripe); flex-shrink: 0; }
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; padding: 22px 22px 16px; text-decoration: none;
  color: var(--nav-active-text); font-family: var(--font-display); font-size: 1.3rem; line-height: 1.15;
}
.sidebar-brand .brand-mark { font-size: 1.6rem; line-height: 1; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 4px 12px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; min-height: 44px;
  color: var(--nav-text); text-decoration: none; font-weight: 500;
}
.sidebar-nav a .icon { color: var(--nav-icon); flex-shrink: 0; }
.sidebar-nav a.active { background: var(--nav-active-bg); color: var(--nav-active-text); box-shadow: inset 3px 0 0 var(--accent-1-deep); font-weight: 600; }
.sidebar-nav a.active .icon { color: var(--nav-active-text); }
.sidebar-group { padding: 14px 24px 4px; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--nav-text); opacity: .8; }
.sidebar-foot { margin-top: auto; padding: 18px 22px; font-size: .8rem; color: var(--nav-text); }
[data-theme="rainbow-pastel"] .sidebar-nav a:nth-child(6n+1) .icon, [data-theme="rainbow-pastel"] .bottom-nav a:nth-child(6n+1) .icon { color: var(--chip-1-text); }
[data-theme="rainbow-pastel"] .sidebar-nav a:nth-child(6n+2) .icon, [data-theme="rainbow-pastel"] .bottom-nav a:nth-child(6n+2) .icon { color: var(--chip-2-text); }
[data-theme="rainbow-pastel"] .sidebar-nav a:nth-child(6n+3) .icon, [data-theme="rainbow-pastel"] .bottom-nav a:nth-child(6n+3) .icon { color: var(--chip-3-text); }
[data-theme="rainbow-pastel"] .sidebar-nav a:nth-child(6n+4) .icon, [data-theme="rainbow-pastel"] .bottom-nav a:nth-child(6n+4) .icon { color: var(--chip-4-text); }
[data-theme="rainbow-pastel"] .sidebar-nav a:nth-child(6n+5) .icon, [data-theme="rainbow-pastel"] .bottom-nav a:nth-child(6n+5) .icon { color: var(--chip-5-text); }
[data-theme="rainbow-pastel"] .sidebar-nav a:nth-child(6n+6) .icon, [data-theme="rainbow-pastel"] .bottom-nav a:nth-child(6n+6) .icon { color: var(--chip-6-text); }
[data-theme="rainbow-pastel"] .bottom-nav { box-shadow: inset 0 3px 0 0 transparent; border-top: 0; }
[data-theme="rainbow-pastel"] .bottom-nav::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--brand-stripe); }

/* Running timer pill (shown on every page while a focus timer runs) */
.timer-pill {
  position: fixed; right: 14px; bottom: calc(var(--bottom-h) + 14px + env(safe-area-inset-bottom)); z-index: 45;
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  background: var(--btn-primary-bg); color: var(--btn-primary-text); font-weight: 600; text-decoration: none;
  box-shadow: var(--shadow); font-variant-numeric: tabular-nums; min-height: 44px;
}
@media (min-width: 1024px) and (hover: hover) and (pointer: fine) { .timer-pill { bottom: 22px; right: 26px; } }

/* ---------- page ---------- */
.page { animation: page-in .22s ease both; }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-header-text { min-width: 0; }
.page-header-text p { color: var(--text-muted); margin-top: 4px; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 22px 2px 10px; }
.section-title h2 { font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.section-title .now-pill { font-size: .72rem; }

.grid { display: grid; gap: var(--gap); }
.grid-2 { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); }
.grid-3 { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1100px) { .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.span-2 { grid-column: 1 / -1; }
.stack > * + * { margin-top: var(--gap); }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm); min-width: 0;
}
.card-accent { border-color: var(--border-accent); border-width: 1.5px; }
.card-soft { background: var(--surface-alt); box-shadow: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-title { font-size: 1.02rem; font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.card-title-icon { color: var(--accent-2-deep); display: inline-flex; }
.callout {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--callout-bg); border: 1.5px solid var(--callout-border); color: var(--text); font-size: .92rem;
}
.callout .icon { flex-shrink: 0; margin-top: 2px; }
.callout-warn { background: var(--warning-bg); color: var(--warning-text); border-color: transparent; }
.callout-ok { background: var(--success-bg); color: var(--success-text); border-color: transparent; }
.callout-info { background: var(--info-bg); color: var(--info-text); border-color: transparent; }
.callout-danger { background: var(--danger-bg); color: var(--danger-text); border-color: transparent; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: .95rem; text-decoration: none; line-height: 1.2; white-space: normal; text-align: center; max-width: 100%;
  transition: background .15s, transform .1s, border-color .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { cursor: not-allowed; background: transparent; color: var(--text-muted); border-color: var(--btn-ghost-border); transform: none; }
.btn-primary { background: var(--btn-primary-bg); color: var(--btn-primary-text); }
.btn-secondary { background: var(--btn-secondary-bg); color: var(--btn-secondary-text); }
.btn-ghost { background: transparent; color: var(--btn-ghost-text); border-color: var(--btn-ghost-border); }
.btn-danger { background: var(--danger-solid-bg); color: var(--danger-solid-text); }
.btn-danger-ghost { background: transparent; color: var(--danger-text); border-color: var(--danger-text); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .85rem; border-radius: 9px; }
.btn-lg { min-height: 54px; padding: 14px 24px; font-size: 1.05rem; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-row.center { justify-content: center; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 10px; border: 0; background: transparent; color: var(--text-muted);
}
.link-btn { background: none; border: 0; padding: 4px 2px; color: var(--link); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; min-height: 32px; }

/* ---------- chips / pills ---------- */
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 38px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--btn-ghost-border);
  background: var(--surface); color: var(--text); font-size: .9rem; font-weight: 500;
}
.chip-active { background: var(--btn-primary-bg); color: var(--btn-primary-text); border-color: transparent; font-weight: 600; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px;
  font-size: .75rem; font-weight: 600; background: var(--chip-3-bg); color: var(--chip-3-text); white-space: nowrap;
}
.pill-1 { background: var(--chip-1-bg); color: var(--chip-1-text); }
.pill-2 { background: var(--chip-2-bg); color: var(--chip-2-text); }
.pill-3 { background: var(--chip-3-bg); color: var(--chip-3-text); }
.pill-4 { background: var(--chip-4-bg); color: var(--chip-4-text); }
.pill-5 { background: var(--chip-5-bg); color: var(--chip-5-text); }
.pill-6 { background: var(--chip-6-bg); color: var(--chip-6-text); }
.pill-ok { background: var(--success-bg); color: var(--success-text); }
.pill-warn { background: var(--warning-bg); color: var(--warning-text); }
.pill-info { background: var(--info-bg); color: var(--info-text); }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; min-width: 0; }
.field > label, .field-label { display: block; font-size: .85rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.field-hint { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }
input[type="text"], input[type="number"], input[type="time"], input[type="date"], input[type="search"], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--btn-ghost-border); background: var(--surface); color: var(--text); font-size: 1rem;
}
/* iPhone draws date/time boxes at its own width unless told otherwise (catalogue #26). */
input[type="date"], input[type="time"] { -webkit-appearance: none; appearance: none; display: block; width: 100%; min-width: 0; max-width: 100%; text-align: left; }
input::-webkit-date-and-time-value { text-align: left; margin: 0; min-height: 1.25em; }
.field > * { min-width: 0; max-width: 100%; }
textarea { min-height: 88px; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 1; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.field-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.inline-add { display: flex; gap: 8px; }
.inline-add input { flex: 1; min-width: 0; }
details.form-section { border-top: 1px solid var(--divider); padding-top: 10px; margin-top: 6px; }
details.form-section > summary {
  cursor: pointer; font-weight: 600; padding: 8px 0; display: flex; align-items: center; gap: 8px; list-style: none; min-height: 40px;
}
details.form-section > summary::-webkit-details-marker { display: none; }
details.form-section > summary::after { content: '+'; margin-left: auto; font-size: 1.2rem; color: var(--text-muted); }
details.form-section[open] > summary::after { content: '–'; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--divider); }
.toggle-row:last-child { border-bottom: 0; }
.toggle-label { font-weight: 600; font-size: .95rem; }
.switch {
  -webkit-appearance: none; appearance: none; flex-shrink: 0; width: 50px; height: 30px; border-radius: 999px; margin: 0;
  background: var(--chart-track); border: 1px solid var(--btn-ghost-border); position: relative; cursor: pointer; transition: background .2s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s;
}
.switch:checked { background: var(--accent-2-deep); border-color: var(--accent-2-deep); }
.switch:checked::after { transform: translateX(20px); }

.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 4px; max-height: 172px; overflow-y: auto; padding: 2px; }
.emoji-grid button { height: 42px; border-radius: 10px; border: 1px solid transparent; background: var(--surface-alt); font-size: 1.3rem; }
.emoji-grid button[aria-pressed="true"] { border-color: var(--accent-2-deep); background: var(--chip-2-bg); box-shadow: inset 0 0 0 1px var(--accent-2-deep); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border);
  background: var(--sw); display: inline-flex; align-items: center; justify-content: center; color: var(--text);
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--text); }

/* ---------- tabs ---------- */
/* Tabs wrap onto a second line on narrow screens: never hidden behind a scrollbar. */
.tab-bar { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-alt); border: 1px solid var(--border); margin-bottom: 16px; }
.tab { flex: 0 0 auto; padding: 8px 14px; border-radius: 9px; text-decoration: none; color: var(--text); font-weight: 500; font-size: .92rem; min-height: 40px; display: inline-flex; align-items: center; }
.tab.active { background: var(--surface); box-shadow: var(--shadow-sm), inset 0 -2px 0 var(--accent-1-deep); font-weight: 600; color: var(--heading); }

/* ---------- progress / ring / charts ---------- */
.progress { height: 10px; border-radius: 999px; background: var(--progress-track); overflow: hidden; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--chart-edge) 25%, transparent); }
.progress-fill { height: 100%; border-radius: 999px; background: var(--progress-fill); transition: width .4s ease; }
.ring { position: relative; flex-shrink: 0; }
.ring svg { display: block; }
.ring-track { stroke: var(--chart-track); }
.ring-fill { stroke: var(--accent-2-deep); transition: stroke-dashoffset .5s ease; }
[data-theme="rainbow-pastel"] .ring-fill { stroke: var(--chart-5); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 700; color: var(--heading); font-size: 1.15rem; line-height: 1.05; text-align: center; }
.ring-center small { font-size: .68rem; font-weight: 500; color: var(--text-muted); }

.bar-chart { margin: 0; }
.bars { position: relative; display: grid; gap: 6px; align-items: end; height: var(--h); padding-top: 18px; }
.bar-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar-stack { width: 100%; max-width: 46px; display: flex; flex-direction: column; justify-content: flex-end; border-radius: 6px 6px 3px 3px; overflow: hidden; }
.bar-seg { flex: 1; background: var(--chart-2); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--chart-edge) 35%, transparent); border-radius: inherit; }
.bar-seg.seg-2 { background: var(--chart-1); }
.bar-col-hl .bar-seg { background: var(--chart-4); }
.bar-col-over .bar-seg { background: var(--chart-3); }
.bar-value { font-size: .72rem; color: var(--text-muted); margin-bottom: 3px; font-variant-numeric: tabular-nums; }
.bar-label { font-size: .72rem; color: var(--text-muted); margin-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.hbar + .hbar { margin-top: 12px; }
.hbar-top { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; margin-bottom: 5px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .8rem; color: var(--text-muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.line-chart { width: 100%; height: auto; display: block; }
.line-chart .grid-line { stroke: var(--divider); stroke-dasharray: 3 5; }
.line-chart text { fill: var(--text-muted); font-size: 10px; font-family: var(--font-body); }

.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 700px) { .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { padding: 14px; border-radius: var(--radius-sm); background: var(--surface-alt); border: 1px solid var(--border); min-width: 0; }
.stat-label { font-size: .74rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-family: var(--font-display); font-size: 1.7rem; line-height: 1.15; color: var(--heading); margin-top: 3px; overflow-wrap: anywhere; }
.stat-note { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }

/* ---------- Today welcome panel (pwa-dashboard-illustration) ----------
   Laid out by the panel's own width (container query): phones keep the picture
   small beside the message so the habit list stays near the top; wider panels
   give it the right-hand column. Low-stimulation: plain card, no picture. */
.hb-hero {
  container-type: inline-size; position: relative; overflow: hidden;
  background: var(--hero-bg, var(--surface)); border: 1px solid var(--hero-border, var(--border));
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); margin-bottom: 14px;
}
.hb-hero__grid {
  display: grid; grid-template-columns: minmax(0, 1fr) 112px; grid-template-areas: "text art" "foot foot";
  gap: 12px; align-items: center; padding: 16px;
}
.hb-hero__text { grid-area: text; min-width: 0; }
.hb-hero__art { grid-area: art; line-height: 0; }
.hb-hero__art svg { width: 100%; height: auto; display: block; }
.hb-hero__foot { grid-area: foot; min-width: 0; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.hb-hero__eyebrow {
  display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--hero-eyebrow-bg); color: var(--hero-eyebrow-text);
  font-size: .76rem; font-weight: 700; letter-spacing: .02em;
}
.hb-hero__title { margin-top: 8px; font-family: var(--font-display); font-size: 1.45rem; font-weight: 400; line-height: 1.2; color: var(--heading); }
.hb-hero__line { margin-top: 4px; font-size: .92rem; color: var(--text); line-height: 1.4; }
.hb-hero__tiles { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.hb-tile { padding: 8px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); min-width: 0; }
.hb-tile b { display: block; font-size: 1.05rem; color: var(--heading); font-variant-numeric: tabular-nums; }
.hb-tile span { font-size: .74rem; color: var(--text-muted); }
@container (min-width: 600px) {
  .hb-hero__grid { grid-template-columns: minmax(0, 1fr) minmax(220px, 280px); gap: 16px 22px; padding: 22px 26px; }
  .hb-hero__title { font-size: 2rem; }
  .hb-hero__line { font-size: 1rem; }
}
@container (min-width: 880px) {
  .hb-hero__grid { grid-template-columns: minmax(0, 1fr) minmax(320px, 380px); grid-template-areas: "text art" "foot art"; }
  .hb-hero__art { align-self: end; }
}
html[data-lowstim="on"] .hb-hero { background: var(--surface); border-color: var(--border); }
html[data-lowstim="on"] .hb-hero__art { display: none; }
html[data-lowstim="on"] .hb-hero__grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "text" "foot"; }

.hb-glow { fill: var(--art-glow); }
.hb-shadow { fill: var(--art-shadow); opacity: .08; }
.hb-spark { fill: var(--art-spark); animation: hbTwinkle 4.5s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.hb-spark--soft { opacity: .55; animation-delay: 2.2s; }
.hb-note { fill: var(--art-note); }
.hb-fold { fill: var(--art-ink); opacity: .08; }
.hb-heart { fill: var(--art-heart); }
.hb-board { fill: var(--art-board); }
.hb-paper { fill: var(--art-paper); }
.hb-clip { fill: var(--art-clip); }
.hb-line { fill: var(--art-ink); opacity: .16; }
.hb-line--soft { opacity: .09; }
.hb-h1 { fill: var(--art-h1); } .hb-h2 { fill: var(--art-h2); } .hb-h3 { fill: var(--art-h3); }
.hb-tick { fill: none; stroke: var(--art-ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: .75; }
.hb-todo { fill: none; stroke: var(--art-ink); stroke-width: 1.6; opacity: .3; }
.hb-rest { fill: none; stroke: var(--art-ink); stroke-width: 1.4; stroke-dasharray: 2.5 2.5; opacity: .35; }
.hb-rest-line { stroke: var(--art-ink); stroke-width: 1.4; opacity: .3; stroke-linecap: round; }
.hb-glass { fill: var(--art-glass); }
.hb-water { fill: var(--art-water); }
.hb-shine { fill: var(--art-paper); opacity: .55; }
.hb-straw { fill: var(--art-straw); }
.hb-stem { fill: none; stroke: var(--art-leaf); stroke-width: 3; stroke-linecap: round; }
.hb-leaf { fill: var(--art-leaf); } .hb-leaf2 { fill: var(--art-leaf2); }
.hb-pot { fill: var(--art-pot); }
@keyframes hbTwinkle { 0%, 100% { opacity: .9; transform: scale(1); } 50% { opacity: .35; transform: scale(.7); } }
@media (prefers-reduced-motion: reduce) { .hb-spark { animation: none; } }
html[data-motion="off"] .hb-spark { animation: none; }

/* ---------- Today: check-in ---------- */
.checkin-grid { display: flex; flex-direction: column; gap: 6px; }
.checkin { display: flex; align-items: center; gap: 8px; min-width: 0; }
.checkin-label { flex: 0 0 64px; font-size: .74rem; font-weight: 700; color: var(--text-muted); letter-spacing: .05em; text-transform: uppercase; }
.checkin-row { flex: 1; display: flex; justify-content: space-between; gap: 2px; flex-wrap: nowrap; min-width: 0; max-width: 260px; }
.checkin-row button {
  flex: 1 1 0; min-width: 0; max-width: 42px; aspect-ratio: 1; border-radius: 50%; border: 1px solid transparent; background: transparent;
  font-size: 1.2rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.checkin-row button[aria-pressed="true"] { background: var(--chip-2-bg); border-color: var(--accent-2-deep); }

.capacity { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.capacity button {
  padding: 10px 6px; border-radius: 12px; border: 1px solid var(--btn-ghost-border); background: var(--surface);
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 64px; text-align: center;
}
.capacity button b { font-size: .92rem; }
.capacity button span { font-size: .74rem; color: var(--text-muted); }
.capacity button[aria-pressed="true"] { background: var(--btn-primary-bg); color: var(--btn-primary-text); border-color: transparent; }
.capacity button[aria-pressed="true"] span { color: var(--btn-primary-text); }

/* ---------- habit rows ---------- */
.habit-list { display: flex; flex-direction: column; gap: 10px; }
.habit-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: opacity .2s, background .2s;
}
.habit-row.is-done { background: var(--surface-alt); }
.habit-row.is-done .habit-name { text-decoration: line-through; text-decoration-color: var(--border-accent); text-decoration-thickness: 2px; color: var(--text-muted); }
.habit-row.is-quiet { opacity: .72; }
.habit-row.is-next { border-color: var(--border-accent); border-width: 1.5px; }
.habit-emoji {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.3rem; background: color-mix(in srgb, var(--hc, var(--accent-2)) 30%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--hc, var(--accent-2)) 55%, transparent);
}
.habit-emoji-lg { width: 64px; height: 64px; font-size: 2rem; border-radius: 18px; }
.habit-emoji-sm { width: 30px; height: 30px; font-size: .95rem; border-radius: 9px; }
.habit-main { flex: 1 1 150px; min-width: 0; }
.habit-row { flex-wrap: wrap; }
.habit-actions { margin-left: auto; }
.habit-name { font-weight: 600; display: block; overflow-wrap: anywhere; color: var(--heading); text-decoration: none; }
.habit-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: .8rem; color: var(--text-muted); margin-top: 2px; }
.habit-meta .pill { font-size: .7rem; }
.habit-level { font-size: .82rem; color: var(--text); margin-top: 3px; }
.habit-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.check-btn {
  width: 48px; height: 48px; border-radius: 14px; flex-shrink: 0; border: 2px solid var(--btn-ghost-border); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; color: var(--btn-primary-text);
  transition: background .18s, border-color .18s, transform .18s;
}
.check-btn .icon { opacity: 0; transform: scale(.5); transition: opacity .18s, transform .18s; }
.check-btn[aria-pressed="true"] { background: var(--accent-2); border-color: var(--accent-2); }
.check-btn[aria-pressed="true"] .icon { opacity: 1; transform: scale(1); color: var(--btn-primary-text); }
[data-theme="neutral"] .check-btn[aria-pressed="true"] { background: var(--btn-primary-bg); border-color: var(--btn-primary-bg); }
.check-btn.pop { animation: pop .32s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes pop { 0% { transform: scale(1); } 50% { transform: scale(1.18); } 100% { transform: scale(1); } }
.counter { display: inline-flex; align-items: center; gap: 2px; flex-shrink: 0; }
.counter button {
  width: 40px; height: 44px; border: 1px solid var(--btn-ghost-border); background: var(--surface); color: var(--btn-ghost-text);
  display: inline-flex; align-items: center; justify-content: center;
}
.counter button:first-child { border-radius: 12px 0 0 12px; }
.counter button:last-child { border-radius: 0 12px 12px 0; }
.counter output { min-width: 54px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-top: 1px solid var(--btn-ghost-border); border-bottom: 1px solid var(--btn-ghost-border); font-weight: 700; font-variant-numeric: tabular-nums; font-size: .9rem; padding: 0 4px; background: var(--surface); }
.counter.is-done output { background: var(--chip-2-bg); color: var(--chip-2-text); }
.mini-progress { height: 5px; border-radius: 999px; background: var(--progress-track); margin-top: 6px; overflow: hidden; max-width: 220px; }
.mini-progress i { display: block; height: 100%; background: var(--progress-fill); border-radius: inherit; }
.status-note { font-size: .78rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.level-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.level-chip { flex: 1 1 0; min-width: 0; text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--btn-ghost-border); background: var(--surface); }
.level-chip b { display: block; font-size: .9rem; }
.level-chip span { display: block; font-size: .8rem; color: var(--text-muted); overflow-wrap: anywhere; }
.level-chip[aria-pressed="true"] { background: var(--chip-2-bg); border-color: var(--accent-2-deep); }
.next-card { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.next-card > .btn-row { flex: 1 1 140px; }
.next-card .habit-main { min-width: 0; }
.welcome-back { background: var(--callout-bg); border: 1.5px solid var(--callout-border); }
.part-head { display: flex; align-items: center; gap: 8px; margin: 18px 2px 8px; font-weight: 600; color: var(--heading); }
.part-head .icon { color: var(--accent-2-deep); }
.part-head .count { margin-left: auto; font-size: .8rem; color: var(--text-muted); font-weight: 500; }

/* ---------- habits manager ---------- */
.manage-row .order-btns { display: flex; flex-direction: column; }
.manage-row .order-btns .icon-btn { width: 32px; height: 26px; }
.library-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.idea {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); text-align: left; min-height: 56px; width: 100%;
}
.idea b { display: block; font-size: .92rem; font-weight: 600; }
.idea small { display: block; font-size: .78rem; color: var(--text-muted); }
.idea .add-plus { margin-left: auto; color: var(--accent-2-deep); flex-shrink: 0; }
.pack { display: flex; flex-direction: column; gap: 8px; }
.pack-list { font-size: .85rem; color: var(--text-muted); }

/* ---------- calendars ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.cal-head strong { font-size: 1rem; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; max-width: 520px; margin: 0 auto; }
.cal-head { max-width: 520px; margin-left: auto; margin-right: auto; }
.cal-dow { font-size: .72rem; font-weight: 600; color: var(--text-muted); text-align: center; padding: 2px 0 4px; }
.cal-day {
  aspect-ratio: 1; min-height: 36px; border-radius: 10px; border: 1px solid transparent; background: var(--surface-alt);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: .8rem;
  color: var(--text); position: relative; padding: 0;
}
.cal-day.out { visibility: hidden; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--accent-1-deep); }
.cal-day.future { color: var(--text-muted); background: transparent; border: 1px dashed var(--divider); }
.cal-day .mark { font-size: .7rem; line-height: 1; }
.cal-day.st-done { background: var(--chart-2); color: var(--btn-primary-text); font-weight: 700; }
[data-theme="dark"] .cal-day.st-done { color: #1D1E2B; }
.cal-day.st-done.lv-tiny { background: color-mix(in srgb, var(--chart-2) 45%, var(--surface)); color: var(--text); }
.cal-day.st-done.lv-bonus { background: var(--chart-4); color: var(--btn-primary-text); }
[data-theme="dark"] .cal-day.st-done.lv-bonus { color: #1D1E2B; }
[data-theme="neutral"] .cal-day.st-done, [data-theme="neutral"] .cal-day.st-done.lv-bonus { color: #1F2A2A; }
.cal-day.st-skip, .cal-day.st-rest, .cal-day.st-paused { background: repeating-linear-gradient(135deg, var(--surface-alt) 0 5px, var(--chart-track) 5px 7px); }
.cal-day.st-shielded { background: var(--info-bg); color: var(--info-text); }
.cal-day.st-miss { background: var(--surface); border-color: var(--divider); }
.cal-day.st-off, .cal-day.st-before { background: transparent; color: var(--text-muted); }
.heat-0 { background: var(--surface-alt); }
.heat-1 { background: color-mix(in srgb, var(--chart-2) 30%, var(--surface)); }
.heat-2 { background: color-mix(in srgb, var(--chart-2) 60%, var(--surface)); }
.heat-3 { background: var(--chart-2); }
.heat-4 { background: var(--chart-4); }
.cal-day.heat-3, .cal-day.heat-4 { color: var(--btn-primary-text); font-weight: 700; }
[data-theme="dark"] .cal-day.heat-3, [data-theme="dark"] .cal-day.heat-4 { color: #1D1E2B; }
[data-theme="neutral"] .cal-day.heat-3, [data-theme="neutral"] .cal-day.heat-4 { color: #1F2A2A; }
.heat-rest { background: repeating-linear-gradient(135deg, var(--surface-alt) 0 5px, var(--chart-track) 5px 7px); }
.key { display: flex; flex-wrap: wrap; gap: 10px 14px; font-size: .78rem; color: var(--text-muted); margin-top: 10px; align-items: center; }
.key i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 5px; border: 1px solid var(--divider); }

.week-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.week-grid { display: grid; grid-template-columns: minmax(130px, 1.6fr) repeat(7, minmax(40px, 1fr)); gap: 4px; min-width: 470px; align-items: center; }
.week-grid .wg-head { font-size: .74rem; color: var(--text-muted); text-align: center; font-weight: 600; line-height: 1.2; padding-bottom: 4px; }
.week-grid .wg-head.today { color: var(--heading); }
.week-grid .wg-name { display: flex; align-items: center; gap: 8px; font-size: .88rem; font-weight: 500; min-width: 0; }
.week-grid .wg-name span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wg-cell {
  height: 40px; border-radius: 10px; border: 1px solid var(--divider); background: var(--surface); display: flex; align-items: center; justify-content: center;
  font-size: .85rem; padding: 0; color: var(--btn-primary-text); width: 100%;
}
.wg-cell.today { box-shadow: inset 0 0 0 2px var(--accent-1-deep); }
.wg-cell.st-done { background: var(--chart-2); border-color: transparent; font-weight: 700; }
.wg-cell.st-done.lv-tiny { background: color-mix(in srgb, var(--chart-2) 45%, var(--surface)); color: var(--text); }
.wg-cell.st-done.lv-bonus { background: var(--chart-4); }
[data-theme="dark"] .wg-cell.st-done { color: #1D1E2B; }
[data-theme="neutral"] .wg-cell.st-done { color: #1F2A2A; }
.wg-cell.st-off, .wg-cell.st-before, .wg-cell.st-future { background: transparent; border-style: dashed; color: var(--text-muted); }
.wg-cell.st-skip, .wg-cell.st-rest, .wg-cell.st-paused { background: repeating-linear-gradient(135deg, var(--surface-alt) 0 5px, var(--chart-track) 5px 7px); color: var(--text-muted); }
.wg-cell.st-shielded { background: var(--info-bg); color: var(--info-text); }

/* ---------- badges / rewards ---------- */
.badge-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.badge { padding: 14px 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); text-align: center; min-width: 0; }
.badge-emoji { font-size: 2rem; line-height: 1.2; }
.badge b { display: block; font-size: .9rem; margin-top: 4px; color: var(--heading); }
.badge small { display: block; font-size: .76rem; color: var(--text-muted); margin-top: 2px; }
.badge.locked { background: var(--surface-alt); }
.badge.locked .badge-emoji { filter: grayscale(1); opacity: .4; }
.level-card { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.level-num { font-family: var(--font-display); font-size: 2.6rem; line-height: 1; color: var(--heading); }
.reward-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--divider); }
.reward-row:last-child { border-bottom: 0; }
.reward-emoji { font-size: 1.5rem; width: 44px; height: 44px; border-radius: 12px; background: var(--surface-alt); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.menu-cols { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.menu-col h3 { font-size: .9rem; margin-bottom: 6px; }
.menu-col ul { margin: 0; padding: 0; list-style: none; }
.menu-col li { padding: 6px 0; border-bottom: 1px dashed var(--divider); font-size: .9rem; display: flex; gap: 8px; align-items: center; justify-content: space-between; }

/* ---------- list rows (brain dump, journal, routines) ---------- */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--divider); min-width: 0; }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list-row.is-done .grow { text-decoration: line-through; color: var(--text-muted); }
.tick-box {
  width: 32px; height: 32px; border-radius: 9px; border: 2px solid var(--btn-ghost-border); background: var(--surface); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; padding: 0; color: var(--btn-primary-text);
}
.tick-box .icon { opacity: 0; }
.tick-box[aria-pressed="true"] { background: var(--accent-2); border-color: var(--accent-2); }
.tick-box[aria-pressed="true"] .icon { opacity: 1; }
.step-list { counter-reset: step; margin: 0; padding: 0; list-style: none; }
.step-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--divider); }
.step-list li::before {
  counter-increment: step; content: counter(step); width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: var(--chip-2-bg); color: var(--chip-2-text); font-size: .78rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.chain { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .85rem; }
.chain .link-arrow { color: var(--text-muted); }
.chain .pill { white-space: normal; overflow-wrap: anywhere; }

/* ---------- timer disc + player ---------- */
.disc-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.disc { width: min(260px, 70vw); aspect-ratio: 1; position: relative; }
.disc svg { width: 100%; height: 100%; display: block; }
.disc-track { fill: var(--chart-track); }
.disc-fill { fill: var(--chart-1); }
[data-theme="neutral"] .disc-fill, [data-theme="dark"] .disc-fill { fill: var(--chart-2); }
.disc-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.disc-time { font-size: 2.4rem; font-weight: 700; color: var(--heading); font-variant-numeric: tabular-nums; background: var(--surface); padding: 2px 14px; border-radius: 14px; }
.disc-sub { font-size: .85rem; color: var(--text); margin-top: 6px; background: var(--surface); padding: 2px 10px; border-radius: 10px; }
.player { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; padding: 8px 0 20px; }
.player-step { font-family: var(--font-display); font-size: 1.9rem; color: var(--heading); line-height: 1.2; overflow-wrap: anywhere; }
.player-dots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.player-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--chart-track); border: 1px solid var(--divider); }
.player-dots i.on { background: var(--accent-2-deep); border-color: transparent; }
.one-thing { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 10px 0 24px; }
.one-thing .big-name { font-family: var(--font-display); font-size: 2rem; line-height: 1.2; color: var(--heading); overflow-wrap: anywhere; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 300; background: rgba(30, 24, 28, .45); display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity .2s;
}
.modal-backdrop.open { opacity: 1; }
.modal {
  width: 100%; max-width: 560px; max-height: 92vh; max-height: calc(100dvh - max(16px, env(safe-area-inset-top)) - 8px);
  overflow-y: auto; overscroll-behavior: contain; background: var(--surface); color: var(--text);
  border-radius: 22px 22px 0 0; box-shadow: var(--shadow); transform: translateY(16px); transition: transform .22s;
  padding-bottom: env(safe-area-inset-bottom);
}
.modal-wide { max-width: 760px; }
.modal-backdrop.open .modal { transform: none; }
.modal-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 10px; background: var(--surface); border-bottom: 1px solid var(--divider); }
.modal-header h2 { font-family: var(--font-display); font-weight: 400; font-size: 1.4rem; min-width: 0; overflow-wrap: anywhere; }
.modal-close { width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--surface-alt); display: inline-flex; align-items: center; justify-content: center; color: var(--text); flex-shrink: 0; }
.modal-body { padding: 16px 18px 22px; }
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal { border-radius: 22px; }
}
.modal-backdrop-full { align-items: stretch; padding: 0 !important; }
.modal-full { max-width: none; max-height: none; height: 100%; border-radius: 0 !important; display: flex; flex-direction: column; }
.modal-full .modal-body { flex: 1; display: flex; flex-direction: column; justify-content: center; max-width: 640px; width: 100%; margin: 0 auto; }
body.modal-open { overflow: hidden; }

/* ---------- toast ---------- */
.toast-container {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--bottom-h) + 16px + env(safe-area-inset-bottom)); z-index: 350;
  display: flex; flex-direction: column; gap: 8px; width: min(92vw, 440px); pointer-events: none;
}
@media (min-width: 1024px) and (hover: hover) and (pointer: fine) { .toast-container { bottom: 24px; left: calc(50% + var(--sidebar-w) / 2); } }
.toast {
  pointer-events: auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-radius: 14px;
  background: var(--heading); color: var(--surface); box-shadow: var(--shadow); font-size: .92rem; animation: toast-in .2s ease;
}
.toast.leaving { opacity: 0; transition: opacity .25s; pointer-events: none; }
.toast-action { background: none; border: 0; color: inherit; font-weight: 700; text-decoration: underline; padding: 6px 4px; min-height: 36px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- empty states ---------- */
.empty-state { text-align: center; padding: 34px 18px; color: var(--text); }
.empty-state .empty-icon { color: var(--accent-1-deep); margin-bottom: 8px; }
.empty-state h3 { font-family: var(--font-display); font-weight: 400; font-size: 1.35rem; margin-bottom: 6px; }
.empty-state p { color: var(--text-muted); max-width: 440px; margin: 0 auto 14px; }

/* ---------- sync card bits ---------- */
.sync-code { font-size: 2.2rem; font-weight: 700; letter-spacing: .12em; text-align: center; font-variant-numeric: tabular-nums; color: var(--heading); }
.sync-code-input { font-size: 1.4rem; letter-spacing: .1em; text-align: center; }
.sync-pics { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; margin: 6px 0 10px; }
.sync-pics > span { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.sync-pic { font-size: 2.2rem; }
.sync-key { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .95rem; width: 100%; text-align: left; padding: 12px; border-radius: 10px; border: 1px solid var(--btn-ghost-border); background: var(--surface-alt); color: var(--text); overflow-wrap: anywhere; }
.sync-key-hidden { color: transparent; text-shadow: 0 0 8px var(--text); }

/* ---------- install banner ---------- */
.install-card { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.install-card .grow { flex: 1; min-width: 200px; }

/* ---------- confetti ---------- */
.confetti-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 380; }

/* ---------- comfort modes ---------- */
html[data-lowstim="on"] .hb-hero__eyebrow, html[data-lowstim="on"] .emoji-deco { display: none; }
html[data-lowstim="on"] .habit-emoji { background: var(--surface-alt); box-shadow: inset 0 0 0 1px var(--border); }
html[data-lowstim="on"] .badge-emoji { filter: grayscale(.6); }
html[data-motion="off"] *, html[data-motion="off"] *::before, html[data-motion="off"] *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- printable fridge sheet ---------- */
.print-sheet { background: #fff; color: #222; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; overflow-x: auto; }
.print-sheet h2 { color: #222; font-family: var(--font-display); font-weight: 400; font-size: 1.5rem; }
.print-table { width: 100%; border-collapse: collapse; margin-top: 12px; min-width: 560px; }
.print-table th, .print-table td { border: 1px solid #bbb; padding: 8px 6px; font-size: .85rem; color: #222; vertical-align: middle; }
.print-table th { background: #f3f3f3; font-weight: 600; }
.print-table td.box { width: 9%; height: 38px; text-align: center; }
.print-table td.box.off { background: repeating-linear-gradient(135deg, #fff 0 5px, #eee 5px 7px); }
.print-table .tiny { display: block; font-size: .72rem; color: #555; }
.print-foot { margin-top: 12px; font-size: .8rem; color: #444; }

@media print {
  .sidebar, .bottom-nav, #update-banner, .demo-bar, .no-print, .toast-container, .timer-pill, .page-header-actions { display: none !important; }
  #app-main { margin: 0 !important; padding: 0 !important; max-width: none !important; }
  body { background: #fff !important; }
  .card { box-shadow: none !important; break-inside: avoid; }
  .hb-hero__art { display: none !important; }
  .print-sheet { border: 0; padding: 0; }
  .print-table { min-width: 0; }
}

/* ---------- hover (mouse only: on touch a hover sticks after a tap) ---------- */
@media (hover: hover) {
  .sidebar-nav a:hover { background: var(--nav-hover-bg); }
  .btn-primary:hover:not(:disabled) { background: var(--btn-primary-hover); }
  .btn-secondary:hover:not(:disabled) { background: var(--btn-secondary-hover); }
  .btn-ghost:hover:not(:disabled) { background: var(--surface-alt); }
  .icon-btn:hover { background: var(--surface-alt); color: var(--text); }
  .chip:hover { background: var(--surface-alt); }
  .chip-active:hover { background: var(--btn-primary-hover); }
  .checkin-row button:hover { background: var(--surface-alt); }
  a.habit-name:hover { text-decoration: underline; }
  .check-btn:hover { border-color: var(--accent-2-deep); }
  .idea:hover { border-color: var(--border-accent); background: var(--surface-alt); }
  button.cal-day:hover { border-color: var(--border-accent); }
}

/* Print is always dark ink on white, whatever the theme (catalogue #49). */
@media print {
  html[data-theme] {
    color-scheme: light;
    --bg: #FFFFFF; --surface: #FFFFFF; --surface-alt: #F6F6F6; --text: #222222; --heading: #111111; --text-muted: #555555;
    --border: #CCCCCC; --divider: #DDDDDD; --link: #333333;
  }
  .modal-backdrop, #app-splash { display: none !important; }
}

/* Done-square contrast fixes (audit): Neutral uses its lighter sage-gray for "done" so the
   dark tick reads at 7:1+; Dark keeps light text on tiny squares, on a deeper tint. */
[data-theme="neutral"] .cal-day.st-done, [data-theme="neutral"] .wg-cell.st-done { background: var(--chart-1); }
[data-theme="neutral"] .cal-day.st-done.lv-tiny, [data-theme="neutral"] .wg-cell.st-done.lv-tiny { background: color-mix(in srgb, var(--chart-1) 45%, var(--surface)); }
[data-theme="dark"] .cal-day.st-done.lv-tiny, [data-theme="dark"] .wg-cell.st-done.lv-tiny { background: color-mix(in srgb, var(--chart-2) 35%, var(--surface)); color: var(--text); }
[data-theme="neutral"] .heat-1 { background: color-mix(in srgb, var(--chart-1) 30%, var(--surface)); }
[data-theme="neutral"] .heat-2 { background: color-mix(in srgb, var(--chart-1) 60%, var(--surface)); }
[data-theme="neutral"] .heat-3 { background: var(--chart-1); }
[data-theme="neutral"] .heat-4 { background: var(--chart-4); }

/* Phones: keep the welcome panel short so Today's habits start sooner (two tiles, not four). */
@container (max-width: 459px) {
  .hb-hero__tiles .hb-tile:nth-child(n+3) { display: none; }
  .hb-hero__title { font-size: 1.35rem; }
}

/* Chart marks: a very thin edge in each theme's own --chart-edge, so the soft pastel fills
   stay easy to see on white (Joanne's choice: keep the colors, add a thin border). */
:root { --mark-edge: color-mix(in srgb, var(--chart-edge) 75%, transparent); }
.bar-seg, .progress-fill, .mini-progress i { box-shadow: inset 0 0 0 1px var(--mark-edge); }
.cal-day.st-done, .cal-day.heat-1, .cal-day.heat-2, .cal-day.heat-3, .cal-day.heat-4,
.wg-cell.st-done { border-color: var(--mark-edge); }
.key i.heat-1, .key i.heat-2, .key i.heat-3, .key i.heat-4, .key i[style*="--chart"], .legend i { border: 1px solid var(--mark-edge); }
.disc-fill { stroke: var(--mark-edge); stroke-width: .6; }
