/* ======================================================================
   Clinic app (index.html)
   ====================================================================== */
.app-shell { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.screens { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.screen { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; padding: 16px; }
.screen-live { overflow: hidden; padding: 0 0 max(10px, env(safe-area-inset-bottom)); }
.container { width: 100%; max-width: 560px; margin: 0 auto; }
.setup-container { max-width: 1100px; }
.container-wide { width: 100%; max-width: 860px; margin: 0 auto; }
.page-header { margin: 0 0 var(--sp-3); }
.page-title { margin: 0; font-size: var(--fs-xl); font-weight: 700; color: rgb(var(--c-primary)); }
.page-subtitle { margin: 4px 0 0; color: rgb(var(--c-mute)); font-size: var(--fs-sm); }
.hero { text-align: center; margin: 24px 0 20px; }
.hero h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -0.02em; color: rgb(var(--c-primary)); }
.hero p { margin: 4px 0 0; color: rgb(var(--c-mute)); font-size: 14px; }
.setup-footer { margin-top: var(--sp-5); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--sp-2); }
.recent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.recent-item { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: stretch; }
.recent-resume { flex: 1 1 auto; justify-content: flex-start; text-align: left; white-space: normal; }
.recent-discard { flex: none; }
.form-error { margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius-control); background: rgb(var(--c-danger) / 0.08); color: rgb(var(--c-danger-text)); font-size: 14px; }
.notice { padding: 10px 12px; border-radius: var(--radius-control); background: rgb(var(--c-warn) / 0.09); color: rgb(var(--c-warn-text)); font-size: 13px; }

/* Setup two-column layout */
.setup-grid {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: 1fr;
}
@media (min-width: 900px) {
  .setup-grid { grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.9fr); align-items: start; }
}
.ready-check { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ready-check li { display: flex; justify-content: space-between; gap: 12px; font-size: var(--fs-sm); }
.ready-label { color: rgb(var(--c-mute)); }
.ready-value { font-weight: 600; color: rgb(var(--c-ink)); text-align: right; }

/* Typeahead */
.typeahead { position: relative; }
.typeahead-list {
  position: absolute; left: 0; right: 0; top: calc(100% - 2px); z-index: 30;
  margin: 0; padding: 4px 0; list-style: none;
  max-height: 220px; overflow-y: auto;
  background: rgb(var(--c-surface));
  border: 1px solid rgb(var(--c-line));
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
}
.typeahead-option {
  display: block; width: 100%; padding: 8px 12px; border: 0; background: transparent;
  text-align: left; font: inherit; cursor: pointer; color: rgb(var(--c-ink));
}
.typeahead-option:hover, .typeahead-option[aria-selected="true"] {
  background: rgb(var(--c-primary) / 0.08);
}
.typeahead-option .muted { display: block; font-size: var(--fs-xs); }

/* live consult bar */
.live-bar {
  flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 12px; padding: 8px 12px;
  border-bottom: 1px solid rgb(var(--c-line));
  background: rgb(var(--c-surface));
}
.live-bar-actions { margin-left: auto; }
.end-btn { margin-left: 4px; }
.live-title { font-size: 14px; font-weight: 600; color: rgb(var(--c-primary)); }
.live-lock { margin-top: 2px; font-size: 11.5px; font-weight: 500; text-align: right; color: rgb(var(--c-mute)); }
.live-lock[data-mode="owner"] { color: rgb(var(--c-accent-text)); }
.live-lock[data-mode="doctor"] { color: rgb(var(--c-primary)); }
.live-lock[data-mode="auto"] { color: rgb(var(--c-warn-text)); }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 3px 10px;
  border-radius: 999px; background: rgb(var(--c-ink) / 0.06);
  font-size: 12px; font-weight: 500; color: rgb(var(--c-mute));
}
.status-pill::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: rgb(var(--c-mute) / 0.6); }
.status-pill[data-state="listening"]::before { background: rgb(var(--c-accent)); animation: pulse-dot 1.6s ease-in-out infinite; }
.status-pill[data-state="busy"]::before { background: rgb(var(--c-warn)); }
.status-pill[data-state="paused"]::before { background: rgb(var(--c-warn)); }
.status-pill[data-state="error"]::before { background: rgb(var(--c-danger)); }

.screen-live .patient-banner {
  flex: none;
  position: relative;
  top: auto;
}

