/* ═══════════════════════════════════════════════════════════════════════════
   Personal Coach — "Aurora" design system
   A premium, native-feeling mobile app: crisp surfaces, warm ember identity,
   soft depth, fluid motion. Light + dark. Safe-area + reduced-motion aware.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  color-scheme: light dark;

  /* warm neutral surfaces */
  --bg: #f4f1ec;
  --bg-tint-1: rgba(255, 141, 84, 0.10);
  --bg-tint-2: rgba(120, 150, 200, 0.08);
  --surface: #ffffff;
  --surface-2: #f7f4ef;
  --surface-3: #eee9e1;
  --surface-glass: rgba(255, 255, 255, 0.72);
  --hairline: rgba(40, 30, 20, 0.09);
  --hairline-2: rgba(40, 30, 20, 0.14);

  /* ink */
  --ink: #211b14;
  --ink-2: #5f584e;
  --ink-3: #938b7e;
  --ink-inv: #fffaf4;

  /* ember (primary) */
  --ember: #f26a3a;
  --ember-2: #e2571f;
  --ember-ink: #7a3315;
  --ember-tint: rgba(242, 106, 58, 0.12);
  --ember-grad: linear-gradient(150deg, #ff8a52 0%, #f05f2b 55%, #d94e1f 100%);

  /* semantic */
  --moss: #5c8a5a;
  --moss-tint: rgba(92, 138, 90, 0.14);
  --sky: #4d7fa8;
  --sky-tint: rgba(77, 127, 168, 0.14);
  --gold: #b78a2b;
  --gold-tint: rgba(183, 138, 43, 0.15);
  --clay: #c0503c;
  --clay-tint: rgba(192, 80, 60, 0.13);

  /* type */
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "SF Pro Display", var(--sans);
  --serif: "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  /* depth */
  --sh-1: 0 1px 2px rgba(40, 28, 16, 0.06), 0 1px 1px rgba(40, 28, 16, 0.04);
  --sh-2: 0 2px 6px -1px rgba(40, 28, 16, 0.10), 0 6px 20px -8px rgba(40, 28, 16, 0.16);
  --sh-3: 0 8px 30px -6px rgba(40, 28, 16, 0.20), 0 2px 8px -2px rgba(40, 28, 16, 0.10);
  --sh-ember: 0 8px 22px -6px rgba(226, 87, 31, 0.45);

  /* geometry */
  --r-xl: 26px;
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;

  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  --tab-h: 62px;
  --appbar-h: 52px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141210;
    --bg-tint-1: rgba(255, 141, 84, 0.10);
    --bg-tint-2: rgba(120, 150, 200, 0.07);
    --surface: #211d19;
    --surface-2: #2a2621;
    --surface-3: #34302a;
    --surface-glass: rgba(28, 25, 21, 0.72);
    --hairline: rgba(255, 240, 225, 0.09);
    --hairline-2: rgba(255, 240, 225, 0.15);
    --ink: #f3ede4;
    --ink-2: #b7ada0;
    --ink-3: #8b8175;
    --ink-inv: #211b14;
    --ember: #ff824f;
    --ember-2: #ff6a35;
    --ember-tint: rgba(255, 130, 79, 0.16);
    --sh-1: 0 1px 2px rgba(0, 0, 0, 0.35);
    --sh-2: 0 2px 8px -1px rgba(0, 0, 0, 0.45), 0 8px 24px -10px rgba(0, 0, 0, 0.55);
    --sh-3: 0 10px 34px -6px rgba(0, 0, 0, 0.6);
    --moss-tint: rgba(92, 138, 90, 0.22);
    --sky-tint: rgba(77, 127, 168, 0.22);
    --gold-tint: rgba(183, 138, 43, 0.22);
    --clay-tint: rgba(192, 80, 60, 0.22);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background:
    radial-gradient(120% 60% at 90% -8%, var(--bg-tint-1), transparent 62%),
    radial-gradient(110% 55% at -10% 108%, var(--bg-tint-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}
#root { height: 100%; }

h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -0.022em; margin: 0; }
h1 { font-size: 30px; line-height: 1.1; }
h2 { font-size: 22px; line-height: 1.15; }
h3 { font-size: 17px; line-height: 1.25; }
p { margin: 0 0 12px; }
a { color: var(--ember-2); text-decoration: none; }
small, .muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
code, .mono { font-family: var(--mono); font-size: 0.85em; }
::selection { background: var(--ember-tint); }
b, strong { font-weight: 650; }

/* ── app layout ────────────────────────────────────────────────────────── */

.shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.content-col { min-width: 0; display: flex; flex-direction: column; }

/* desktop sidebar */
.rail {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
  padding: 20px 16px 16px;
  border-right: 1px solid var(--hairline);
  background: linear-gradient(180deg, var(--surface-glass), transparent 30%);
  backdrop-filter: saturate(1.3) blur(8px);
}
.rail .brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 18px; }
.rail .brand img { width: 40px; height: 40px; border-radius: 12px; box-shadow: var(--sh-1); }
.rail .brand .name { font-family: var(--display); font-size: 17px; font-weight: 750; letter-spacing: -0.02em; }
.rail .brand .tag { font-size: 12px; color: var(--ink-3); }
.rail-section { margin: 14px 10px 6px; font-size: 11px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.navlink {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: var(--r-md);
  color: var(--ink-2); font-size: 15px; font-weight: 550;
  transition: background 0.16s, color 0.16s, transform 0.1s;
}
.navlink svg { width: 21px; height: 21px; flex: none; opacity: 0.9; }
.navlink:hover { background: var(--surface-2); color: var(--ink); }
.navlink:active { transform: scale(0.98); }
.navlink.active { background: var(--ember-tint); color: var(--ember-2); font-weight: 650; }
.navlink.active svg { opacity: 1; }
.rail .foot { margin-top: auto; padding: 14px 8px 4px; border-top: 1px solid var(--hairline); font-size: 13px; color: var(--ink-3); }
.rail .foot b { color: var(--ink); font-weight: 600; }

.main {
  min-width: 0;
  padding: 30px 40px 60px;
  max-width: 1120px; width: 100%; margin: 0 auto;
  animation: page-in 0.34s var(--ease-out);
}
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .lede { color: var(--ink-2); max-width: 60ch; font-size: 15.5px; margin-top: 4px; }

/* mobile app bar + tab bar (hidden on desktop) */
.appbar, .tabbar { display: none; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
  padding: 20px 22px;
}
.card + .card { margin-top: 16px; }
.card.sunken { background: var(--surface-2); box-shadow: none; border-color: var(--hairline); }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ── chips ─────────────────────────────────────────────────────────────── */

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 550; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--hairline-2); background: var(--surface); color: var(--ink-2);
  white-space: nowrap; line-height: 1;
}
.chip svg { width: 13px; height: 13px; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.local { background: var(--moss-tint); border-color: transparent; color: var(--moss); }
.chip.cloud, .chip.care { background: var(--sky-tint); border-color: transparent; color: var(--sky); }
.chip.ember { background: var(--ember-tint); border-color: transparent; color: var(--ember-2); }
.chip.gold { background: var(--gold-tint); border-color: transparent; color: var(--gold); }
.chip.clay { background: var(--clay-tint); border-color: transparent; color: var(--clay); }

/* ── buttons ───────────────────────────────────────────────────────────── */

.btn {
  appearance: none; cursor: pointer; user-select: none;
  font-family: var(--sans); font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
  border-radius: 999px; padding: 11px 20px;
  border: 1px solid var(--hairline-2);
  background: var(--surface); color: var(--ink);
  box-shadow: var(--sh-1);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.12s var(--ease-spring), box-shadow 0.16s, background 0.16s, opacity 0.16s;
}
.btn svg { width: 17px; height: 17px; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.955); }
.btn.primary {
  background: var(--ember-grad); border-color: transparent; color: #fff;
  box-shadow: var(--sh-ember);
}
.btn.primary:hover { filter: brightness(1.04); }
.btn.quiet { border-color: transparent; background: transparent; box-shadow: none; color: var(--ink-2); }
.btn.quiet:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger { color: var(--clay); border-color: color-mix(in srgb, var(--clay) 40%, transparent); background: var(--clay-tint); box-shadow: none; }
.btn.danger:hover { background: color-mix(in srgb, var(--clay) 18%, transparent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.small { font-size: 13.5px; padding: 7px 14px; }
.btn.block { width: 100%; }

/* ── forms ─────────────────────────────────────────────────────────────── */

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 7px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], textarea, select {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--hairline-2); border-radius: var(--r-md);
  padding: 12px 14px; transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--ember); background: var(--surface); box-shadow: 0 0 0 4px var(--ember-tint); }
