/* =========================================================
   F*** YEAH · The One Minute Diary
   One material, four forms: .m-raised, .m-key, .m-well, .m-ink.
   Every shadow token derives from the light direction (--lx, --ly),
   which light.js moves. One theme, one material: fabric pushed up or pressed in.
   Vibe colors only appear as solid marks: LEDs, numbers, the picked face, the graph.
   One typeface: Montserrat Light (300) and Bold (700).
   ========================================================= */

:root {
  /* Light direction in screen space (-1…1). Top-left by default. */
  --lx: -0.7;
  --ly: -0.7;
  --light-angle: 135deg;

  --font-head: 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
  --font-body: 'Montserrat', 'Helvetica Neue', Arial, sans-serif;

  --radius: 26px;
  --radius-m: 18px;
  --radius-s: 13px;
  --gutter: 16px;
  --key-size: 44px; /* every small round key: top bar, arrows, mic */
  --ease-press: cubic-bezier(.3, .7, .4, 1.4);
  --ease-out: cubic-bezier(.2, .8, .2, 1);
}

/* ---------- Color: cool porcelain (the one theme) ---------- */

:root {
  color-scheme: light;
  --base: #dde1e8;
  --text: #16181c;
  --muted: #555c68;
  --faint: #b3bac6;
  --ink-top: #3b3f47;
  --ink-bottom: #121316;
  --on-ink: #f1f3f6;
  --neg: #e3186d;
  --zero: #6345ff;
  --pos: #00b2a3;
  /* Vibe colors as text: darker so numbers keep 4.5:1 on --base */
  --neg-ink: #bf155c;
  --zero-ink: #5d41f0;
  --pos-ink: #006d64;
  --focus: #16181c;
  --scrim: rgb(40 46 58 / .3);

  /* ---------- The material: fabric ----------
     Everything raised is the background pushed up from below; everything
     sunk is pressed in. One recipe, scaled by depth d (px):
       shoulder  inset ±0.35d, blur 0.9d  (the soft fillet on the face, never a line)
       crease    ±0.25d, blur 0.6d        (where the fabric meets the background)
       slope     ±0.9d, blur 2.2d         (short: it sits in the surface, it does not float)
     Shadow falls away from the light, highlight toward it (--lx, --ly, moved by light.js).
     Knobs (tuned in lab.html): --depth, --shadow-a, --highlight-a, --shoulder. */
  --depth: .6;
  --shadow-a: .38;
  --highlight-a: 1;
  --shoulder: .05;
  --shadow: rgb(138 149 170 / var(--shadow-a));
  --crease: rgb(120 131 152 / calc(var(--shadow-a) * .7));
  --crease-in: rgb(120 131 152 / calc(var(--shadow-a) * .5));
  --highlight: rgb(255 255 255 / var(--highlight-a));
  --shoulder-light: rgb(255 255 255 / calc(.75 * var(--shoulder)));
  --shoulder-dark: rgb(138 149 170 / calc(.45 * var(--shoulder)));

  /* Faces: a convex roll, lighter toward the light */
  --face: linear-gradient(var(--light-angle),
    color-mix(in srgb, var(--base), #fff 45%),
    var(--base) 52%,
    color-mix(in srgb, var(--base), #7d889c 12%));
  --face-dome: radial-gradient(circle at calc(50% + var(--lx) * 30%) calc(50% + var(--ly) * 30%),
    color-mix(in srgb, var(--base), #fff 70%),
    var(--base) 55%,
    color-mix(in srgb, var(--base), #7d889c 16%));

  /* Depth tiers */
  --sh-raised:
    inset calc(var(--lx) * var(--depth) * -4.2px) calc(var(--ly) * var(--depth) * -4.2px) calc(var(--depth) * 10.8px) var(--shoulder-light),
    inset calc(var(--lx) * var(--depth) * 4.2px) calc(var(--ly) * var(--depth) * 4.2px) calc(var(--depth) * 10.8px) var(--shoulder-dark),
    calc(var(--lx) * var(--depth) * -3px) calc(var(--ly) * var(--depth) * -3px) calc(var(--depth) * 7.2px) var(--crease),
    calc(var(--lx) * var(--depth) * 3px) calc(var(--ly) * var(--depth) * 3px) calc(var(--depth) * 7.2px) var(--highlight),
    calc(var(--lx) * var(--depth) * -10.8px) calc(var(--ly) * var(--depth) * -10.8px) calc(var(--depth) * 26.4px) var(--shadow),
    calc(var(--lx) * var(--depth) * 10.8px) calc(var(--ly) * var(--depth) * 10.8px) calc(var(--depth) * 26.4px) var(--highlight);
  --sh-float:
    inset calc(var(--lx) * var(--depth) * -6.3px) calc(var(--ly) * var(--depth) * -6.3px) calc(var(--depth) * 16.2px) var(--shoulder-light),
    inset calc(var(--lx) * var(--depth) * 6.3px) calc(var(--ly) * var(--depth) * 6.3px) calc(var(--depth) * 16.2px) var(--shoulder-dark),
    calc(var(--lx) * var(--depth) * -4.5px) calc(var(--ly) * var(--depth) * -4.5px) calc(var(--depth) * 10.8px) var(--crease),
    calc(var(--lx) * var(--depth) * 4.5px) calc(var(--ly) * var(--depth) * 4.5px) calc(var(--depth) * 10.8px) var(--highlight),
    calc(var(--lx) * var(--depth) * -16.2px) calc(var(--ly) * var(--depth) * -16.2px) calc(var(--depth) * 39.6px) var(--shadow),
    calc(var(--lx) * var(--depth) * 16.2px) calc(var(--ly) * var(--depth) * 16.2px) calc(var(--depth) * 39.6px) var(--highlight);
  --sh-dome:
    inset calc(var(--lx) * var(--depth) * -3.15px) calc(var(--ly) * var(--depth) * -3.15px) calc(var(--depth) * 8.1px) var(--shoulder-light),
    inset calc(var(--lx) * var(--depth) * 3.15px) calc(var(--ly) * var(--depth) * 3.15px) calc(var(--depth) * 8.1px) var(--shoulder-dark),
    calc(var(--lx) * var(--depth) * -2.25px) calc(var(--ly) * var(--depth) * -2.25px) calc(var(--depth) * 5.4px) var(--crease),
    calc(var(--lx) * var(--depth) * 2.25px) calc(var(--ly) * var(--depth) * 2.25px) calc(var(--depth) * 5.4px) var(--highlight),
    calc(var(--lx) * var(--depth) * -8.1px) calc(var(--ly) * var(--depth) * -8.1px) calc(var(--depth) * 19.8px) var(--shadow),
    calc(var(--lx) * var(--depth) * 8.1px) calc(var(--ly) * var(--depth) * 8.1px) calc(var(--depth) * 19.8px) var(--highlight);
  --sh-key:
    inset calc(var(--lx) * var(--depth) * -2.1px) calc(var(--ly) * var(--depth) * -2.1px) calc(var(--depth) * 5.4px) var(--shoulder-light),
    inset calc(var(--lx) * var(--depth) * 2.1px) calc(var(--ly) * var(--depth) * 2.1px) calc(var(--depth) * 5.4px) var(--shoulder-dark),
    calc(var(--lx) * var(--depth) * -1.5px) calc(var(--ly) * var(--depth) * -1.5px) calc(var(--depth) * 3.6px) var(--crease),
    calc(var(--lx) * var(--depth) * 1.5px) calc(var(--ly) * var(--depth) * 1.5px) calc(var(--depth) * 3.6px) var(--highlight),
    calc(var(--lx) * var(--depth) * -5.4px) calc(var(--ly) * var(--depth) * -5.4px) calc(var(--depth) * 13.2px) var(--shadow),
    calc(var(--lx) * var(--depth) * 5.4px) calc(var(--ly) * var(--depth) * 5.4px) calc(var(--depth) * 13.2px) var(--highlight);
  --sh-key-pressed:
    inset calc(var(--lx) * var(--depth) * -2.5px) calc(var(--ly) * var(--depth) * -2.5px) calc(var(--depth) * 5px) var(--shadow),
    inset calc(var(--lx) * var(--depth) * -1px) calc(var(--ly) * var(--depth) * -1px) calc(var(--depth) * 2px) var(--crease-in),
    inset calc(var(--lx) * var(--depth) * 2.5px) calc(var(--ly) * var(--depth) * 2.5px) calc(var(--depth) * 5px) var(--highlight);
  --sh-well:
    inset calc(var(--lx) * var(--depth) * -4px) calc(var(--ly) * var(--depth) * -4px) calc(var(--depth) * 8px) var(--shadow),
    inset calc(var(--lx) * var(--depth) * -1.6px) calc(var(--ly) * var(--depth) * -1.6px) calc(var(--depth) * 3.2px) var(--crease-in),
    inset calc(var(--lx) * var(--depth) * 4px) calc(var(--ly) * var(--depth) * 4px) calc(var(--depth) * 8px) var(--highlight);
  --sh-ink:
    calc(var(--lx) * var(--depth) * -1.25px) calc(var(--ly) * var(--depth) * -1.25px) calc(var(--depth) * 3px) var(--crease),
    calc(var(--lx) * var(--depth) * -4.5px) calc(var(--ly) * var(--depth) * -4.5px) calc(var(--depth) * 11px) var(--shadow),
    calc(var(--lx) * var(--depth) * 3px) calc(var(--ly) * var(--depth) * 3px) calc(var(--depth) * 7px) var(--highlight);
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--base); }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--base);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

h1, h2, h3 { font-family: var(--font-head); font-weight: 700; line-height: 1.1; margin: 0; letter-spacing: -.01em; }
b, strong { font-weight: 700; }
button { font: inherit; color: inherit; }
a { color: inherit; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

[hidden] { display: none !important; }

.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;
}

/* The room: the plain fabric everything is pushed out of */
.room { position: fixed; inset: 0; z-index: -1; pointer-events: none; background: var(--base); }

/* ---------- The four forms ---------- */

.m-raised {
  background: var(--face);
  border-radius: var(--radius);
  box-shadow: var(--sh-raised);
}

.m-key {
  background: var(--face);
  border: 0;
  box-shadow: var(--sh-key);
  transition: box-shadow .18s var(--ease-out), transform .2s var(--ease-press), color .2s;
}
.m-key:active:not(:disabled),
.m-key.is-pressed,
.m-key[aria-pressed="true"],
.m-key[aria-checked="true"] {
  box-shadow: var(--sh-key-pressed);
  background: var(--base);
}
.m-key:active:not(:disabled) { transform: scale(.97); }

.m-well {
  background: var(--base);
  border: 0;
  border-radius: var(--radius-m);
  box-shadow: var(--sh-well);
}

.m-ink {
  background: linear-gradient(var(--light-angle), var(--ink-top), var(--ink-bottom));
  color: var(--on-ink);
  border: 0;
  box-shadow: var(--sh-ink);
  transition: box-shadow .18s var(--ease-out), transform .2s var(--ease-press);
}
.m-ink:active:not(:disabled) { transform: scale(.97); box-shadow: var(--sh-key-pressed); }

/* ---------- Controls ---------- */

.btn {
  border-radius: 999px;
  padding: .75em 1.45em;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: .9rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.btn:disabled { opacity: .4; cursor: default; }
.btn-quiet { color: var(--muted); }
.btn-small { font-size: .76rem; padding: .6em 1.15em; }

.icon-btn {
  width: var(--key-size); height: var(--key-size); padding: 0;
  display: inline-grid; place-items: center;
  flex: none;
  border-radius: 50%;
}
.icon-btn svg, .mic-btn svg, .install-glyph svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.icon-btn-spacer { width: var(--key-size); flex: none; }

.input {
  width: 100%;
  padding: .85em 1.1em;
  border-radius: var(--radius-s);
  font: inherit;
  font-weight: 300;
  color: var(--text);
}
.input::placeholder { color: var(--muted); opacity: .85; }
.input:focus { outline: none; }
.input:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

/* LED: a tiny dot that takes its color when on */
.led {
  --c: var(--faint);
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--faint);
  box-shadow: inset 0 1px 1px rgb(0 0 0 / .2);
  transition: background .3s, box-shadow .3s;
}
.is-lit > .led, .led.is-lit {
  background: var(--c);
  box-shadow: none;
}

/* Segmented control: a well with one raised thumb */
.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 6px; gap: 4px; border-radius: 999px;
}
.segmented button {
  border: 0; background: transparent; border-radius: 999px;
  padding: .62em .4em; cursor: pointer;
  font-family: var(--font-head); font-weight: 700; font-size: clamp(.66rem, 3vw, .76rem); letter-spacing: .04em; text-transform: uppercase; white-space: nowrap;
  color: var(--muted);
  transition: box-shadow .22s var(--ease-out), color .2s, transform .15s var(--ease-press);
}
.segmented button:active { transform: scale(.96); }
.segmented button[aria-checked="true"],
.segmented button[aria-selected="true"] {
  color: var(--text);
  background: var(--face);
  box-shadow: var(--sh-key);
}

/* Switch: well track, key knob with a solid LED when on */
.switch {
  appearance: none; -webkit-appearance: none;
  flex: none; position: relative;
  width: 60px; height: 34px; margin: 0; border-radius: 999px; cursor: pointer;
  background: var(--base);
  box-shadow: var(--sh-well);
  transition: box-shadow .3s;
}
.switch::after {
  content: ''; position: absolute; top: 5px; left: 5px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--face);
  box-shadow: var(--sh-key);
  transition: transform .32s var(--ease-press);
}
.switch:checked::after { background: radial-gradient(circle, var(--pos) 0 3px, transparent 3.5px), var(--face); }
.switch:checked::after { transform: translateX(26px); }
.switch::after { transition: transform .32s var(--ease-press), background .2s; }

/* ---------- App shell ---------- */

#app { min-height: 100dvh; }

.view {
  min-height: 100dvh;
  padding: max(var(--gutter), env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) max(var(--gutter), env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  animation: view-in .35s var(--ease-out);
}
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1180px; margin: 0 auto 8px;
  min-height: 54px;
}
.topbar-actions { display: flex; gap: 12px; }
.view-day .topbar { justify-content: flex-end; }
.topbar-title { font-size: 1.15rem; text-align: center; }

.logo-bar { display: inline-block; width: 1.9em; height: .76em; margin-right: .14em; border-radius: 2px; }

/* ---------- Day view ---------- */

.day-layout {
  max-width: 1180px; margin: 0 auto;
  display: flex; flex-direction: column;
  min-height: calc(100dvh - 2 * var(--gutter) - 62px);
}

.greeting { position: relative; padding: 16px 4px 4px; }
.greeting-title { font-size: clamp(2.1rem, 8vw, 3rem); }
.greeting-sub { margin: .35em 0 0; font-size: 1.1rem; }
.saved-tick {
  position: absolute; right: 4px; top: 22px;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-head); font-weight: 700; font-size: .68rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); opacity: 0; transition: opacity .3s;
}
.saved-tick .led { --c: var(--pos); }
.saved-tick.is-visible { opacity: 1; }

