/* ───────── Tokens ───────── */
:root {
  --bg: #F0F4F8;
  --surface: #FFFFFF;
  --ink: #0F1B2D;
  --ink-2: #3A4A60;
  --ink-3: #6B7A8F;
  --line: #DCE4EE;
  --line-2: #E8EEF5;
  --accent: #2563EB;
  --accent-ink: #FFFFFF;
  --accent-tint: #E8F0FE;
  --danger: #DC2626;
  --good: #16A34A;
  --warn: #D97706;

  /* stage colors */
  --stage-rapport: #2563EB;
  --stage-problem: #7C3AED;
  --stage-explore: #EA580C;
  --stage-solve:   #16A34A;
  --stage-wrap:    #94A3B8;

  --r-card: 16px;
  --r-pill: 999px;
  --r-input: 12px;

  --hit: 48px;
  --pad: 24px;

  --fz-base: 17px;
  --fz-scale: 1;

  --serif: Georgia, "Iowan Old Style", "Apple Garamond", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --shadow-sm: 0 1px 2px rgba(15,27,45,0.06), 0 1px 3px rgba(15,27,45,0.04);
  --shadow-md: 0 6px 20px rgba(15,27,45,0.08), 0 2px 6px rgba(15,27,45,0.05);
  --shadow-lg: 0 18px 50px rgba(15,27,45,0.14), 0 4px 12px rgba(15,27,45,0.06);
}

/* Elder mode: scales type +25%, hits to 64 */
body.elder {
  --fz-scale: 1.25;
  --hit: 64px;
  --pad: 28px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: calc(var(--fz-base) * var(--fz-scale));
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin: 0;
}

button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, textarea { font-family: inherit; font-size: inherit; }

/* ───────── Topbar ───────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(240,244,248,0.85);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1320px; margin: 0 auto;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--serif);
  font-size: calc(20px * var(--fz-scale));
  color: var(--ink);
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, #2563EB 0%, #7C3AED 100%);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 7px;
  background: #fff; border-radius: 4px;
}

/* ───────── Page shell ───────── */
main { max-width: 1320px; margin: 0 auto; padding: 32px 24px 120px; }
.screen { display: none; animation: fade .25s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.screen-meta {
  display: flex; align-items: baseline; gap: 12px;
  margin-bottom: 20px; color: var(--ink-3);
  font-size: calc(13px * var(--fz-scale));
  text-transform: uppercase; letter-spacing: 0.08em;
}
.screen-meta .num { color: var(--accent); font-weight: 600; }
.screen-meta .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--ink-3); display: inline-block; }

/* ───────── Buttons ───────── */
.btn {
  appearance: none; border: 0;
  min-height: var(--hit);
  padding: 0 22px;
  border-radius: var(--r-pill);
  background: var(--accent); color: var(--accent-ink);
  font-weight: 600;
  font-size: calc(16px * var(--fz-scale));
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform 80ms, background 120ms, box-shadow 120ms;
  box-shadow: 0 1px 0 rgba(255,255,255,0.4) inset, 0 6px 16px rgba(37,99,235,0.25);
}
.btn:hover { background: #1D4FD7; }
.btn:active { transform: translateY(1px); }
.btn.ghost {
  background: transparent; color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--line);
}
.btn.ghost:hover { background: var(--line-2); }
.btn.subtle {
  background: var(--surface); color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-sm);
}
.btn.subtle:hover { background: #FAFCFE; }
.btn.danger { background: var(--danger); box-shadow: 0 6px 16px rgba(220,38,38,0.3); }
.btn.danger:hover { background: #BE1D1D; }
.btn.lg { font-size: calc(18px * var(--fz-scale)); padding: 0 28px; }

/* ──────────────────────────────────────────────
   1. LANDING
   ────────────────────────────────────────────── */
.hero { text-align: center; padding: 56px 16px 40px; }
.hero h1 {
  font-size: calc(96px * var(--fz-scale));
  line-height: 1; letter-spacing: -0.03em;
  margin-bottom: 14px;
}
.hero .subtitle {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-2);
  font-size: calc(26px * var(--fz-scale));
  margin-bottom: 22px;
}
.hero .tagline {
  font-size: calc(18px * var(--fz-scale));
  color: var(--ink-3);
  max-width: 540px; margin: 0 auto 36px;
}
.hero .cta-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero .trust {
  margin-top: 56px;
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--ink-3);
  font-size: calc(13px * var(--fz-scale));
}
.hero .trust .lock {
  width: 14px; height: 14px; border-radius: 3px; border: 1.5px solid var(--ink-3);
  position: relative;
}
.hero .trust .lock::before {
  content:""; position: absolute; left: 3px; right: 3px; top: -4px; height: 5px;
  border: 1.5px solid var(--ink-3); border-bottom: 0; border-radius: 4px 4px 0 0;
}

