:root {
  --forest: #173f32;
  --forest-deep: #0d2a21;
  --mint: #dcecdf;
  --cream: #f7f1e4;
  --paper: #fffdf8;
  --copper: #b96635;
  --ink: #17241f;
  --muted: #66746d;
  --line: rgba(23, 63, 50, 0.16);
  --danger: #a83b3f;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Avenir Next", "Century Gothic", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at 9% 12%, rgba(185, 102, 53, .18), transparent 23rem),
    linear-gradient(115deg, var(--forest-deep) 0 34%, var(--cream) 34% 100%);
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.assistant-header {
  min-height: 76px;
  padding: 16px clamp(20px, 5vw, 76px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: white;
}
.brand { color: inherit; text-decoration: none; display: flex; gap: 12px; align-items: center; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.35); border-radius: 50%; font-family: Georgia, serif; }
.brand strong, .brand small { display: block; }
.brand small { opacity: .7; margin-top: 2px; }
.status-pill { border: 1px solid rgba(255,255,255,.24); border-radius: 999px; padding: 9px 14px; font-size: .84rem; }
.status-pill i { display: inline-block; width: 8px; height: 8px; background: #82d69a; border-radius: 50%; margin-right: 6px; box-shadow: 0 0 0 5px rgba(130,214,154,.12); }

.assistant-shell { width: min(1760px, calc(100% - 64px)); margin: 2vh auto 7vh; display: grid; grid-template-columns: minmax(0, .95fr) minmax(620px, 1.05fr); gap: clamp(32px, 4vw, 72px); align-items: start; }
.intro-panel { color: white; padding: clamp(20px, 5vw, 64px) 0; position: sticky; top: 24px; }
.eyebrow { color: var(--copper); text-transform: uppercase; letter-spacing: .15em; font-weight: 800; font-size: .76rem; margin: 0 0 12px; }
.intro-panel h1 { margin: 0; font: 400 clamp(2.5rem, 4.2vw, 4.35rem)/.98 Georgia, serif; max-width: 8ch; }
.intro-panel > p:not(.eyebrow) { color: rgba(255,255,255,.72); line-height: 1.7; max-width: min(29rem, 25vw); }
.trust-list { display: grid; gap: 10px; margin-top: 32px; font-size: .9rem; }
.trust-list span::before { content: ""; display: inline-block; width: 18px; height: 1px; background: var(--copper); margin: 0 10px 4px 0; }

.conversation-card { width: min(100%, 674px); justify-self: start; background: rgba(255,253,248,.97); border: 1px solid rgba(255,255,255,.7); box-shadow: 0 28px 90px rgba(4,24,17,.24); border-radius: 28px; padding: clamp(20px, 4vw, 42px); min-height: 650px; }
.conversation-card--chat { display: grid; grid-template-rows: auto minmax(360px, 1fr) auto auto auto; min-height: min(760px, calc(100vh - 120px)); }
.chat-heading { display: flex; justify-content: space-between; gap: 20px; align-items: start; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.chat-heading h2 { margin: 0; font: 400 clamp(1.5rem, 3vw, 2.1rem) Georgia, serif; }
.patient-chat { display: grid; align-content: start; gap: 15px; min-height: 360px; max-height: 520px; overflow-y: auto; padding: 24px 4px; scroll-behavior: smooth; }
.patient-chat__message { display: flex; gap: 11px; width: min(82%, 680px); animation: reveal .28s ease both; }
.patient-chat__bubble { padding: 13px 16px; border-radius: 6px 18px 18px 18px; background: var(--mint); line-height: 1.5; }
.patient-chat__bubble p { margin: 0; }
.patient-chat__bubble p + p { margin-top: 7px; }
.patient-chat__message--user { justify-self: end; }
.patient-chat__message--user .patient-chat__bubble { color: white; background: var(--forest); border-radius: 18px 6px 18px 18px; }
.patient-chat__message--thinking { opacity: .65; }
.patient-chat__avatar { flex: 0 0 36px; height: 36px; display: grid; place-items: center; color: white; background: var(--forest); border-radius: 13px 13px 13px 3px; font-family: Georgia, serif; }
.patient-chat__actions { display: flex; flex-wrap: wrap; gap: 9px; padding: 4px 0 16px; }
.patient-chat__choice { border: 1px solid var(--line); border-radius: 999px; padding: 10px 14px; color: var(--forest); background: white; cursor: pointer; font-weight: 700; }
.patient-chat__choice:hover { color: white; background: var(--forest); transform: translateY(-1px); }
.patient-chat__choice--danger { color: var(--danger); border-color: rgba(168,59,63,.3); }
.patient-chat__composer { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding-top: 15px; border-top: 1px solid var(--line); }
.patient-chat__composer input { min-height: 50px; border-radius: 15px; }
.privacy-note { margin: 12px 0 0; color: var(--muted); font-size: .78rem; text-align: center; }
.chat-result-card { margin-top: 9px; padding: 14px; border: 1px solid rgba(23,63,50,.14); border-radius: 13px; background: rgba(255,255,255,.72); }
.chat-result-card strong, .chat-result-card span { display: block; }
.chat-result-card span { margin-top: 4px; color: var(--muted); }
.chat-result-card a { margin-top: 12px; }
.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; }

body.widget-mode {
  min-height: 100vh;
  background: var(--paper);
}
.widget-mode .assistant-header,
.widget-mode .intro-panel {
  display: none;
}
.widget-mode .assistant-shell {
  display: block;
  width: 100%;
  margin: 0;
}
.widget-mode .conversation-card--chat {
  min-height: 100vh;
  height: 100vh;
  padding: 18px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.widget-mode .chat-heading {
  padding-bottom: 12px;
}
.widget-mode .chat-heading .eyebrow {
  display: none;
}
.widget-mode .chat-heading h2 {
  font-size: 1.35rem;
}
.widget-mode .patient-chat {
  min-height: 0;
  max-height: none;
}
.conversation-tabs { display: flex; gap: 6px; padding: 5px; background: #edf1eb; border-radius: 14px; margin-bottom: 30px; }
.tab { flex: 1; border: 0; background: transparent; color: var(--muted); border-radius: 10px; padding: 12px; cursor: pointer; font-weight: 700; }
.tab.active { background: var(--paper); color: var(--forest); box-shadow: 0 4px 18px rgba(23,63,50,.1); }
.assistant-message { display: flex; gap: 14px; margin-bottom: 26px; }
.assistant-message.compact { margin-bottom: 20px; }
.assistant-avatar { flex: 0 0 38px; height: 38px; border-radius: 13px 13px 13px 3px; display: grid; place-items: center; color: white; background: var(--forest); font-family: Georgia, serif; }
.assistant-message strong { display: block; margin: 2px 0 5px; }
.assistant-message p { margin: 0; color: var(--muted); line-height: 1.5; }
.flow-step { padding: 20px 0; border-top: 1px solid var(--line); animation: reveal .35s ease both; }
.flow-step > label:first-child, .lookup-form label, .field-grid label, .reschedule-panel label { display: grid; gap: 8px; color: var(--forest); font-weight: 750; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; background: white; color: var(--ink); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(23,63,50,.1); }
label small { color: var(--muted); font-weight: 500; }
.date-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.choice-note { color: var(--muted); margin-top: 10px; line-height: 1.5; font-size: .9rem; }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 9px; margin-top: 16px; }
.slot { border: 1px solid var(--line); background: white; border-radius: 11px; padding: 11px 8px; cursor: pointer; color: var(--forest); font-weight: 750; }
.slot:hover, .slot.selected { background: var(--forest); color: white; transform: translateY(-1px); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.field-grid .full { grid-column: 1 / -1; }
.check-row { display: flex; align-items: flex-start; gap: 10px; color: var(--muted); margin: 16px 0; line-height: 1.4; }
.check-row input { width: auto; margin-top: 3px; accent-color: var(--forest); }
.confirmation { color: var(--ink); padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--mint); }
.booking-summary, .managed-card, .confirmation-box { margin-top: 20px; padding: 18px; border-radius: 15px; background: #f0f3ed; line-height: 1.6; }
.booking-summary strong { color: var(--forest); }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 11px; padding: 10px 16px; border: 1px solid transparent; text-decoration: none; cursor: pointer; font-weight: 750; }
.button.primary { color: white; background: var(--forest); }
.button.secondary { color: var(--forest); background: transparent; border-color: var(--line); }
.button.danger { color: var(--danger); border-color: rgba(168,59,63,.25); background: #fff5f4; }
.button.wide { width: 100%; }
.button:disabled { opacity: .55; cursor: wait; }
.success-panel { text-align: center; padding: 22px 0; animation: reveal .4s ease both; }
.success-icon { margin: 0 auto 20px; width: 62px; height: 62px; display: grid; place-items: center; color: white; background: var(--forest); border-radius: 50%; font-size: 1.7rem; }
.success-panel h2 { font: 400 2rem Georgia, serif; }
.private-key { margin: 24px 0; border: 1px dashed var(--copper); background: #fff8ec; padding: 18px; border-radius: 14px; }
.private-key span, .private-key small { display: block; color: var(--muted); }
.private-key strong { display: block; letter-spacing: .14em; font-size: 1.35rem; margin: 8px; }
.action-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 20px; }
.lookup-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; }
.saved-access { width: 100%; border: 1px dashed var(--copper); color: var(--forest); background: #fff8ec; padding: 12px; border-radius: 12px; margin-bottom: 18px; cursor: pointer; }
.reschedule-panel { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 22px; display: grid; gap: 13px; }
.attention-alert { margin-bottom: 16px; padding: 14px; border: 1px solid rgba(185,102,53,.35); border-radius: 12px; background: #fff4df; color: #6d3c1e; line-height: 1.5; }
.feedback { border-radius: 12px; margin: 20px 0 0; padding: 13px 15px; background: #fff1ef; color: var(--danger); }
.hidden { display: none !important; }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 850px) {
  body { background: var(--cream); }
  .assistant-header { background: var(--forest-deep); }
  .assistant-shell { width: min(100% - 28px, 760px); grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .conversation-card { width: 100%; }
  .intro-panel {
    position: static;
    margin: -8px -9px 12px;
    padding: 36px 18px 44px;
    background:
      radial-gradient(circle at 95% 10%, rgba(185,102,53,.24), transparent 13rem),
      var(--forest-deep);
    border-radius: 0 0 30px 30px;
  }
  .intro-panel h1 { max-width: 12ch; font-size: clamp(2.6rem, 13vw, 4.2rem); }
  .intro-panel > p:not(.eyebrow) { max-width: 34rem; }
  .status-pill { display: none; }
}
@media (max-width: 600px) {
  .assistant-header { padding: 14px 18px; }
  .assistant-shell { width: min(100% - 18px, 1240px); }
  .intro-panel { margin-inline: -9px; padding: 28px 18px 32px; border-radius: 0 0 22px 22px; }
  .intro-panel h1 { font-size: clamp(2.15rem, 11vw, 3.2rem); }
  .intro-panel > p:not(.eyebrow) { line-height: 1.55; }
  .trust-list { margin-top: 22px; }
  .conversation-card { border-radius: 20px; padding: 18px 15px; }
  .field-grid, .lookup-form { grid-template-columns: 1fr; }
  .date-row { grid-template-columns: 1fr; }
  .action-row .button { width: 100%; }
  .conversation-card--chat { min-height: min(680px, calc(100dvh - 20px)); }
  .chat-heading { display: grid; }
  .chat-heading .button { justify-self: start; }
  .patient-chat__message { width: 94%; }
  .patient-chat { min-height: 280px; max-height: 48dvh; padding-block: 18px; }
  .patient-chat__composer { grid-template-columns: 1fr; }
  .patient-chat__composer input,
  input,
  select,
  textarea { font-size: 16px; }
  .private-key strong { margin-inline: 0; overflow-wrap: anywhere; font-size: 1.1rem; }
  .conversation-tabs { margin-bottom: 20px; }
}

@media (max-width: 380px) {
  .assistant-header { padding-inline: 12px; }
  .brand small { display: none; }
  .conversation-card { padding-inline: 12px; }
  .patient-chat__message { width: 100%; gap: 8px; }
  .patient-chat__avatar { flex-basis: 32px; height: 32px; }
  .patient-chat__bubble { padding: 12px 13px; }
  .patient-chat__actions .patient-chat__choice { width: 100%; text-align: left; }
}
