/* OpenHealth demo. Tokens from docs/wireframes (spec 1.5). No gradients, calm motion (150 to 250 ms ease-out). */
/* Hanken Grotesk, self-hosted from @fontsource/hanken-grotesk (SIL Open Font License 1.1). */
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/hanken-grotesk-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/hanken-grotesk-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/hanken-grotesk-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/hanken-grotesk-latin-700-normal.woff2") format("woff2"); }

:root {
  --ground: #F3F5F7;
  --ink: #14202B;
  --muted: #56636F;
  --text-2: #3C4853;
  --line: #E3E8EC;
  --divider: #EEF1F4;
  --card: #FFFFFF;
  --cobalt: #2747D8;
  --cobalt-hover: #1A33A8;
  --cobalt-tint: #EAF0FF;
  --teal: #1E6B69;
  --teal-tint: #E3F2F1;
  --purple: #5B3BA8;
  --purple-tint: #F1ECFB;
  --peach: #FCE9E1;
  --peach-text: #8A3A1C;
  --peach-accent: #C2603A;
  --good: #14613F;
  --good-tint: #E3F4EC;
  --ghost-border: #D2DAE1;
  --dashed: #BFC9D2;
  --radius: 22px;
  --shadow: 0 1px 2px rgba(20, 32, 43, 0.06);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --t-fast: 150ms;
  --t-med: 220ms;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Hanken Grotesk", system-ui, sans-serif;
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; }
.num, .tab-num { font-variant-numeric: tabular-nums; }

/* Banner on every view (hard rule 4) */
.banner {
  position: sticky; top: 0; z-index: 10;
  height: 36px; display: flex; align-items: center; justify-content: center;
  background: var(--ink); color: #fff;
  font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
}

