/* ═══════════════════════════════════════════════
   AI DOCTOR — Stylesheet
   Aesthetic: Dark clinical luxury
   Fonts: DM Serif Display + DM Sans
   ═══════════════════════════════════════════════ */

:root {
  color-scheme: dark;
  --header-h:  72px;
  --consult-bar-h: 58px;
  --bg:        #0a0f18;
  --bg2:       #0e1520;
  --bg3:       #131d2e;
  --surface:   #172030;
  --surface2:  #1d2a3f;
  --border:    #243347;
  --border2:   #2e4060;
  --accent:    #3b9eff;
  --accent2:   #1e7ed4;
  --teal:      #2ecfcf;
  --green:     #27c783;
  --yellow:    #f5c842;
  --red:       #f05252;
  --orange:    #f5884a;
  --text:      #e2ecf8;
  --text2:     #8ba8c4;
  --text3:     #4e6a87;
  --serif:     'DM Serif Display', serif;
  --sans:      'DM Sans', sans-serif;
  --mono:      'JetBrains Mono', monospace;
  --radius:    12px;
  --radius-lg: 20px;
  --shadow:    0 8px 32px rgba(0,0,0,0.4);
  --header-bg: rgba(10, 15, 24, 0.92);
  --consult-bar-bg: linear-gradient(180deg, rgba(14, 21, 32, 0.98), rgba(10, 15, 24, 0.95));
  --consult-bar-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  --grid-line: rgba(59, 158, 255, 0.03);
  --focus-ring: rgba(59, 158, 255, 0.12);
  --btn-shadow: 0 4px 20px rgba(59, 158, 255, 0.35);
  --primary:   #2a6fb8;
}

[data-theme="light"] {
  color-scheme: light;
  --primary:   #1873cc;
  --bg:        #f4f6fa;
  --bg2:       #ffffff;
  --bg3:       #e8edf5;
  --surface:   #ffffff;
  --surface2:  #eef2f9;
  --border:    #d3dce8;
  --border2:   #bcc8d8;
  --accent:    #1873cc;
  --accent2:   #125fa8;
  --teal:      #0d9488;
  --green:     #0d8f5f;
  --yellow:    #b45309;
  --red:       #dc2626;
  --orange:    #ea580c;
  --text:      #142032;
  --text2:     #3d4f66;
  --text3:     #5c6b7f;
  --shadow:    0 8px 28px rgba(15, 23, 42, 0.08);
  --header-bg: rgba(255, 255, 255, 0.94);
  --consult-bar-bg: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  --consult-bar-shadow: 0 4px 24px rgba(15, 23, 42, 0.07);
  --grid-line: rgba(24, 90, 160, 0.07);
  --focus-ring: rgba(24, 115, 204, 0.18);
  --btn-shadow: 0 4px 20px rgba(24, 115, 204, 0.22);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-size: 15px;
  line-height: 1.6;
  overflow-x: hidden;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* Subtle grid overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* ── Header ─────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.header-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.theme-switch {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  gap: 2px;
}

.theme-switch__btn {
  border: none;
  background: transparent;
  color: var(--text3);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.theme-switch__btn:hover {
  color: var(--text2);
}

.theme-switch__btn.is-active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 2px 10px var(--btn-shadow);
}

.lang-select {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  cursor: pointer;
  min-width: 140px;
}

.lang-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.header-lang {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  max-width: 240px;
}

.lang-hint {
  font-size: 11px;
  color: var(--text3);
  line-height: 1.25;
  max-width: 240px;
  text-align: right;
}

.header-inbox-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}

.header-inbox-link:hover {
  border-color: var(--accent);
  background: rgba(59, 158, 255, 0.08);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 28px;
  color: var(--accent);
  line-height: 1;
}

.logo-title {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--text);
  display: block;
  letter-spacing: -0.3px;
}

.logo-sub {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  display: block;
  margin-top: -2px;
}

.doctor-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 8px 16px 8px 8px;
}

.doctor-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.doctor-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: block;
}

