/* mentalme · Celadon
   Register: instrument (an everyday app), mobile first.
   Ground: a celadon glaze in rain light. Ink: deep glaze green. Accent: the teak
   tray the cup sits on, spent only on the one action that commits something.
   Components read tokens only; colour literals live in :root and nowhere else. */

/* ---------- faces (self-hosted, split by script so Latin pages skip the Thai file) ---------- */
@font-face { font-family: "Sarabun"; font-style: normal; font-weight: 400; font-display: swap; src: url(/static/sarabun-latin-400.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Sarabun"; font-style: normal; font-weight: 400; font-display: swap; src: url(/static/sarabun-thai-400.woff2) format("woff2"); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Sarabun"; font-style: normal; font-weight: 600; font-display: swap; src: url(/static/sarabun-latin-600.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Sarabun"; font-style: normal; font-weight: 600; font-display: swap; src: url(/static/sarabun-thai-600.woff2) format("woff2"); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Sarabun"; font-style: normal; font-weight: 700; font-display: swap; src: url(/static/sarabun-latin-700.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Sarabun"; font-style: normal; font-weight: 700; font-display: swap; src: url(/static/sarabun-thai-700.woff2) format("woff2"); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Trirong"; font-style: normal; font-weight: 500; font-display: swap; src: url(/static/trirong-latin-500.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Trirong"; font-style: normal; font-weight: 500; font-display: swap; src: url(/static/trirong-thai-500.woff2) format("woff2"); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }

/* ---------- the design contract ---------- */
:root {
  /* ground and ink: never white, never black */
  --ground: #E9EFE8;      /* page: celadon glaze in rain light */
  --paper: #F6F9F5;       /* raised surface (cards, sheets) */
  --well: #DCE5DA;        /* inset: bubbles, tracks, segmented controls */
  --ink: #1F2E28;         /* deep glaze green */
  --ink-2: #405049;
  --ink-3: #56655D;       /* 5.3:1 on ground, 5.7:1 on paper */

  /* lines are the ink hue at low alpha, never neutral grey */
  --line: rgba(31, 46, 40, .12);
  --line-mid: rgba(31, 46, 40, .22);
  --line-strong: rgba(31, 46, 40, .42);

  /* brand glaze: marks, selection, the "you" bubble */
  --glaze: #5E8C76;
  --glaze-ink: #3D6654;   /* glaze as text: 5.6:1 on ground */
  --glaze-wash: #D3E2D6;

  /* the one accent: the teak tray. Only for the action that commits */
  --teak: #8C5A33;        /* 5.4:1 with paper text */
  --teak-hover: #74482A;
  --teak-wash: #F0E3D6;

  /* state as tokens: what stress level a colour means lives here only */
  --calm: #3D6654;
  --steady: #7A5F14;
  --strain: #9C3B26;
  --strain-wash: #F3DED7;

  /* activity categories: base for text and icon, wash for the chip */
  --cat-physical: #9A4A30;   --cat-physical-wash: #F2E2DA;
  --cat-rest: #3D6654;       --cat-rest-wash: #D9E7DC;
  --cat-deep: #3A5A80;       --cat-deep-wash: #DFE6EF;
  --cat-connection: #7A5F14; --cat-connection-wash: #F0E8D2;
  --cat-sleep: #565089;      --cat-sleep-wash: #E5E3F0;
  --cat-nourish: #93435F;    --cat-nourish-wash: #F2E0E7;
  --cat-other: #56655D;      --cat-other-wash: #E1E8DF;

  /* elevation as ring plus shadow */
  --lift-1: 0 0 0 1px rgba(31, 46, 40, .07), 0 1px 2px rgba(31, 46, 40, .05);
  --lift-2: 0 0 0 1px rgba(31, 46, 40, .05), 0 8px 20px rgba(31, 46, 40, .10);
  --lift-3: 0 18px 44px rgba(31, 46, 40, .20);
  --scrim: rgba(23, 34, 30, .56);
  --glass: rgba(23, 34, 30, .62);

  /* radius by role */
  --r-control: 10px;
  --r-card: 16px;
  --r-sheet: 22px;
  --r-commit: 999px;

  /* named z ladder */
  --z-bar: 45;
  --z-header: 50;
  --z-scrim: 60;
  --z-gate: 70;
  --z-skip: 80;

  /* type */
  --ui: "Sarabun", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Thai", sans-serif;
  --display: "Trirong", Georgia, "Noto Serif Thai", serif;
  --t-micro: .78rem;
  --t-meta: .875rem;
  --t-body: 1rem;
  --t-lede: 1.0625rem;
  --t-card: 1.0625rem;
  --t-sec: 1.25rem;
  --t-h1: 1.5rem;
  --t-greet: clamp(1.5rem, 1.15rem + 1.5vw, 2rem);
  --t-stat: 1.625rem;

  /* spacing, 4px base */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  /* layout and app chrome */
  --pad: clamp(16px, 4vw, 32px);
  --content: 1120px;
  --measure: 62ch;
  --header-h: 52px;
  --ticker-h: 34px;
  --tabbar-h: 60px;
  --rail-w: 232px;
  --tap: 44px;

  --ease: cubic-bezier(.23, 1, .32, 1);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--ui);
  font-size: var(--t-body);
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--glaze-ink); outline-offset: 2px; border-radius: var(--r-control); }
::selection { background: var(--glaze-wash); }

.skip { position: absolute; left: -999px; top: var(--s3); z-index: var(--z-skip); background: var(--paper); color: var(--ink); padding: var(--s2) var(--s3); border-radius: var(--r-control); }
.skip:focus { left: var(--s3); }

/* ---------- shell ---------- */
.rail { display: none; }
.frame { min-height: 100dvh; }

.topbar {
  position: sticky; top: 0; z-index: var(--z-header);
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: 0 var(--pad);
  background: var(--ground);
  border-bottom: 1px solid var(--line);
}
.topbar-tools { display: flex; align-items: center; gap: var(--s2); }

.brand { display: flex; align-items: center; gap: var(--s2); }
.brand-mark {
  width: 32px; height: 32px; border-radius: var(--r-control);
  display: grid; place-items: center;
  background: var(--glaze-wash); color: var(--glaze-ink);
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-name { font-family: var(--display); font-weight: 500; font-size: 1.25rem; letter-spacing: -.01em; color: var(--ink); }

.help-pill {
  white-space: nowrap;
  min-height: 36px; padding: 0 var(--s3);
  border-radius: var(--r-commit);
  border: 1px solid var(--line-mid);
  background: var(--strain-wash); color: var(--strain);
  font-size: var(--t-micro); font-weight: 700; letter-spacing: .01em;
}
.loc-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 var(--s3);
  border-radius: var(--r-commit); border: 1px solid var(--line-mid);
  background: var(--paper); color: var(--ink-2);
  font-size: var(--t-micro); font-weight: 600;
}
.ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* the ticker: location, weather and local time, always moving gently */
.ticker {
  height: var(--ticker-h);
  overflow: hidden;
  background: var(--glaze-wash);
  color: var(--ink-2);
  font-size: var(--t-micro); font-weight: 600;
  display: flex; align-items: center;
  border-bottom: 1px solid var(--line);
  -webkit-mask-image: linear-gradient(90deg, transparent, var(--ink) 6%, var(--ink) 94%, transparent);
          mask-image: linear-gradient(90deg, transparent, var(--ink) 6%, var(--ink) 94%, transparent);
  cursor: default;
}
.ticker-track { display: flex; width: max-content; animation: tick 80s linear infinite; }
.tk { white-space: nowrap; padding-right: var(--s7); }
.tk-sep { margin: 0 var(--s2); color: var(--ink-3); }
.tk-pin { color: var(--glaze-ink); }
.tk-time { color: var(--ink); font-weight: 700; }
@keyframes tick { to { transform: translateX(-50%); } }

.main {
  max-width: var(--content);
  margin: 0 auto;
  padding: var(--s5) var(--pad) calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s6));
}

/* ---------- greeting + week ---------- */
.greet { margin-bottom: var(--s5); }
.eyebrow {
  font-size: var(--t-micro); font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-3);
}
.greet-title {
  font-family: var(--display); font-weight: 500;
  font-size: var(--t-greet); line-height: 1.2; letter-spacing: -.01em;
  margin: var(--s2) 0 var(--s1);
  text-wrap: balance;
}
.greet-sub { color: var(--ink-2); font-size: var(--t-lede); }
.greet-meta { margin-top: var(--s1); color: var(--ink-3); font-size: var(--t-meta); }