.install-nag {
  margin: 14px 0 0; padding: 14px 16px 14px 18px;
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; justify-content: space-between;
  border-radius: var(--radius-m);
  font-size: .92rem;
}
.install-nag p { margin: 0; flex: 1 1 220px; }
.install-nag-actions { display: flex; gap: 12px; }

/* Cards: a swipeable carousel on phones. Generous padding: the shadows are long. */
.cards {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: min(84%, 380px);
  gap: 24px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  margin: 0 calc(-1 * var(--gutter));
  padding: 30px var(--gutter) 40px;
  scroll-padding-inline: var(--gutter);
  flex: 1 1 auto;
  min-height: 300px;
}
.cards::-webkit-scrollbar { display: none; }

/* Card = raised frame around a recessed well (the flint construction) */
.card {
  position: relative;
  scroll-snap-align: start;
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px 12px 12px;
  min-height: 270px;
}
.card-label {
  display: flex; align-items: center;
  padding: 2px 8px 0;
  font-family: var(--font-head); font-weight: 700; font-size: 1.3rem; line-height: 1.2; letter-spacing: -.01em;
  color: var(--text);
}
.censored { display: inline-flex; align-items: center; gap: .14em; letter-spacing: 0; vertical-align: -.08em; }
.censored .logo-bar { width: 1.9em; height: .76em; margin: 0; border-radius: 2px; }

