/* ══════════════════════════════════════════════════════════════════════════
   Roshii — Nocturne design system.

   Nocturne is a quiet, compact dark interface: a near-neutral blue-grey
   ground, Inter at medium weight, soft 8px radii, and an accent used as a
   line and a glow rather than a flood.

   The accent is retuned from Nocturne's blurple to a light blue: same OKLCH
   lightness ramp and chroma proportions, hue 240. Lilac (accent-2) is the
   second role. They are not interchangeable:

       blue  = progress and actions   (ring, completions, primary buttons)
       lilac = streak and habits      (flame, week bars, habit tags)
   ══════════════════════════════════════════════════════════════════════ */

/* Inter is vendored into static/fonts/ — no third-party request, no blocking
   round trip before text paints, and the app keeps its typeface offline.
   Regenerate with scripts/fetch_fonts.py. */
/* >>> Inter — generated by scripts/fetch_fonts.py, do not edit by hand */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/inter-400-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/inter-400-latin.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: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/inter-500-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/inter-500-latin.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;
}
/* <<< Inter */

:root {
  --color-bg: #161826;
  --color-surface: #232532;
  --color-text: #e9e9ed;
  --color-divider: color-mix(in srgb, #e9e9ed 16%, transparent);

  /* Accent — light blue. Progress and actions. */
  --color-accent: oklch(.72 .11 240);
  --color-accent-100: oklch(.97 .02 240);
  --color-accent-200: oklch(.94 .04 240);
  --color-accent-300: oklch(.88 .07 240);
  --color-accent-400: oklch(.81 .10 240);
  --color-accent-500: oklch(.72 .11 240);
  --color-accent-600: oklch(.62 .11 240);
  --color-accent-700: oklch(.50 .10 240);
  --color-accent-800: oklch(.39 .08 240);
  --color-accent-900: oklch(.29 .06 240);
  /* rgb of the accent, for glows */
  --accent-rgb: 108, 168, 232;

  /* Accent 2 — lilac. Streak and habits. */
  --color-accent-2: #a7a1db;
  --color-accent-2-100: #f5f4ff;
  --color-accent-2-200: #e7e5fe;
  --color-accent-2-300: #d2cefd;
  --color-accent-2-400: #b5afe8;
  --color-accent-2-500: #9690c9;
  --color-accent-2-600: #7972a9;
  --color-accent-2-700: #5c5783;
  --color-accent-2-800: #423e5d;
  --color-accent-2-900: #2b293a;
  --accent-2-rgb: 145, 132, 217;

  /* Neutrals — one shared OKLCH lightness scale, so the same step of any
     ramp carries the same visual weight. */
  --color-neutral-100: #f3f5fe;
  --color-neutral-200: #e4e7f5;
  --color-neutral-300: #cfd3e5;
  --color-neutral-400: #b2b6ca;
  --color-neutral-500: #9397ab;
  --color-neutral-600: #75798c;
  --color-neutral-700: #595d6c;
  --color-neutral-800: #3f424d;
  --color-neutral-900: #292b31;

  --color-danger: #e88c8c;

  --font-heading: "Inter", system-ui, -apple-system, sans-serif;
  --font-heading-weight: 500;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;

  --space-1: 2.8px;
  --space-2: 5.6px;
  --space-3: 8.4px;
  --space-4: 11.2px;
  --space-6: 16.8px;
  --space-8: 22.4px;

  --radius-sm: 4px;
  --radius-md: 8px;

  --radius-lg: 14px;

  /* Elevation on a dark ground is a hairline edge plus ambient darkness,
     never a stack of heavy shadows. */
  --shadow-sm: 0 0 0 1px #3f424d;
  --shadow-md: 0 0 0 1px #595d6c, 0 6px 18px rgba(0,0,0,0.55);
  --shadow-lg: 0 0 0 1px #9397ab, 0 16px 40px rgba(0,0,0,0.65);
}

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

html, body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0;
}
h3 { font-size: 25px; }
h4 { font-size: 20px; }
h5 { font-size: 16px; }

a { color: var(--color-accent); text-underline-offset: 3px; }
a:hover { color: var(--color-accent-300); }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }

.text-muted { color: var(--color-neutral-500); }

/* ── Icons ─────────────────────────────────────────────────────────────── */