.week-wrap { margin-top: var(--s4); }
.week-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s2); }
.week-label { font-size: var(--t-meta); font-weight: 600; color: var(--ink-2); }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--s1); }
.wk-day {
  min-height: 62px; padding: var(--s1) 0;
  border: 1px solid var(--line); border-radius: var(--r-control);
  background: var(--paper); color: var(--ink);
  display: grid; justify-items: center; align-content: center; gap: 2px;
  transition: transform .15s var(--ease), background .2s var(--ease);
}
.wk-day:active { transform: scale(.96); }
.wk-dow { font-size: var(--t-micro); color: var(--ink-3); font-weight: 600; }
.wk-num { font-size: var(--t-body); font-weight: 700; line-height: 1.1; }
.wk-dots { display: flex; gap: 3px; min-height: 6px; }
.wk-day.is-today { border-color: var(--glaze); box-shadow: inset 0 0 0 1px var(--glaze); }
.wk-day.is-selected { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.wk-day.is-selected .wk-dow { color: var(--glaze-wash); }

/* dots shared by the week strip and the month grid */
.cal-dot { display: inline-block; width: 6px; height: 6px; border-radius: var(--r-commit); background: var(--glaze); }
.cal-dot.sky { background: var(--cat-deep); }
.cal-dot.amber { background: var(--teak); }
.wk-day.is-selected .cal-dot { box-shadow: 0 0 0 1px var(--paper); }

/* ---------- cards ---------- */
.card {
  background: var(--paper);
  border-radius: var(--r-card);
  box-shadow: var(--lift-1);
  padding: var(--s4);
}
.card + .card { margin-top: var(--s3); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.card-title { font-size: var(--t-card); font-weight: 700; color: var(--ink); }
.card-sub { display: block; font-size: var(--t-micro); color: var(--ink-3); font-weight: 600; }
.card-hint { font-size: var(--t-micro); color: var(--ink-3); margin-bottom: var(--s3); }
.card-danger { box-shadow: var(--lift-1), inset 3px 0 0 var(--strain); }

/* ---------- today layout ---------- */
.today { display: grid; gap: var(--s3); grid-template-areas: "checkin" "state" "plan"; }
.today > .card + .card { margin-top: 0; }
.checkin { grid-area: checkin; }
.state { grid-area: state; }
.plan { grid-area: plan; }

/* ---------- check-in ---------- */
.help-link { color: var(--strain); }
.chat-thread {
  display: flex; flex-direction: column; gap: var(--s2);
  max-height: min(44vh, 380px); min-height: 88px;
  overflow-y: auto; overscroll-behavior: contain;
  padding: var(--s1) 0 var(--s3);
}
.bubble {
  max-width: 86%;
  padding: var(--s2) var(--s3);
  border-radius: 14px;
  line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.bubble-bot { align-self: flex-start; background: var(--well); color: var(--ink); border-bottom-left-radius: var(--s1); }
.bubble-me { align-self: flex-end; background: var(--glaze-ink); color: var(--paper); border-bottom-right-radius: var(--s1); }
.chat-row { margin: 0; }
.chat-note { margin-top: var(--s2); font-size: var(--t-micro); color: var(--ink-3); }

/* disclosure: the long tail stays one tap away */
.fold { margin-top: var(--s3); border-top: 1px solid var(--line); }
.fold > summary {
  list-style: none;
  display: flex; align-items: center; gap: var(--s2);
  min-height: var(--tap);
  font-size: var(--t-meta); font-weight: 600; color: var(--ink-2);
  cursor: pointer;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: "›"; margin-left: auto; font-size: 1.25rem; color: var(--ink-3); transition: transform .2s var(--ease); }
.fold[open] > summary::after { transform: rotate(90deg); }
.fold-count:not(:empty) {
  min-width: 22px; padding: 0 var(--s2);
  border-radius: var(--r-commit);
  background: var(--well); color: var(--ink-2);
  font-size: var(--t-micro); text-align: center;
}

/* ---------- how you are ---------- */
.live-pill { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-micro); font-weight: 700; color: var(--glaze-ink); text-transform: uppercase; letter-spacing: .1em; }
.live-dot { width: 7px; height: 7px; border-radius: var(--r-commit); background: var(--glaze); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.stress-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); }
.stress-heading { font-size: var(--t-meta); font-weight: 600; color: var(--ink-2); }
.stress-val { font-size: var(--t-sec); font-weight: 700; white-space: nowrap; }
#stress-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: var(--tap); margin: var(--s1) 0 0;
  background: transparent; cursor: grab;
}
#stress-slider::-webkit-slider-runnable-track { height: 8px; border-radius: var(--r-commit); background: linear-gradient(90deg, var(--calm), var(--steady) 55%, var(--strain)); }
#stress-slider::-moz-range-track { height: 8px; border-radius: var(--r-commit); background: linear-gradient(90deg, var(--calm), var(--steady) 55%, var(--strain)); }
#stress-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -9px; border-radius: var(--r-commit); background: var(--paper); border: 2px solid var(--ink); box-shadow: var(--lift-2); }
#stress-slider::-moz-range-thumb { width: 24px; height: 24px; border-radius: var(--r-commit); background: var(--paper); border: 2px solid var(--ink); box-shadow: var(--lift-2); }
#stress-slider:focus-visible { outline: 2px solid var(--glaze-ink); }
.stress-scale { display: flex; justify-content: space-between; font-size: var(--t-micro); color: var(--ink-3); }
.stress-hint { font-weight: 700; color: var(--teak); }

