:root {
  --blue: #123b5d;
  --blue2: #0b4258;
  --green: #56c987;
  --cyan: #30b8d7;
  --cream: #fffaf3;
  --mint: #e9fbf6;
  --ink: #14324a;
  --muted: #52626e;
  --line: rgba(18, 59, 93, 0.12);
  --shadow: 0 24px 70px rgba(18, 59, 93, 0.14);
  --radius: 24px;
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 4%, rgba(86, 201, 135, 0.18), transparent 28%),
    radial-gradient(circle at 92% 18%, rgba(48, 184, 215, 0.14), transparent 30%),
    linear-gradient(180deg, #fffaf3 0%, #fafcfb 40%, #f6fbfb 100%);
}

a { color: inherit; text-decoration: none; }

.shell {
  width: min(1100px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.brand {
  display: grid;
  gap: 4px;
}

.brand strong {
  font-family: var(--display);
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  color: #0d3655;
}

.brand span {
  color: var(--muted);
  font-size: 0.92rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
  font-size: 0.85rem;
  font-weight: 700;
  color: #0a7190;
}

.pill.ok { background: var(--mint); }
.pill.warn { background: #fff4e8; color: #8a4b12; }

.grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
}

.card {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.card h1, .card h2 {
  font-family: var(--display);
  letter-spacing: -0.04em;
  color: #0d3655;
  margin: 0 0 10px;
}

.card h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.05; }
.card h2 { font-size: 1.25rem; }

.lead {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.55;
}

.form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  font-size: 0.92rem;
}

input, select {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid rgba(66, 183, 233, 0.22);
  background: #fff;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 999px;
  border: 0;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.btn.primary {
  background: linear-gradient(135deg, var(--green), var(--cyan));
  color: #fff;
  box-shadow: 0 15px 35px rgba(48, 184, 215, 0.24);
}

.btn.soft {
  background: rgba(255, 255, 255, 0.86);
  color: var(--blue);
  border: 1px solid rgba(66, 183, 233, 0.18);
}

.btn.block { width: 100%; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.room-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.room-item {
  display: grid;
  gap: 4px;
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(255,255,255,.95), rgba(243,248,248,.8));
  border: 1px solid rgba(220, 236, 236, 0.9);
}

.room-item strong { color: #0d3655; }
.room-item span { color: var(--muted); font-size: 0.88rem; }
.room-item a { color: #108a9c; font-weight: 800; font-size: 0.9rem; }

.room-layout {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.room-layout-fullscreen {
  height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
}

.room-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: rgba(255, 250, 243, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.room-bar-compact {
  padding: 10px 14px;
  z-index: 5;
}

.room-bar-left,
.room-bar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.room-bar h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.15rem;
  color: #0d3655;
}

.room-frame {
  width: 100%;
  height: calc(100vh - 74px);
  border: 0;
  background: #0b2739;
}

.room-frame-fill {
  height: auto;
  min-height: 0;
  flex: 1;
}

.room-layout-fullscreen .room-frame-fill {
  height: 100%;
}

.room-frame-empty {
  display: grid;
  place-items: center;
  color: #d7eef4;
  font-weight: 700;
}

.host-menu {
  position: relative;
}

.host-menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.host-menu-toggle::-webkit-details-marker {
  display: none;
}

.host-menu-chevron {
  flex-shrink: 0;
  transition: transform 0.18s ease;
}

.host-menu[open] .host-menu-chevron {
  transform: rotate(180deg);
}

.host-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(420px, calc(100vw - 24px));
  max-height: min(70vh, 520px);
  overflow: auto;
  padding: 16px;
  border-radius: 16px;
  background: #fffdf9;
  border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(13, 54, 85, 0.14);
  z-index: 20;
}

.host-menu-panel h2 {
  margin: 0 0 6px;
  font-size: 1.05rem;
  color: #0d3655;
}

.chat-controls {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: #0d3655;
  margin: 8px 0;
  cursor: pointer;
}

.switch-row input {
  width: 18px;
  height: 18px;
  accent-color: #108a9c;
}

whereby-embed.room-frame,
whereby-embed.room-frame-fill {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #0b2739;
}

#whereby-host-wrap,
#whereby-patient-wrap {
  min-height: 0;
}

/* WhatsApp-style clinical chat */
.bw-chat {
  --wa-green: #128c7e;
  --wa-green-deep: #075e54;
  --wa-bubble-out: #d9fdd3;
  --wa-bubble-in: #ffffff;
  --wa-composer: #f0f2f5;
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 40;
  font-family: var(--sans, "DM Sans", system-ui, sans-serif);
}

.bw-chat-fab {
  position: relative;
  width: 58px;
  height: 58px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--wa-green);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(7, 94, 84, 0.35);
  transition: transform 0.15s ease, background 0.15s ease;
}

.bw-chat.is-open .bw-chat-fab {
  background: var(--wa-green-deep);
}

.bw-chat-fab:hover {
  transform: scale(1.04);
}

.bw-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #25d366;
  border: 2px solid #fff;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
}

.bw-chat-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: min(380px, calc(100vw - 20px));
  height: min(560px, calc(100vh - 100px));
  display: flex;
  flex-direction: column;
  background: #efeae2;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.bw-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--wa-green-deep);
  color: #fff;
}

