/* Self-hosted character fonts — no third-party CDN request, works fully offline once
   the service worker has precached the files (see sw.js ASSETS). Fraunces is the
   variable heading face (optical-size 9..144, weight 500/600 — the two weights this
   app actually uses for headings); Bricolage Grotesque is the variable body face
   (weight 200-800, covering everything from captions to the big stat numbers).
   Both are SIL Open Font License — free for commercial use. */
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 500 600;
  font-display: swap;
  src: url("../assets/fonts/fraunces-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 500 600;
  font-display: swap;
  src: url("../assets/fonts/fraunces-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Named FALLBACK faces, tuned with metric-override properties so the system font that
   briefly shows during font-display:swap occupies (almost) the same box as the real
   webfont — this is what actually keeps CLS low on swap, not just font-display itself.
   Numbers follow the standard fallback-matching formula (same approach the fontaine
   tool uses): size-adjust matches average character width, then ascent/descent/
   line-gap are the real font's own metrics scaled by that same ratio. Pure metrics on
   a local system font — never downloaded. */
@font-face {
  font-family: "Fraunces Fallback";
  src: local("Georgia"), local("Times New Roman");
  size-adjust: 98%;
  ascent-override: 92%;
  descent-override: 24%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("../assets/fonts/bricolage-grotesque-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Bricolage Grotesque Fallback";
  src: local("Arial"), local("Helvetica"), local("Segoe UI");
  size-adjust: 105.43%;
  ascent-override: 88.21%;
  descent-override: 25.61%;
  line-gap-override: 0%;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background-color: var(--bg); background-image: var(--grad); background-attachment: fixed; color: var(--ink); -webkit-font-smoothing: antialiased; line-height: 1.5; padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
[data-reduce="1"] * { transition: none !important; animation: none !important; }
/* Always honour the OS-level reduced-motion preference, independent of the in-app
   toggle (that toggle is also seeded FROM this same media query at boot — see
   js/app.js boot() — but this rule is a hard floor so motion never leaks through
   before JS runs, or for a user who never opens Settings). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
h1, h2 { letter-spacing: -0.3px; }

/* Inline SVG icon set (replaces the old Material Symbols webfont + emoji-as-icon).
   Every <svg class="ic"> is generated by the icon() helper in js/app.js with
   aria-hidden="true" — the control that wraps it always carries the real
   accessible name via aria-label/text, so the icon itself stays decorative. */
.ic { width: 20px; height: 20px; display: inline-block; flex: 0 0 auto; vertical-align: middle; }
.tab .ic { width: 22px; height: 22px; }
.stat-ic { width: 20px; height: 20px; color: var(--primary); display: block; margin: 0 auto 2px; }
.tip-ic { width: 18px; height: 18px; color: var(--primary); }
.h-ic { width: 20px; height: 20px; color: var(--primary); }
/* Round-1: sheets used to open with a big decorative emoji. Replaced with a soft
   tinted badge holding an SVG from the same icon set — same warm anchor, no emoji,
   renders identically on every OS/offline. */
.sheet-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-2); color: var(--primary); border: 1px solid var(--line); margin-bottom: 4px; }
.sheet-ic { width: 24px; height: 24px; }

.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: 12px; top: 12px; background: var(--ink); color: var(--bg); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.app { max-width: var(--maxw); margin: 0 auto; padding: calc(env(safe-area-inset-top) + 16px) var(--space) 24px; }
/* Text stays at full opacity/contrast throughout the transition — only position
   animates — so a newly-shown view is never briefly below the 4.5:1 text-contrast
   floor mid-motion (also respects prefers-reduced-motion via the global rule above). */
.view { animation: viewIn .25s ease; }
@keyframes viewIn { from { transform: translateY(6px); } to { transform: none; } }
.view-head { margin: 8px 0 16px; }
.view-head h1 { font-family: var(--font-heading); font-size: 30px; margin: 0; font-weight: 600; }
.sub { color: var(--ink-soft); font-size: 14px; margin: 4px 0 0; }
.muted { color: var(--ink-soft); font-weight: 400; font-size: 12px; }
.mini-h { font-size: 14px; color: var(--ink-soft); margin: 24px 0 8px; font-weight: 600; }

.btn { font: inherit; font-size: 15px; cursor: pointer; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 16px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .08s ease; }
.btn:active { transform: scale(.96); }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.big { width: 100%; padding: 15px; font-size: 16px; font-weight: 600; margin-top: 8px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.field { width: 100%; font: inherit; font-size: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); min-height: 44px; }
.field-label { display: block; font-size: 14px; margin: 16px 0 8px; color: var(--ink-soft); }
.quick-add { display: flex; gap: 8px; margin: 8px 0 8px; }
.quick-add input { flex: 1; font: inherit; font-size: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); min-height: 44px; }
.quick-add .btn { font-size: 20px; padding: 10px 16px; width: 44px; }

/* hero */
.hero { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 20px; text-align: center; box-shadow: 0 10px 30px -22px rgba(0,0,0,.4); }
.greeting { font-family: var(--font-heading); font-size: 24px; font-weight: 600; margin: 0; }
.hero .affirm { color: var(--ink-soft); font-size: 16px; font-style: italic; margin: 8px 0 0; }
.intent-pill { display: inline-block; margin-top: 12px; background: var(--surface-2); color: var(--ink-soft); font-size: 12px; padding: 6px 12px; border-radius: 999px; }

/* self-care */
.selfcare { display: flex; gap: 8px; margin: 16px 0 8px; }
.care { flex: 1; font: inherit; font-size: 13px; padding: 12px 8px; min-height: 44px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; transition: transform .08s; }
.care:active { transform: scale(.95); }
.care.on { background: var(--surface-2); border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.care .ic { width: 20px; height: 20px; color: var(--primary); }

/* lists */
.list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.item { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.item.done { opacity: .6; }
.item.done .item-text { text-decoration: line-through; color: var(--ink-soft); }
.item-check { width: 44px; height: 44px; border-radius: 50%; flex: 0 0 auto; border: 2px solid var(--primary); background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--primary-ink); transition: transform .12s, background .12s; }
.item-check .ic { width: 18px; height: 18px; }
.item.done .item-check { background: var(--primary); animation: pop .25s ease; }
@keyframes pop { 0% { transform: scale(.6);} 60% { transform: scale(1.15);} 100% { transform: scale(1);} }
.item-text { flex: 1; font-size: 16px; word-break: break-word; }
.item-actions { display: flex; gap: 8px; }
.mini { font-size: 12px; padding: 0 14px; min-height: 44px; min-width: 44px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.mini .ic { width: 16px; height: 16px; }
.empty { color: var(--ink-soft); text-align: center; padding: 24px 10px; font-style: italic; }

/* habits + garden */
#garden { width: 100%; height: 200px; display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; }
.habit { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 14px; cursor: pointer; }
.habit.done { border-color: var(--good); box-shadow: inset 0 0 0 1px var(--good); }
.habit-em { font-size: 22px; }
.habit-name { flex: 1; font-size: 16px; }
.habit-streak { font-size: 13px; color: var(--ink-soft); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.habit-streak .ic { width: 14px; height: 14px; color: var(--danger); }
.habit-water { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--good); background: transparent; display: grid; place-items: center; color: var(--good); flex: 0 0 auto; cursor: pointer; padding: 0; }
.habit-water .ic { width: 18px; height: 18px; }
.habit.done .habit-water { background: var(--good); color: var(--primary-ink); }
.habit .x { background: none; border: none; color: var(--ink-soft); cursor: pointer; width: 44px; height: 44px; display: grid; place-items: center; flex: 0 0 auto; }
.habit .x .ic { width: 18px; height: 18px; }

/* week plan */
.day-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.day-top { display: flex; align-items: center; justify-content: space-between; }
.day-name { font-weight: 600; }
.day-name.today { color: var(--primary); }
.day-count { font-size: 12px; color: var(--ink-soft); }
.day-tasks { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.day-task { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.day-task .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.day-task.done { color: var(--ink-soft); text-decoration: line-through; }
.day-add { margin-top: 8px; display: flex; gap: 8px; }
.day-add input { flex: 1; font: inherit; font-size: 14px; padding: 8px 10px; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--ink); }
.day-add .mini { min-width: 44px; }

/* reflect */
.mood-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.mood-label { font-size: 14px; color: var(--ink-soft); }
.mood-pick { display: flex; gap: 8px; }
.mood-btn { font: inherit; font-size: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 50%; width: 44px; height: 44px; cursor: pointer; }
.mood-btn.on { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); transform: scale(1.05); }
#reflect-fields textarea { width: 100%; font: inherit; font-size: 15px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); margin-bottom: 8px; resize: vertical; min-height: 56px; }
.reflect-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; }
.reflect-item .rdate { font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; }

/* wins */
.stats { display: flex; gap: 8px; margin-bottom: 8px; }
.stat { flex: 1; background: var(--surface-2); border-radius: var(--radius-sm); padding: 16px 8px; text-align: center; }
.stat-n { display: block; font-size: 26px; font-weight: 800; }
.stat-l { font-size: 11px; color: var(--ink-soft); }
#activity-chart { width: 100%; height: 120px; display: block; }
.soft-note { margin-top: 16px; }

/* settings */
.setting-group { margin: 24px 0; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.setting-group h2 { font-size: 16px; margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 15px; padding: 6px 0; min-height: 44px; }
.toggle input { width: 20px; height: 20px; accent-color: var(--primary); }
.theme-picker { display: flex; gap: 12px; flex-wrap: wrap; }
.swatch { width: 44px; height: 44px; border-radius: 14px; border: 2px solid var(--line); cursor: pointer; }
.swatch[aria-pressed="true"] { outline: 4px solid var(--primary); outline-offset: 2px; }
.version { color: var(--ink-soft); font-size: 12px; text-align: center; margin-top: 16px; }
.affirm { color: var(--ink-soft); font-size: 15px; text-align: center; font-style: italic; }

/* tip card */
.tip-card { display: flex; width: 100%; gap: 8px; align-items: flex-start; text-align: left; font: inherit; background: var(--surface); border: 1px solid var(--line); box-shadow: inset 3px 0 0 var(--accent); border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 16px; font-size: 14px; color: var(--ink-soft); line-height: 1.5; cursor: pointer; min-height: 44px; }
.tip-card .tip-ic { margin-top: 1px; }
.tip-card:focus-visible, .care:focus-visible, .mood-btn:focus-visible, .habit-water:focus-visible, .habit:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* tabbar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: var(--maxw); z-index: 20; display: flex; background: var(--surface); border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -6px 24px -18px rgba(0,0,0,.5); }
.tab { flex: 1; background: none; border: none; cursor: pointer; color: var(--ink-soft); min-height: 48px; padding: 8px 2px 7px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font: inherit; font-size: 10px; }
.tab[aria-current="true"] { color: var(--primary); font-weight: 600; }
.tab:active { transform: scale(.92); }

/* overlay / sheet */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.42); display: flex; align-items: center; justify-content: center; padding: 16px; }
.sheet { position: relative; background: var(--surface); width: 100%; max-width: var(--maxw); border-radius: 24px; max-height: 88vh; overflow-y: auto; padding: 24px 24px calc(24px + env(safe-area-inset-bottom)); animation: rise .3s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet h2 { font-family: var(--font-heading); margin: 8px 0; font-size: 22px; }
.sheet-sm { max-width: 380px; text-align: center; }
.sheet-sm .sheet-icon { margin-left: auto; margin-right: auto; }
.sheet-close { position: absolute; top: 12px; right: 12px; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); cursor: pointer; display: grid; place-items: center; }
.legend-help { list-style: none; padding: 0; margin: 8px 0; }
.legend-help li { font-size: 14px; line-height: 1.5; padding: 8px 0; border-bottom: 1px solid var(--line); }