.seg-row { margin-top: var(--s4); }
.seg-label { display: block; font-size: var(--t-meta); font-weight: 600; color: var(--ink-2); margin-bottom: var(--s2); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 3px; background: var(--well); border-radius: var(--r-control); }
.tap {
  min-height: 40px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink-2);
  font-size: var(--t-meta); font-weight: 600;
}
.tap-active { background: var(--paper); color: var(--ink); box-shadow: var(--lift-1); }

.cap { margin-top: var(--s4); }
.cap-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); font-size: var(--t-meta); }
#cap-pct { font-weight: 700; }
.cap-status {
  font-size: var(--t-micro); font-weight: 700;
  padding: 2px var(--s2); border-radius: var(--r-commit);
  background: var(--glaze-wash); color: var(--calm);
}
.cap-status.warn { background: var(--strain-wash); color: var(--strain); }
.cap-status.good { background: var(--glaze-wash); color: var(--calm); }
.cap-bar { height: 8px; margin: var(--s2) 0; border-radius: var(--r-commit); background: var(--well); overflow: hidden; }
.cap-fill { height: 100%; width: 0; background: var(--glaze); transition: width 1s linear; }
.cap-row-quiet { color: var(--ink-3); }
.cap-remain { font-weight: 700; color: var(--ink-2); }
.cap-why { margin-top: var(--s2); font-size: var(--t-micro); color: var(--ink-3); }
.cap-note {
  display: flex; gap: var(--s2); align-items: flex-start;
  margin-top: var(--s3); padding: var(--s2) var(--s3);
  border-radius: var(--r-control);
  background: var(--teak-wash); color: var(--ink);
  font-size: var(--t-meta);
}
.cap-note svg { margin-top: 3px; flex-shrink: 0; }
.cap-buffer { margin-top: var(--s2); }
.state-foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap;
  margin-top: var(--s4); padding-top: var(--s3);
  border-top: 1px solid var(--line);
}