/* Phosphor glyphs, vendored as a sprite in templates/_icons.svg and inlined
   once per page. Sized in em so `style="font-size:16px"` reads the same way
   the icon font did, and filled with currentColor so an icon takes the colour
   of whatever it sits in. */
.icon {
  width: 1em; height: 1em; flex: none;
  display: block; fill: currentColor;
}

/* ── Container ─────────────────────────────────────────────────────────── */

.container {
  max-width: 540px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Shown on a card when its action failed and was rolled back. Inline on the
   card rather than a toast, so the message sits next to the thing that did not
   happen. Retargeted onto the Nocturne palette in the merge: the old --red and
   --red-dim do not exist here, so this matches .auth-error instead. */
.card-error {
  display: none;
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--color-danger) 40%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-danger) 10%, transparent);
  color: var(--color-danger);
  font-size: 13px;
}

/* ── Buttons — outlined, never flooded ─────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none;
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 14px; line-height: 1.2; color: var(--color-text);
  background: transparent; border: 1px solid transparent;
  padding: var(--space-2) calc(var(--space-3) * 1.2);
  border-radius: var(--radius-md);
  -webkit-tap-highlight-color: transparent;
  transition: background .15s, border-color .15s, color .15s, transform .12s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(.985); }

.btn-primary { color: var(--color-accent); border-color: var(--color-accent); }
.btn-primary:hover { background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.btn-primary:active { background: color-mix(in srgb, var(--color-accent) 22%, transparent); }

.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.btn-secondary:active { background: color-mix(in srgb, var(--color-text) 14%, transparent); }

.btn-ghost { color: var(--color-accent); padding-inline: var(--space-1); }
.btn-ghost:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.btn-ghost:active { background: color-mix(in srgb, var(--color-accent) 18%, transparent); }

.btn-danger { color: var(--color-neutral-500); border-color: transparent; }
.btn-danger:hover { color: var(--color-danger); }

.btn-icon { width: 36px; height: 36px; padding: 0; flex: none; }
.btn-block { width: 100%; }
.btn-sm { font-size: 12.5px; padding: 5px 11px; }

/* ── Forms ─────────────────────────────────────────────────────────────── */