.card-well {
  position: relative; flex: 1;
  display: flex;
  border-radius: calc(var(--radius) - 10px);
  overflow: hidden;
}
.card-text {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 150px;
  border: 0; outline: 0; resize: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.28rem;
  line-height: 1.36;
  padding: 18px 18px 64px;
}
.card-text::placeholder { color: var(--muted); font-weight: 300; opacity: 1; }
.card-text:focus::placeholder { opacity: .5; }
.card-well:focus-within { box-shadow: var(--sh-well), 0 0 0 2px var(--focus); }

.mic-btn {
  position: absolute; right: 12px; bottom: 12px;
  width: var(--key-size); height: var(--key-size); padding: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--muted);
}
.mic-btn.is-listening { color: var(--neg); }
.mic-btn.is-listening svg { filter: drop-shadow(0 0 5px var(--neg)); animation: listening 1.4s ease-in-out infinite; }
@keyframes listening { 50% { opacity: .55; } }

/* Vibe card: three raised domes right on the card. The picked one sinks. */
.card-vibe .card-question-full {
  display: block; padding: 2px 8px 0;
  font-family: var(--font-head); font-weight: 700; font-size: 1.3rem; line-height: 1.2; letter-spacing: -.01em; text-transform: none;
  color: var(--text);
}