/* ---------- plan + activity cards ---------- */
.add-btn {
  display: inline-flex; align-items: center; gap: var(--s1);
  min-height: 40px; padding: 0 var(--s3);
  border-radius: var(--r-commit);
  border: 1px solid var(--line-mid);
  background: var(--paper); color: var(--ink);
  font-size: var(--t-meta); font-weight: 700;
}
.add-btn span { font-size: 1.2rem; line-height: 1; color: var(--teak); }

.activity {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center; gap: var(--s3);
  padding: var(--s3);
  margin-bottom: var(--s2);
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--paper);
  cursor: pointer;
  transition: transform .15s var(--ease), box-shadow .2s var(--ease);
}
.activity:hover { box-shadow: var(--lift-2); }
.activity:active { transform: scale(.98); }
.act-check {
  position: relative;
  width: 26px; height: 26px; padding: 0;
  border-radius: var(--r-commit);
  border: 2px solid var(--line-strong); background: transparent;
}
.act-check::before { content: ""; position: absolute; inset: -9px; } /* thumb-sized target around a small circle */
.act-check.checked { background: var(--glaze); border-color: var(--glaze); }
.act-check.checked::after {
  content: ""; position: absolute; left: 7px; top: 3px; width: 6px; height: 11px;
  border: solid var(--paper); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.act-icon {
  width: 40px; height: 40px; border-radius: var(--r-control);
  display: grid; place-items: center;
  color: var(--c, var(--cat-other)); background: var(--cw, var(--cat-other-wash));
}
.act-icon svg { width: 22px; height: 22px; }
.act-titlerow { display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--s2); }
.act-name { font-weight: 700; }
.act-tag {
  font-size: var(--t-micro); font-weight: 700;
  padding: 0 var(--s2); border-radius: var(--r-commit);
  color: var(--c, var(--cat-other)); background: var(--cw, var(--cat-other-wash));
}
.act-desc { margin-top: 2px; font-size: var(--t-micro); color: var(--ink-3); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.act-right { display: flex; align-items: center; gap: var(--s2); text-align: right; }
.act-time { font-weight: 700; font-size: var(--t-meta); }
.act-dur { font-size: var(--t-micro); color: var(--ink-3); }
.act-chev { color: var(--ink-3); font-size: 1.25rem; }
.activity.is-done .act-name { text-decoration: line-through; color: var(--ink-3); }

.cat-physical { --c: var(--cat-physical); --cw: var(--cat-physical-wash); }
.cat-rest { --c: var(--cat-rest); --cw: var(--cat-rest-wash); }
.cat-deep { --c: var(--cat-deep); --cw: var(--cat-deep-wash); }
.cat-connection { --c: var(--cat-connection); --cw: var(--cat-connection-wash); }
.cat-sleep { --c: var(--cat-sleep); --cw: var(--cat-sleep-wash); }
.cat-nourish { --c: var(--cat-nourish); --cw: var(--cat-nourish-wash); }
.cat-other { --c: var(--cat-other); --cw: var(--cat-other-wash); }

.empty {
  padding: var(--s4); text-align: center;
  font-size: var(--t-meta); color: var(--ink-3);
  border: 1px dashed var(--line-mid); border-radius: 14px;
}

/* ---------- buttons ---------- */
.btn-primary {
  min-height: var(--tap); padding: 0 var(--s5);
  border: 0; border-radius: var(--r-commit);
  background: var(--teak); color: var(--paper);
  font-size: var(--t-meta); font-weight: 700;
  transition: background .2s var(--ease), transform .15s var(--ease);
}
.btn-primary:hover { background: var(--teak-hover); }
.btn-primary:active, .btn-ghost:active { transform: scale(.97); }
.btn-primary:disabled { opacity: .55; cursor: default; }
.btn-ghost {
  min-height: var(--tap); padding: 0 var(--s4);
  border: 1px solid var(--line-mid); border-radius: var(--r-commit);
  background: var(--paper); color: var(--ink);
  font-size: var(--t-meta); font-weight: 600;
  transition: transform .15s var(--ease), border-color .2s var(--ease);
}
.btn-ghost:hover { border-color: var(--line-strong); }
.btn-danger {
  min-height: var(--tap); padding: 0 var(--s4);
  border: 1px solid var(--strain); border-radius: var(--r-commit);
  background: transparent; color: var(--strain);
  font-size: var(--t-meta); font-weight: 700;
}
.btn-block { display: block; width: 100%; margin-top: var(--s2); }
.link-btn {
  border: 0; background: none; padding: var(--s2) 0;
  color: var(--glaze-ink); font-size: var(--t-meta); font-weight: 700;
}
.btn-send { padding: 0 var(--s5); }

/* ---------- forms ---------- */
input[type="text"], input[type="password"], input[type="time"], textarea, .select {
  width: 100%; min-height: 46px;
  padding: 0 var(--s3);
  border: 1px solid var(--line-mid); border-radius: var(--r-control);
  background: var(--paper); color: var(--ink);
  font: inherit; font-size: 16px; /* 16px stops iOS zooming into the field */
}
textarea { padding: var(--s2) var(--s3); resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:focus, textarea:focus, .select:focus { outline: none; border-color: var(--glaze-ink); box-shadow: 0 0 0 3px var(--glaze-wash); }
.select {
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2356655D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--s3) center;
  padding-right: var(--s7);
}
.row { display: flex; gap: var(--s2); margin: var(--s3) 0; }
.row input { flex: 1; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.form-grid { display: grid; gap: var(--s3); margin: var(--s3) 0 var(--s2); }
.modal-label { font-size: var(--t-micro); font-weight: 700; color: var(--ink-2); letter-spacing: .02em; }
.field-label { font-size: var(--t-meta); color: var(--ink-2); margin-top: var(--s1); }
.auth-error { font-size: var(--t-meta); color: var(--strain); font-weight: 600; }

/* ---------- views ---------- */
.view-h { font-size: var(--t-h1); font-weight: 700; letter-spacing: -.01em; margin-bottom: var(--s1); }
.view-p { font-size: var(--t-meta); color: var(--ink-2); margin-bottom: var(--s4); max-width: var(--measure); }
.back { border: 0; background: none; padding: 0; min-height: 36px; color: var(--ink-2); font-size: var(--t-meta); font-weight: 700; margin-bottom: var(--s1); }
.tiny { font-size: var(--t-micro); color: var(--ink-3); margin-top: var(--s3); max-width: var(--measure); }
.section-title { font-size: var(--t-meta); font-weight: 700; color: var(--ink-2); margin: var(--s4) 0 var(--s2); }

/* calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s3); }
.cal-nav { width: var(--tap); height: var(--tap); border-radius: var(--r-commit); border: 1px solid var(--line-mid); background: var(--paper); font-size: 1.25rem; }
.cal-month { font-weight: 700; font-size: var(--t-card); }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: var(--t-micro); font-weight: 700; color: var(--ink-3); margin-bottom: var(--s1); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--s1); }
.cal-cell {
  min-height: var(--tap); aspect-ratio: 1 / .92;
  border: 0; border-radius: var(--r-control);
  background: var(--ground); color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: var(--t-meta); font-weight: 700;
}
.cal-cell.empty { background: transparent; }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--glaze); }
.cal-cell.selected { background: var(--ink); color: var(--paper); }
.cal-dots { display: flex; gap: 3px; }
.cal-key { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); margin-top: var(--s3); font-size: var(--t-micro); color: var(--ink-3); }
.cal-key .cal-dot { margin-right: 6px; vertical-align: middle; }
#calendar-detail { margin-top: var(--s3); }
#calendar-detail .btn-block { margin-top: var(--s3); }

.day-card { background: var(--paper); border-radius: var(--r-card); box-shadow: var(--lift-1); padding: var(--s4); }
.day-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s2); }
.day-label { font-weight: 700; }
.day-mood { margin-left: var(--s2); font-size: var(--t-micro); font-weight: 700; padding: 1px var(--s2); border-radius: var(--r-commit); background: var(--teak-wash); color: var(--teak); }
.day-meta { font-size: var(--t-micro); color: var(--ink-3); font-weight: 600; }
.htask { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) 0; border-top: 1px solid var(--line); font-size: var(--t-meta); }
.tick { color: var(--glaze-ink); font-weight: 700; }
.untick { color: var(--ink-3); }
.htask-name { flex: 1; }
.htask-done .htask-name { text-decoration: line-through; color: var(--ink-3); }
.htask-time { font-size: var(--t-micro); color: var(--ink-3); }
.hjournal { margin-top: var(--s3); padding-top: var(--s2); border-top: 1px solid var(--line); }
.hj-a { font-size: var(--t-meta); }
.hj-q { font-size: var(--t-micro); color: var(--ink-3); margin-bottom: var(--s2); }

/* journal */
.journal-day { background: var(--paper); border-radius: var(--r-card); box-shadow: var(--lift-1); padding: var(--s3) var(--s4); margin-bottom: var(--s3); }
.journal-day-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; padding-bottom: var(--s2); }
.journal-day-head span { font-size: var(--t-micro); color: var(--ink-3); font-weight: 600; }
.journal-item { padding: var(--s2) 0; border-top: 1px solid var(--line); }
.journal-when { font-size: var(--t-micro); color: var(--ink-3); font-weight: 700; }
.journal-prompt { font-size: var(--t-micro); color: var(--ink-3); }
.journal-answer { white-space: pre-wrap; overflow-wrap: anywhere; }
#journal-list .empty { margin-bottom: var(--s3); }

/* progress */
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); margin-bottom: var(--s3); }
.stat { background: var(--paper); border-radius: var(--r-card); box-shadow: var(--lift-1); padding: var(--s3); }
.stat-num { font-size: var(--t-stat); font-weight: 700; line-height: 1.1; }
.stat-label { font-size: var(--t-micro); color: var(--ink-3); font-weight: 600; }
.bars { display: flex; align-items: flex-end; gap: var(--s2); height: 140px; padding-top: var(--s3); }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.bar { width: 100%; max-width: 30px; min-height: 3px; border-radius: 6px 6px 2px 2px; background: var(--glaze); }
.bar-day { margin-top: 6px; font-size: var(--t-micro); color: var(--ink-3); font-weight: 600; }