.field > label {
  display: block; font-size: 11px; margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--color-neutral-500);
}
.input {
  width: 100%; min-height: 36px; padding: 8px 12px; font: inherit;
  /* 16px keeps iOS from zooming the viewport on focus */
  font-size: 16px; color: var(--color-text); caret-color: var(--color-accent);
  background: var(--color-surface);
  border: 1px solid var(--color-divider); border-radius: var(--radius-md);
  outline: none; -webkit-appearance: none;
  transition: border-color .15s;
}
.input:hover { border-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.input:focus, .input:focus-visible { border-color: var(--color-accent); outline-offset: 0; }
.input::placeholder { color: var(--color-neutral-600); }
textarea.input { min-height: 90px; resize: none; line-height: 1.5; }
select.input option { background: var(--color-surface); }

/* Category chips — a segmented choice built on real radios, so the keyboard
   and screen readers get the native control and the tint is purely visual. */
.cat-chip {
  flex: 1; display: inline-flex; align-items: center; justify-content: center;
  min-height: 38px; padding: 0 10px;
  border: 1px solid var(--color-divider); border-radius: var(--radius-md);
  font-size: 12.5px; color: var(--color-neutral-400);
  cursor: pointer; text-transform: capitalize;
  transition: border-color .15s, background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.cat-chip input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.cat-chip:hover { border-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.cat-chip:has(input:checked) {
  border-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 14%, transparent);
  color: var(--color-accent-100);
}
.cat-chip:has(input:focus-visible) { outline: 2px solid var(--color-accent); outline-offset: 2px; }

/* ── Tags ──────────────────────────────────────────────────────────────── */

.tag {
  display: inline-flex; align-items: center; font-size: 11px;
  letter-spacing: .02em; padding: 3px 10px;
  border-radius: calc(var(--radius-md) * .75);
  white-space: nowrap;
}
.tag-accent   { background: var(--color-accent-2-800); color: var(--color-accent-2-100); }
.tag-neutral  { background: var(--color-neutral-800);  color: var(--color-neutral-100); }
.tag-outline  { border: 1px solid var(--color-accent); color: var(--color-accent); }

/* Category badges carry the two roles: habits are lilac, tasks are blue,
   milestones are the deep step. */
.badge-habit     { background: var(--color-accent-2-800); color: var(--color-accent-2-100); }
.badge-task      { background: var(--color-neutral-800);  color: var(--color-neutral-100); }
.badge-milestone { border: 1px solid var(--color-accent); color: var(--color-accent); }

/* ── Rules ─────────────────────────────────────────────────────────────── */

/* Freestanding rules fade to transparent at their ends — a Nocturne
   signature. Box outlines and in-control separators stay solid. */
.rule {
  height: 1px; border: 0; margin: 0;
  background: linear-gradient(to right, transparent, var(--color-divider) 24px,
              var(--color-divider) calc(100% - 24px), transparent);
}

/* ── Surfaces ──────────────────────────────────────────────────────────── */

.panel {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 16px 14px;
}

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.section-title {
  font-size: 11px; font-weight: 400; letter-spacing: .09em;
  text-transform: uppercase; color: var(--color-neutral-500);
}

/* ── Progress header — ring, streak, week ──────────────────────────────── */

.progress-card {
  display: flex; gap: 16px; align-items: center;
  padding: 15px 16px; border-radius: var(--radius-md);
  background: var(--color-surface); box-shadow: var(--shadow-sm);
}

.ring {
  width: 78px; height: 78px; flex: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 22px rgba(var(--accent-rgb), .18);
  transition: background .3s;
}
.ring-inner {
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--color-surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring-count {
  font-family: var(--font-heading); font-size: 21px; line-height: 1;
  letter-spacing: -.02em;
}
.ring-label {
  font-size: 8.5px; color: var(--color-neutral-500);
  letter-spacing: .06em; margin-top: 3px;
}

.progress-right { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }

.streak-line {
  display: flex; align-items: baseline; gap: 6px;
  color: var(--color-accent-2);
}
.streak-count { font-family: var(--font-heading); font-size: 22px; line-height: 1; }
.streak-label { font-size: 11.5px; color: var(--color-neutral-500); }

.week-strip { display: flex; gap: 5px; }
.week-day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.week-bar {
  width: 100%; height: 24px; border-radius: 3px;
  background: var(--color-neutral-900);
  transition: background .25s;
}
.week-bar.full  { background: var(--color-accent-2-700); }
.week-bar.part  { background: var(--color-accent-2-800); }
.week-bar.today { background: var(--color-accent); box-shadow: 0 0 10px rgba(var(--accent-rgb), .5); }
.week-bar.today-empty { background: transparent; border: 1px dashed var(--color-accent-700); }
.week-letter { font-size: 8.5px; color: var(--color-neutral-600); }
.week-day.is-today .week-letter { color: var(--color-accent); }

/* ── Task cards ────────────────────────────────────────────────────────── */

.task-card {
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 9px;
}

.task-row { display: flex; gap: 12px; padding: 13px 14px; align-items: flex-start; }

/* The complete button is the check circle itself — one tap, no menu. */
.check-btn {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  border: 1.5px solid var(--color-neutral-700);
  background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: transparent; margin-top: 1px;
  transition: transform .12s, border-color .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.check-btn:hover { border-color: var(--color-accent); color: var(--color-accent-600); }
.check-btn:active { transform: scale(.86); border-color: var(--color-accent); }

.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 14.5px; line-height: 1.35; text-wrap: pretty; }
.task-meta {
  display: flex; align-items: center; gap: 8px; margin-top: 7px;
  flex-wrap: wrap; font-size: 11.5px; color: var(--color-neutral-600);
}
.task-notes {
  font-size: 12.5px; color: var(--color-neutral-500);
  margin-top: 7px; line-height: 1.45;
}

.due-today { color: var(--color-accent-300); display: inline-flex; align-items: center; gap: 4px; }
.due-soon  { color: var(--color-accent-300); display: inline-flex; align-items: center; gap: 4px; }
.due-over  { color: var(--color-danger); display: inline-flex; align-items: center; gap: 4px; }
.due-ok    { color: var(--color-neutral-500); display: inline-flex; align-items: center; gap: 4px; }

.task-icon-btn {
  width: 34px; height: 34px; flex: none; border-radius: var(--radius-md);
  border: 1px solid var(--color-divider); background: transparent;
  cursor: pointer; color: var(--color-neutral-400);
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.task-icon-btn:hover { border-color: var(--color-accent); color: var(--color-accent); }

.task-drawer { display: none; padding: 0 14px 14px; flex-direction: column; gap: 9px; }
.task-drawer.open { display: flex; }
.drawer-rule { height: 1px; background: var(--color-divider); margin-bottom: 3px; }
.drawer-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Check-in history — a timeline, not a list ─────────────────────────── */

.ci-entry { display: flex; gap: 13px; }
.ci-date { width: 52px; flex: none; font-size: 11px; color: var(--color-neutral-500); padding-top: 2px; }
.ci-spine { width: 1px; flex: none; background: var(--color-neutral-800); position: relative; }
.ci-dot {
  position: absolute; top: 4px; left: -3px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--color-neutral-600);
}
.ci-entry:first-child .ci-dot {
  left: -3.5px; width: 8px; height: 8px;
  background: var(--color-accent); box-shadow: 0 0 8px rgba(var(--accent-rgb), .6);
}
.ci-content { flex: 1; padding-bottom: 18px; }
.ci-time { font-size: 11px; color: var(--color-neutral-600); }
.ci-note { font-size: 13.5px; line-height: 1.5; margin-top: 4px; text-wrap: pretty; }
.ci-note.empty { color: var(--color-neutral-500); }

/* ── Completed list ────────────────────────────────────────────────────── */

.done-row {
  display: flex; gap: 11px; align-items: center; padding: 11px 0;
  background: linear-gradient(to right, transparent, rgba(233,233,237,.07) 20px,
              rgba(233,233,237,.07) calc(100% - 20px), transparent) no-repeat bottom / 100% 1px;
}
.done-title {
  flex: 1; font-size: 13.5px; color: var(--color-neutral-500);
  text-decoration: line-through;
}

/* ── Skipped ───────────────────────────────────────────────────────────── */

.skipped-card { opacity: .92; }

/* ── Empty state ───────────────────────────────────────────────────────── */

.empty {
  padding: 30px 22px; border-radius: var(--radius-md);
  background: var(--color-surface); box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  text-align: center;
}
.empty-title { font-family: var(--font-heading); font-size: 15px; }
.empty-body { font-size: 13px; color: var(--color-neutral-500); }

/* ── Generator prompt row ──────────────────────────────────────────────── */

.nudge-row {
  padding: 14px; border-radius: var(--radius-md);
  border: 1px solid var(--color-divider);
  display: flex; gap: 12px; align-items: flex-start;
  text-decoration: none; color: inherit;
  cursor: pointer; background: transparent;
  width: 100%; text-align: left; font-family: inherit;
  transition: border-color .15s;
}
.nudge-row:hover { border-color: var(--color-accent-700); }
.nudge-title { font-size: 13.5px; }
.nudge-body { font-size: 12px; color: var(--color-neutral-500); margin-top: 4px; text-wrap: pretty; }

/* ── AI results ────────────────────────────────────────────────────────── */

.ai-card {
  padding: 13px 14px; border-radius: var(--radius-md);
  background: var(--color-surface); box-shadow: var(--shadow-sm);
  display: flex; gap: 11px; align-items: flex-start;
  animation: ch-rise .3s ease both;
}
.ai-card-title { font-size: 14.5px; line-height: 1.35; text-wrap: pretty; }
.ai-card-notes { font-size: 12.5px; color: var(--color-neutral-500); margin-top: 7px; line-height: 1.45; }

.ai-loading {
  display: flex; align-items: center; gap: 9px;
  color: var(--color-neutral-400); font-size: 13.5px; padding: 14px 0;
}
.ai-error {
  color: var(--color-danger); font-size: 13px; padding: 10px 0; line-height: 1.5;
}

.skeleton {
  height: 66px; border-radius: var(--radius-md);
  background: var(--color-surface);
  animation: ch-pulse 1.4s ease-in-out infinite;
}

/* ── Report charts ─────────────────────────────────────────────────────── */

.chart-card {
  padding: 16px 14px; border-radius: var(--radius-md);
  background: var(--color-surface); box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 12px;
}
.chart-kicker {
  font-size: 11px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--color-accent);
}
.chart-figure {
  font-family: var(--font-heading); font-size: 30px;
  letter-spacing: -.02em; line-height: 1;
}
.chart-axis {
  display: flex; justify-content: space-between;
  font-size: 8.5px; color: var(--color-neutral-600); letter-spacing: .04em;
}
.chart-note {
  font-size: 12.5px; color: var(--color-neutral-400);
  line-height: 1.5; text-wrap: pretty;
}

/* Category bars */
.cat-row { display: flex; flex-direction: column; gap: 5px; }
.cat-head { display: flex; justify-content: space-between; font-size: 12.5px; }
.cat-head span:last-child { color: var(--color-neutral-500); }
.cat-track {
  height: 7px; border-radius: 4px;
  background: var(--color-neutral-800); overflow: hidden;
}
.cat-fill { height: 100%; border-radius: 4px; }
.cat-fill.habit     { background: var(--color-accent-2); }
.cat-fill.task      { background: var(--color-accent); }
.cat-fill.milestone { background: var(--color-accent-700); }

/* Monthly streak columns */
.col-row { display: flex; align-items: flex-end; gap: 8px; min-height: 96px; }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.col-value { font-size: 9px; color: var(--color-neutral-500); }
.col-bar { width: 100%; border-radius: 3px 3px 0 0; background: var(--color-accent-800); }
.col-label { font-size: 8.5px; color: var(--color-neutral-600); }
.col.is-current .col-value,
.col.is-current .col-label { color: var(--color-accent-2); }
.col.is-current .col-bar {
  background: var(--color-accent-2);
  box-shadow: 0 0 12px rgba(var(--accent-2-rgb), .4);
}

/* Hour histogram */
.hour-row { display: flex; align-items: flex-end; gap: 4px; min-height: 78px; }
.hour {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: transparent; border: 0; padding: 0; cursor: pointer;
  font-family: inherit; -webkit-tap-highlight-color: transparent;
}
.hour-bar {
  width: 100%; border-radius: 2px 2px 0 0;
  background: var(--color-neutral-800);
  transition: background .18s;
}
.hour-bar.busy { background: var(--color-accent-700); }
.hour.is-active .hour-bar {
  background: var(--color-accent);
  box-shadow: 0 0 12px rgba(var(--accent-rgb), .45);
}
.hour-label { font-size: 8.5px; color: var(--color-neutral-600); }
.hour.is-active .hour-label { color: var(--color-accent); }

/* Generated report prose */
.report-section { display: flex; flex-direction: column; gap: 7px; }
.report-heading { display: flex; align-items: center; gap: 9px; }
.report-mark { width: 18px; height: 1px; background: var(--color-accent); flex: none; }
.report-body {
  font-size: 13.5px; line-height: 1.65;
  color: var(--color-neutral-300); text-wrap: pretty;
  white-space: pre-wrap;
}

/* ── Tab bar ───────────────────────────────────────────────────────────── */

.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; padding: 6px 8px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom));
  background: rgba(22,24,38,.94);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 -1px 0 var(--color-divider);
  z-index: 200;
}
.tab-item {
  flex: 1; min-height: 50px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: transparent; border: 0; cursor: pointer;
  color: var(--color-neutral-600);
  font-family: var(--font-body); font-size: 10px; font-weight: 500;
  text-decoration: none;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}