textarea { min-height: 80px; resize: vertical; }
::placeholder { color: var(--ink-3); }

.choice-row { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); }
.choice {
  border: 1.5px solid var(--hairline-2); border-radius: var(--r-md);
  background: var(--surface); padding: 13px 15px; cursor: pointer;
  transition: border-color 0.14s, background 0.14s, transform 0.1s;
}
.choice:active { transform: scale(0.985); }
.choice:hover { border-color: var(--ink-3); }
.choice.selected { border-color: var(--ember); background: var(--ember-tint); }
.choice .t { font-weight: 650; font-size: 14.5px; }
.choice .d { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; line-height: 1.4; }

.switch { display: inline-flex; align-items: center; gap: 11px; cursor: pointer; font-size: 15px; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 46px; height: 28px; border-radius: 999px; background: var(--surface-3); position: relative; transition: background 0.2s var(--ease-out); flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--sh-1); transition: left 0.22s var(--ease-spring); }
.switch input:checked + .track { background: var(--moss); }
.switch input:checked + .track::after { left: 21px; }

/* ── notices ───────────────────────────────────────────────────────────── */

.notice { border-radius: var(--r-md); padding: 13px 15px; font-size: 14.5px; margin-bottom: 14px; border: 1px solid transparent; }
.notice.info { background: var(--surface-2); color: var(--ink-2); }
.notice.good { background: var(--moss-tint); color: var(--moss); }
.notice.care { background: var(--sky-tint); color: var(--sky); }
.notice.warn { background: var(--gold-tint); color: var(--gold); }
.notice.bad { background: var(--clay-tint); color: var(--clay); }

