:root {
  --enamel: #F6FAF9;
  --paper: #FFFFFF;
  --ink: #0F3D3E;
  --ink-soft: #4A6B6B;
  --sea: #1E7F74;
  --sea-deep: #135E56;
  --mint: #CDEFE1;
  --floss: #DDE8E5;
  --alert: #C8374E;
  --alert-soft: #FBE6EA;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, sans-serif;
  --r-sm: 10px;
  --r-lg: 22px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--enamel);
  color: var(--ink);
  font: 400 17px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--sea); outline-offset: 2px; border-radius: 6px; }
svg { fill: currentColor; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- layout ---------- */
.shell {
  display: grid;
  grid-template-columns: minmax(300px, 400px) 1fr;
  height: 100dvh;
}

/* ---------- reception desk ---------- */
.desk {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 36px 36px 28px;
  background: var(--ink);
  color: #E6F3EF;
  overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  color: inherit; text-decoration: none;
  font: 700 17px/1.1 var(--display);
}
.brand__mark { width: 40px; height: 40px; fill: var(--mint); }
.desk__title {
  margin: 18px 0 0;
  font: 800 clamp(34px, 3.4vw, 46px)/1.02 var(--display);
  letter-spacing: -0.02em;
  color: #fff;
}
.desk__lede { margin: 0; max-width: 34ch; color: #B9D6CF; }
.call-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  align-self: flex-start;
  padding: 14px 22px;
  border: 0; border-radius: 999px;
  background: var(--mint); color: var(--ink);
  font: 700 17px/1 var(--display);
  transition: transform .15s ease, background .15s ease;
}
.call-btn svg { width: 20px; height: 20px; }
.call-btn:hover { background: #fff; }
.call-btn:active { transform: scale(.97); }
.call-btn:disabled { opacity: .5; cursor: not-allowed; }
.desk__hint { margin: -12px 0 0; font-size: 14px; color: #8FB5AC; min-height: 1em; }
.facts { margin: auto 0 0; display: grid; gap: 14px; }
.facts div { display: grid; grid-template-columns: 76px 1fr; gap: 12px; padding-top: 14px; border-top: 1px solid #2A5657; }
.facts dt { color: #8FB5AC; font-size: 14px; }
.facts dd { margin: 0; font-size: 15px; }
.open { color: var(--mint); font-weight: 700; }
.closed { color: #F3B7C1; font-weight: 700; }
.desk__foot { margin: 0; font-size: 13px; color: #8FB5AC; }
.desk__foot a { color: inherit; }

/* ---------- chat ---------- */
.chat {
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  min-height: 0;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px;
}
.chat__head {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 0 16px;
  border-bottom: 1px solid var(--floss);
}
.avatar {
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--mint); color: var(--sea-deep);
  font: 800 20px/1 var(--display);
}
.chat__name { margin: 0; font: 700 18px/1.2 var(--display); }
.chat__status { margin: 0; font-size: 14px; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #2DBE8C; }
.ghost {
  margin-left: auto; padding: 8px 14px; white-space: nowrap;
  background: none; border: 1px solid var(--floss); border-radius: 999px;
  font-size: 14px; color: var(--ink-soft);
}
.ghost:hover { border-color: var(--sea); color: var(--sea); }

/* booking progress: a real sequence, so it earns its markers */
.steps {
  list-style: none; margin: 0; padding: 12px 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  border-bottom: 1px solid var(--floss);
  font-size: 13px; color: var(--ink-soft);
}
.steps li { display: flex; align-items: center; gap: 8px; position: relative; padding-top: 10px; }
.steps li::before {  /* the track segment above each step */
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; border-radius: 4px;
  background: var(--floss); transition: background .3s ease;
}
.steps__dot {
  width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 2px solid var(--floss); background: var(--paper);
  display: grid; place-items: center;
}
.steps li[data-state="done"]::before, .steps li[data-state="current"]::before { background: var(--sea); }
.steps li[data-state="current"] { color: var(--ink); font-weight: 700; }
.steps li[data-state="current"] .steps__dot { border-color: var(--sea); background: var(--mint); }
.steps li[data-state="done"] { color: var(--sea-deep); }
.steps li[data-state="done"] .steps__dot { border-color: var(--sea); background: var(--sea); }
.steps li[data-state="done"] .steps__dot::after {  /* check mark, so state isn't colour-only */
  content: ""; width: 4px; height: 7px; margin-top: -2px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}

.log {
  list-style: none; margin: 0; padding: 20px 0 8px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}
.msg { max-width: min(78%, 560px); }
.msg p { margin: 0; }
.msg--bot { align-self: flex-start; }
.msg--user { align-self: flex-end; }
.bubble { padding: 12px 16px; border-radius: var(--r-lg); }
.msg--bot .bubble { background: var(--paper); border: 1px solid var(--floss); border-bottom-left-radius: 6px; }
.msg--user .bubble { background: var(--sea); color: #fff; border-bottom-right-radius: 6px; }
.msg--urgent .bubble { border-color: #F0B3BE; background: var(--alert-soft); }
.msg--error .bubble { background: none; border: 1px dashed var(--alert); color: var(--alert); }
.msg--new { animation: rise .22s ease-out; }
.msg__meta { display: block; margin: 4px 6px 0; font-size: 12px; color: var(--ink-soft); }
.msg--user .msg__meta { text-align: right; }
.send:disabled { opacity: .55; cursor: progress; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.typing .bubble { display: flex; gap: 5px; padding: 16px 18px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-soft); opacity: .4; animation: blink 1s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 50% { opacity: 1; } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0 12px; min-height: 8px; }
.chip {
  padding: 8px 14px;
  border: 1.5px solid var(--sea); border-radius: 999px;
  background: var(--paper); color: var(--sea-deep);
  font: 700 15px/1.2 var(--display);
}
.chip:hover { background: var(--mint); }
.chip--link { text-decoration: none; display: inline-flex; align-items: center; }
/* appointment times: a small calendar card instead of a pill */
.chip--slot {
  display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center;
  padding: 8px 14px 8px 10px; border-radius: var(--r-sm); text-align: left;
}
.chip--slot svg { grid-row: span 2; width: 20px; height: 20px; fill: var(--sea); }
.chip--slot .chip__day { font: 400 13px/1.2 var(--body); color: var(--ink-soft); }
.chip--slot .chip__time { font: 700 16px/1.2 var(--display); color: var(--ink); }
.chip--slot:hover .chip__day { color: var(--ink); }

.composer {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 20px; padding: 6px 6px 6px 18px;
  background: var(--paper);
  border: 1.5px solid var(--floss); border-radius: 999px;
}
.composer:focus-within { border-color: var(--sea); }
.composer input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; padding: 10px 0; font-size: 17px; }
.mic, .send {
  display: grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%; border: 0;
}
.mic { background: none; color: var(--ink-soft); }
.mic:hover { color: var(--sea); background: var(--enamel); }
.mic[aria-pressed="true"] { color: #fff; background: var(--alert); animation: pulse 1.2s infinite; }
.send { background: var(--sea); color: #fff; }
.send:hover { background: var(--sea-deep); }
.mic svg, .send svg { width: 22px; height: 22px; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(200, 55, 78, .18); } }

/* ---------- the appointment card (the one bold moment) ---------- */
.msg--card { max-width: min(100%, 560px); align-self: flex-start; }
.appt {
  --cut: 12px;
  display: grid;
  grid-template-columns: 1fr 112px;
  background: var(--paper);
  border-radius: var(--r-sm);
  filter: drop-shadow(0 10px 24px rgba(15, 61, 62, .12));
  /* punched notches where the stub tears off */
  -webkit-mask: radial-gradient(circle var(--cut) at calc(100% - 112px) 0, #0000 98%, #000) top / 100% 51% no-repeat,
                radial-gradient(circle var(--cut) at calc(100% - 112px) 100%, #0000 98%, #000) bottom / 100% 51% no-repeat;
          mask: radial-gradient(circle var(--cut) at calc(100% - 112px) 0, #0000 98%, #000) top / 100% 51% no-repeat,
                radial-gradient(circle var(--cut) at calc(100% - 112px) 100%, #0000 98%, #000) bottom / 100% 51% no-repeat;
}
.appt__main { padding: 20px 22px; border-right: 2px dashed var(--floss); }
.appt__clinic { margin: 0; font-size: 13px; color: var(--ink-soft); }
.appt__when { margin: 4px 0 2px; font: 800 26px/1.1 var(--display); letter-spacing: -.01em; }
.appt__doc { margin: 0 0 14px; color: var(--sea-deep); font-weight: 700; }
.appt__rows { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 0; }
.appt__rows dt { font-size: 12px; color: var(--ink-soft); }
.appt__rows dd { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.appt__details { margin: 12px 0 0; font-size: 14px; color: var(--ink-soft); }
.appt__details:empty { display: none; }
.appt__stub {
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px;
  padding: 16px 10px;
  background: var(--mint);
  text-align: center;
}
.appt__stubLabel { margin: 0; font-size: 12px; color: var(--sea-deep); }
.appt__ref { margin: 0; font: 800 17px/1.1 var(--display); color: var(--ink); writing-mode: vertical-rl; transform: rotate(180deg); letter-spacing: .04em; }
.appt--pending .appt__stub { background: var(--enamel); }
.appt--urgent .appt__stub { background: var(--alert); }
.appt--urgent .appt__stubLabel, .appt--urgent .appt__ref { color: #fff; }
.appt--confirmed { animation: stamp .45s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes stamp { from { transform: scale(.94) rotate(-1deg); opacity: .4; } }

/* ---------- voice call ---------- */
.call {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center;
  padding: 28px 20px 32px;
  background: radial-gradient(120% 80% at 50% 30%, #17585A 0%, var(--ink) 70%);
  color: #E6F3EF;
}
.call[hidden] { display: none; }
.call__top { text-align: center; }
.call__who { margin: 0; font: 700 18px/1.2 var(--display); }
.call__timer { margin: 4px 0 0; color: #8FB5AC; font-variant-numeric: tabular-nums; }
.orb {
  --level: 0;
  position: relative;
  width: 210px; height: 210px; margin: 6vh 0 22px;
  display: grid; place-items: center;
  border: 0; background: none; cursor: pointer;
}
.orb span {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(205, 239, 225, .35);
  transform: scale(calc(.62 + var(--level) * .5));
  transition: transform .08s linear;
}
.orb span:nth-child(2) { transform: scale(calc(.74 + var(--level) * .38)); opacity: .6; }
.orb span:nth-child(3) { transform: scale(calc(.86 + var(--level) * .22)); opacity: .3; }
.orb__core {
  width: 120px; height: 120px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--mint); color: var(--ink);
  font: 800 46px/1 var(--display);
  transition: transform .2s ease;
}
.orb--speaking .orb__core { animation: talk 1.1s ease-in-out infinite; }
.orb--listening .orb__core { background: #fff; }
@keyframes talk { 50% { transform: scale(1.06); } }
.call__state { margin: 0; font: 700 20px/1.3 var(--display); min-height: 1.3em; }
.captions { width: min(640px, 100%); margin-top: 18px; max-height: 30vh; overflow-y: auto; text-align: center; }
.captions p { margin: 0 0 10px; color: #B9D6CF; }
.captions .cap--you { color: #fff; font-weight: 700; }
.captions .cap--interim { opacity: .6; }
.call__chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; max-width: 640px; }
.call__chips .chip { background: transparent; color: var(--mint); border-color: rgba(205, 239, 225, .5); }
.call__chips .chip:hover { background: rgba(205, 239, 225, .12); }
.call__controls { display: flex; gap: 28px; margin-top: auto; }
.round { width: 64px; height: 64px; border-radius: 50%; border: 0; display: grid; place-items: center; background: rgba(255,255,255,.12); color: #fff; }
.round svg { width: 28px; height: 28px; }
.round[aria-pressed="true"] { background: #fff; color: var(--ink); }
.round--end { background: var(--alert); }
.round--end:hover { background: #A72B40; }
.call__tip { margin: 14px 0 0; font-size: 13px; color: #8FB5AC; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .desk { padding: 16px; gap: 10px; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .desk__title, .desk__lede, .facts, .desk__foot, .desk__hint { display: none; }
  .brand span { font-size: 15px; }
  .brand__mark { width: 32px; height: 32px; }
  .call-btn { margin-left: auto; padding: 10px 16px; font-size: 15px; }
  .chat { padding: 0 16px; }
  .msg { max-width: 88%; }
  .chat__status { font-size: 13px; }
  .chat__head { padding: 14px 0 10px; }
  .steps { gap: 6px; padding: 10px 0; font-size: 12px; }
  .steps li { padding-top: 6px; white-space: nowrap; }
  .steps__dot { display: none; }
  .steps li:not([data-state="current"]) { font-size: 0; }  /* phones: track + current label only; others stay for screen readers via aria */
  .appt { grid-template-columns: 1fr 76px; --cut: 9px;
    -webkit-mask: radial-gradient(circle var(--cut) at calc(100% - 76px) 0, #0000 98%, #000) top / 100% 51% no-repeat,
                  radial-gradient(circle var(--cut) at calc(100% - 76px) 100%, #0000 98%, #000) bottom / 100% 51% no-repeat;
            mask: radial-gradient(circle var(--cut) at calc(100% - 76px) 0, #0000 98%, #000) top / 100% 51% no-repeat,
                  radial-gradient(circle var(--cut) at calc(100% - 76px) 100%, #0000 98%, #000) bottom / 100% 51% no-repeat; }
  .appt__rows { grid-template-columns: 1fr; }
  .appt__when { font-size: 22px; }
}

@media (max-width: 400px) {
  .desk { padding: 12px 16px; }
  .call-btn__more { display: none; }
  .call-btn { padding: 10px 14px; }
  .chat__status { display: none; }
  .msg { max-width: 92%; }
  .msg--card { max-width: 100%; }
  .composer { padding-left: 14px; gap: 4px; }
  .mic, .send { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