.tab-item.active { color: var(--color-accent); }
.tab-icon { font-size: 21px; line-height: 1; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Toast and milestone moment ────────────────────────────────────────── */

.toast-wrap {
  position: fixed; left: 0; right: 0; bottom: calc(92px + env(safe-area-inset-bottom));
  display: flex; justify-content: center; z-index: 300; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 15px; border-radius: 20px;
  background: var(--color-surface); box-shadow: var(--shadow-md);
  font-size: 13px;
  animation: ch-toast 1.9s ease forwards;
}

.moment-backdrop {
  position: fixed; inset: 0; z-index: 400;
  display: flex; align-items: center; justify-content: center; padding: 28px;
  background: rgba(15,17,25,.72);
}
.moment {
  width: 100%; max-width: 340px; padding: 26px 22px;
  border-radius: var(--radius-lg);
  background: var(--color-surface); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; align-items: center; gap: 13px;
  text-align: center;
  animation: ch-pop .4s ease both;
}
.moment-flame {
  width: 64px; height: 64px; border-radius: 50%;
  border: 1px solid var(--color-accent-2);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 32px rgba(var(--accent-2-rgb), .35);
  color: var(--color-accent-2);
}
.moment-title { font-family: var(--font-heading); font-size: 23px; letter-spacing: -.02em; }
.moment-body { font-size: 13.5px; color: var(--color-neutral-400); line-height: 1.55; text-wrap: pretty; }

/* ── Auth and onboarding shell ─────────────────────────────────────────── */

.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 60px 26px calc(40px + env(safe-area-inset-bottom));
  gap: 26px; position: relative; overflow: hidden;
  max-width: 440px; margin: 0 auto;
}
/* One soft accent bloom behind the mark — a glow, never a flood. */
.auth-bloom {
  position: absolute; top: -70px; left: -40px;
  width: 280px; height: 280px; border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--accent-rgb), .15), transparent 70%);
  pointer-events: none;
}
.auth-mark {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--color-accent);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 22px rgba(var(--accent-rgb), .3);
  color: var(--color-accent); margin-bottom: 20px;
}
.auth-title { font-size: 30px; letter-spacing: -.02em; }
.auth-sub { font-size: 14px; color: var(--color-neutral-500); margin-top: 8px; }
.auth-error {
  padding: 10px 14px; border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--color-danger) 40%, transparent);
  background: color-mix(in srgb, var(--color-danger) 10%, transparent);
  font-size: 13px; color: var(--color-danger);
}
.auth-footer { font-size: 13px; color: var(--color-neutral-500); text-align: center; }
.auth-footer a { text-decoration: none; }
.auth-hint { font-size: 12px; color: var(--color-neutral-500); margin-top: 6px; }