.toast-holder { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 14px); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 200; pointer-events: none; padding: 0 16px; }
.toast { background: var(--ink); color: var(--ink-inv); border-radius: 999px; padding: 11px 20px; font-size: 14.5px; font-weight: 550; box-shadow: var(--sh-3); animation: toast-in 0.4s var(--ease-spring); max-width: 440px; }
.toast.bad { background: var(--clay); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.96); } to { opacity: 1; transform: none; } }

/* ── tables / kv ───────────────────────────────────────────────────────── */

.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); font-weight: 650; padding: 9px 12px; border-bottom: 1px solid var(--hairline-2); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr.rowlink { cursor: pointer; transition: background 0.12s; }
.table tr.rowlink:active td { background: var(--surface-2); }
@media (hover: hover) { .table tr.rowlink:hover td { background: var(--surface-2); } }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; font-size: 14.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }

/* ── the presence (avatar) ─────────────────────────────────────────────── */

.presence-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.presence { position: relative; width: var(--presence-size, 190px); height: var(--presence-size, 190px); }
.presence svg { width: 100%; height: 100%; display: block; overflow: visible; }
.presence .state-word { text-align: center; font-family: var(--serif); font-style: italic; font-size: 16px; color: var(--ink-2); min-height: 22px; }

.presence .ember-core { transform-origin: 50% 50%; animation: breathe 5s var(--ease-out) infinite; }
.presence .halo { transform-origin: 50% 50%; opacity: 0; }
.presence .ripple { transform-origin: 50% 50%; opacity: 0; }
.presence .mote { opacity: 0; transform-origin: 50% 50%; }
.presence .spark { opacity: 0; transform-origin: 50% 50%; }
.presence .ring-privacy { opacity: 0; }
.presence .rest-line { opacity: 0; }