.doctor-spec {
  font-size: 11px;
  color: var(--text3);
  display: block;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Main Layout ─────────────────────────────────── */
.main {
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  min-width: 0;
  padding: 32px;
  display: grid;
  grid-template-columns: 480px 1fr;
  gap: 28px;
  position: relative;
  z-index: 1;
}

/* ── Panel ───────────────────────────────────────── */
.panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-width: 0;
}

.form-panel {
  height: fit-content;
  position: sticky;
  top: calc(var(--header-h) + var(--consult-bar-h) + 16px);
  max-height: calc(100vh - var(--header-h) - var(--consult-bar-h) - 48px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}

.panel-header {
  padding: 28px 28px 0;
}

.panel-title {
  font-family: var(--serif);
  font-size: 26px;
  color: var(--text);
  margin-bottom: 4px;
}

.panel-sub {
  font-size: 13px;
  color: var(--text3);
}

/* ── Form Sections ───────────────────────────────── */
.form-section {
  padding: 24px 28px 0;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text2);
}

.section-num {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--surface2);
  color: var(--accent);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--border2);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  letter-spacing: 0.3px;
}

.required { color: var(--red); }

.field input,
.field select,
.field textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  resize: none;
}

.field select option { background: var(--surface); }

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--text3);
}

/* ── Vitals Grid ─────────────────────────────────── */
.vitals-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.vital-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  transition: border-color 0.2s;
}

.vital-card:focus-within {
  border-color: var(--accent);
}

.vital-icon {
  font-size: 16px;
  margin-bottom: 4px;
  display: block;
}

.vital-card label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text3);
  display: block;
  margin-bottom: 6px;
}

.vital-input-wrap,
.vital-bp-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.vital-input-wrap input,
.vital-bp-wrap input {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border2);
  border-radius: 0;
  padding: 4px 0;
  font-size: 18px;
  font-family: var(--mono);
  font-weight: 500;
  color: var(--text);
  width: 60px;
  outline: none;
}

.vital-bp-wrap input { width: 42px; font-size: 15px; }

.vital-input-wrap input:focus,
.vital-bp-wrap input:focus {
  border-bottom-color: var(--accent);
  box-shadow: none;
}

.vital-unit {
  font-size: 10px;
  color: var(--text3);
  white-space: nowrap;
  font-family: var(--mono);
}

.bp-sep {
  font-size: 18px;
  color: var(--text3);
  font-family: var(--mono);
}

/* ── Consult Button ──────────────────────────────── */
.consult-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 24px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  border-radius: var(--radius);
  color: white;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  box-shadow: var(--btn-shadow);
  letter-spacing: 0.2px;
}

.consult-btn--bar {
  flex-shrink: 0;
  min-width: 200px;
  padding: 12px 22px;
  font-size: 14px;
}

.consult-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px var(--btn-shadow);
}

.consult-btn:active:not(:disabled) {
  transform: translateY(0);
}

.consult-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-icon { font-size: 18px; }
.btn-arrow { font-size: 18px; margin-left: auto; }