/* ── Onboarding quiz ───────────────────────────────────────────────────── */
/* Sits inside .auth-shell, so the mark, title and bloom are already handled.
   Only the parts that are unique to a multi-step quiz live here. */

.ob-progress { display: flex; gap: 5px; }
.ob-pip {
  flex: 1; height: 3px; border-radius: 2px;
  background: var(--color-divider); transition: background .25s;
}
.ob-pip.done { background: var(--color-accent); }

.step { display: none; flex-direction: column; gap: 18px; }
.step.active { display: flex; }

.q-prompt {
  font-family: var(--font-heading); font-size: 19px;
  line-height: 1.3; text-wrap: pretty;
}

/* One choice per row, full width and left aligned: these are sentences, not
   chips, and .cat-chip's centred segmented look fights that. */
.opts { display: flex; flex-direction: column; gap: 9px; }
.opt {
  width: 100%; text-align: left;
  background: var(--color-surface);
  border: 1px solid var(--color-divider); border-radius: var(--radius-md);
  padding: 13px 15px; color: var(--color-text);
  font-size: 15px; font-family: inherit; line-height: 1.35;
  cursor: pointer; text-wrap: pretty;
  transition: border-color .12s, background .12s, color .12s;
  -webkit-tap-highlight-color: transparent;
}
.opt:hover { border-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.opt.chosen {
  border-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 14%, transparent);
  color: var(--color-accent-100);
}
.opt:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