.presence[data-state="ready"] .ember-core { animation: breathe 5s ease-in-out infinite; }
.presence[data-state="listening"] .ember-core { animation: breathe 2.3s ease-in-out infinite; }
.presence[data-state="listening"] .ripple { animation: ripple 2.3s ease-out infinite; }
.presence[data-state="listening"] .ripple.r2 { animation-delay: 0.8s; }
.presence[data-state="reflecting"] .ember-core { animation: swirl 3.4s ease-in-out infinite; }
.presence[data-state="reflecting"] .halo { opacity: 0.7; animation: turn 6.5s linear infinite; }
.presence[data-state="speaking"] .ember-core { animation: speak 0.85s ease-in-out infinite; }
.presence[data-state="gentle_challenge"] .ember-core { animation: lean 3.8s ease-in-out infinite; filter: saturate(1.15); }
.presence[data-state="action_captured"] .spark { animation: sparkle 1.5s ease-out 1 forwards; }
.presence[data-state="action_captured"] .ember-core { animation: affirm 1.5s ease-out 1, breathe 5s ease-in-out 1.5s infinite; }
.presence[data-state="memory_candidate_ready"] .mote { opacity: 1; animation: orbit 4.2s linear infinite; }
.presence[data-state="privacy_local"] .ring-privacy { opacity: 1; }
.presence[data-state="cloud_route_visible"] .halo { opacity: 0.5; }
.presence[data-state="escalation"] .ember-core { animation: steady 5.5s ease-in-out infinite; }
.presence[data-state="escalation"] .ember-fill { fill: url(#pc-care-grad); }
.presence[data-state="session_complete"] .ember-core { animation: settle 2s ease-out 1 forwards; }
.presence[data-state="session_complete"] .rest-line { opacity: 0.85; }
.presence[data-state="blocked"] .ember-core { animation: none; opacity: 0.45; }

@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes speak { 0%, 100% { transform: scale(1); } 30% { transform: scale(1.07); } 60% { transform: scale(0.99); } }
@keyframes swirl { 0%, 100% { transform: scale(1) rotate(0deg); } 50% { transform: scale(1.03) rotate(7deg); } }
@keyframes lean { 0%, 100% { transform: rotate(0deg) scale(1); } 50% { transform: rotate(-4deg) scale(1.03); } }
@keyframes turn { to { transform: rotate(360deg); } }
@keyframes ripple { 0% { transform: scale(0.6); opacity: 0.5; } 100% { transform: scale(1.32); opacity: 0; } }
@keyframes orbit { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes sparkle { 0% { opacity: 0; transform: scale(0.4); } 25% { opacity: 1; transform: scale(1.15); } 100% { opacity: 0; transform: scale(1.45); } }
@keyframes affirm { 0% { transform: scale(1); } 30% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes steady { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.025); } }
@keyframes settle { 0% { transform: scale(1); } 100% { transform: scale(0.92) translateY(4px); } }

.presence.reduced * { animation: none !important; }

/* ── hero card (home) ──────────────────────────────────────────────────── */

.hero {
  position: relative; overflow: hidden;
  border-radius: var(--r-xl);
  background:
    radial-gradient(90% 70% at 50% -10%, var(--ember-tint), transparent 65%),
    var(--surface);
  border: 1px solid var(--hairline);
  box-shadow: var(--sh-2);
  padding: 26px 22px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.hero .hero-cta { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ── session console ───────────────────────────────────────────────────── */

.console { display: grid; grid-template-columns: 300px 1fr; gap: 22px; align-items: start; }
.console-side { position: sticky; top: 22px; display: flex; flex-direction: column; gap: 16px; }
.transcript { display: flex; flex-direction: column; gap: 12px; min-height: 340px; }
.bubble { max-width: 74ch; padding: 12px 16px; border-radius: 20px; font-size: 15.5px; line-height: 1.45; animation: bubble-in 0.34s var(--ease-out); }
@keyframes bubble-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.bubble.user { align-self: flex-end; background: var(--ember-grad); color: #fff; border-bottom-right-radius: 6px; box-shadow: var(--sh-ember); }
.bubble.coach { align-self: flex-start; background: var(--surface); border: 1px solid var(--hairline); border-bottom-left-radius: 6px; box-shadow: var(--sh-1); }
.bubble.coach.truncated::after { content: "— you stepped in here"; display: block; font-size: 11.5px; font-style: italic; color: var(--ink-3); margin-top: 6px; }
.bubble .route-line { display: block; font-size: 11px; color: var(--ink-3); margin-top: 6px; font-family: var(--mono); }
.bubble.user .route-line { color: rgba(255, 255, 255, 0.75); }
.sysline { align-self: center; font-size: 12.5px; color: var(--ink-2); display: inline-flex; gap: 7px; align-items: center; background: var(--surface-2); padding: 6px 12px; border-radius: 999px; }
.sysline svg { width: 14px; height: 14px; }
.sysline.gold { color: var(--gold); background: var(--gold-tint); }
.safety-card { align-self: stretch; background: var(--sky-tint); border: 1px solid color-mix(in srgb, var(--sky) 30%, transparent); border-radius: var(--r-lg); padding: 16px 18px; color: var(--sky); }
.safety-card h3 { color: var(--sky); }

.composer { display: flex; gap: 10px; margin-top: 18px; align-items: flex-end; }
.composer textarea { flex: 1; min-height: 52px; max-height: 140px; border-radius: 22px; padding: 13px 16px; }
.talk-btn {
  flex: none; width: 60px; height: 60px; border-radius: 50%;
  border: none; background: var(--ember-grad); color: #fff; cursor: pointer;
  box-shadow: var(--sh-ember); display: grid; place-items: center;
  transition: transform 0.12s var(--ease-spring);
}
.talk-btn svg { width: 24px; height: 24px; }
.talk-btn:active { transform: scale(0.92); }
.talk-btn.recording { animation: recpulse 1.3s ease-in-out infinite; }
.talk-btn:disabled { opacity: 0.4; }
@keyframes recpulse { 0%, 100% { transform: scale(1); box-shadow: var(--sh-ember); } 50% { transform: scale(1.08); box-shadow: 0 0 0 10px var(--ember-tint); } }
.recording-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--clay); animation: recpulse 1.2s infinite; }

/* ── keepsake (summary artifact) ───────────────────────────────────────── */

.keepsake {
  position: relative; overflow: hidden;
  background:
    radial-gradient(120% 60% at 100% 0%, var(--ember-tint), transparent 55%),
    var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl); box-shadow: var(--sh-3);
  padding: 32px 30px;
}
.keepsake .k-date { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.keepsake h1 { font-family: var(--serif); font-weight: 700; font-size: 27px; margin: 10px 0 18px; letter-spacing: -0.01em; }
.keepsake .k-section { margin: 18px 0 0; }
.keepsake .k-label { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ember-2); font-weight: 700; }
.keepsake ul { margin: 8px 0 0; padding-left: 20px; }
.keepsake li { margin: 5px 0; }
.keepsake .k-foot { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--hairline); display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-3); }