/* you */
.me { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s3); }
.me-badge {
  width: 52px; height: 52px; flex-shrink: 0;
  border-radius: var(--r-card);
  display: grid; place-items: center;
  background: var(--glaze-wash); color: var(--glaze-ink);
  font-family: var(--display); font-size: var(--t-sec); font-weight: 500;
}
.me-name { font-size: var(--t-sec); font-weight: 700; }
.me-since { font-size: var(--t-micro); color: var(--ink-3); font-weight: 600; }
.me-bio { margin-top: 2px; font-size: var(--t-meta); color: var(--ink-2); }
.menu { margin-top: var(--s3); background: var(--paper); border-radius: var(--r-card); box-shadow: var(--lift-1); overflow: hidden; }
.menu-row {
  width: 100%; min-height: 60px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: var(--s3);
  padding: var(--s3) var(--s4);
  border: 0; border-bottom: 1px solid var(--line); background: transparent;
  text-align: left;
}
.menu-row:last-child { border-bottom: 0; }
.menu-row > span:first-child { font-weight: 700; }
.menu-meta { grid-column: 1; font-size: var(--t-micro); color: var(--ink-3); }
.menu-chev { grid-column: 2; grid-row: 1 / span 2; color: var(--ink-3); font-size: 1.25rem; }

