/* Call page. One screen, built around the portrait: a brand-coloured disc with the
   receptionist rising out of it. Ink and paper everywhere else, so any brand colour works. */
:root {
  --ink: #10231F;
  --ink-soft: #4C5F5A;
  --paper: #F2F5F1;
  --surface: #FFFFFF;
  --line: #D9E0DA;
  --end: #D93A3A;
  --brand: #0C8F6B;
  --display: 'Bricolage Grotesque Variable', 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'Instrument Sans Variable', 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --level: 0;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.stage {
  position: relative;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  padding: max(14px, env(safe-area-inset-top)) 20px max(18px, env(safe-area-inset-bottom));
  overflow: hidden;
}

/* Top bar */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: 34px; height: 34px; border-radius: 9px; object-fit: contain; background: var(--surface); }
.brand-name { font-family: var(--display); font-weight: 650; font-size: 1.12rem; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 13px; border-radius: 999px;
  border: 1.5px solid var(--ink); font-weight: 600; font-size: 0.86rem; white-space: nowrap;
}
.chip svg { width: 16px; height: 16px; stroke-width: 2.2; }
.chip.solid { background: var(--ink); color: var(--paper); }
.timer { font-family: var(--display); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 1.05rem; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.timer::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--end); margin-right: 8px; vertical-align: 1px; }

/* Portrait */
.portrait { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; gap: 14px; }
.frame {
  --d: min(84vw, 48dvh, 400px);
  position: relative;
  width: var(--d);
  height: calc(var(--d) * 1.2);
  flex: none;
}
.disc {
  position: absolute; left: 0; bottom: 0;
  width: var(--d); height: var(--d);
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 calc(var(--level) * 14px) color-mix(in srgb, var(--brand) 22%, transparent);
}
.stage[data-state='connecting'] .disc { animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { box-shadow: 0 0 0 12px color-mix(in srgb, var(--brand) 20%, transparent); } }
.bust {
  position: absolute; inset: 0;
  border-radius: 0 0 calc(var(--d) / 2) calc(var(--d) / 2);
  overflow: hidden;
}
.bust canvas { display: block; width: 100%; height: 100%; }