/* ── memory cards ──────────────────────────────────────────────────────── */

.memory-card { display: grid; gap: 12px; }
.memory-card .content { font-family: var(--serif); font-size: 18px; line-height: 1.45; }
.confidence { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; max-width: 160px; }
.confidence > i { display: block; height: 100%; background: var(--ember-grad); border-radius: 999px; }
.meta-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── goals ─────────────────────────────────────────────────────────────── */

.goal-flag { display: flex; gap: 14px; align-items: flex-start; }
.goal-flag svg { width: 26px; height: 26px; flex: none; margin-top: 2px; color: var(--ember-2); }
.action-line { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--hairline); }
.action-line:last-child { border-bottom: none; }
.action-line.done .t { text-decoration: line-through; color: var(--ink-3); }
.checkring { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--hairline-2); background: var(--surface); cursor: pointer; display: grid; place-items: center; flex: none; padding: 0; transition: transform 0.12s var(--ease-spring), background 0.15s, border-color 0.15s; }
.checkring svg { width: 13px; height: 13px; opacity: 0; color: #fff; }
.checkring:active { transform: scale(0.85); }
.checkring.on { background: var(--moss); border-color: var(--moss); }
.checkring.on svg { opacity: 1; }

/* ── stats / health / login / onboarding ──────────────────────────────── */

.stat { padding: 18px 20px; }
.stat .n { font-family: var(--display); font-size: 32px; font-weight: 750; line-height: 1; letter-spacing: -0.03em; }
.stat .l { font-size: 12.5px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); margin-top: 8px; font-weight: 600; }
.health-line { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--hairline); }
.health-line:last-child { border-bottom: none; }
.health-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.health-dot.ok { background: var(--moss); box-shadow: 0 0 0 4px var(--moss-tint); }
.health-dot.bad { background: var(--clay); box-shadow: 0 0 0 4px var(--clay-tint); }
.invoice-total { font-family: var(--display); font-size: 22px; font-weight: 750; letter-spacing: -0.02em; }