/* ── Results Panel ───────────────────────────────── */
.results-panel {
  min-height: 500px;
  min-height: min(500px, 70dvh);
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

.results-panel > .chat-state:not(.hidden) {
  flex: 1;
  min-height: 0;
}

.results-panel > .empty-state:not(.hidden),
.results-panel > .loading-state:not(.hidden) {
  flex: 1;
}

/* ── Empty State ─────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 100%;
  min-height: 500px;
  padding: 48px;
  gap: 16px;
}

.empty-icon { opacity: 0.7; }

.empty-state h3 {
  font-family: var(--serif);
  font-size: 24px;
  color: var(--text);
}

.empty-state p {
  font-size: 14px;
  color: var(--text2);
  max-width: 320px;
  line-height: 1.7;
}

.empty-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}

.empty-tags span {
  font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text3);
  padding: 4px 12px;
  border-radius: 50px;
}

/* ── Loading ─────────────────────────────────────── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 500px;
  gap: 24px;
}

.pulse-ring {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  position: relative;
  animation: spin 2s linear infinite;
}

.pulse-ring::before {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 2px solid var(--teal);
  animation: spin 1.5s linear infinite reverse;
}

.pulse-ring::after {
  content: '⚕';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  animation: none;
  animation: counterSpin 2s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes counterSpin { to { transform: rotate(-360deg); } }

.loading-text {
  text-align: center;
  color: var(--text2);
  font-size: 14px;
}

.loading-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 8px;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%,80%,100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-8px); opacity: 1; }
}

/* ── Results Content ─────────────────────────────── */
.results-content {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.result-doc-name {
  font-family: var(--serif);
  font-size: 22px;
  display: block;
  color: var(--text);
}

.result-doc-spec {
  font-size: 12px;
  color: var(--text3);
  display: block;
  margin-top: 2px;
}

.urgency-badge {
  padding: 8px 18px;
  border-radius: 50px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  flex-shrink: 0;
  font-family: var(--mono);
}

.urgency-badge.routine {
  background: rgba(39,199,131,0.15);
  border: 1px solid rgba(39,199,131,0.4);
  color: var(--green);
}

.urgency-badge.urgent {
  background: rgba(245,200,66,0.15);
  border: 1px solid rgba(245,200,66,0.4);
  color: var(--yellow);
}

.urgency-badge.emergency {
  background: rgba(240,82,82,0.15);
  border: 1px solid rgba(240,82,82,0.5);
  color: var(--red);
  animation: flash 1s infinite;
}

@keyframes flash {
  0%,100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.urgency-reason {
  font-size: 13px;
  color: var(--text2);
  font-style: italic;
  padding: 8px 14px;
  background: var(--surface);
  border-left: 3px solid var(--border2);
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* ── Chat questionnaire ──────────────────────────── */
.chat-state {
  display: flex;
  flex-direction: column;
  flex: 1;
  align-self: stretch;
  min-height: min(70dvh, 640px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.chat-state__head {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  margin-bottom: 0;
  background: var(--surface2);
}

.chat-state__head.result-header {
  padding-bottom: 12px;
}

.chat-state__messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-state__options {
  flex-shrink: 0;
  padding: 10px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--surface);
}

.chat-state__composer {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  align-items: stretch;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: var(--surface2);
}

.chat-state__input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
}

.chat-state__send {
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  border: none;
  font-weight: 600;
  font-family: var(--sans);
  font-size: 15px;
  cursor: pointer;
  touch-action: manipulation;
}

/* ── OP sheet (outpatient-style record) ───────────── */
.op-sheet {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.op-sheet__banner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 18px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.op-sheet__banner-title {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}

.op-sheet__banner-sub {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.45;
}

.op-sheet__patient {
  padding: 12px 18px;
  font-size: 13px;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  line-height: 1.55;
}

.op-sheet__section {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  animation: fadeUp 0.35s ease both;
}

.op-sheet__section:last-child {
  border-bottom: none;
}

.op-sheet__section--accent {
  background: rgba(74, 158, 202, 0.06);
  border-left: 3px solid var(--accent);
  padding-left: 15px;
}

.op-sheet__section--alert {
  background: rgba(240, 82, 82, 0.06);
  border-left: 3px solid var(--red);
  padding-left: 15px;
}

.op-sheet__label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--text3);
  margin-bottom: 8px;
}

.op-sheet__body--prose {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.75;
  white-space: pre-wrap;
}

.op-med-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 4px;
  font-size: 13px;
}

.op-med-table th,
.op-med-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.op-med-table th {
  background: var(--surface2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text3);
}

.op-med-table td:first-child {
  font-weight: 600;
  color: var(--accent);
}

.op-sheet__section:has(.op-med-table) {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Result Cards ─────────────────────────────────── */
.greeting-card {
  background: linear-gradient(135deg, var(--surface) 0%, rgba(59,158,255,0.08) 100%);
  border-color: rgba(59,158,255,0.2);
  font-style: italic;
  font-family: var(--serif);
  font-size: 16px;
  color: var(--text);
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color 0.2s;
  animation: fadeUp 0.4s ease both;
}

.result-card:hover { border-color: var(--border2); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Stagger animation delays */
.results-grid .result-card:nth-child(1) { animation-delay: 0.05s; }
.results-grid .result-card:nth-child(2) { animation-delay: 0.1s; }
.results-grid .result-card:nth-child(3) { animation-delay: 0.15s; }
.results-grid .result-card:nth-child(4) { animation-delay: 0.2s; }
.results-grid .result-card:nth-child(5) { animation-delay: 0.25s; }
.results-grid .result-card:nth-child(6) { animation-delay: 0.3s; }

.red-flag-card {
  grid-column: 1 / -1;
  border-color: rgba(240,82,82,0.35);
  background: rgba(240,82,82,0.06);
}

.card-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text3);
  margin-bottom: 10px;
}

.card-icon { font-size: 14px; }

.card-content {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.75;
  white-space: pre-wrap;
}

.greeting-card .card-content {
  font-size: 15px;
  color: var(--text);
}

/* ── Disclaimer ──────────────────────────────────── */
.disclaimer-box {
  display: flex;
  gap: 12px;
  background: rgba(245,200,66,0.07);
  border: 1px solid rgba(245,200,66,0.25);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 4px;
}

.disc-icon {
  font-size: 16px;
  color: var(--yellow);
  flex-shrink: 0;
  margin-top: 2px;
}

.disclaimer-box p {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.6;
}

/* ── Result Footer ───────────────────────────────── */
.result-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

#consultTimestamp {
  font-size: 11px;
  color: var(--text3);
  font-family: var(--mono);
}

.new-consult-btn {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text2);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 18px;
  cursor: pointer;
  transition: all 0.15s;
}