.section-head {
  display: flex; align-items: end; justify-content: space-between;
  margin: 56px 8px 20px;
}
.section-head h2 { font-size: calc(28px * var(--fz-scale)); }
.section-head .meta { color: var(--ink-3); font-size: calc(14px * var(--fz-scale)); }

.care-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.care-card {
  background: var(--surface);
  border-radius: var(--r-card);
  padding: 24px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 14px;
  transition: transform 160ms, box-shadow 160ms;
}
.care-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.care-photo {
  width: 80px; height: 80px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif);
  font-size: calc(28px * var(--fz-scale));
  color: #fff;
  flex-shrink: 0;
}
.care-photo.a { background: linear-gradient(135deg, #2563EB, #7C3AED); }
.care-photo.b { background: linear-gradient(135deg, #EA580C, #DC2626); }
.care-photo.c { background: linear-gradient(135deg, #16A34A, #0891B2); }
.care-photo.d { background: linear-gradient(135deg, #7C3AED, #EC4899); }
.care-name { font-family: var(--serif); font-size: calc(20px * var(--fz-scale)); }
.care-spec { color: var(--ink-3); font-size: calc(14px * var(--fz-scale)); margin-top: 2px; }
.care-match {
  display: flex; align-items: center; gap: 10px;
  margin-top: 2px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.care-match .ring {
  --p: 92;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p)*1%), var(--line-2) 0);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.care-match .ring::after {
  content: "";
  width: 28px; height: 28px;
  background: var(--surface);
  border-radius: 50%;
}
.care-match .ring-label {
  position: absolute;
  font-size: calc(11px * var(--fz-scale));
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.care-match .ring-wrap { position: relative; display: grid; place-items: center; }
.care-match-meta { display: flex; flex-direction: column; line-height: 1.2; }
.care-match-pct { font-weight: 600; font-size: calc(15px * var(--fz-scale)); }
.care-match-lbl { color: var(--ink-3); font-size: calc(12px * var(--fz-scale)); }

/* ──────────────────────────────────────────────
   2. SESSION LOBBY
   ────────────────────────────────────────────── */
.lobby-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  max-width: 1100px; margin: 0 auto;
}
@media (max-width: 880px) { .lobby-wrap { grid-template-columns: 1fr; } }

.lobby-card {
  background: var(--surface);
  border-radius: var(--r-card);
  padding: 36px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}
.lobby-card h2 {
  font-size: calc(28px * var(--fz-scale));
  margin-bottom: 6px;
}
.lobby-card .lede {
  color: var(--ink-3);
  margin-bottom: 28px;
  font-size: calc(15px * var(--fz-scale));
}
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.field label {
  font-size: calc(14px * var(--fz-scale));
  color: var(--ink-2); font-weight: 500;
}
.field input {
  min-height: var(--hit);
  padding: 0 16px;
  border-radius: var(--r-input);
  border: 1.5px solid var(--line);
  background: #FAFCFE;
  color: var(--ink);
  font-size: calc(16px * var(--fz-scale));
  transition: border-color 120ms, background 120ms;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(37,99,235,0.12);
}
.lobby-card .btn { width: 100%; margin-top: 8px; }

.privacy {
  margin-top: 22px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--accent-tint);
  color: #1B3A8C;
  display: flex; gap: 10px;
  font-size: calc(13px * var(--fz-scale));
  line-height: 1.45;
}
.privacy .lock-ico {
  width: 16px; height: 16px; border: 2px solid #1B3A8C;
  border-radius: 3px; position: relative; flex-shrink: 0; margin-top: 2px;
}
.privacy .lock-ico::before {
  content:""; position: absolute; left: 3px; right: 3px; top: -5px; height: 6px;
  border: 2px solid #1B3A8C; border-bottom: 0; border-radius: 5px 5px 0 0;
}

.lobby-welcome { display: flex; flex-direction: column; justify-content: center; }
.lobby-welcome .greeting {
  font-family: var(--serif);
  font-size: calc(22px * var(--fz-scale));
  color: var(--ink-2);
  margin-bottom: 4px;
}
.lobby-welcome h2 { font-size: calc(40px * var(--fz-scale)); margin-bottom: 12px; }
.returning-detail {
  margin: 22px 0;
  padding: 18px;
  background: var(--bg);
  border-radius: 12px;
  display: flex; align-items: center; gap: 14px;
}
.returning-detail .avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, #2563EB, #7C3AED);
  color: #fff;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: calc(18px * var(--fz-scale));
}
.returning-detail .who { font-weight: 600; }
.returning-detail .when { color: var(--ink-3); font-size: calc(13px * var(--fz-scale)); }

/* ──────────────────────────────────────────────
   3. AUTO-DETECT WIZARD
   ────────────────────────────────────────────── */
.wizard {
  max-width: 720px; margin: 0 auto;
  background: var(--surface);
  border-radius: var(--r-card);
  padding: 36px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}
.wizard h2 {
  font-size: calc(26px * var(--fz-scale));
  margin-bottom: 4px;
}
.wizard .lede {
  color: var(--ink-3);
  font-size: calc(15px * var(--fz-scale));
  margin-bottom: 24px;
}
.video-preview {
  background: #0B1424;
  border-radius: var(--r-card);
  aspect-ratio: 16 / 10;
  position: relative;
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}
.video-preview::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 30% 35%, rgba(37,99,235,0.18) 0%, transparent 55%),
    radial-gradient(ellipse at 70% 70%, rgba(124,58,237,0.14) 0%, transparent 55%);
}
.video-preview .silhouette {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 38%; aspect-ratio: 1 / 1.15;
  background: radial-gradient(circle at 50% 30%, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0.08) 30%, transparent 60%);
  border-radius: 50% 50% 20% 20% / 60% 60% 12% 12%;
}
.video-preview .badge {
  position: absolute; top: 16px; left: 16px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-radius: var(--r-pill);
  background: rgba(11,20,36,0.6);
  color: #fff;
  font-size: calc(12px * var(--fz-scale));
  backdrop-filter: blur(8px);
}
.video-preview .badge .rec {
  width: 8px; height: 8px; border-radius: 50%;
  background: #DC2626;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}
.video-preview .lvl {
  position: absolute; bottom: 16px; right: 16px;
  display: flex; align-items: end; gap: 3px;
  height: 32px;
}
.video-preview .lvl span {
  width: 4px;
  background: linear-gradient(to top, #2563EB, #7C3AED);
  border-radius: 2px;
  animation: lvl 0.9s ease-in-out infinite;
}
.video-preview .lvl span:nth-child(1) { height: 30%; animation-delay: -0.1s; }
.video-preview .lvl span:nth-child(2) { height: 70%; animation-delay: -0.3s; }
.video-preview .lvl span:nth-child(3) { height: 50%; animation-delay: -0.5s; }
.video-preview .lvl span:nth-child(4) { height: 90%; animation-delay: -0.7s; }
.video-preview .lvl span:nth-child(5) { height: 40%; animation-delay: -0.9s; }
@keyframes lvl {
  0%, 100% { transform: scaleY(0.4); }
  50% { transform: scaleY(1); }
}
/* video-preview video element for live feed */
.video-preview video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 1;
}
.video-preview.has-video::before,
.video-preview.has-video .silhouette { display: none; }

.checks {
  display: flex; flex-direction: column; gap: 12px;
  margin-bottom: 22px;
}
.check-row {
  display: flex; align-items: center; gap: 16px;
  padding: 16px;
  border-radius: 12px;
  background: var(--bg);
  transition: background 200ms;
}
.check-row.done { background: #ECFDF5; }
.check-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  flex-shrink: 0;
  position: relative;
  background: var(--line-2);
  color: var(--ink-3);
}

.check-row.pending .check-icon {
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--line);
}
.check-row.checking .check-icon {
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--accent-tint);
}
.check-row.checking .check-icon::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  border-right-color: var(--accent);
  animation: spin 0.85s linear infinite;
}
.check-row.done .check-icon {
  background: var(--good);
  box-shadow: none;
  color: #fff;
}
@keyframes spin { to { transform: rotate(360deg); } }
.check-icon svg { width: 18px; height: 18px; opacity: 0; transform: scale(0.5); transition: opacity 250ms, transform 350ms cubic-bezier(.2,1.4,.5,1); }
.check-row.done .check-icon svg { opacity: 1; transform: scale(1); }