/* fab + banner + toast */
.help-fab { position: fixed; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 25; width: 44px; height: 44px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); color: var(--primary); cursor: pointer; display: grid; place-items: center; box-shadow: 0 6px 18px -8px rgba(0,0,0,.5); }
/* Fixed overlay (not in normal flow) so the install prompt appearing/disappearing
   never pushes the rest of the page and never contributes to CLS. */
.banner { position: fixed; top: 0; left: 0; right: 0; z-index: 40; background: var(--primary); color: var(--primary-ink); padding: 12px 16px; font-size: 14px; text-align: center; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; box-shadow: 0 6px 18px -8px rgba(0,0,0,.4); }
.banner button { background: var(--primary-ink); color: var(--primary); border: none; border-radius: 8px; padding: 8px 12px; min-height: 40px; font: inherit; cursor: pointer; }
.banner .close { background: transparent; color: var(--primary-ink); width: 40px; height: 40px; padding: 0; display: grid; place-items: center; }
.banner .close .ic { width: 18px; height: 18px; }
.toast { position: fixed; left: 50%; bottom: 98px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 999px; font-size: 14px; z-index: 70; max-width: 90%; text-align: center; box-shadow: 0 10px 30px -10px rgba(0,0,0,.5); }

/* visually-hidden helper — used for canvas captions read by screen readers */
.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; }

/* Small layout utilities (replace the inline style="" attributes the previous
   markup used, per html-validate's no-inline-style rule). */
#add-habit, #save-you { margin-top: 8px; }
.confirm-actions { margin-top: 16px; }
.btn-flex { flex: 1; }