.new-consult-btn:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--accent);
}

/* ── Sticky consult bar ─────────────────────────── */
.consult-action-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 95;
  background: var(--consult-bar-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  box-shadow: var(--consult-bar-shadow);
}

.consult-action-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.consult-action-hint {
  font-size: 13px;
  color: var(--text2);
  max-width: min(560px, 100%);
  line-height: 1.45;
  margin: 0;
}

/* ── Form: priority section & voice ───────────────── */
.panel-header--modern {
  padding-bottom: 8px;
}

.form-section--priority {
  padding-top: 20px;
  background: linear-gradient(180deg, rgba(59, 158, 255, 0.06), transparent 120px);
  border-radius: 0 0 var(--radius) var(--radius);
}

.section-label--accent .section-num {
  background: rgba(59, 158, 255, 0.15);
  border-color: rgba(59, 158, 255, 0.35);
  color: var(--accent);
}

.voice-strip {
  margin-bottom: 18px;
}

.voice-mic-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border2);
  background: linear-gradient(135deg, var(--surface2), var(--surface));
  color: var(--text);
  cursor: pointer;
  font-family: var(--sans);
  text-align: left;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.voice-mic-btn:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: 0 8px 28px rgba(59, 158, 255, 0.18);
  transform: translateY(-1px);
}

.voice-mic-btn--listening {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(46, 207, 207, 0.2);
  animation: voicePulse 1.4s ease-in-out infinite;
}

.voice-mic-btn--disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(46, 207, 207, 0.15); }
  50% { box-shadow: 0 0 0 6px rgba(46, 207, 207, 0.25); }
}

.voice-mic-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(59, 158, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.voice-mic-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.voice-strip-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text3);
  line-height: 1.5;
}

/* ── Collapsible optional panel ───────────────────── */
.collapse-panel {
  margin: 8px 0 0;
  border-top: 1px solid var(--border);
}

.collapse-panel-summary {
  list-style: none;
  cursor: pointer;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  transition: background 0.15s;
}

.collapse-panel-summary::-webkit-details-marker { display: none; }
.collapse-panel summary::marker { display: none; }

.collapse-panel[open] .collapse-panel-summary {
  background: rgba(59, 158, 255, 0.04);
  color: var(--text);
}