/* panes + bubbles */
.panes { flex: 1 1 auto; min-height: 0; display: flex; gap: 10px; padding: 8px 12px 0; }
.panes[data-layout="lr"] { flex-direction: row; }
.panes[data-layout="tb"], .panes[data-layout="tb-flip"] { flex-direction: column; }
.panes[data-layout="tb-flip"] .pane-owner { transform: rotate(180deg); transform-origin: center center; }
@media (max-width: 640px) { .panes[data-layout="lr"] { flex-direction: column; gap: 8px; } }
@media (orientation: portrait) and (max-width: 1024px) {
  .panes[data-layout="lr"] { flex-direction: column; }
}
.pane {
  flex: 1 1 0; min-width: 0; min-height: 0; overflow-y: auto; padding: 0 12px 10px;
  background: #fff; border: 1px solid rgb(var(--c-ink) / 0.06); border-radius: var(--radius); box-shadow: var(--shadow-soft, var(--shadow-1));
}
.pane-title {
  position: sticky; top: 0; z-index: 2; padding: 10px 0 6px;
  background: rgb(255 255 255 / 0.92);
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
}
.pane-owner .pane-title { color: rgb(var(--c-accent-text)); }
.pane-vet .pane-title { color: rgb(var(--c-primary)); }
.pane-d11 {
  position: sticky; top: 28px; z-index: 2; margin: 0 0 8px; padding: 4px 0 6px;
  background: rgb(255 255 255 / 0.96);
  font-size: 11px; font-weight: 600; line-height: 1.35; color: rgb(var(--c-warn-text));
}
.bubble {
  max-width: 95%; margin-bottom: 8px; padding: 8px 12px;
  border: 1px solid transparent; border-radius: var(--radius);
}
.bubble-vet, .bubble-clinician { background: rgb(var(--c-primary) / 0.07); }
.bubble-owner, .bubble-client { background: rgb(var(--c-accent) / 0.1); }
.bubble.is-unverified { border-color: rgb(var(--c-warn) / 0.45); }
.bubble.is-verified { border-color: rgb(var(--c-ok) / 0.45); }
.bubble-error { border-color: rgb(var(--c-danger) / 0.5); background: rgb(var(--c-danger) / 0.06); }
.bubble-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: rgb(var(--c-mute)); }
.bubble-act, .bubble-tools { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.pane-owner .bubble-tools { display: none; }
.pane-vet .bubble:hover .bubble-tools,
.pane-vet .bubble:focus-within .bubble-tools { opacity: 1; }
.bubble .body { display: block; margin-top: 2px; font-size: var(--fs-live, 1.25rem); font-weight: 500; line-height: 1.5; word-break: break-word; }
@media (min-width: 768px) { .bubble .body { font-size: 1.5rem; } }
@media (min-width: 1024px) { .bubble .body { font-size: 1.75rem; } }
.bubble-live { background: transparent; border: 1px dashed rgb(var(--c-ink) / 0.2); color: rgb(var(--c-ink) / 0.75); }
.bubble-live .body::after { content: "▍"; margin-left: 2px; color: rgb(var(--c-accent)); animation: caret 1s steps(1) infinite; }
.spk-chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: 28px; padding: 2px 10px;
  border: 0; border-radius: 999px; background: rgb(var(--c-ink) / 0.07);
  font-size: 11px; font-weight: 700; letter-spacing: 0.03em; text-transform: none; color: rgb(var(--c-ink) / 0.8); cursor: pointer;
}
.spk-chip:hover { background: rgb(var(--c-ink) / 0.12); }
@media (pointer: coarse) { .spk-chip { min-height: 44px; padding: 4px 14px; } }
.w { cursor: pointer; border-radius: 4px; }
.w:hover, .w.is-playing { background: rgb(var(--c-accent) / 0.18); }
.bubble-pending {
  background: rgb(var(--c-ink) / 0.06);
  animation: skel 1.2s ease-in-out infinite;
}
.bubble-pending .body { min-height: 1.6em; color: rgb(var(--c-mute)); }

/* record bar + level meter */
.rec-bar { flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 12px 0; }
.rec-bar-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
.kbd-hint { font-size: var(--fs-xs); color: rgb(var(--c-mute)); }
@media (pointer: coarse) { .kbd-hint { display: none; } }
.wave { display: block; width: min(240px, 60vw); height: 28px; }
.rec-btn {
  position: relative;
  width: 70px; height: 70px; padding: 0; border: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: rgb(var(--c-primary)); color: #fff; box-shadow: 0 2px 10px rgb(var(--c-primary) / 0.2);
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; line-height: 1.15;
  cursor: pointer; transition: transform 0.12s, background 0.15s;
}
.rec-btn:active { transform: scale(0.97); }
.rec-btn.is-listening { animation: none; }
.rec-btn.is-recording { background: rgb(var(--c-accent)); animation: none; box-shadow: 0 2px 12px rgb(var(--c-accent) / 0.3); }
.rec-btn.is-recording::after { display: none; }