.bw-chat-peer {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.bw-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #25d366;
  color: #fff;
  font-weight: 800;
  flex-shrink: 0;
}

.bw-chat-head strong {
  display: block;
  color: #fff;
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.bw-chat-sub {
  margin: 1px 0 0;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.75rem;
}

.bw-chat-head-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.bw-chat-icon-btn {
  border: 0;
  background: transparent;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.bw-chat-icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.bw-chat-log {
  flex: 1;
  overflow: auto;
  padding: 12px 10px 16px;
  background-color: #efeae2;
  background-image:
    radial-gradient(rgba(0, 0, 0, 0.035) 1px, transparent 1px);
  background-size: 18px 18px;
}

.bw-chat-empty-wrap {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 24px;
}

.bw-chat-empty {
  margin: 0;
  max-width: 260px;
  text-align: center;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.88);
  color: #54656f;
  font-size: 0.88rem;
  line-height: 1.4;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.bw-chat-day {
  display: flex;
  justify-content: center;
  margin: 10px 0 12px;
}

.bw-chat-day span {
  background: #ffffffd9;
  color: #54656f;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

.bw-chat-msg {
  display: flex;
  margin-bottom: 6px;
  max-width: 82%;
}

.bw-chat-msg.mine {
  margin-left: auto;
  justify-content: flex-end;
}

.bw-chat-msg.theirs {
  margin-right: auto;
  justify-content: flex-start;
}

.bw-chat-bubble {
  position: relative;
  padding: 6px 8px 4px 10px;
  border-radius: 10px;
  background: var(--wa-bubble-in);
  color: #111b21;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
  word-break: break-word;
}

.bw-chat-msg.mine .bw-chat-bubble {
  background: var(--wa-bubble-out);
  border-top-right-radius: 2px;
}

.bw-chat-msg.theirs .bw-chat-bubble {
  border-top-left-radius: 2px;
}

.bw-chat-author {
  font-size: 0.78rem;
  font-weight: 800;
  color: #128c7e;
  margin-bottom: 2px;
}

.bw-chat-text {
  font-size: 0.94rem;
  line-height: 1.35;
  white-space: pre-wrap;
}

.bw-chat-text a {
  color: #027eb5;
}

.bw-chat-time {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
  color: #667781;
  font-size: 0.68rem;
  line-height: 1;
}

.bw-chat-checks {
  color: #53bdeb;
  font-size: 0.72rem;
  letter-spacing: -1px;
}

.bw-chat-form {
  padding: 8px 8px 10px;
  background: var(--wa-composer);
}

.bw-chat-composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.bw-chat-composer input {
  width: 100%;
  border: 0;
  border-radius: 24px;
  padding: 12px 16px;
  font: inherit;
  background: #fff;
  color: #111b21;
  outline: none;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

.bw-chat-send {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--wa-green);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(7, 94, 84, 0.28);
}

.bw-chat-send:hover {
  background: var(--wa-green-deep);
}

.bw-chat-footer {
  display: none;
}

.rating-form fieldset {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin: 0 0 14px;
}

.rating-form legend {
  font-weight: 800;
  color: #0d3655;
  padding: 0 6px;
}

.star-picker {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  gap: 4px;
  font-size: 2rem;
  line-height: 1;
}

.star-picker input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.star-picker label {
  cursor: pointer;
  color: #c9d6dd;
  transition: color 0.12s ease;
}

.star-picker label:hover,
.star-picker label:hover ~ label,
.star-picker input:checked ~ label {
  color: #0a7190;
}

.rating-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  resize: vertical;
}

@media (max-width: 640px) {
  .bw-chat {
    right: 10px;
    bottom: 10px;
  }
  .bw-chat-panel {
    width: min(100vw - 12px, 400px);
    height: min(78vh, 620px);
    bottom: 68px;
  }
}

.banner {
  padding: 10px 14px;
  border-radius: 14px;
  background: #fff4e8;
  color: #8a4b12;
  font-weight: 700;
  margin-bottom: 12px;
}

.banner.ok {
  background: var(--mint);
  color: #0a7190;
}

.copy-box {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.copy-box code {
  display: block;
  word-break: break-all;
  padding: 12px;
  border-radius: 12px;
  background: #f3fafb;
  border: 1px solid var(--line);
  font-size: 0.88rem;
}

.footer-note {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; }
  .room-frame { height: calc(100vh - 120px); }
}