.step-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ob-thinking {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 13px; color: var(--color-neutral-500); padding: 6px 0;
}

/* ── Plan negotiation ──────────────────────────────────────────────────── */
/* The screen where Roshii proposes a first plan and you argue with it. The
   conversation reuses the chat classes above; only the plan itself is new. */

.plan-wrap {
  max-width: 540px; margin: 0 auto;
  padding: 24px 16px 132px;
  display: flex; flex-direction: column; gap: 18px;
}
.plan-head { text-align: center; }
.plan-title { font-family: var(--font-heading); font-size: 23px; letter-spacing: -.02em; }
.plan-sub {
  font-size: 13.5px; color: var(--color-neutral-500);
  margin-top: 8px; line-height: 1.5; text-wrap: pretty;
}

.msgs { display: flex; flex-direction: column; gap: 14px; }

/* Chat creates and removes a typing indicator per reply; this page keeps one
   in the DOM and toggles it, so it needs an off state chat does not. */
.typing.toggled { display: none; }
.typing.toggled.on { display: flex; }

/* A reply that tripped the crisis check. Marked, never hidden. */
.msg.support .msg-bubble {
  border: 1px solid var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 10%, transparent);
}

.plan-card {
  background: var(--color-surface); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.plan-card-head {
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--color-neutral-500);
}
.ptask {
  padding: 12px 0;
  box-shadow: 0 -1px 0 var(--color-divider);
}
.ptask:first-of-type { box-shadow: none; padding-top: 0; }
.ptask-title { font-size: 14.5px; line-height: 1.4; text-wrap: pretty; }
.ptask-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
  margin-top: 7px; font-size: 12px; color: var(--color-neutral-500);
}
.ptask-notes {
  font-size: 13px; color: var(--color-neutral-400);
  margin-top: 7px; line-height: 1.5; text-wrap: pretty;
}
.plan-actions { display: flex; flex-direction: column; gap: 8px; }
.revisions { font-size: 12px; color: var(--color-neutral-600); text-align: center; }