/* review screen */
.screen-review {
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.screen-review .patient-banner { flex: none; }
.review-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}
.review-edit-panel { margin: 8px 16px 0; max-width: 960px; }
.review-record {
  background: rgb(var(--c-surface));
  border: 1px solid rgb(var(--c-line));
  border-radius: var(--radius-sheet);
  overflow: hidden;
}
.value-flags-panel {
  margin: 0;
  padding: 12px 16px;
  border-bottom: 1px solid rgb(var(--c-line));
  background: rgb(var(--c-warn) / 0.07);
}
.value-flags-title {
  margin: 0 0 8px;
  font-size: var(--fs-sm);
  font-weight: 700;
  color: rgb(var(--c-warn-text));
}
.value-flags-fyi-title {
  margin: 10px 0 6px;
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgb(var(--c-mute));
}
.value-flags-list {
  margin: 0;
  padding: 0 0 0 1.2em;
  list-style: disc;
}
.value-flags-item {
  margin: 0 0 4px;
  font-size: var(--fs-sm);
  color: rgb(var(--c-ink));
}
.value-flags-dlg .value-flags-list { margin-top: 0; }
.value-flags-weak-title {
  margin: 0 0 8px;
  font-size: var(--fs-sm);
  font-weight: 700;
  color: rgb(var(--c-mute));
}
.check-numbers {
  color: rgb(var(--c-mute));
  border-color: rgb(var(--c-line));
  background: rgb(var(--c-ink) / 0.04);
}
.check-numbers:hover:not(:disabled) {
  color: rgb(var(--c-mute));
  background: rgb(var(--c-ink) / 0.08);
}
.value-flags-ack {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  font-size: var(--fs-sm);
  color: rgb(var(--c-ink));
}
.value-flags-ack input { margin-top: 3px; flex: none; }
.tab-panels { padding: 12px 16px 16px; }
.soap-field {
  field-sizing: content;
  min-height: 7rem;
  max-height: none;
  overflow: hidden;
  resize: none;
}
.owner-draft-badge { margin-bottom: 12px; }
.amend-history { display: flex; flex-direction: column; gap: 10px; }
.amend-item {
  padding: 10px 12px;
  border: 1px solid rgb(var(--c-line));
  border-radius: var(--radius-control, 8px);
  background: rgb(var(--c-surface-2, var(--c-surface)));
}
.amend-item-meta { font-size: var(--fs-sm); color: rgb(var(--c-mute)); margin-bottom: 4px; }
.amend-item-reason { font-weight: 600; color: rgb(var(--c-ink)); }

.review-actions {
  flex: none;
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid rgb(var(--c-line));
  background: rgb(var(--c-surface));
  box-shadow: 0 -4px 16px rgb(0 0 0 / 0.06);
}
.approver-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.pin-input { max-width: 8rem; letter-spacing: 0.2em; }
.review-action-btns { width: 100%; }

.conflict-banner {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 10px 16px;
  background: rgb(var(--c-danger) / 0.12);
  color: rgb(var(--c-danger-text));
  border-bottom: 1px solid rgb(var(--c-danger) / 0.35);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.conflict-banner[hidden] { display: none !important; }

.tx-list { max-height: min(50vh, 28rem); overflow-y: auto; }
.tx-item { padding: 8px 0; border-bottom: 1px solid rgb(var(--c-ink) / 0.07); }
.tx-item:last-child { border-bottom: 0; }
.tx-who { font-size: 13px; font-weight: 700; }
.tx-who.is-doctor { color: rgb(var(--c-primary)); }
.tx-who.is-owner { color: rgb(var(--c-accent-text)); }
.tx-orig { margin-top: 2px; font-size: 16px; }
.tx-tr { font-size: 14px; color: rgb(var(--c-mute)); }
.soap-grid { display: grid; gap: 12px; }
@media (min-width: 640px) { .soap-grid { grid-template-columns: 1fr 1fr; } }

/* Sync drawer */
.sync-drawer-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.sync-drawer-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid rgb(var(--c-line));
  border-radius: var(--radius);
  background: rgb(var(--c-surface-2, var(--c-surface)));
}
.sync-drawer-meta { flex: 1; min-width: 0; }
.sync-drawer-label { font-weight: 600; font-size: var(--fs-md); color: rgb(var(--c-ink)); }
.sync-drawer-detail { margin-top: 2px; font-size: var(--fs-sm); color: rgb(var(--c-mute)); }
.sync-drawer-empty { text-align: center; }

/* Consent dialog */
.consent-tick-row {
  display: flex; flex-wrap: nowrap; align-items: flex-start; gap: 12px;
  min-height: 48px; padding: 8px 0; cursor: pointer;
  font-size: var(--fs-md); font-weight: 500;
}
.consent-tick-row input {
  width: 22px; height: 22px; flex: none; margin-top: 2px;
}
.disclaimer-heading { padding-top: 14px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* PWA update banner */
.update-bar {
  position: fixed; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 90;
  display: flex; align-items: center; gap: 12px; max-width: calc(100% - 24px); padding: 6px 6px 6px 16px;
  border-radius: 999px; border: 1px solid rgb(var(--c-ink) / 0.08); box-shadow: var(--shadow-glass, var(--shadow-2));
  background: rgb(255 255 255 / 0.7); -webkit-backdrop-filter: blur(24px) saturate(1.5); backdrop-filter: blur(24px) saturate(1.5);
  font-size: 13px; font-weight: 500;
}

/* keyframes (sheet-up, toast-in, skel, rec-pulse, caret, pulse-dot) live in components.css */