.check-meta { flex: 1; }
.check-name {
  font-weight: 600;
  font-size: calc(16px * var(--fz-scale));
}
.check-detail {
  color: var(--ink-3);
  font-size: calc(13px * var(--fz-scale));
}
.check-row.done .check-detail { color: var(--good); }

.wizard-status {
  text-align: center;
  padding: 18px;
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink-2);
  font-size: calc(15px * var(--fz-scale));
}
.wizard-status .all-good { color: var(--good); font-weight: 600; }

/* ──────────────────────────────────────────────
   4. VIDEO ROOM
   ────────────────────────────────────────────── */
.room {
  position: relative;
  background: #0A0F1A;
  border-radius: var(--r-card);
  padding: 16px;
  min-height: 720px;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.room-head {
  display: flex; align-items: center; gap: 14px;
  color: #E6EDF7;
  padding: 8px 4px 14px;
}
.conn {
  display: inline-flex; align-items: center; gap: 8px;
  color: #BFE9CB;
  font-size: calc(13px * var(--fz-scale));
}
.conn .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #22C55E;
  box-shadow: 0 0 0 0 rgba(34,197,94,0.6);
  animation: heartbeat 2s ease-in-out infinite;
}
.conn.disconnected .dot { background: #DC2626; animation: none; }
.conn.connecting .dot { background: #D97706; }
@keyframes heartbeat {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
  50% { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
}
.room-head .sep { width: 1px; height: 16px; background: rgba(255,255,255,0.1); }
.room-name { font-family: var(--serif); font-size: calc(17px * var(--fz-scale)); color: #fff; }
.room-spacer { flex: 1; }
.pcount {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.06);
  color: #E6EDF7;
  padding: 6px 10px;
  border-radius: var(--r-pill);
  font-size: calc(13px * var(--fz-scale));
}
.pcount .ic {
  width: 14px; height: 14px; border-radius: 50%;
  background: currentColor; opacity: 0.7;
}
.room-time {
  color: rgba(230,237,247,0.7);
  font-size: calc(13px * var(--fz-scale));
  font-variant-numeric: tabular-nums;
}

.video-grid {
  flex: 1;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  grid-auto-rows: 1fr;
  min-height: 480px;
}
/* nicer scaling: when 4 children, force 2x2 */
.video-grid[data-count="1"] { grid-template-columns: 1fr; }
.video-grid[data-count="2"] { grid-template-columns: 1fr 1fr; }
.video-grid[data-count="4"] { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }

.vtile {
  background: #111B2E;
  border-radius: 14px;
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}
.vtile.pri { box-shadow: inset 0 0 0 2px rgba(37,99,235,0.55); }
.vtile::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 35%, rgba(255,255,255,0.10) 0%, transparent 55%);
}
.vtile video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 1;
}
.vtile .avatar {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -55%);
  width: 30%; aspect-ratio: 1; max-width: 96px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  font-family: var(--serif);
  font-size: calc(28px * var(--fz-scale));
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.vtile .av-a { background: linear-gradient(135deg, #2563EB, #7C3AED); }
.vtile .av-b { background: linear-gradient(135deg, #EA580C, #DC2626); }
.vtile .av-c { background: linear-gradient(135deg, #16A34A, #0891B2); }
.vtile .av-d { background: linear-gradient(135deg, #DB2777, #7C3AED); }

.vtile .label {
  position: absolute; bottom: 12px; left: 12px;
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: calc(13px * var(--fz-scale));
  padding: 6px 10px;
  border-radius: var(--r-pill);
  backdrop-filter: blur(8px);
  z-index: 2;
}
.vtile .label .mic-on, .vtile .label .mic-off {
  width: 12px; height: 12px;
}
.vtile .label .mic-off { color: #FCA5A5; }
.vtile .speaking {
  position: absolute; inset: 0;
  border-radius: 14px;
  pointer-events: none;
  box-shadow: inset 0 0 0 2px #22C55E;
  opacity: 0;
  animation: speak 2.4s ease-in-out infinite;
}
@keyframes speak {
  0%, 100% { opacity: 0; }
  40%, 60% { opacity: 1; }
}

.toolbar {
  display: flex; justify-content: center; align-items: center;
  gap: 14px; margin-top: 14px;
  padding: 10px;
}
.tool-btn {
  width: var(--hit); height: var(--hit);
  min-width: var(--hit);
  border-radius: 50%;
  border: 0;
  background: rgba(255,255,255,0.08);
  color: #fff;
  display: grid; place-items: center;
  transition: background 120ms, transform 80ms;
}
.tool-btn:hover { background: rgba(255,255,255,0.16); }
.tool-btn:active { transform: translateY(1px); }
.tool-btn.off { background: rgba(252,165,165,0.18); color: #FCA5A5; }
.tool-btn.end {
  background: var(--danger);
  width: calc(var(--hit) + 16px);
  border-radius: var(--r-pill);
}
.tool-btn.end:hover { background: #BE1D1D; }
.tool-btn svg { width: 22px; height: 22px; }

/* ──────────────────────────────────────────────
   5. INSIGHT PANEL (overlay on the room)
   ────────────────────────────────────────────── */
.insight {
  position: absolute;
  top: 64px; left: 28px;
  width: 320px;
  background: rgba(255,255,255,0.96);
  color: var(--ink);
  border-radius: var(--r-card);
  padding: 18px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  z-index: 5;
  display: none;
}
.insight.visible { display: block; }
.insight-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.insight-title {
  font-family: var(--serif);
  font-size: calc(15px * var(--fz-scale));
  color: var(--ink-2);
}
.insight-pip {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--ink-3);
  font-size: calc(11px * var(--fz-scale));
  text-transform: uppercase; letter-spacing: 0.1em;
}
.insight-pip .live {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--good);
  animation: pulse 1.6s ease-in-out infinite;
}
.stage-label {
  font-size: calc(12px * var(--fz-scale));
  color: var(--ink-3);
  margin-bottom: 6px;
  display: flex; justify-content: space-between;
}
.stage-label b { color: var(--ink); font-weight: 600; }
.stage-bar {
  display: flex; gap: 3px; height: 10px;
  margin-bottom: 12px;
}
.stage-seg {
  flex: 1; border-radius: 3px;
  background: var(--c);
  opacity: 0.28;
  transition: opacity 200ms;
  position: relative;
}
.stage-seg.done { opacity: 0.7; }
.stage-seg.now { opacity: 1; box-shadow: 0 0 0 2px rgba(255,255,255,0.6) inset, 0 0 0 1px var(--c); }
.stage-seg.now::after {
  content: "";
  position: absolute; inset: 0; border-radius: 3px;
  background: var(--c);
  animation: flicker 1.5s ease-in-out infinite;
}
@keyframes flicker { 0%,100% { opacity:1 } 50% { opacity: 0.5 } }
.stage-legend {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  font-size: calc(10px * var(--fz-scale));
  color: var(--ink-3);
  margin-bottom: 18px;
  text-align: center;
}

.insight-divider { height: 1px; background: var(--line); margin: 16px -18px; }

.mood {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.mood .mood-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: #FBBF24;
  box-shadow: 0 0 0 4px rgba(251,191,36,0.18);
}
.mood-label {
  font-size: calc(13px * var(--fz-scale));
  color: var(--ink-2);
}
.mood-label b { font-weight: 600; color: var(--ink); }
.mood-trend {
  margin-left: auto;
  color: var(--ink-3);
  font-size: calc(11px * var(--fz-scale));
}

.timer-row {
  display: flex; align-items: baseline; gap: 8px;
  padding: 10px 0 0;
}
.timer {
  font-family: var(--serif);
  font-variant-numeric: tabular-nums;
  font-size: calc(34px * var(--fz-scale));
  line-height: 1;
  color: var(--ink);
}
.timer-lbl {
  color: var(--ink-3);
  font-size: calc(12px * var(--fz-scale));
  text-transform: uppercase; letter-spacing: 0.1em;
}
.timer-of {
  margin-left: auto;
  color: var(--ink-3);
  font-size: calc(12px * var(--fz-scale));
}

/* ──────────────────────────────────────────────
   6. NOTES EDITOR
   ────────────────────────────────────────────── */
.notes {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  background: var(--surface);
  border-radius: var(--r-card);
  border: 1px solid var(--line);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  min-height: 720px;
}
@media (max-width: 880px) { .notes { grid-template-columns: 1fr; } }

.notes-side {
  background: #FAFCFE;
  border-right: 1px solid var(--line);
  padding: 24px;
  overflow: hidden;
}
.notes-side h3 {
  font-size: calc(15px * var(--fz-scale));
  color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.1em;
  font-family: var(--sans); font-weight: 600;
  margin-bottom: 16px;
}
.timeline {
  position: relative;
  padding-left: 22px;
}
.timeline::before {
  content: ""; position: absolute;
  left: 7px; top: 6px; bottom: 6px;
  width: 2px; background: var(--line);
}
.tl-item {
  position: relative;
  padding: 10px 0 14px 4px;
}
.tl-item::before {
  content: ""; position: absolute;
  left: -20px; top: 14px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--c, var(--accent));
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--line);
}
.tl-time {
  font-variant-numeric: tabular-nums;
  font-size: calc(12px * var(--fz-scale));
  color: var(--ink-3);
}
.tl-text {
  font-size: calc(14px * var(--fz-scale));
  color: var(--ink);
  line-height: 1.4;
}

.notes-main { display: flex; flex-direction: column; }
.notes-head {
  padding: 24px 28px;
  border-bottom: 1px solid var(--line);
}
.notes-meta { color: var(--ink-3); font-size: calc(13px * var(--fz-scale)); }
.notes-title { font-size: calc(24px * var(--fz-scale)); margin-top: 4px; }
.redact {
  display: inline-block; vertical-align: -2px;
  background: var(--ink); color: var(--ink);
  padding: 0 28px; height: 0.85em;
  border-radius: 3px;
  margin: 0 2px;
  user-select: none;
}

.notes-toolbar {
  display: flex; gap: 4px; align-items: center;
  padding: 10px 28px;
  border-bottom: 1px solid var(--line);
  background: #FAFCFE;
}
.tb-btn {
  appearance: none; border: 0;
  min-width: 40px; min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-size: calc(14px * var(--fz-scale));
  display: inline-flex; align-items: center; justify-content: center;
}
.tb-btn:hover { background: var(--line-2); color: var(--ink); }
.tb-btn.active { background: var(--ink); color: #fff; }
.tb-sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }

.notes-body {
  padding: 28px;
  flex: 1;
  font-size: calc(16px * var(--fz-scale));
  line-height: 1.7;
  color: var(--ink);
  outline: none;
  overflow: auto;
}
.notes-body h2 {
  font-family: var(--serif);
  font-size: calc(24px * var(--fz-scale));
  margin: 6px 0 12px;
}
.notes-body p { margin: 0 0 14px; }
.notes-body em { color: var(--ink-2); }
.notes-foot {
  padding: 12px 28px;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: calc(12px * var(--fz-scale));
  display: flex; gap: 14px; align-items: center;
}
.notes-foot .sync {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--good);
}

/* ──────────────────────────────────────────────
   7. SCHEDULE
   ────────────────────────────────────────────── */
.sched {
  background: var(--surface);
  border-radius: var(--r-card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.sched-head {
  padding: 22px 24px;
  display: flex; align-items: center; gap: 16px;
  border-bottom: 1px solid var(--line);
}
.sched-head h2 { font-size: calc(24px * var(--fz-scale)); }
.sched-head .week { color: var(--ink-3); font-size: calc(14px * var(--fz-scale)); }
.sched-head .nav {
  display: flex; gap: 4px;
  margin-left: auto;
}
.nav-btn {
  appearance: none; border: 0;
  width: 40px; height: 40px;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  display: grid; place-items: center;
  box-shadow: inset 0 0 0 1px var(--line);
}
.nav-btn:hover { background: var(--line-2); }

.sched-grid {
  display: grid;
  grid-template-columns: 64px repeat(7, 1fr);
  overflow-x: auto;
}
.col-head {
  padding: 14px 8px;
  text-align: center;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line-2);
  font-size: calc(13px * var(--fz-scale));
  color: var(--ink-3);
}
.col-head .dnum {
  font-family: var(--serif);
  font-size: calc(22px * var(--fz-scale));
  color: var(--ink);
  display: block;
  line-height: 1.1;
}
.col-head.today .dnum {
  background: var(--accent);
  color: #fff;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  line-height: 1;
}
.col-head:first-child { border-right: 1px solid var(--line-2); }
.col-head:last-child { border-right: 0; }

.hour-cell {
  padding: 6px 8px;
  text-align: right;
  color: var(--ink-3);
  font-size: calc(11px * var(--fz-scale));
  border-right: 1px solid var(--line-2);
  border-bottom: 1px solid var(--line-2);
  height: 64px;
}
.day-cell {
  border-right: 1px solid var(--line-2);
  border-bottom: 1px solid var(--line-2);
  height: 64px;
  position: relative;
}
.day-cell.today-col {
  background: rgba(37,99,235,0.04);
}
.day-cell:last-child, .col-head:nth-last-child(1) { border-right: 0; }

.now-line {
  position: absolute; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  z-index: 2;
}
.now-line::before {
  content: ""; position: absolute;
  left: -5px; top: -4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
}

.appt {
  position: absolute; left: 4px; right: 4px;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: calc(12px * var(--fz-scale));
  line-height: 1.25;
  color: #fff;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
  overflow: hidden;
  cursor: pointer;
}
.appt .a-time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  opacity: 0.95;
}
.appt .a-name { display: flex; align-items: center; gap: 6px; margin-top: auto; }
.appt .a-init {
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: grid; place-items: center;
  font-size: calc(11px * var(--fz-scale));
  font-weight: 700;
}
.appt.blue   { background: linear-gradient(135deg, #2563EB, #1D4FD7); }
.appt.purple { background: linear-gradient(135deg, #7C3AED, #6D28D9); }
.appt.orange { background: linear-gradient(135deg, #EA580C, #C2410C); }
.appt.green  { background: linear-gradient(135deg, #16A34A, #15803D); }
.appt.gray   { background: linear-gradient(135deg, #64748B, #475569); }
.appt.tentative {
  background: repeating-linear-gradient(135deg, rgba(37,99,235,0.16) 0 8px, rgba(37,99,235,0.08) 8px 16px);
  color: var(--accent);
  box-shadow: inset 0 0 0 1.5px rgba(37,99,235,0.4);
}
.appt.tentative .a-init { background: rgba(37,99,235,0.2); color: var(--accent); }

/* ──────────────────────────────────────────────
   Elder Mode FAB
   ────────────────────────────────────────────── */
.elder-fab {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 100;
  width: 56px; height: 56px;
  border-radius: var(--r-pill);
  border: 0;
  background: var(--ink);
  color: #fff;
  font-family: var(--serif);
  font-size: 22px;
  box-shadow: var(--shadow-lg);
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0;
  justify-content: center;
  transition: width 220ms cubic-bezier(.2,.9,.4,1), background 200ms;
}
.elder-fab .label {
  overflow: hidden;
  max-width: 0;
  white-space: nowrap;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  transition: max-width 220ms, padding 220ms;
  padding: 0;
}
body.elder .elder-fab {
  width: auto;
  padding: 0 22px 0 18px;
  background: var(--accent);
}
body.elder .elder-fab .label {
  max-width: 200px;
  padding-right: 4px;
}

/* ──────────────────────────────────────────────
   Chat Panel
   ────────────────────────────────────────────── */
.chat-panel {
  position: absolute;
  top: 64px; right: 28px;
  width: 320px; max-height: 480px;
  background: rgba(255,255,255,0.96);
  color: var(--ink);
  border-radius: var(--r-card);
  padding: 0;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  z-index: 5;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.chat-panel.visible { display: flex; }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  max-height: 360px;
}
.chat-msg {
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: calc(14px * var(--fz-scale));
  line-height: 1.4;
}
.chat-msg.local {
  background: var(--accent-tint);
  margin-left: 20%;
}
.chat-msg.remote {
  background: var(--bg);
  margin-right: 20%;
}
.chat-msg strong {
  display: block;
  font-size: calc(12px * var(--fz-scale));
  color: var(--ink-3);
  margin-bottom: 2px;
}
.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}
.chat-form input {
  flex: 1;
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--r-input);
  border: 1.5px solid var(--line);
  background: #fff;
  font-size: calc(14px * var(--fz-scale));
}
.chat-form input:focus {
  outline: none;
  border-color: var(--accent);
}
.chat-form button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--r-pill);
  border: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: calc(13px * var(--fz-scale));
}

/* ──────────────────────────────────────────────
   Toast & Utilities
   ────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 96px; left: 50%; transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--r-pill);
  font-size: calc(14px * var(--fz-scale));
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 1;
  transition: opacity 300ms;
}
.toast.hidden { opacity: 0; pointer-events: none; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  padding: 12px 20px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-pill);
  font-weight: 600;
  z-index: 1000;
  text-decoration: none;
}
.skip-link:focus { left: 16px; }

/* small helpers */
.sr { position: absolute; left: -9999px; }
.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;
}
.hidden { display: none !important; }