.login-stage { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-panel { width: min(960px, 100%); display: grid; grid-template-columns: 1.05fr 1fr; border-radius: var(--r-xl); overflow: hidden; border: 1px solid var(--hairline); box-shadow: var(--sh-3); background: var(--surface); }
.login-hero { background: radial-gradient(120% 90% at 20% 0%, var(--ember-tint), transparent 60%), var(--surface-2); padding: 40px 38px; display: flex; flex-direction: column; }
.login-hero .presence-wrap { margin: 28px auto; }
.login-hero h1 { font-size: 34px; }
.login-form { padding: 40px 38px; }
.demo-strip { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0 4px; }
.hr-word { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; margin: 20px 0 14px; }
.hr-word::before, .hr-word::after { content: ""; height: 1px; background: var(--hairline); flex: 1; }

.wizard { max-width: 620px; margin: 0 auto; }
.steps-dots { display: flex; gap: 8px; justify-content: center; margin-bottom: 24px; }
.steps-dots i { width: 40px; height: 6px; border-radius: 999px; background: var(--surface-3); transition: background 0.3s; }
.steps-dots i.on { background: var(--ember-grad); }

.route-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--ink-3); padding: 36px 12px; font-family: var(--serif); font-style: italic; font-size: 16px; }
.spin { display: inline-block; width: 22px; height: 22px; border: 2.5px solid var(--surface-3); border-top-color: var(--ember); border-radius: 50%; animation: turn 0.7s linear infinite; }
.loading-page { display: grid; place-items: center; min-height: 60vh; }

/* ── PWA strip ─────────────────────────────────────────────────────────── */

#pwa-strip .pwa-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 250;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  background: var(--ink); color: var(--ink-inv);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  font-size: 14.5px; font-weight: 550; box-shadow: var(--sh-3);
}
#pwa-strip .pwa-chips {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 12px);
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; z-index: 180; max-width: calc(100% - 24px);
}
#pwa-strip .pwa-chips .chip { box-shadow: var(--sh-2); cursor: pointer; font-weight: 600; padding: 8px 14px; }

/* ── bottom sheet (mobile "More") ──────────────────────────────────────── */

.sheet-scrim { position: fixed; inset: 0; background: rgba(20, 14, 8, 0.42); z-index: 300; opacity: 0; transition: opacity 0.25s; backdrop-filter: blur(2px); }
.sheet-scrim.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 310;
  background: var(--surface); border-radius: 24px 24px 0 0;
  box-shadow: var(--sh-3); border-top: 1px solid var(--hairline);
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform 0.32s var(--ease-out);
  max-height: 82vh; overflow-y: auto;
}
.sheet.open { transform: none; }
.sheet .grabber { width: 40px; height: 5px; border-radius: 999px; background: var(--hairline-2); margin: 6px auto 14px; }
.sheet .sheet-id { display: flex; align-items: center; gap: 12px; padding: 6px 8px 14px; border-bottom: 1px solid var(--hairline); margin-bottom: 8px; }
.sheet .sheet-id .avatar { width: 42px; height: 42px; border-radius: 12px; background: var(--ember-grad); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 17px; }
.sheet-link { display: flex; align-items: center; gap: 14px; padding: 13px 8px; border-radius: var(--r-md); color: var(--ink); font-size: 16px; font-weight: 550; }
.sheet-link svg { width: 22px; height: 22px; color: var(--ink-2); }
.sheet-link:active { background: var(--surface-2); }
.sheet-sec { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); font-weight: 650; margin: 14px 8px 4px; }

/* ═══ mobile / installed-app layout ════════════════════════════════════ */