/* community */
.empty-lg { text-align: left; }
.empty-title { font-weight: 700; margin-bottom: var(--s1); }
.empty-text { font-size: var(--t-meta); color: var(--ink-2); max-width: var(--measure); }

/* help */
.help-item { background: var(--paper); border-radius: var(--r-card); box-shadow: var(--lift-1); padding: var(--s3) var(--s4); margin-bottom: var(--s2); }
.help-q { font-weight: 700; margin-bottom: 2px; }
.help-a { font-size: var(--t-meta); color: var(--ink-2); max-width: var(--measure); }

/* ---------- tab bar (phones) ---------- */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: var(--z-bar);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--paper);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 18px rgba(31, 46, 40, .06);
}
.tab {
  position: relative;
  display: grid; place-items: center; align-content: center; gap: 2px;
  min-height: 48px; border: 0; background: none;
  color: var(--ink-3); font-size: var(--t-micro); font-weight: 600;
}
.tab[aria-current="page"] { color: var(--ink); font-weight: 700; }
.tab[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px;
  border-radius: 0 0 3px 3px; background: var(--teak);
}
.ni { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- overlays and sheets ---------- */
.overlay {
  position: fixed; inset: 0; z-index: var(--z-scrim);
  background: var(--scrim);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 460px; max-height: 92dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--s3);
  padding: var(--s5) var(--s5) calc(var(--s5) + env(safe-area-inset-bottom));
  background: var(--paper);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  box-shadow: var(--lift-3);
  animation: rise .35s var(--ease);
}
.sheet-wide { max-width: 580px; }
.sheet-title { font-size: var(--t-sec); font-weight: 700; }
.sheet-text { font-size: var(--t-meta); color: var(--ink-2); }
.sheet .btn-block { margin-top: 0; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }

.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-x { width: 40px; height: 40px; border-radius: var(--r-commit); border: 1px solid var(--line-mid); background: var(--paper); font-size: 1.4rem; line-height: 1; }
.modal-body { display: flex; flex-direction: column; gap: var(--s3); }
.modal-two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin-top: var(--s2); }
.modal-foot-right { display: flex; gap: var(--s2); margin-left: auto; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip, .cat-chip {
  min-height: 36px; padding: 0 var(--s3);
  border-radius: var(--r-commit);
  border: 1px solid var(--line-mid);
  background: var(--paper); color: var(--ink-2);
  font-size: var(--t-micro); font-weight: 700;
}
.cat-chip { border-color: transparent; color: var(--c, var(--cat-other)); background: var(--cw, var(--cat-other-wash)); }
.cat-chip.cat-selected { box-shadow: inset 0 0 0 2px currentColor; }

.help-o-body { display: flex; flex-direction: column; gap: var(--s2); }
.help-res { background: var(--ground); border-radius: var(--r-control); padding: var(--s3); }
.help-res-name { font-weight: 700; }
.help-res-contact { font-size: var(--t-meta); color: var(--ink-2); }
.help-res-link { display: inline-block; margin-top: var(--s1); padding: var(--s1) 0; color: var(--glaze-ink); font-size: var(--t-meta); font-weight: 700; }

.sheet-breath { align-items: center; text-align: center; }
.breath-circle {
  width: 176px; height: 176px; margin: var(--s4) 0;
  border-radius: var(--r-commit);
  display: grid; place-items: center;
  background: radial-gradient(circle, var(--paper), var(--glaze-wash));
  border: 2px solid var(--glaze);
  color: var(--glaze-ink); font-weight: 700;
  transition: transform 4s ease-in-out;
}
.breath-timer { font-size: var(--t-h1); font-weight: 700; }

/* ---------- sign-in gate ---------- */
.gate {
  position: fixed; inset: 0; z-index: var(--z-gate);
  background: var(--ground);
  display: grid; grid-template-rows: minmax(190px, 36dvh) auto;
  overflow-y: auto;
}
.gate-photo { position: relative; margin: 0; overflow: hidden; background: var(--well); }
.gate-photo img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 62%; }
.prov {
  position: absolute; left: var(--s3); bottom: var(--s3);
  padding: var(--s1) var(--s3); border-radius: var(--r-commit);
  background: var(--glass); color: var(--paper);
  font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.gate-panel {
  width: 100%; max-width: 420px; margin: 0 auto;
  padding: var(--s5) var(--pad) var(--s6);
  display: flex; flex-direction: column; gap: var(--s3);
}
.gate-brand { margin-bottom: var(--s1); }
.gate-title { font-family: var(--display); font-weight: 500; font-size: var(--t-greet); line-height: 1.2; }
.gate-lead { color: var(--ink-2); }
.gate-panel .btn-block { margin-top: var(--s1); }
.auth-toggle { align-self: center; }
.gate-proof { margin-top: var(--s2); padding-top: var(--s3); border-top: 1px solid var(--line); font-size: var(--t-micro); color: var(--ink-3); }

/* ---------- landing page ---------- */
.landing { min-height: 100dvh; display: grid; grid-template-rows: minmax(240px, 46dvh) auto; }
.landing .gate-photo { min-height: 240px; }
.landing-copy { width: 100%; max-width: 520px; margin: 0 auto; padding: var(--s5) var(--pad) var(--s7); display: flex; flex-direction: column; gap: var(--s3); }
.landing-title { font-family: var(--display); font-weight: 500; font-size: clamp(1.9rem, 1.3rem + 2.4vw, 2.75rem); line-height: 1.15; letter-spacing: -.015em; text-wrap: balance; }
.landing-lead { font-size: var(--t-lede); color: var(--ink-2); max-width: var(--measure); }
.facts { list-style: none; padding: 0; margin: var(--s2) 0; display: grid; gap: var(--s2); }
.facts li { padding: var(--s3) var(--s4); background: var(--paper); border-radius: var(--r-card); box-shadow: var(--lift-1); font-size: var(--t-meta); color: var(--ink-2); }
.facts strong { display: block; color: var(--ink); font-size: var(--t-body); }
.cta { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.landing-note { font-size: var(--t-micro); color: var(--ink-3); }

/* ---------- narrow phones ---------- */
@media (max-width: 599px) {
  .loc-btn span { display: none; }          /* the pin alone; the ticker also says "tap to enable location" */
  .loc-btn { padding: 0; width: 36px; justify-content: center; }
  .act-chev { display: none; }               /* titles need the width more than the arrow does */
}

/* ---------- wider screens ---------- */
@media (min-width: 600px) {
  .overlay { align-items: center; padding: var(--s5); }
  .sheet { border-radius: var(--r-sheet); padding-bottom: var(--s5); }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .card { padding: var(--s5); }
}

@media (min-width: 900px) {
  .tabbar { display: none; }
  .rail {
    display: flex; flex-direction: column; gap: var(--s4);
    position: fixed; top: 0; bottom: 0; left: 0; width: var(--rail-w);
    padding: var(--s5) var(--s3);
    background: var(--paper);
    border-right: 1px solid var(--line);
  }
  .rail .brand { padding: 0 var(--s2) var(--s2); }
  .rail-nav { display: flex; flex-direction: column; gap: 2px; }
  .rail-nav .nav-item {
    display: flex; align-items: center; gap: var(--s3);
    width: 100%; min-height: var(--tap); padding: 0 var(--s3);
    border: 0; border-radius: var(--r-control); background: none;
    color: var(--ink-2); font-size: var(--t-meta); font-weight: 600; text-align: left;
  }
  .rail-nav .nav-item:hover { background: var(--ground); }
  .rail-nav .nav-item[aria-current="page"] { background: var(--glaze-wash); color: var(--ink); font-weight: 700; }
  .rail-nav .nav-quiet { color: var(--ink-3); font-weight: 500; }
  .rail-nav .ni { width: 20px; height: 20px; }
  .rail-rule { height: 1px; background: var(--line); margin: var(--s2) var(--s3); }
  .rail-note { margin-top: auto; padding: var(--s3); font-size: var(--t-micro); color: var(--ink-3); }
  .rail-note strong { color: var(--strain); }

  .frame { margin-left: var(--rail-w); }
  .brand-top { visibility: hidden; }
  .main { padding-bottom: var(--s7); }
  .menu { display: none; } /* the rail already lists these */

  .today { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); grid-template-areas: "checkin state" "plan state"; align-items: start; }
  .state { position: sticky; top: calc(var(--header-h) + var(--s4)); }
  .chat-thread { max-height: 420px; }

  .gate { grid-template-rows: none; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
  .gate-panel { align-self: center; }
  .landing { grid-template-rows: none; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .landing .gate-photo { min-height: 100dvh; position: sticky; top: 0; }
  .landing-copy { align-self: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .ticker { overflow-x: auto; -webkit-mask-image: none; mask-image: none; }
  .ticker-track { animation: none; }
}
