/* Smart Health live demo — presentation styles.
 *
 * Committed single light theme, deliberately. This page is shown on projectors and
 * shared screens in client meetings, where dark UIs go muddy; every colour is painted
 * explicitly so it holds regardless of the viewer's OS theme.
 *
 * Type: Archivo (headings, institutional grotesque) / Source Sans 3 (body, humanist —
 * a different skeleton, so the pairing actually reads as a pairing) / IBM Plex Mono
 * (timers, premiums, JSON — anywhere digits need to line up).
 */

:root{
  /* Neutrals are biased toward the teal rather than pure grey. */
  --ink:#0f1e1d; --ink-2:#3d4f4e; --ink-3:#6d7e7d;
  --line:#dfe6e5; --line-2:#eef2f2;
  --bg:#f1f4f4; --card:#ffffff;
  --accent:#0a6c66; --accent-dk:#085550; --accent-soft:#e2f0ee;
  --navy:#17324a;
  --ok:#15803d; --ok-soft:#e7f4ec;
  --warn:#b45309; --warn-soft:#fbf0e0;
  --bad:#b42318; --bad-soft:#fbeae8;

  --r:14px; --r-sm:10px;
  --sh:0 1px 2px rgba(15,30,29,.05), 0 10px 28px -14px rgba(15,30,29,.22);

  --display:"Archivo","Segoe UI",system-ui,-apple-system,sans-serif;
  --font:"Source Sans 3","Segoe UI",system-ui,-apple-system,sans-serif;
  --mono:"IBM Plex Mono",ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
}

*{box-sizing:border-box}

/* The `hidden` attribute is UA-styled as display:none — the weakest possible rule, which
   ANY class-level display declaration outranks. .stage, .stat and .fld all set
   display:flex, so without this every "hidden" element still renders: all three call
   stages stack on top of each other. Global and !important on purpose; hidden must mean
   hidden regardless of what a component sets. */
[hidden]{display:none !important}