.vibe-buttons {
  position: relative; flex: 1;
  display: flex; align-items: center; justify-content: space-around; gap: 10px;
  min-height: 130px;
  padding: 18px 10px 20px;
}
.vibe-btn {
  --c: var(--muted);
  background: var(--face-dome);
  box-shadow: var(--sh-dome);
  width: clamp(64px, 22%, 88px);
  aspect-ratio: 1;
  padding: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
}
.vibe-btn[data-vibe="-1"] { --c-ink: var(--neg-ink); }
.vibe-btn[data-vibe="0"]  { --c-ink: var(--zero-ink); }
.vibe-btn[data-vibe="1"]  { --c-ink: var(--pos-ink); }
.vibe-btn svg { display: block; width: 58%; height: auto; fill: currentColor; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; transition: color .3s; }
.vibe-btn svg path { fill: none; }
.vibe-btn[aria-checked="true"] svg { color: var(--c-ink); }
.vibe-btn[aria-checked="true"] { background: var(--base); box-shadow: var(--sh-key-pressed); }
/* The smiley never shrinks: the press is the inverted shadow alone */
.vibe-btn:active:not(:disabled) { transform: none; }

/* ---------- Calendar ---------- */

.calendar { margin-top: auto; }

.week-strip {
  display: grid; grid-template-columns: repeat(7, 1fr);
  margin: 4px calc(-1 * var(--gutter)) 22px;
  padding: 10px 8px 12px;
  border-radius: 0;
  touch-action: pan-y;
}