.collapse-title {
  font-size: 14px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.optional-pill {
  font-size: 11px;
  font-weight: 500;
  color: var(--text3);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
}

.collapse-panel-body {
  padding: 0 28px 24px;
}

.section-label--sub {
  margin-top: 8px;
  margin-bottom: 12px;
}

.grid-2 .field--span {
  grid-column: 1 / -1;
}

.vitals-lead,
.nested-vitals-lead {
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 12px;
  line-height: 1.5;
}

.vitals-grid--primary {
  grid-template-columns: repeat(2, 1fr);
}

.vitals-grid--secondary {
  grid-template-columns: repeat(3, 1fr);
}

.nested-vitals {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px dashed var(--border2);
  background: rgba(0, 0, 0, 0.15);
}

.nested-vitals-summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  list-style: none;
}

.nested-vitals-summary::-webkit-details-marker { display: none; }

.nested-vitals[open] .nested-vitals-summary {
  color: var(--accent);
  margin-bottom: 8px;
}

.field--flush {
  margin-top: 12px;
}

/* ── Empty state (mic / optional gif) ─────────────── */
.empty-hero {
  position: relative;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-hero-gif {
  border-radius: 16px;
  max-height: 140px;
  width: auto;
  object-fit: contain;
  box-shadow: var(--shadow);
}

.empty-hero-gif--hidden {
  display: none !important;
}

.empty-hero.has-gif .empty-mic-ring {
  display: none;
}

.empty-mic-ring {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-mic-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(59, 158, 255, 0.35);
  animation: micRing 2.2s ease-out infinite;
}

@keyframes micRing {
  0% { transform: scale(0.92); opacity: 0.9; }
  70% { transform: scale(1.08); opacity: 0.2; }
  100% { transform: scale(1.15); opacity: 0; }
}

.empty-mic-icon-wrap {
  position: relative;
  z-index: 1;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(59, 158, 255, 0.35), var(--surface2));
  border: 1px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.empty-title {
  margin-top: 8px;
}

.empty-desc {
  max-width: 420px;
}

/* ── Doctor verification banner ───────────────────── */
.doctor-verify-banner {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid rgba(39, 199, 131, 0.35);
  background: rgba(39, 199, 131, 0.08);
  margin-top: 8px;
}

.doctor-verify-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(39, 199, 131, 0.2);
  color: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.doctor-verify-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.55;
}

.doctor-verify-text strong {
  color: var(--text);
  font-size: 14px;
}

/* ── Pending doctor (patient) ───────────────────── */
.pending-doctor-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 480px;
  padding: 40px 28px;
  gap: 12px;
}

.pending-pulse-icon {
  animation: pendingPulse 2s ease-in-out infinite;
}

@keyframes pendingPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.65; transform: scale(1.05); }
}

.pending-title {
  font-family: var(--serif);
  font-size: 24px;
  color: var(--text);
  margin-top: 8px;
}

.pending-text,
.pending-hint {
  font-size: 14px;
  color: var(--text2);
  max-width: 420px;
  line-height: 1.6;
}

.pending-ref {
  font-size: 12px;
  color: var(--text3);
  margin-top: 4px;
}

.pending-ref code {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--surface2);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* ── Digital signature (patient, after sign-off) ─ */
.digital-signature-banner {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid rgba(39, 199, 131, 0.45);
  background: linear-gradient(135deg, rgba(39, 199, 131, 0.12), rgba(59, 158, 255, 0.06));
  margin-bottom: 4px;
}

.digital-signature-seal {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(39, 199, 131, 0.25);
  color: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
}

.digital-signature-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
}

.digital-signature-body strong {
  color: var(--text);
  font-size: 15px;
}

.digital-signature-time {
  font-size: 12px;
  color: var(--text3);
  font-family: var(--mono);
}

.digital-dispatch-line {
  font-size: 12px;
  color: var(--accent);
  margin-top: 4px;
}