html,body{height:100%}
body{
  margin:0; font-family:var(--font); font-size:15px; color:var(--ink); background:var(--bg);
  background-image:radial-gradient(1100px 460px at 50% -180px,#e3ecea 0%,transparent 72%);
  -webkit-font-smoothing:antialiased; line-height:1.5;
}
h1,h2,h3{margin:0; font-family:var(--display); font-weight:650; letter-spacing:-.021em; line-height:1.15; text-wrap:balance}
p{margin:0}
.mono{font-family:var(--mono); font-variant-numeric:tabular-nums}
:focus-visible{outline:2px solid var(--accent); outline-offset:2px; border-radius:4px}

/* ── Top bar ───────────────────────────────────────────────────────────── */
.topbar{
  display:flex; align-items:center; justify-content:space-between; gap:16px;
  padding:13px clamp(16px,3vw,28px); background:rgba(255,255,255,.88);
  backdrop-filter:blur(10px); border-bottom:1px solid var(--line);
  position:sticky; top:0; z-index:20;
}
.brand{display:flex; align-items:center; gap:12px; min-width:0}
.brand-mark{
  width:38px; height:38px; flex:none; border-radius:11px; display:grid; place-items:center;
  background:linear-gradient(150deg,var(--accent),var(--navy)); color:#fff;
}
.brand-mark svg{width:20px; height:20px}
.brand-text{display:flex; flex-direction:column; min-width:0}
.brand-text strong{font-family:var(--display); font-size:15px; font-weight:650; letter-spacing:-.015em}
.brand-text span{font-size:12.5px; color:var(--ink-3)}
.topbar-right{display:flex; align-items:center; gap:20px}
.stat{display:flex; flex-direction:column; align-items:flex-end; line-height:1.25}
.stat-label{font-size:10px; text-transform:uppercase; letter-spacing:.09em; color:var(--ink-3); font-weight:600}
.stat-value{font-size:14px; font-weight:600}

.pill{
  display:inline-flex; align-items:center; gap:8px; padding:7px 14px 7px 11px;
  border-radius:999px; font-size:13px; font-weight:600; border:1px solid transparent;
  white-space:nowrap; transition:background .2s,color .2s,border-color .2s;
}
.pill .dot{width:8px; height:8px; border-radius:50%; background:currentColor; flex:none}
.pill-idle{background:#e9eeee; color:var(--ink-2); border-color:var(--line)}
.pill-wait{background:var(--warn-soft); color:var(--warn); border-color:#efdcbe}
.pill-live{background:var(--ok-soft); color:#116432; border-color:#c6e5d2}
.pill-live .dot{animation:pulse 1.6s ease-out infinite}
.pill-bad{background:var(--bad-soft); color:var(--bad); border-color:#f0cdc9}
@keyframes pulse{0%{box-shadow:0 0 0 0 rgba(21,128,61,.5)}70%{box-shadow:0 0 0 7px rgba(21,128,61,0)}100%{box-shadow:0 0 0 0 rgba(21,128,61,0)}}

/* ── Layout ────────────────────────────────────────────────────────────── */
.layout{
  display:grid; grid-template-columns:minmax(0,1fr) 392px; gap:20px;
  padding:20px clamp(16px,3vw,28px) 28px; max-width:1400px; margin:0 auto;
  align-items:start;
}
.panel{background:var(--card); border:1px solid var(--line); border-radius:var(--r); box-shadow:var(--sh)}
/* A DEFINITE height, not min-height. With only a min-height the transcript's flex:1 has
   no ceiling to resolve against, so overflow-y never engages: the list grows the panel,
   the panel grows the page, and the End call button ends up below the fold. */
.console{height:min(78vh,720px); display:flex; flex-direction:column; overflow:hidden}
.stage{display:flex; flex-direction:column; flex:1; min-height:0}

/* The setup form, collapsed to one line for the duration of the call. */
.callerbar{
  display:flex; align-items:center; gap:9px; flex:none;
  padding:10px clamp(16px,3vw,28px); border-bottom:1px solid var(--line-2);
  background:#fafbfb; font-size:12.5px; color:var(--ink-2);
}
.callerbar .cb-dot{width:6px; height:6px; border-radius:50%; background:var(--ok); flex:none}
.callerbar b{font-weight:600; color:var(--ink)}
.cb-room{margin-left:auto; color:var(--ink-3); font-size:11.5px; font-family:var(--mono)}

/* ── Setup ─────────────────────────────────────────────────────────────── */
.setup-inner{padding:clamp(24px,4vw,46px); max-width:620px; margin:auto; width:100%}
.setup-inner h1{font-size:clamp(27px,3.4vw,36px); font-weight:700; margin-bottom:10px}
.setup-inner h1 span{color:var(--accent)}
.lede{color:var(--ink-2); font-size:15.5px; max-width:60ch}
#setupForm{margin-top:26px; display:flex; flex-direction:column; gap:14px}
.field-grid{display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:12px}
.fld{display:flex; flex-direction:column; gap:6px}
.fld>span{font-size:12px; font-weight:600; color:var(--ink-2); letter-spacing:.015em}
.fld>span em{font-style:normal; font-weight:400; color:var(--ink-3)}
.fld input,.fld select{
  font:inherit; font-size:14.5px; color:var(--ink); padding:10px 12px; background:#fff;
  border:1px solid var(--line); border-radius:var(--r-sm); outline:none;
  transition:border-color .15s, box-shadow .15s; width:100%;
}
.fld input:focus,.fld select:focus{border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-soft)}
.hint{font-size:12.5px; color:var(--ink-3)}
.error{
  font-size:13.5px; color:var(--bad); background:var(--bad-soft); border:1px solid #f0cdc9;
  padding:10px 12px; border-radius:var(--r-sm);
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:9px;
  font-family:var(--font); font-size:14.5px; font-weight:600; padding:11px 18px;
  border-radius:var(--r-sm); border:1px solid transparent; cursor:pointer;
  transition:transform .06s, background .15s, box-shadow .15s;
}
.btn svg{width:17px; height:17px; flex:none}
.btn:active{transform:translateY(1px)}
.btn:disabled{opacity:.55; cursor:not-allowed}
.btn-lg{padding:14px 22px; font-size:15.5px}
.btn-primary{background:var(--accent); color:#fff; box-shadow:0 6px 16px -8px rgba(10,108,102,.9)}
.btn-primary:hover:not(:disabled){background:var(--accent-dk)}
.btn-ghost{background:#fff; color:var(--ink-2); border-color:var(--line)}
.btn-ghost:hover:not(:disabled){background:#f6f9f8; color:var(--ink)}
.btn-ghost[aria-pressed="true"]{background:var(--warn-soft); border-color:#efdcbe; color:var(--warn)}
.btn-danger{background:var(--bad); color:#fff}
.btn-danger:hover:not(:disabled){background:#8f1c13}

/* ── Orb ───────────────────────────────────────────────────────────────── */
.orb-wrap{display:flex; flex-direction:column; align-items:center; gap:14px; padding:34px 20px 22px}
.orb{position:relative; width:132px; height:132px; display:grid; place-items:center}
.orb-ring{position:absolute; inset:0; border-radius:50%; border:1.5px solid var(--accent); opacity:0}
.orb.speaking .orb-ring{animation:ripple 2.1s cubic-bezier(.2,.6,.3,1) infinite}
.orb.speaking .r2{animation-delay:.7s} .orb.speaking .r3{animation-delay:1.4s}
@keyframes ripple{0%{transform:scale(.62); opacity:.5}100%{transform:scale(1.25); opacity:0}}
.orb-core{
  width:96px; height:96px; border-radius:50%; display:grid; place-items:center;
  background:linear-gradient(150deg,#0d8079,var(--navy)); color:#fff;
  box-shadow:0 12px 30px -12px rgba(10,108,102,.75), inset 0 1px 0 rgba(255,255,255,.25);
  transition:transform .25s;
}
.orb.thinking .orb-core{animation:breathe 1.5s ease-in-out infinite}
@keyframes breathe{0%,100%{transform:scale(1)}50%{transform:scale(1.06)}}
.bars{display:flex; align-items:center; gap:3px; height:40px}
.bars i{
  display:block; width:4px; height:6px; border-radius:2px; background:rgba(255,255,255,.92);
  transform-origin:center; transition:height .07s linear;
}
.orb-caption{text-align:center; line-height:1.35}
.orb-caption strong{display:block; font-family:var(--display); font-size:16.5px; font-weight:650}
.orb-caption span{font-size:13px; color:var(--ink-3)}

/* ── Transcript ────────────────────────────────────────────────────────── */
.transcript{
  flex:1; min-height:180px; overflow-y:auto; padding:4px clamp(16px,3vw,28px) 8px;
  display:flex; flex-direction:column; gap:10px; scroll-behavior:smooth;
}
.tr-empty,.fields-empty,.feed-empty{color:var(--ink-3); font-size:13.5px; text-align:center; padding:22px 0}
.msg{max-width:82%; padding:10px 14px; border-radius:14px; font-size:14.5px; animation:rise .22s ease-out}
@keyframes rise{from{opacity:0; transform:translateY(6px)}to{opacity:1; transform:none}}
.msg.agent{align-self:flex-start; background:var(--accent-soft); color:#07423e; border-bottom-left-radius:4px}
.msg.user{align-self:flex-end; background:var(--navy); color:#fff; border-bottom-right-radius:4px}
.msg.interim{opacity:.6; font-style:italic}
.msg .who{display:block; font-size:10px; font-weight:700; letter-spacing:.09em; text-transform:uppercase; opacity:.66; margin-bottom:3px}

.controls{
  display:flex; gap:10px; justify-content:center; padding:14px clamp(16px,3vw,28px) 20px;
  border-top:1px solid var(--line-2);
}
#liveError{margin:0 clamp(16px,3vw,28px) 18px}

/* ── Summary ───────────────────────────────────────────────────────────── */
.summary-inner{padding:clamp(24px,4vw,40px); overflow-y:auto}
.sum-head{display:flex; align-items:flex-start; justify-content:space-between; gap:16px; margin-bottom:22px}
.sum-head h2{font-size:25px; font-weight:700; margin-bottom:6px}
.badge{
  padding:7px 13px; border-radius:999px; font-size:12px; font-weight:700; letter-spacing:.03em;
  background:#e9eeee; color:var(--ink-2); white-space:nowrap;
}
.badge.ok{background:var(--ok-soft); color:#116432}
.badge.warn{background:var(--warn-soft); color:var(--warn)}
.badge.bad{background:var(--bad-soft); color:var(--bad)}
.sum-grid{display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); gap:1px; background:var(--line); border:1px solid var(--line); border-radius:var(--r-sm); overflow:hidden; margin:0}
.sum-grid>div{background:#fff; padding:12px 14px}
.sum-grid dt{font-size:10.5px; text-transform:uppercase; letter-spacing:.07em; color:var(--ink-3); margin-bottom:3px; font-weight:600}
.sum-grid dd{margin:0; font-size:14.5px; font-weight:600}
.sum-actions{display:flex; gap:10px; margin:22px 0 18px; flex-wrap:wrap}
.json-wrap summary{cursor:pointer; font-size:13px; color:var(--ink-2); font-weight:600}
.json-wrap pre{
  background:#0d1f1e; color:#bfdedb; padding:16px; border-radius:var(--r-sm); overflow-x:auto;
  font-family:var(--mono); font-size:12.5px; line-height:1.6; margin-top:10px;
}

/* ── Brief panel ───────────────────────────────────────────────────────── */
.brief{padding:20px; position:sticky; top:82px; display:flex; flex-direction:column; gap:16px; max-height:calc(100vh - 102px)}
.brief-head{display:flex; align-items:center; justify-content:space-between; gap:14px}
.brief-head h2{font-size:16.5px; font-weight:650}
.brief-head p{font-size:12.5px; color:var(--ink-3); margin-top:2px}
.ring-wrap{position:relative; width:56px; height:56px; flex:none}
.ring{width:56px; height:56px; transform:rotate(-90deg)}
.ring circle{fill:none; stroke-width:4.5; stroke-linecap:round}
.ring-bg{stroke:var(--line)}
.ring-fg{stroke:var(--accent); stroke-dasharray:119.4; stroke-dashoffset:119.4; transition:stroke-dashoffset .5s cubic-bezier(.4,0,.2,1), stroke .3s}
.ring-fg.complete{stroke:var(--ok)}
.ring-label{position:absolute; inset:0; display:grid; place-items:center; line-height:1; font-family:var(--mono); font-variant-numeric:tabular-nums}
.ring-label strong{font-size:14.5px; font-weight:600}
.ring-label span{font-size:10px; color:var(--ink-3)}

.chips{display:flex; gap:7px; flex-wrap:wrap}
.chip{
  display:inline-flex; align-items:center; gap:6px; font-size:11.5px; font-weight:600;
  padding:5px 10px; border-radius:999px; background:#eef2f2; color:var(--ink-3); border:1px solid var(--line-2);
}
.chip .dot{width:6px; height:6px; border-radius:50%; background:currentColor}
.chip.on{background:var(--ok-soft); color:#116432; border-color:#c6e5d2}
.chip.blocked{background:var(--bad-soft); color:var(--bad); border-color:#f0cdc9}

.fields{list-style:none; margin:0; padding:0; overflow-y:auto; flex:1; min-height:120px; border-top:1px solid var(--line-2)}
.fields li{display:flex; align-items:baseline; gap:10px; padding:9px 2px; border-bottom:1px solid var(--line-2); font-size:13.5px}
.fields li.pending{color:var(--ink-3)}
.f-label{flex:1; min-width:0; display:flex; align-items:center; gap:6px}
.f-req{font-size:8.5px; font-weight:700; color:var(--accent); letter-spacing:.07em; background:var(--accent-soft); padding:2px 5px; border-radius:4px}
.f-val{font-weight:600; text-align:right; max-width:52%; word-break:break-word}
.fields li.pending .f-val{font-weight:400; opacity:.62}
.fields li.flash{animation:flash 1.5s ease-out}
@keyframes flash{0%{background:#fdf6dc}60%{background:#fdf6dc}100%{background:transparent}}

.feed-wrap h3{font-size:10.5px; text-transform:uppercase; letter-spacing:.09em; color:var(--ink-3); margin-bottom:8px; font-weight:600}
.feed{list-style:none; margin:0; padding:0; max-height:150px; overflow-y:auto; display:flex; flex-direction:column-reverse; gap:6px}
.feed li{font-size:12.5px; color:var(--ink-2); padding-left:16px; position:relative; animation:rise .22s ease-out}
.feed li::before{content:""; position:absolute; left:2px; top:6px; width:6px; height:6px; border-radius:50%; background:var(--accent)}
.feed li.k-outcome::before,.feed li.k-handoff::before,.feed li.k-consent::before{background:var(--ok)}
.feed li.k-gate::before{background:var(--warn)}
.feed li.feed-empty{padding-left:0} .feed li.feed-empty::before{display:none}

.cheat{border-top:1px solid var(--line-2); padding-top:12px}
.cheat summary{cursor:pointer; font-size:12.5px; font-weight:600; color:var(--accent)}
.cheat-body{font-size:12.5px; color:var(--ink-2); margin-top:10px; max-height:230px; overflow-y:auto}
.cheat-body p{margin:9px 0 5px; font-weight:600}
.cheat-body ol,.cheat-body ul{margin:0; padding-left:18px; display:flex; flex-direction:column; gap:4px}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width:1080px){
  .layout{grid-template-columns:1fr}
  .brief{position:static; max-height:none; order:2}
  /* Stacked, a fixed console height would waste the screen — let it size to content
     and cap the transcript instead, so the controls stay reachable either way. */
  .console{height:auto; min-height:520px; order:1}
  .transcript{max-height:46vh}
  .fields{max-height:none}
}
@media (max-width:560px){
  .topbar-right .stat{display:none}
  .orb-wrap{padding:22px 16px 16px}
  .msg{max-width:92%}
  .transcript{max-height:52vh}
}
@media (prefers-reduced-motion:reduce){
  *{animation:none !important; transition:none !important; scroll-behavior:auto !important}
}