.status {
  margin: 0; min-height: 1.5em;
  font-weight: 600; font-size: 0.95rem; color: var(--ink-soft);
  display: flex; align-items: center; gap: 8px;
}
.stage[data-state='idle'] .status { font-family: var(--display); font-size: clamp(1.5rem, 6.4vw, 2rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; color: var(--ink); text-align: center; }
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); }
.stage[data-state='listening'] .status .dot { transform: scale(calc(1 + var(--mic, 0) * 1.6)); transition: transform 80ms; }
.stage[data-state='thinking'] .status .dot, .stage[data-state='connecting'] .status .dot { animation: pulse 0.9s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

/* Captions */
.captions { min-height: 5.6em; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; padding: 8px 0 14px; text-align: center; }
.stage[data-state='idle'] .captions, .stage[data-state='ended'] .captions { min-height: 0.5em; }
.line { margin: 0; }
.line.agent { font-family: var(--display); font-size: clamp(1.08rem, 4.6vw, 1.3rem); font-weight: 550; line-height: 1.3; letter-spacing: -0.01em; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.line.caller { font-size: 0.92rem; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line.caller:not(:empty)::before { content: 'You: '; font-weight: 600; }

/* Dock */
.dock { display: grid; }
.talk {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 19px 24px; border-radius: 999px;
  background: var(--ink); color: var(--paper);
  font-family: var(--display); font-weight: 650; font-size: 1.22rem; letter-spacing: -0.01em;
  transition: transform 120ms;
}
.talk svg { width: 24px; height: 24px; fill: currentColor; stroke: none; }
.talk:active { transform: scale(0.98); }
.talk:disabled { opacity: 0.45; cursor: default; }
.talk.small { padding: 15px 20px; font-size: 1.05rem; }
.fine { margin: 12px auto 0; max-width: 34em; text-align: center; font-size: 0.78rem; line-height: 1.45; color: var(--ink-soft); }

.controls { display: grid; grid-template-columns: 1fr 1.25fr 1fr; gap: 10px; align-items: stretch; }
.round {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  padding: 13px 8px; border-radius: 22px;
  background: var(--surface); border: 1px solid var(--line);
  font-weight: 600; font-size: 0.82rem;
}
.round[aria-pressed='true'] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.round.end { background: var(--end); border-color: var(--end); color: #fff; }
.round.end svg { fill: currentColor; stroke: none; width: 26px; height: 26px; }
.mic-off { display: none; }
#muteBtn[aria-pressed='true'] .mic-on { display: none; }
#muteBtn[aria-pressed='true'] .mic-off { display: block; }

.type-row { display: flex; gap: 8px; margin-bottom: 10px; }
.type-row input {
  flex: 1; min-width: 0; padding: 13px 16px; border-radius: 999px;
  border: 1.5px solid var(--ink); background: var(--surface); font: inherit; font-size: 1rem; color: var(--ink);
}
.send { width: 48px; height: 48px; border-radius: 50%; background: var(--ink); color: var(--paper); display: grid; place-items: center; flex: none; }

/* Cards, sheets, banner, toast */
.card {
  position: absolute; left: 20px; right: 20px; bottom: calc(150px + env(safe-area-inset-bottom));
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 16px;
  box-shadow: 0 18px 40px -18px rgba(16, 35, 31, 0.45);
  animation: rise 220ms ease-out;
}
.card-title { margin: 0 0 10px; font-weight: 700; }
.contact-list { display: grid; gap: 8px; }
.contact-list a {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px;
  background: var(--paper); color: var(--ink); text-decoration: none; font-weight: 600; overflow-wrap: anywhere;
}
.sheet .contact-list a { background: var(--surface); border: 1px solid var(--line); }
.contact-list a small { display: block; font-weight: 500; color: var(--ink-soft); }
.link { margin-top: 10px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; font-size: 0.9rem; }

.sheet { position: absolute; inset: 0; background: rgba(16, 35, 31, 0.38); display: flex; align-items: flex-end; z-index: 5; }
.sheet-body {
  width: 100%; background: var(--paper); border-radius: 28px 28px 0 0;
  padding: 26px 22px max(22px, env(safe-area-inset-bottom));
  display: grid; gap: 14px; animation: rise 240ms ease-out;
  max-height: 86dvh; overflow: auto;
}
.sheet h2 { margin: 0; font-family: var(--display); font-size: 1.6rem; letter-spacing: -0.02em; }
.muted { margin: 0; color: var(--ink-soft); }
.rate p { margin: 0 0 8px; font-weight: 600; }
.rate-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rate-buttons button { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 13px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; }
.rate-buttons button[aria-pressed='true'] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.steps { margin: 0; padding-left: 1.2em; display: grid; gap: 10px; line-height: 1.45; }

.banner {
  position: absolute; left: 12px; right: 12px; top: max(64px, calc(env(safe-area-inset-top) + 58px));
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 12px 14px;
  box-shadow: 0 18px 40px -20px rgba(16, 35, 31, 0.5);
  animation: rise 260ms ease-out; z-index: 4;
}
.banner img { width: 44px; height: 44px; border-radius: 11px; grid-row: span 2; }
.banner p { margin: 0; font-size: 0.9rem; font-weight: 600; line-height: 1.3; grid-column: 2 / 4; }
.banner .chip { grid-column: 2; justify-self: start; margin-top: 4px; }
.banner .link { margin-top: 4px; justify-self: end; }

.toast {
  position: absolute; left: 20px; right: 20px; top: max(70px, calc(env(safe-area-inset-top) + 62px));
  background: var(--ink); color: var(--paper); border-radius: 16px; padding: 13px 16px;
  font-weight: 600; font-size: 0.92rem; line-height: 1.4; text-align: center; z-index: 6; animation: rise 200ms ease-out;
}
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }

.embed .banner, .embed #installBtn { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