/* ── Light theme polish (accent tints) ──────────── */
[data-theme="light"] .greeting-card {
  background: linear-gradient(135deg, var(--surface) 0%, rgba(24, 115, 204, 0.07) 100%);
  border: 1px solid rgba(24, 115, 204, 0.2);
}

[data-theme="light"] .red-flag-card {
  border-color: rgba(220, 38, 38, 0.28);
  background: rgba(220, 38, 38, 0.05);
}

[data-theme="light"] .disclaimer-box {
  background: rgba(180, 83, 9, 0.06);
  border-color: rgba(180, 83, 9, 0.22);
}

[data-theme="light"] .form-section--priority {
  background: linear-gradient(180deg, rgba(24, 115, 204, 0.06), transparent 120px);
}

[data-theme="light"] .section-label--accent .section-num {
  background: rgba(24, 115, 204, 0.12);
  border-color: rgba(24, 115, 204, 0.28);
  color: var(--accent2);
}

[data-theme="light"] .voice-mic-icon {
  background: rgba(24, 115, 204, 0.1);
  color: var(--accent);
}

[data-theme="light"] .nested-vitals {
  background: rgba(15, 23, 42, 0.035);
}

[data-theme="light"] .empty-mic-pulse {
  border-color: rgba(24, 115, 204, 0.28);
}

[data-theme="light"] .empty-mic-icon-wrap {
  background: radial-gradient(circle at 30% 30%, rgba(24, 115, 204, 0.2), var(--surface2));
  box-shadow: 0 10px 32px rgba(15, 23, 42, 0.12);
}

[data-theme="light"] .doctor-verify-banner {
  border-color: rgba(13, 143, 95, 0.32);
  background: rgba(13, 143, 95, 0.07);
}

[data-theme="light"] .doctor-verify-icon {
  background: rgba(13, 143, 95, 0.14);
}

[data-theme="light"] .digital-signature-banner {
  border-color: rgba(13, 143, 95, 0.4);
  background: linear-gradient(135deg, rgba(13, 143, 95, 0.1), rgba(24, 115, 204, 0.06));
}

[data-theme="light"] .urgency-badge.routine {
  background: rgba(13, 143, 95, 0.12);
  border-color: rgba(13, 143, 95, 0.35);
}

[data-theme="light"] .urgency-badge.urgent {
  background: rgba(180, 83, 9, 0.1);
  border-color: rgba(180, 83, 9, 0.35);
}

[data-theme="light"] .urgency-badge.emergency {
  background: rgba(220, 38, 38, 0.1);
  border-color: rgba(220, 38, 38, 0.4);
}

/* ── Utility ─────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Scrollbar ───────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 10px; }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 1100px) {
  .main {
    grid-template-columns: 1fr;
    padding: 20px;
    gap: 20px;
  }
  .form-panel {
    position: static;
    max-height: none;
  }
  .consult-action-inner {
    flex-direction: column;
    align-items: stretch;
  }
  .consult-btn--bar {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }
  .results-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .vitals-grid { grid-template-columns: 1fr 1fr; }
  .vitals-grid--primary,
  .vitals-grid--secondary { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .header-inner { padding: 10px 12px; gap: 8px; }
  .header-tools { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
  .theme-switch__btn { padding: 8px 12px; font-size: 11px; min-height: 40px; }
  .lang-select { min-width: 0; max-width: 100%; width: 100%; }
  .header-lang { max-width: 100%; align-items: stretch; }
  .lang-hint { text-align: left; max-width: 100%; }
  .header-inbox-link { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .main { padding: 12px; gap: 16px; }
  .consult-action-inner { padding: 12px 14px; }
  .results-content { padding: 14px; }
  .empty-state { padding: 28px 16px; min-height: min(420px, 60dvh); }
  .result-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .result-doc-name { font-size: 18px; }
  .op-sheet__banner,
  .op-sheet__patient,
  .op-sheet__section { padding-left: 14px; padding-right: 14px; }
  .chat-state { min-height: min(65dvh, 560px); }
  .consult-btn { min-height: 44px; }
  .new-consult-btn { min-height: 44px; }
}