/* Day cells: plain engraved numbers. A rated day's number glows in its vibe color;
   the selected day pops up as a key. */
.day-cell, .month-day {
  --c: transparent;
  position: relative;
  border: 0; background: transparent; cursor: pointer;
  color: var(--text);
  transition: box-shadow .22s var(--ease-out), transform .18s var(--ease-press), background .3s;
}
.day-cell:active:not(:disabled), .month-day:active:not(:disabled) { transform: scale(.92); }
.day-cell:disabled, .month-day:disabled { cursor: default; opacity: .28; }
.lit-neg { --c: var(--neg); --c-ink: var(--neg-ink); }
.lit-zero { --c: var(--zero); --c-ink: var(--zero-ink); }
.lit-pos { --c: var(--pos); --c-ink: var(--pos-ink); }

.day-cell {
  display: grid; justify-items: center;
  padding: 7px 0 11px; margin: 0 3px;
  border-radius: 16px;
}
.day-cell .dow { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.day-cell .num { font-family: var(--font-head); font-weight: 700; font-size: 1.4rem; line-height: 1.15; }
.day-cell[class*="lit-"] .num, .month-day[class*="lit-"] { color: var(--c-ink); }
.day-cell.is-selected {
  background: var(--face);
  box-shadow: var(--sh-key);
}
.day-cell.is-today:not(.is-selected) .num { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }

.monthbar { display: flex; align-items: center; gap: 14px; }
.month-label {
  background: none; border: 0; cursor: pointer;
  display: grid; justify-items: center; line-height: 1.1; padding: 4px 6px;
  text-transform: uppercase; font-size: 1rem; letter-spacing: .03em;
}
.month-label b { font-family: var(--font-head); font-weight: 700; font-size: .88rem; }
.btn-today { margin-left: auto; padding-inline: 1.7em; }

/* Month panel: bottom sheet on phones/tablets, fixed panel on desktop */
.month-scrim {
  position: fixed; inset: 0; z-index: 20;
  background: var(--scrim);
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.month-panel {
  position: fixed; z-index: 21; left: 0; right: 0; bottom: 0;
  max-width: 560px; margin: 0 auto;
  padding: 20px 18px max(18px, env(safe-area-inset-bottom));
  border-radius: 30px 30px 0 0;
  box-shadow: var(--sh-float);
  transform: translateY(110%);
  transition: transform .38s var(--ease-out);
}
.calendar.month-open .month-scrim { opacity: 1; pointer-events: auto; }
.calendar.month-open .month-panel { transform: none; }

.month-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.month-title { font-size: 1.1rem; text-transform: uppercase; letter-spacing: .04em; text-align: center; }
.month-weekdays, .month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.month-weekdays span { text-align: center; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding-bottom: 4px; }

.month-day {
  aspect-ratio: 1;
  display: grid; place-items: center;
  border-radius: 14px;
  font-family: var(--font-head); font-weight: 700; font-size: 1rem;
}
.month-day.out { opacity: .35; }
.month-day.is-today { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }
.month-day.is-selected {
  background: var(--face);
  box-shadow: var(--sh-key);
}

.month-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; }
.legend { display: flex; align-items: center; gap: 7px; font-size: .66rem; letter-spacing: .08em; color: var(--muted); }
.legend .led { margin-left: 8px; }
.legend .led:first-child { margin-left: 0; }

/* ---------- Pages (graph, settings) ---------- */

.settings-tabs { position: sticky; top: max(10px, env(safe-area-inset-top)); z-index: 5; }
.tab-panel { display: grid; gap: 28px; }
.tab-panel[hidden] { display: none; }

.page { max-width: 720px; margin: 0 auto; padding: 8px 0 48px; display: grid; gap: 28px; }
.lede { margin: 6px 4px 0; font-size: 1.08rem; }

.graph-card { padding: 22px 18px 16px; display: grid; gap: 8px; }
.graph-readout { display: grid; gap: 4px; padding: 0 4px; }
.graph-trend {
  display: flex; align-items: center; gap: 6px; margin: 0;
  font-family: var(--font-head); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.graph-eyebrow { font-weight: 700; margin-right: 4px; }
.trend-arrow { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .3s var(--ease-out); }
.trend-dir { font-weight: 700; }
.trend-rate { letter-spacing: .04em; text-transform: none; }
.graph-trend[data-dir="up"] { color: var(--pos-ink); }
.graph-trend[data-dir="up"] .trend-arrow { transform: rotate(-40deg); }
.graph-trend[data-dir="down"] { color: var(--neg-ink); }
.graph-trend[data-dir="down"] .trend-arrow { transform: rotate(40deg); }
.graph-trend .graph-eyebrow { color: var(--muted); }
.graph-day { font-size: clamp(1.8rem, 7vw, 2.4rem); line-height: 1.1; }
.graph-vibe { margin: 0; min-height: 1.5em; font-size: 1rem; color: var(--muted); }
.graph-vibe .vibe-word { font-weight: 700; color: var(--c-ink); }
.graph { position: relative; border-radius: 14px; outline: none; }
.graph:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
.graph-svg { display: block; width: 100%; height: auto; overflow: visible; cursor: crosshair; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.graph-trend-line { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 6; stroke-linecap: round; }
.graph-line { fill: none; stroke: var(--text); stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.graph-tick { stroke: var(--faint); stroke-width: 1; }
.graph-tick.major { stroke: var(--muted); }
.graph-axis { fill: var(--muted); font-size: 11px; font-family: var(--font-body); }
.graph-scrub { pointer-events: none; }
.graph-scrub line { stroke: var(--text); stroke-width: 1; stroke-dasharray: 2 3; }
.graph-scrub circle { fill: var(--base); stroke: var(--text); stroke-width: 2.5; }
.graph-chip {
  position: absolute; top: 0; transform: translateX(-50%);
  padding: .4em .85em; border-radius: 999px; cursor: pointer;
  font-family: var(--font-head); font-weight: 700; font-size: .72rem; line-height: 1.2; white-space: nowrap;
}
.graph-empty { text-align: center; padding: 48px 16px; margin: 0; color: var(--muted); }

/* KPIs: quiet text under the graph, never louder than the curve */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 4px 6px 0; }
.kpi { margin: 0; display: grid; gap: 4px; align-content: start; font-size: clamp(.8rem, 3.7vw, .92rem); }
.kpi dt { margin-bottom: 4px; font-family: var(--font-head); font-weight: 700; font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.kpi dd { margin: 0; color: var(--muted); white-space: nowrap; }
.kpi dd span { color: var(--muted); }
.kpi b { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.kpi b[class*="lit-"] { color: var(--c-ink); }

.panel { padding: 22px 20px; display: grid; gap: 16px; }
.panel h2 { font-size: 1.15rem; }
.panel-text { margin: -6px 0 0; }
.panel-note { margin: 0; font-size: .85rem; color: var(--muted); }
.panel > .btn { justify-self: start; }

.field { display: grid; gap: 8px; }
.field > span { font-weight: 700; font-size: .9rem; }
.field-inline { grid-template-columns: auto 1fr; align-items: center; gap: 12px; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; }
.switch-row > span { display: grid; font-weight: 700; }
.switch-row small { font-weight: 300; color: var(--muted); font-size: .85rem; }

.reminder-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.reminder-row .field { flex: 1 1 180px; }

.data-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.data-grid .btn { font-size: .78rem; }

/* Hold-to-delete: the censor-bar material, filling with red while you hold */
.hold-btn {
  position: relative; overflow: hidden;
  display: block; width: 100%; text-align: left;
  padding: 18px 20px; border-radius: var(--radius-m);
  cursor: pointer;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.hold-btn.is-holding { transform: scale(.98); }
.hold-fill { position: absolute; inset: 0; background: var(--neg); transform-origin: left; transform: scaleX(0); }
.hold-btn.is-holding .hold-fill { transform: scaleX(1); transition: transform 2s linear; }
.hold-text { position: relative; display: grid; gap: 2px; }
.hold-text b { font-family: var(--font-head); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.hold-text small { font-size: .85rem; opacity: .8; }

/* ---------- Sheets (dialogs) ---------- */

dialog.sheet {
  width: min(520px, calc(100vw - 2 * var(--gutter)));
  max-height: calc(100dvh - 48px);
  overflow: auto;
  padding: 26px 22px 22px;
  border: 0;
  color: var(--text);
  border-radius: 30px;
  box-shadow: var(--sh-float);
}
dialog.sheet::backdrop { background: var(--scrim); backdrop-filter: blur(4px); }
dialog.sheet[open] { animation: sheet-in .3s var(--ease-out); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.sheet h2 { font-size: 1.4rem; margin-bottom: 8px; }
.sheet-lede { margin: 0 0 18px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 22px; }
.sheet-note { margin: 16px 0 0; font-size: .85rem; color: var(--muted); }
.import-summary { margin: 0; }

.install-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.install-steps li { display: flex; align-items: center; gap: 14px; }
.install-glyph { flex: none; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; }
.install-why { margin: 18px 0 0; font-size: .88rem; color: var(--muted); }
.install-now { margin-bottom: 20px; }
.install-done { display: flex; gap: 14px; align-items: center; }
.install-done p { margin: 0; }

/* ---------- Welcome ---------- */

.view-welcome {
  display: flex; flex-direction: column;
  max-width: 640px; margin: 0 auto;
}
.welcome-track { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.welcome-step { padding: 24px 6px 12px; animation: view-in .4s var(--ease-out); }
.welcome-step h1 { font-size: clamp(2.2rem, 9vw, 3.4rem); margin-bottom: 22px; }
.welcome-step p { font-size: 1.12rem; margin: 0 0 1em; }
.welcome-step ol { font-size: 1.12rem; padding-left: 1.4em; margin: 0 0 1em; }
.welcome-step .field { margin-top: 20px; }
.welcome-step .install-guide { margin-top: 8px; }
.welcome-art { display: block; width: 100%; max-width: 420px; height: auto; margin: 10px auto 0; }
.welcome-art .bar { fill: var(--ink-bottom); }
.welcome-art .glow { filter: blur(.4px) drop-shadow(0 0 6px currentColor); }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 22px; }
.welcome-step .panel-note { margin-top: 16px; }

.welcome-foot { display: flex; align-items: center; gap: 14px; padding-top: 18px; }
.welcome-dots { display: flex; gap: 8px; margin-right: auto; }
.welcome-dots i { width: 7px; height: 7px; border-radius: 4px; background: var(--faint); transition: width .25s var(--ease-press), background .25s; }
.welcome-dots i.is-active { width: 22px; background: var(--text); }
.welcome-next { padding-inline: 2em; }

/* ---------- Toasts ---------- */

.toast-region {
  position: fixed; z-index: 50; left: 0; right: 0; bottom: max(20px, env(safe-area-inset-bottom));
  display: grid; justify-items: center; gap: 10px; pointer-events: none; padding: 0 var(--gutter);
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px; border-radius: 999px;
  font-weight: 300; font-size: .95rem;
  animation: toast-in .3s var(--ease-press);
}
.toast-error { background: var(--neg); color: #fff; }
.toast-leaving { opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.toast-action {
  border: 0; background: var(--on-ink); color: var(--ink-bottom); border-radius: 999px; padding: .35em 1em;
  font-family: var(--font-head); font-weight: 700; font-size: .78rem; text-transform: uppercase; cursor: pointer;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } }

/* =========================================================
   Responsive
   ========================================================= */

/* Phone: one clear column. Greeting, pick the day, then one sheet with the whole entry.
   Spacing runs on an 8pt rhythm: 8 / 16 / 24. */
@media (max-width: 699.98px) {
  :root { --gutter: 20px; --key-size: 40px; }
  .topbar { margin-bottom: 0; min-height: var(--key-size); }

  /* The day fills the screen: the entry sheet takes whatever height is left */
  .view-day { display: flex; flex-direction: column; }
  .view-day .topbar { width: 100%; }
  .view-day .day-layout { flex: 1 0 auto; width: 100%; min-height: 0; }

  .greeting { padding: 24px 2px 0; }
  .greeting-title { font-size: clamp(1.9rem, 9vw, 2.4rem); }
  .greeting-sub { margin-top: .5em; font-size: 1rem; color: var(--muted); }
  .saved-tick { top: 32px; right: 2px; }

  /* The day picker comes first */
  .calendar { order: 1; margin-top: 40px; display: flex; flex-direction: column; gap: 16px; }
  .monthbar { order: -1; gap: 12px; }
  .monthbar .month-label {
    order: -2; flex: 1; display: flex; align-items: baseline; gap: .35em; justify-items: start;
    padding: 4px 2px; text-transform: none; letter-spacing: 0; font-size: 1.05rem; text-align: left;
  }
  .monthbar .month-label .month-name { font-weight: 700; }
  .monthbar .month-label b { font-size: 1.05rem; font-weight: 300; color: var(--muted); }
  .monthbar .month-label::after {
    content: ''; width: 7px; height: 7px; margin-left: .2em; align-self: center;
    border: solid var(--muted); border-width: 0 2px 2px 0; transform: translateY(-2px) rotate(45deg);
  }
  .monthbar .btn-today { order: -1; margin-left: 0; padding: .55em 1.1em; font-size: .72rem; }
  .monthbar .btn-today:disabled { display: none; }
  .calendar .week-strip {
    margin: 0; padding: 6px; border-radius: 22px;
    background: var(--base); box-shadow: var(--sh-well);
  }
  .day-cell { margin: 0 2px; padding: 6px 0 7px; }
  .day-cell .dow { font-size: .64rem; }
  .day-cell .num { font-size: 1.2rem; }

  /* One raised sheet holds the whole entry: worst, best, vibe */
  .cards {
    order: 2; flex: 1 0 auto;
    grid-auto-flow: row; grid-auto-columns: auto;
    grid-template-rows: 1fr 1fr auto;
    overflow: visible; scroll-snap-type: none;
    margin: 24px 0 0; padding: 20px; gap: 24px;
    min-height: 0;
    border-radius: var(--radius);
    background: var(--face); box-shadow: var(--sh-raised);
  }
  .card { background: none; box-shadow: none; border-radius: 0; padding: 0; min-height: 0; gap: 12px; }
  .card-label { padding: 0 4px; }
  /* The well sets the height (grows with the sheet); the textarea just fills it */
  .card-well { min-height: 88px; }
  .card-text { position: absolute; inset: 0; min-height: 0; font-size: 1.1rem; padding: 14px 16px 50px; }
  .mic-btn { right: 10px; bottom: 10px; }
  .card-vibe .card-question-full { padding: 0 4px; }
  .vibe-buttons { min-height: 0; padding: 8px 4px 0; }
  .vibe-btn { width: 72px; }

  /* Pages */
  .page { gap: 24px; padding-top: 4px; }
  .lede { margin: 4px 2px 0; font-size: 1rem; color: var(--muted); }
  .graph-card { padding: 20px 14px 14px; }
}

/* Tablet: worst + best side by side, the vibe as a row below, calendar under it */
@media (min-width: 700px) {
  :root { --gutter: 28px; }
  .cards {
    grid-auto-flow: row;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: minmax(260px, 1fr) auto;
    overflow: visible;
    margin: 0; padding: 26px 0 40px;
  }
  .card { min-height: 0; }
  .card-vibe { grid-column: 1 / -1; min-height: 0; display: grid; grid-template-columns: minmax(180px, 1fr) minmax(300px, 1.3fr); align-items: center; column-gap: 18px; }
  .card-vibe .card-question-full { grid-column: 1; grid-row: 1; padding-block: 0; }
  .card-vibe .vibe-buttons { grid-column: 2; grid-row: 1; min-height: 120px; padding-block: 14px; }
  .week-strip { margin-inline: 0; border-radius: var(--radius); }
}

/* Desktop / laptop: month calendar on the left, the day on the right */
@media (min-width: 1040px) {
  :root { --gutter: 40px; }
  .day-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    grid-template-rows: auto auto 1fr;
    grid-template-areas: ". greet" ". nag" "cal cards";
    column-gap: 52px;
    align-items: start;
  }
  .greeting { grid-area: greet; padding-top: 6px; }
  .install-nag { grid-area: nag; }
  .cards {
    grid-area: cards;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: minmax(280px, 1fr) auto;
  }
  .calendar { grid-area: cal; margin-top: 26px; position: sticky; top: var(--gutter); }
  .week-strip, .monthbar, .month-scrim { display: none; }
  .month-panel {
    position: static; transform: none; max-width: none;
    border-radius: var(--radius);
    box-shadow: var(--sh-raised);
    padding: 20px;
  }
}

@media (min-width: 1040px) and (min-height: 760px) {
  .cards { grid-template-rows: minmax(330px, 1fr) auto; }
}

/* Short landscape phones: let things scroll rather than squeeze */
@media (max-height: 560px) and (orientation: landscape) {
  .day-layout { min-height: 0; }
  .card { min-height: 220px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