body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }

  /* glass app bar */
  .appbar {
    display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 90;
    height: calc(var(--appbar-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 16px 0;
    background: var(--surface-glass);
    backdrop-filter: saturate(1.6) blur(18px);
    -webkit-backdrop-filter: saturate(1.6) blur(18px);
    border-bottom: 1px solid var(--hairline);
  }
  .appbar .ab-title { font-family: var(--display); font-weight: 750; font-size: 17px; letter-spacing: -0.02em; flex: 1; text-align: center; }
  .appbar .ab-slot { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: var(--ink); }
  .appbar .ab-slot:active { background: var(--surface-2); }
  .appbar .ab-slot img { width: 30px; height: 30px; border-radius: 9px; }
  .appbar .ab-slot .avatar { width: 32px; height: 32px; border-radius: 10px; background: var(--ember-grad); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
  .appbar .ab-slot svg { width: 22px; height: 22px; }

  .main {
    padding: 16px 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 20px);
    animation: page-slide 0.32s var(--ease-out);
  }
  @keyframes page-slide { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

  /* iOS large-title: first h1 in a page acts as the big title */
  .page-head { margin-bottom: 16px; align-items: flex-start; flex-direction: column; gap: 8px; }
  h1 { font-size: 28px; }
  .page-head .lede { font-size: 15px; }

  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .card { padding: 17px 18px; border-radius: var(--r-lg); }
  .kv { grid-template-columns: 1fr; gap: 3px 0; }
  .kv dt { margin-top: 8px; }

  /* bottom tab bar */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
    height: calc(var(--tab-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface-glass);
    backdrop-filter: saturate(1.6) blur(18px);
    -webkit-backdrop-filter: saturate(1.6) blur(18px);
    border-top: 1px solid var(--hairline);
  }
  .tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--ink-3); font-size: 10.5px; font-weight: 600; letter-spacing: 0.01em;
    transition: color 0.16s, transform 0.1s;
    appearance: none; background: none; border: none; font-family: inherit; cursor: pointer; padding: 0;
  }
  .tab:focus { outline: none; }
  .appbar .ab-slot { appearance: none; background: none; border: none; cursor: pointer; padding: 0; }
  .tab svg { width: 25px; height: 25px; }
  .tab:active { transform: scale(0.9); }
  .tab.active { color: var(--ember-2); }
  .tab.active svg { filter: drop-shadow(0 2px 6px var(--ember-tint)); }
  .tab .tab-ic { position: relative; }
  .tab .tab-badge { position: absolute; top: -3px; right: -6px; min-width: 8px; height: 8px; border-radius: 999px; background: var(--ember); border: 1.5px solid var(--surface); }

  /* console → immersive full-height chat */
  .console { grid-template-columns: 1fr; gap: 14px; }
  .console-side { position: static; flex-direction: row; align-items: stretch; gap: 12px; }
  .console-side .card { flex: 1; padding: 14px; }
  .console-side .presence-wrap { --presence-size: 84px; }
  .transcript { padding-bottom: 88px; }
  .bubble { max-width: 88%; }
  .composer {
    position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
    margin: 0; padding: 10px 14px; gap: 10px;
    background: var(--surface-glass); backdrop-filter: blur(18px);
    border-top: 1px solid var(--hairline);
  }
  .composer textarea { min-height: 46px; }
  .talk-btn { width: 52px; height: 52px; }

  /* login full-bleed */
  .login-stage { padding: 0; }
  .login-panel { grid-template-columns: 1fr; border-radius: 0; border: none; min-height: 100vh; min-height: 100dvh; box-shadow: none; }
  .login-hero { padding: calc(30px + env(safe-area-inset-top)) 26px 26px; }
  .login-form { padding: 26px 26px calc(30px + env(safe-area-inset-bottom)); }
  .login-hero h1 { font-size: 30px; }

  .keepsake { padding: 26px 22px; border-radius: var(--r-lg); }
  .keepsake h1 { font-size: 24px; }
  .table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  .hero { border-radius: var(--r-lg); }
}

@media (max-width: 380px) {
  .main { padding-left: 12px; padding-right: 12px; }
  .tab { font-size: 10px; }
}

/* wide screens keep tabbar/appbar hidden (default) */
@media (min-width: 821px) { .appbar, .tabbar, .sheet, .sheet-scrim { display: none !important; } }

/* ── reduced motion + print ────────────────────────────────────────────── */

@media print {
  .rail, .appbar, .tabbar, .composer, .btn, .toast-holder, #pwa-strip { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  body { background: #fff; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  /* fully stop looping/ambient motion (the ember presence, pulses) — not just
     shorten it — for motion-sensitive users */
  .presence *, .talk-btn, .recording-dot, .steps-dots i, .bubble, .toast, .main { animation: none !important; }
}