/* Pinned, because the plan above it can be longer than the screen and the
   reply box is the whole point of the page. */
.composer {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--color-bg); box-shadow: 0 -1px 0 var(--color-divider);
  padding: 10px 16px; padding-bottom: max(14px, env(safe-area-inset-bottom));
}
.composer-inner {
  max-width: 540px; margin: 0 auto;
  display: flex; gap: 8px; align-items: flex-end;
}

/* ── Chat ──────────────────────────────────────────────────────────────── */

.chat-page {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column;
  max-width: 540px; margin: 0 auto;
}

.chat-header {
  display: flex; align-items: center; gap: 11px;
  padding: 14px 16px; flex-shrink: 0;
  background: var(--color-bg);
  box-shadow: 0 1px 0 var(--color-divider);
}
.coach-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: var(--color-accent-800);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-accent-200);
  box-shadow: 0 0 18px rgba(var(--accent-rgb), .3);
}
.coach-info { flex: 1; min-width: 0; }
.coach-name { font-family: var(--font-heading); font-size: 15.5px; }
.coach-status { font-size: 12px; color: var(--color-neutral-500); }

.chat-messages {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 18px 16px 12px;
  display: flex; flex-direction: column; gap: 14px;
}
/* The thread starts at the top and grows down, the way a conversation reads.
   It was pinned to the composer, which kept a short exchange within reach of
   the thumb but opened a screen of empty ground above the first line — the
   greeting looked stranded rather than settled. A long thread still opens on
   its newest message, scrolled there by scrollBottom() on load. */
.chat-messages > * { flex-shrink: 0; }

.msg { display: flex; gap: 8px; align-items: flex-end; animation: ch-rise .18s ease; }
.msg.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  background: var(--color-accent-800); color: var(--color-accent-200);
}
.msg.user .msg-avatar {
  background: transparent; border: 1px solid var(--color-divider);
  color: var(--color-neutral-400);
}

.msg-content { display: flex; flex-direction: column; max-width: 78%; align-items: flex-start; }
.msg.user .msg-content { align-items: flex-end; }

.msg-bubble {
  padding: 10px 13px; border-radius: 16px;
  font-size: 14.5px; line-height: 1.5;
  word-break: break-word; text-wrap: pretty;
  /* Replies come back with real line breaks in them. Honouring them here means
     neither the server render nor the client one has to turn \n into <br>, and
     so neither has to build a bubble out of an HTML string. */
  white-space: pre-wrap;
  background: var(--color-surface); box-shadow: var(--shadow-sm);
  border-bottom-left-radius: 4px;
}
.msg.user .msg-bubble {
  background: color-mix(in srgb, var(--color-accent) 12%, transparent);
  border: 1px solid var(--color-accent-700);
  color: var(--color-accent-100);
  box-shadow: none;
  border-bottom-left-radius: 16px; border-bottom-right-radius: 4px;
}
.msg-time { font-size: 10.5px; color: var(--color-neutral-700); margin-top: 3px; padding: 0 2px; }

.typing {
  display: flex; align-items: center; gap: 5px;
  padding: 13px 15px; border-radius: 16px; border-bottom-left-radius: 4px;
  background: var(--color-surface); box-shadow: var(--shadow-sm);
  width: fit-content;
}
.typing-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-neutral-500); animation: ch-bounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }

.chat-input-area {
  flex-shrink: 0; background: var(--color-bg);
  box-shadow: 0 -1px 0 var(--color-divider);
  padding: 10px 16px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px;
}
.quick-prompts { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; }
.quick-prompts::-webkit-scrollbar { display: none; }
.quick-prompt {
  flex: none; padding: 7px 12px; border-radius: 16px;
  border: 1px solid var(--color-divider); background: transparent;
  color: var(--color-neutral-300); font-size: 12.5px;
  cursor: pointer; font-family: inherit; white-space: nowrap;
  transition: border-color .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.quick-prompt:hover { border-color: var(--color-accent); color: var(--color-accent); }

.chat-input-row { display: flex; gap: 8px; align-items: flex-end; }
.chat-input {
  flex: 1; min-width: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-divider); border-radius: 22px;
  padding: 11px 16px; color: var(--color-text);
  font-size: 16px; font-family: inherit; line-height: 1.4;
  resize: none; outline: none;
  min-height: 44px; max-height: 120px;
  -webkit-appearance: none;
  transition: border-color .15s;
}
.chat-input:focus { border-color: var(--color-accent); }
.chat-input::placeholder { color: var(--color-neutral-600); }