/* Desktop layout: phone left, panel right; stacks below 1100 px */
.layout {
  display: grid; grid-template-columns: 430px minmax(0, 1fr); gap: 32px;
  max-width: 1280px; margin: 0 auto; padding: 24px 24px 48px;
  align-items: start;
}
.phone-col { position: sticky; top: 60px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.panel-col { min-width: 0; }
@media (max-width: 1099px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .phone-col { position: static; }
}

/* ---------- Phone ---------- */
.phone {
  width: 390px; height: 844px; border-radius: 48px; background: var(--ground);
  box-shadow: 0 0 0 10px #0E161E, 0 24px 60px rgba(20, 32, 43, 0.25);
  overflow: hidden; display: flex; flex-direction: column; position: relative;
}
.statusbar { height: 44px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 28px 0 32px; font-size: 15px; font-weight: 600; }
.statusbar .icons { display: flex; gap: 6px; align-items: center; }
.chat-head {
  flex: none; display: flex; align-items: center; gap: 12px; padding: 6px 20px 12px;
  border-bottom: 1px solid var(--line); background: var(--ground);
}
.orb { width: 40px; height: 40px; border-radius: 50%; background: var(--cobalt); position: relative; flex: none; }
.orb::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #fff; opacity: 0.9; top: 9px; left: 10px; }
.chat-head .name { font-size: 17px; font-weight: 700; }
.chat-head .role { font-size: 13px; color: var(--muted); }

.thread { flex: 1; overflow-y: auto; padding: 14px 14px 8px; display: flex; flex-direction: column; gap: 6px; scroll-behavior: smooth; }
.day-sep { align-self: center; font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; margin: 8px 0 4px; }
.empty-hint { margin: auto 18px; text-align: center; color: var(--muted); font-size: 15px; line-height: 1.5; }

.row { display: flex; flex-direction: column; }
.row.new { animation: rise var(--t-med) var(--ease) both; }
.row.member { align-items: flex-end; }
.row.lumi, .row.clinician { align-items: flex-start; }
.row.system { align-items: center; }
.who { display: flex; align-items: center; gap: 6px; margin: 8px 0 4px 4px; font-size: 12px; font-weight: 700; color: var(--peach-text); }
.tag { display: inline-flex; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--peach); color: var(--peach-text); border: 1px solid #F3CDBE; }
.bubble { max-width: 82%; padding: 10px 14px; border-radius: 20px; font-size: 15px; line-height: 1.42; white-space: pre-wrap; overflow-wrap: anywhere; }
.member .bubble { background: var(--cobalt); color: #fff; border-bottom-right-radius: 6px; }
.lumi .bubble { background: var(--card); box-shadow: var(--shadow); border-bottom-left-radius: 6px; }
.clinician .bubble { background: var(--peach); color: var(--ink); border-bottom-left-radius: 6px; }
.typing { display: inline-flex; gap: 4px; padding: 14px 16px; background: var(--card); border-radius: 20px; border-bottom-left-radius: 6px; box-shadow: var(--shadow); }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: #9AA6B1; animation: blink 1.2s infinite ease-out; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

/* Cards inside the chat */
.ccard { width: 86%; margin-top: 6px; background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.row.system .ccard { width: 92%; }
.ccard .t { font-size: 15px; font-weight: 700; }
.ccard .s { font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.ccard .kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--divider); font-size: 13px; }
.ccard .kv:first-of-type { border-top: 0; }
.ccard .k { color: var(--muted); }
.ccard .v { font-weight: 600; text-align: right; }
.ccard.peach { background: var(--peach); }
.ccard.emergency { background: var(--ink); color: #fff; }
.ccard.emergency .s { color: #DCE3E9; }
.ccard .stamp { display: inline-flex; margin-top: 10px; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--peach); color: var(--peach-text); }
.ccard .resolved { margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--good); }
.btns { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 999px; font: 600 15px "Hanken Grotesk", system-ui, sans-serif; border: 0; cursor: pointer;
  background: var(--cobalt); color: #fff; transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.btn:hover { background: var(--cobalt-hover); }
.btn:active { transform: scale(0.98); }
.btn.ink { background: var(--ink); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--ghost-border); }
.btn.white { background: #fff; color: var(--ink); }
a.btn { text-decoration: none; }
.alert { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; background: var(--ink); color: #fff; border-radius: 16px; padding: 12px 14px; margin: 4px 0 8px; font-size: 14px; font-weight: 600; }
.chip.white { background: #fff; color: var(--ink); }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.resource { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--divider); }
.resource:first-of-type { border-top: 0; }
.resource .contact { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Composer */
.composer { flex: none; display: flex; align-items: center; gap: 8px; padding: 10px 12px 26px; border-top: 1px solid var(--line); background: var(--ground); }
.composer input {
  flex: 1; min-width: 0; min-height: 44px; border-radius: 999px; border: 1px solid var(--ghost-border); background: #fff;
  padding: 0 16px; font: 400 15px "Hanken Grotesk", system-ui, sans-serif; color: var(--ink);
}
.composer input:focus { outline: 2px solid var(--cobalt); outline-offset: 1px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.icon-btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.send { background: var(--cobalt); color: #fff; cursor: pointer; }
.send[disabled] { background: #9AA6B1; }
.phone-note { font-size: 12px; color: var(--muted); text-align: center; max-width: 390px; }

/* ---------- Panel ---------- */
.panel-title { display: flex; justify-content: space-between; align-items: flex-end; margin: 4px 4px 14px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.h1 { font-size: 28px; line-height: 1.1; margin: 6px 0 0; font-weight: 700; letter-spacing: -0.02em; }
.panel { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--card); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card.dashed { background: transparent; border: 1.5px dashed var(--dashed); box-shadow: none; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.card-head .t { font-size: 16px; font-weight: 700; }
.label { font-size: 13px; color: var(--muted); }
.small { font-size: 13px; line-height: 1.45; color: var(--muted); margin: 10px 0 0; }
.big { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.chip.chat { background: var(--cobalt-tint); color: var(--cobalt); }
.chip.dev { background: var(--teal-tint); color: var(--teal); }
.chip.doc { background: var(--purple-tint); color: var(--purple); }
.chip.clin { background: var(--peach); color: var(--peach-text); }
.chip.ok { background: var(--good-tint); color: var(--good); }
.chip.neutral { background: var(--divider); color: var(--text-2); }
.chip.hyp { background: #fff; color: var(--muted); border: 1.5px dashed var(--dashed); }
.chip.warn { background: var(--peach); color: var(--peach-text); }

/* Pipeline steps */
.steps { display: flex; flex-direction: column; margin-top: 4px; }
.step { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 12px; padding: 10px 0; border-top: 1px solid var(--divider); align-items: start; }
.step:first-child { border-top: 0; }
.step .dot { width: 12px; height: 12px; margin-top: 4px; border-radius: 50%; border: 2px solid #C5CED6; background: #fff; }
.step.running .dot { border-color: var(--cobalt); background: var(--cobalt); animation: pulse 1.2s infinite ease-out; }
.step.done .dot { border-color: var(--good); background: var(--good); }
.step.skipped .dot { border-color: #C5CED6; background: #C5CED6; }
.step.error .dot { border-color: var(--peach-accent); background: var(--peach-accent); }
.step .name { font-size: 14px; font-weight: 700; }
.step.waiting .name { color: var(--muted); font-weight: 600; }
.step .note { font-size: 13px; color: var(--text-2); line-height: 1.45; margin-top: 2px; }
.step .ms { font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 2px; }
.spec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-top: 8px; }
.spec { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.spec .sname { font-size: 13px; font-weight: 700; display: flex; justify-content: space-between; gap: 8px; }
.spec .snote { font-size: 12px; color: var(--text-2); line-height: 1.4; margin-top: 4px; }

/* Escalation */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.brief { margin-top: 12px; border-top: 1px solid var(--divider); }
.brief .kv { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--divider); font-size: 13px; line-height: 1.45; }
.brief .k { color: var(--muted); }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 6px; }
.note-text { font-size: 14px; line-height: 1.45; }
.axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.timer { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.esc-status { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; }

/* Facts */
.facts { display: flex; flex-direction: column; }
.fact { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 10px 0; border-top: 1px solid var(--divider); transition: opacity var(--t-med) var(--ease); }
.fact:first-child { border-top: 0; }
.fact.new { animation: factin var(--t-med) var(--ease) both, glow 1.6s var(--ease); }
.fact.deleted .fv { text-decoration: line-through; color: var(--muted); }
.fact .cat { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.fact .fv { font-size: 14px; font-weight: 600; margin-top: 2px; }
.fact .meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.fact .conf { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.more { font-size: 13px; color: var(--muted); padding-top: 10px; border-top: 1px solid var(--divider); }

/* Holds */
.bar { height: 10px; border-radius: 999px; background: var(--line); display: flex; overflow: hidden; gap: 2px; margin: 6px 0 4px; }
.bar > div { transition: width var(--t-med) var(--ease); }
.srow { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-top: 1px solid var(--divider); font-size: 14px; }
.srow:first-of-type { border-top: 0; }
.sdot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 8px; vertical-align: -1px; }
.n { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Two-column panel rows on wide screens */
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
@media (max-width: 1280px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }

/* Cost table */
.kvs .kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--divider); font-size: 14px; }
.kvs .kv:first-child { border-top: 0; }
.kvs .k { color: var(--muted); }
.kvs .v { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

/* Presenter controls */
details.card > summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; font-size: 16px; font-weight: 700; min-height: 28px; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "+"; font-size: 20px; color: var(--muted); }
details.card[open] > summary::after { content: "–"; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; align-items: center; }
.controls label { font-size: 13px; color: var(--text-2); display: inline-flex; gap: 8px; align-items: center; }
.controls input[type="range"] { accent-color: var(--cobalt); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes factin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes glow { 0% { background: var(--cobalt-tint); } 100% { background: transparent; } }
@keyframes blink { 0%, 80%, 100% { opacity: 0.35; } 40% { opacity: 1; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(39, 71, 216, 0.35); } 100% { box-shadow: 0 0 0 8px rgba(39, 71, 216, 0); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.reset-confirm { margin-top: 12px; padding: 12px; border: 1px solid var(--divider); border-radius: 12px; }
.reset-confirm .controls { margin-top: 8px; }

/* ---------- iMessage thread (plan.md P25): plain bubbles, no cards or buttons ---------- */
.phone.im { background: #fff; color: #000; font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif; }
.phone.im .statusbar { color: #000; }
.im-head { flex: none; display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; padding: 0 10px 8px; background: rgba(249, 249, 249, 0.94); border-bottom: 0.5px solid #D1D1D6; }
.im-back { color: #007AFF; display: inline-flex; padding-left: 8px; }
.im-video { color: #007AFF; display: inline-flex; justify-content: flex-end; padding-right: 8px; }
.im-contact { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.im-avatar { width: 50px; height: 50px; }
.im-name { font-size: 12px; color: #000; }
.im-name span { color: #8E8E93; }
.im-thread { background: #fff; padding: 10px 14px 6px; gap: 2px; }
.im-stamp { align-self: center; text-align: center; font-size: 11px; color: #8E8E93; margin: 10px 0 8px; line-height: 1.35; }
.im-stamp b { font-weight: 600; }
.im-event { align-self: center; text-align: center; font-size: 11px; color: #8E8E93; margin: 10px 24px 6px; line-height: 1.35; }
.im-row { display: flex; flex-direction: column; }
.im-row.out { align-items: flex-end; }
.im-row.in { align-items: flex-start; }
.im-row.tail { margin-bottom: 8px; }
.im-row.new { animation: rise var(--t-med) var(--ease) both; }
.im-sender { font-size: 11px; color: #8E8E93; margin: 6px 0 2px 14px; }
.im-bubble { position: relative; max-width: 75%; padding: 7px 12px; border-radius: 18px; font-size: 16px; line-height: 1.3; white-space: pre-wrap; overflow-wrap: anywhere; }
.im-row.out .im-bubble { background: #007AFF; color: #fff; }
.im-row.in .im-bubble { background: #E9E9EB; color: #000; }
.im-row.tail.out .im-bubble::before { content: ""; position: absolute; bottom: 0; right: -7px; width: 20px; height: 20px; background: #007AFF; border-bottom-left-radius: 15px; }
.im-row.tail.out .im-bubble::after { content: ""; position: absolute; bottom: 0; right: -10px; width: 10px; height: 20px; background: #fff; border-bottom-left-radius: 10px; }
.im-row.tail.in .im-bubble::before { content: ""; position: absolute; bottom: 0; left: -7px; width: 20px; height: 20px; background: #E9E9EB; border-bottom-right-radius: 15px; }
.im-row.tail.in .im-bubble::after { content: ""; position: absolute; bottom: 0; left: -10px; width: 10px; height: 20px; background: #fff; border-bottom-right-radius: 10px; }
.im-bubble a { text-decoration: underline; }
.im-row.in .im-bubble a { color: #007AFF; }
.im-row.out .im-bubble a { color: #fff; }
.im-receipt { align-self: flex-end; font-size: 11px; color: #8E8E93; margin: -4px 4px 8px 0; }
.im-typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.im-typing span { width: 8px; height: 8px; border-radius: 50%; background: #8E8E93; animation: blink 1.2s infinite ease-out; }
.im-typing span:nth-child(2) { animation-delay: 0.15s; }
.im-typing span:nth-child(3) { animation-delay: 0.3s; }
.im-composer { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 12px 30px; background: #fff; }
.im-plus { width: 34px; height: 34px; border-radius: 50%; border: 0; background: #E9E9EB; color: #8E8E93; display: inline-flex; align-items: center; justify-content: center; flex: none; cursor: not-allowed; }
.im-field { flex: 1; min-width: 0; display: flex; align-items: center; min-height: 36px; border: 1px solid #C7C7CC; border-radius: 18px; padding: 0 4px 0 12px; }
.im-field:focus-within { border-color: #007AFF; }
.im-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 7px 0; color: #000; font: 400 16px -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif; }
.im-mic { border: 0; background: transparent; color: #8E8E93; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; cursor: not-allowed; }
.im-send { width: 28px; height: 28px; border-radius: 50%; border: 0; background: #007AFF; color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; margin: 3px 0; flex: none; }
.im-send[hidden], .im-mic[hidden] { display: none; }