.chat-send {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 14%, transparent);
  color: var(--color-accent);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s, opacity .15s;
  -webkit-tap-highlight-color: transparent;
}
.chat-send:hover { background: color-mix(in srgb, var(--color-accent) 24%, transparent); }
.chat-send:disabled { opacity: .35; cursor: default; }

/* ── Support ───────────────────────────────────────────────────────────── */

.support-card {
  padding: 16px; border-radius: var(--radius-md);
  background: var(--color-surface); box-shadow: var(--shadow-sm);
}
.support-title { font-family: var(--font-heading); font-size: 15px; }
.support-body {
  font-size: 13.5px; color: var(--color-neutral-300);
  margin-top: 7px; line-height: 1.55;
}
.support-footnote {
  font-size: 12.5px; color: var(--color-neutral-500);
  padding-top: 18px; line-height: 1.55; text-wrap: pretty;
  background: linear-gradient(to right, transparent, var(--color-divider) 20px,
              var(--color-divider) calc(100% - 20px), transparent) no-repeat top / 100% 1px;
}

/* Consent line on the register form, and the small print under both auth
   cards. Deliberately readable rather than grey-on-grey: terms nobody can read
   are terms nobody agreed to. */

.consent {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 12.5px; color: var(--color-neutral-300);
  line-height: 1.5; text-wrap: pretty; cursor: pointer;
}
.consent input {
  flex: none; width: 17px; height: 17px; margin-top: 1px;
  accent-color: var(--color-accent); cursor: pointer;
}
.consent a { color: var(--color-neutral-100); text-underline-offset: 3px; }

.auth-legal {
  margin-top: 14px; text-align: center;
  font-size: 12px; color: var(--color-neutral-500);
}
.auth-legal a { color: inherit; text-underline-offset: 3px; }

/* ── Legal pages ───────────────────────────────────────────────────────── */
/* Terms and privacy. Long prose rather than cards, so the type is set wider and
   looser than anywhere else in the app; everything else reuses Nocturne. */

.legal-meta {
  font-size: 12.5px; color: var(--color-neutral-500);
  margin-top: 8px; letter-spacing: .01em;
}
.legal-h {
  font-family: var(--font-heading); font-size: 16px;
  margin-top: 10px; letter-spacing: -.01em;
}
.legal-p {
  font-size: 14px; color: var(--color-neutral-300);
  line-height: 1.65; text-wrap: pretty; margin-top: -4px;
}
.legal-list {
  font-size: 14px; color: var(--color-neutral-300);
  line-height: 1.65; text-wrap: pretty;
  margin-top: -4px; padding-left: 20px;
  display: flex; flex-direction: column; gap: 7px;
}
.legal strong { color: var(--color-neutral-100); font-weight: 600; }
.legal a { color: inherit; text-underline-offset: 3px; }

/* ── Motion ────────────────────────────────────────────────────────────── */

@keyframes ch-spin { to { transform: rotate(360deg); } }
@keyframes ch-pulse { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }
@keyframes ch-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes ch-pop { 0% { transform: scale(.7); opacity: 0; } 55% { transform: scale(1.06); } 100% { transform: scale(1); opacity: 1; } }
@keyframes ch-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-5px); opacity: 1; } }
@keyframes ch-toast {
  0% { opacity: 0; transform: translateY(10px); }
  15% { opacity: 1; transform: none; }
  80% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-8px); }
}

/* A button that is waiting: swap its label for the spinner in place, so the
   button keeps its width and the layout does not jump. */
.btn .spinner { display: none; }
.btn.loading .btn-text { display: none; }
.btn.loading .spinner { display: block; }

.spinner {
  width: 16px; height: 16px; flex: none;
  border: 2px solid var(--color-neutral-800);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: ch-spin .7s linear infinite;
}

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