/* ============================================================
   Sihat TCM — Main Stylesheet
   Plain CSS, no build step. Covers patient, doctor, auth pages.
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand */
  --emerald-900: #064e3b;
  --emerald-800: #065f46;
  --emerald-700: #047857;
  --emerald-600: #059669;
  --emerald-500: #10b981;
  --emerald-100: #d1fae5;
  --emerald-50:  #ecfdf5;

  /* Doctor blue */
  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-100: #dbeafe;
  --blue-50:  #eff6ff;

  /* Neutral */
  --stone-900: #1c1917;
  --stone-700: #44403c;
  --stone-500: #78716c;
  --stone-300: #d6d3d1;
  --stone-200: #e7e5e4;
  --stone-100: #f5f5f4;
  --stone-50:  #fafaf9;
  --slate-700: #334155;
  --slate-500: #64748b;
  --slate-50:  #f8fafc;

  /* Semantic */
  --color-text:    var(--stone-900);
  --color-muted:   var(--stone-500);
  --color-border:  var(--stone-200);
  --color-bg:      var(--stone-50);
  --color-surface: #ffffff;
  --color-primary: var(--emerald-600);
  --color-primary-dark: var(--emerald-700);

  /* Shape */
  --radius-card: 18px;
  --radius-btn:  10px;
  --radius-input: 8px;
  --shadow-card: 0 2px 12px rgba(0,0,0,.07), 0 1px 3px rgba(0,0,0,.05);
  --shadow-card-hover: 0 6px 24px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);

  /* Type */
  --font-body: "Noto Sans TC", "Noto Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "Fira Mono", monospace;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ---------- Typography ---------- */
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 700; line-height: 1.2; }
h2 { font-size: clamp(1.2rem, 3vw, 1.7rem); font-weight: 600; line-height: 1.3; }
h3 { font-size: 1.1rem; font-weight: 600; }
h4 { font-size: .95rem; font-weight: 600; }
p  { color: var(--stone-700); }
a  { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .text-sm  { font-size: .85rem; }
.text-muted      { color: var(--color-muted); }
.text-center     { text-align: center; }
.text-success    { color: var(--emerald-600); }
.text-error      { color: #dc2626; }

/* ---------- Layout Utilities ---------- */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
}
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .25rem; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: .75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ---------- Card ---------- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
}
.card:hover { box-shadow: var(--shadow-card-hover); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .6rem 1.3rem;
  border: none;
  border-radius: var(--radius-btn);
  font-family: var(--font-body);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s, opacity .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active  { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--emerald-600);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--emerald-700); }

.btn-secondary {
  background: var(--stone-100);
  color: var(--stone-700);
}
.btn-secondary:hover:not(:disabled) { background: var(--stone-200); }

.btn-outline {
  background: transparent;
  color: var(--emerald-600);
  border: 1.5px solid var(--emerald-600);
}
.btn-outline:hover:not(:disabled) { background: var(--emerald-50); }

.btn-ghost {
  background: transparent;
  color: var(--stone-700);
}
.btn-ghost:hover:not(:disabled) { background: var(--stone-100); }

.btn-danger {
  background: #dc2626;
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-sm { padding: .35rem .85rem; font-size: .8rem; }
.btn-lg { padding: .8rem 2rem; font-size: 1rem; }
.btn-full { width: 100%; }

.btn-blue {
  background: var(--blue-600);
  color: #fff;
}
.btn-blue:hover:not(:disabled) { background: var(--blue-700); }

/* ---------- Form Elements ---------- */
.form-group { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.form-label { font-size: .875rem; font-weight: 600; color: var(--stone-700); }
.form-hint  { font-size: .78rem; color: var(--color-muted); }

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: .6rem .85rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-input);
  font-family: var(--font-body);
  font-size: .9rem;
  color: var(--color-text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  appearance: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--emerald-500);
  box-shadow: 0 0 0 3px rgba(16,185,129,.12);
}
.form-textarea { resize: vertical; min-height: 90px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ---------- Site Header (patient, green) ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--emerald-900);
  color: #fff;
  padding: 0 1.25rem;
  height: 60px;
  display: flex;
  align-items: center;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}
.site-logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.site-logo .logo-zh {
  font-size: .85rem;
  opacity: .75;
  font-weight: 400;
}
.header-nav {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.header-nav a {
  color: rgba(255,255,255,.85);
  font-size: .88rem;
  font-weight: 500;
  padding: .3rem .6rem;
  border-radius: 6px;
  transition: background .15s, color .15s;
  text-decoration: none;
}
.header-nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.lang-btn {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  font-size: .8rem;
  font-weight: 600;
  padding: .3rem .65rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background .15s;
}
.lang-btn:hover { background: rgba(255,255,255,.25); }

/* ---------- Doctor Header (slate/blue) ---------- */
.doctor-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--slate-700);
  color: #fff;
  padding: 0 1.25rem;
  height: 60px;
  display: flex;
  align-items: center;
}
.doctor-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}
.doctor-header .site-logo { color: #fff; }
.doctor-header .header-nav a { color: rgba(255,255,255,.85); }
.doctor-header .lang-btn { background: rgba(255,255,255,.15); color: #fff; }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 4rem;
  padding: 2rem 1.25rem;
  text-align: center;
  border-top: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: .82rem;
}
.site-footer a { color: var(--color-muted); }
.site-footer a:hover { color: var(--color-primary); }

/* ---------- Page Backgrounds ---------- */
.page-patient {
  background: linear-gradient(135deg, var(--stone-50) 0%, var(--emerald-50) 100%);
  min-height: 100vh;
}
.page-doctor {
  background: var(--slate-50);
  min-height: 100vh;
}
.page-auth {
  background: linear-gradient(135deg, var(--stone-50) 0%, var(--emerald-50) 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Hero (Home landing) ---------- */
.hero-section {
  padding: 4rem 1.25rem 3rem;
  text-align: center;
}
.hero-badge {
  display: inline-block;
  background: var(--emerald-100);
  color: var(--emerald-800);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: .3rem .85rem;
  border-radius: 99px;
  margin-bottom: 1.25rem;
}
.hero-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  color: var(--stone-900);
  line-height: 1.15;
  margin-bottom: .75rem;
}
.hero-title span { color: var(--emerald-600); }
.hero-sub {
  font-size: 1.05rem;
  color: var(--stone-500);
  max-width: 560px;
  margin: 0 auto 2rem;
  line-height: 1.7;
}
.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* ---------- Feature Cards (home) ---------- */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  padding: 0 1.25rem 3rem;
  max-width: 1100px;
  margin: 0 auto;
}
.feature-card {
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.feature-icon {
  font-size: 1.8rem;
  margin-bottom: .25rem;
}
.feature-card h3 { color: var(--stone-900); }
.feature-card p  { font-size: .88rem; color: var(--stone-500); line-height: 1.6; }

/* ---------- Wizard Container ---------- */
#wizard-section {
  padding: 0 1.25rem 4rem;
  max-width: 820px;
  margin: 0 auto;
}
.wizard-card {
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

/* ---------- Stepper ---------- */
.stepper {
  display: flex;
  align-items: flex-start;
  overflow-x: auto;
  padding: 1.25rem 1.5rem;
  gap: 0;
  border-bottom: 1px solid var(--color-border);
  background: var(--stone-50);
  scrollbar-width: none;
}
.stepper::-webkit-scrollbar { display: none; }

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  flex: 1;
  min-width: 60px;
  position: relative;
  cursor: pointer;
}
.step-item:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 14px;
  left: calc(50% + 14px);
  right: calc(-50% + 14px);
  height: 2px;
  background: var(--color-border);
  z-index: 0;
}
.step-item.done:not(:last-child)::after { background: var(--emerald-500); }

.step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: var(--color-muted);
  position: relative;
  z-index: 1;
  transition: background .2s, border-color .2s, color .2s;
}
.step-item.active .step-dot {
  background: var(--emerald-600);
  border-color: var(--emerald-600);
  color: #fff;
}
.step-item.done .step-dot {
  background: var(--emerald-500);
  border-color: var(--emerald-500);
  color: #fff;
}
.step-label {
  font-size: .67rem;
  font-weight: 600;
  color: var(--color-muted);
  text-align: center;
  line-height: 1.2;
  white-space: nowrap;
}
.step-item.active .step-label { color: var(--emerald-700); }
.step-item.done  .step-label  { color: var(--emerald-600); }

/* ---------- Wizard Body ---------- */
.wizard-body {
  padding: 2rem 1.75rem;
}
.wizard-step { display: none; }
.wizard-step.active { display: block; }
.step-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--stone-900);
  margin-bottom: .3rem;
}
.step-subtitle {
  font-size: .88rem;
  color: var(--color-muted);
  margin-bottom: 1.5rem;
}
.wizard-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.75rem;
  border-top: 1px solid var(--color-border);
  gap: 1rem;
}
.wizard-footer .btn-group { display: flex; gap: .75rem; }

/* ---------- Symptom Chips ---------- */
.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .75rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .35rem .75rem;
  border-radius: 99px;
  border: 1.5px solid var(--color-border);
  background: #fff;
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  user-select: none;
}
.chip:hover  { border-color: var(--emerald-500); background: var(--emerald-50); color: var(--emerald-800); }
.chip.active { border-color: var(--emerald-600); background: var(--emerald-100); color: var(--emerald-800); }
.chip-remove { font-size: .7rem; opacity: .6; cursor: pointer; }
.chip-add-input {
  border: 1.5px dashed var(--color-border);
  background: transparent;
  color: var(--color-muted);
  padding: .35rem .75rem;
  border-radius: 99px;
  font-size: .82rem;
  outline: none;
  width: 140px;
  font-family: var(--font-body);
}
.chip-add-input:focus { border-color: var(--emerald-500); color: var(--color-text); }

/* ---------- Chat (Inquiry step) ---------- */
.chat-container {
  border: 1.5px solid var(--color-border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.chat-messages {
  height: 320px;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  background: var(--stone-50);
}
.chat-msg {
  max-width: 80%;
  padding: .65rem 1rem;
  border-radius: 12px;
  font-size: .88rem;
  line-height: 1.55;
  word-break: break-word;
}
.chat-msg.user {
  background: var(--emerald-600);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.chat-msg.assistant {
  background: #fff;
  color: var(--stone-700);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.chat-msg.streaming { opacity: .8; }
.chat-input-row {
  display: flex;
  gap: .5rem;
  padding: .75rem;
  background: #fff;
  border-top: 1px solid var(--color-border);
}
.chat-input {
  flex: 1;
  padding: .55rem .85rem;
  border: 1.5px solid var(--color-border);
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: .88rem;
  outline: none;
  resize: none;
  height: 42px;
  transition: border-color .15s;
}
.chat-input:focus { border-color: var(--emerald-500); }
.chat-progress-bar {
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  margin-bottom: .75rem;
  overflow: hidden;
}
.chat-progress-fill {
  height: 100%;
  background: var(--emerald-500);
  border-radius: 2px;
  transition: width .4s;
}

/* ---------- Image Upload (Tongue / Face steps) ---------- */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
}
.upload-zone:hover,
.upload-zone.drag-over { border-color: var(--emerald-500); background: var(--emerald-50); }
.upload-icon { font-size: 2.5rem; margin-bottom: .5rem; }
.upload-zone p { font-size: .88rem; color: var(--color-muted); margin-top: .3rem; }
.upload-zone input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.image-preview {
  position: relative;
  margin-top: 1rem;
  border-radius: 12px;
  overflow: hidden;
}
.image-preview img {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 12px;
  display: block;
}
.preview-overlay {
  position: absolute;
  top: .5rem;
  right: .5rem;
  display: flex;
  gap: .4rem;
}
.observation-box {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--emerald-50);
  border: 1px solid var(--emerald-100);
  border-radius: 10px;
  font-size: .88rem;
  color: var(--stone-700);
  min-height: 60px;
}
.observation-box.loading { opacity: .6; font-style: italic; }
.observation-edit {
  width: 100%;
  background: transparent;
  border: none;
  font-family: var(--font-body);
  font-size: .88rem;
  color: var(--stone-700);
  resize: vertical;
  outline: none;
  min-height: 80px;
  line-height: 1.6;
}

/* ---------- Audio Recorder ---------- */
.recorder-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.rec-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  background: var(--emerald-600);
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .1s;
  flex-shrink: 0;
}
.rec-btn:hover { background: var(--emerald-700); }
.rec-btn:active { transform: scale(.93); }
.rec-btn.recording { background: #dc2626; animation: pulse-rec 1.4s infinite; }
@keyframes pulse-rec {
  0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,.4); }
  50% { box-shadow: 0 0 0 10px rgba(220,38,38,0); }
}
.rec-timer {
  font-size: 1.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--stone-700);
  min-width: 60px;
}
.rec-status { font-size: .85rem; color: var(--color-muted); }
.audio-preview { margin-top: 1rem; width: 100%; }

/* ---------- Pulse Input ---------- */
.pulse-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.bpm-display {
  font-size: 3rem;
  font-weight: 800;
  color: var(--emerald-600);
  line-height: 1;
  min-width: 90px;
  text-align: center;
}
.bpm-unit { font-size: 1rem; font-weight: 400; color: var(--color-muted); }
.pulse-quality-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
  margin-top: 1rem;
}
.quality-chip {
  padding: .5rem;
  border-radius: 8px;
  border: 1.5px solid var(--color-border);
  background: #fff;
  text-align: center;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.quality-chip:hover  { border-color: var(--emerald-400); background: var(--emerald-50); }
.quality-chip.active { border-color: var(--emerald-600); background: var(--emerald-100); color: var(--emerald-800); }

/* ---------- Summary Review ---------- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}
.summary-item {
  background: var(--stone-50);
  border-radius: 10px;
  padding: 1rem;
  border: 1px solid var(--color-border);
}
.summary-item-label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-muted);
  margin-bottom: .4rem;
}
.summary-item-value {
  font-size: .9rem;
  color: var(--stone-800);
  line-height: 1.5;
}

/* ---------- Report / Results ---------- */
.report-section { margin-bottom: 2rem; }
.report-section h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--emerald-800);
  border-left: 3px solid var(--emerald-500);
  padding-left: .65rem;
  margin-bottom: .85rem;
}
.constitution-card {
  background: linear-gradient(135deg, var(--emerald-50), #fff);
  border: 1.5px solid var(--emerald-100);
  border-radius: 14px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.constitution-type {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--emerald-700);
  margin-bottom: .3rem;
}
.constitution-desc { font-size: .88rem; color: var(--stone-600); line-height: 1.6; }

/* Five Elements Bar Chart */
.five-elements { margin: 1rem 0; }
.element-row {
  display: flex;
  align-items: center;
  gap .75rem;
  margin-bottom: .6rem;
}
.element-label {
  width: 80px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--stone-700);
  flex-shrink: 0;
}
.element-bar-track {
  flex: 1;
  height: 10px;
  background: var(--stone-100);
  border-radius: 99px;
  overflow: hidden;
}
.element-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .8s cubic-bezier(.4,0,.2,1);
}
.element-bar-fill.liver  { background: #16a34a; }
.element-bar-fill.heart  { background: #dc2626; }
.element-bar-fill.spleen { background: #d97706; }
.element-bar-fill.lung   { background: #f0f9ff; background: #94a3b8; }
.element-bar-fill.kidney { background: #1d4ed8; }
.element-score { width: 32px; font-size: .8rem; font-weight: 700; color: var(--stone-600); text-align: right; }

.diagnosis-item {
  background: var(--stone-50);
  border-radius: 10px;
  padding: .9rem 1.1rem;
  margin-bottom: .6rem;
  border: 1px solid var(--color-border);
}
.diagnosis-item h4 { font-size: .9rem; color: var(--stone-900); margin-bottom: .25rem; }
.diagnosis-item p  { font-size: .82rem; color: var(--stone-600); }

.rec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .75rem;
  margin-top: .5rem;
}
.rec-card {
  background: #fff;
  border-radius: 10px;
  padding: .9rem;
  border: 1px solid var(--color-border);
}
.rec-card-icon { font-size: 1.4rem; margin-bottom: .3rem; }
.rec-card h4 { font-size: .82rem; font-weight: 700; margin-bottom: .35rem; }
.rec-card ul  { list-style: disc; padding-left: 1.1rem; }
.rec-card li  { font-size: .8rem; color: var(--stone-600); line-height: 1.6; }

.disclaimer-box {
  background: var(--stone-50);
  border: 1px solid var(--stone-200);
  border-radius: 10px;
  padding: 1rem;
  font-size: .78rem;
  color: var(--color-muted);
  line-height: 1.7;
  margin-top: 1.5rem;
}

/* Loading Spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner-dark {
  border-color: rgba(0,0,0,.12);
  border-top-color: var(--emerald-600);
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.5rem;
  justify-content: center;
  color: var(--color-muted);
  font-size: .9rem;
}

/* Alert / Toast */
.alert {
  padding: .75rem 1rem;
  border-radius: 10px;
  font-size: .88rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: .6rem;
}
.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border: 1px solid var(--emerald-100); color: var(--emerald-800); }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

/* ---------- Auth Page ---------- */
.auth-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
}
.auth-card {
  background: #fff;
  border-radius: var(--radius-card);
  box-shadow: 0 4px 32px rgba(0,0,0,.10);
  padding: 2.5rem;
  width: 100%;
  max-width: 440px;
}
.auth-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}
.auth-logo a {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--emerald-900);
  text-decoration: none;
}
.auth-logo .logo-zh { font-size: .85rem; opacity: .55; font-weight: 400; margin-left: .3rem; }
.auth-title { font-size: 1.4rem; font-weight: 700; text-align: center; margin-bottom: .35rem; }
.auth-sub   { text-align: center; font-size: .88rem; color: var(--color-muted); margin-bottom: 1.75rem; }

/* Tabs */
.tab-row {
  display: flex;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 1.75rem;
}
.tab-btn {
  flex: 1;
  padding: .65rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-family: var(--font-body);
  font-size: .9rem;
  font-weight: 600;
  color: var(--color-muted);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.tab-btn.active {
  color: var(--emerald-700);
  border-color: var(--emerald-600);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Patient Dashboard ---------- */
.dashboard-main {
  padding: 2rem 1.25rem 4rem;
  max-width: 900px;
  margin: 0 auto;
}
.dashboard-hero {
  background: linear-gradient(135deg, var(--emerald-800), var(--emerald-600));
  border-radius: var(--radius-card);
  padding: 2rem;
  color: #fff;
  margin-bottom: 2rem;
}
.dashboard-hero h2 { color: #fff; margin-bottom: .35rem; }
.dashboard-hero p  { color: rgba(255,255,255,.8); font-size: .9rem; margin-bottom: 1.25rem; }

.session-list { display: flex; flex-direction: column; gap: 1rem; }
.session-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  padding: 1.25rem;
  cursor: pointer;
  transition: box-shadow .2s;
  border: 1px solid transparent;
}
.session-card:hover { box-shadow: var(--shadow-card-hover); border-color: var(--emerald-100); }
.session-card.expanded { border-color: var(--emerald-200); }
.session-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.session-date { font-size: .78rem; color: var(--color-muted); font-weight: 600; }
.session-constitution {
  display: inline-block;
  background: var(--emerald-100);
  color: var(--emerald-800);
  font-size: .75rem;
  font-weight: 700;
  padding: .2rem .65rem;
  border-radius: 99px;
}
.session-symptoms { font-size: .85rem; color: var(--stone-600); margin-top: .4rem; }
.session-expand-icon { color: var(--color-muted); font-size: .9rem; transition: transform .2s; }
.session-card.expanded .session-expand-icon { transform: rotate(180deg); }
.session-detail { display: none; margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--color-border); }
.session-card.expanded .session-detail { display: block; }

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--color-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: .75rem; }
.empty-state h3 { color: var(--stone-600); margin-bottom: .4rem; }

/* ---------- Doctor Dashboard ---------- */
.doctor-main {
  padding: 2rem 1.25rem 4rem;
  max-width: 1000px;
  margin: 0 auto;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: #fff;
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--blue-600);
  line-height: 1;
}
.stat-label { font-size: .82rem; color: var(--color-muted); font-weight: 600; }
.stat-sub   { font-size: .75rem; color: var(--stone-400); }

.doctor-cta-card {
  background: linear-gradient(135deg, var(--blue-700), var(--blue-600));
  border-radius: var(--radius-card);
  padding: 2rem;
  color: #fff;
  margin-bottom: 2rem;
}
.doctor-cta-card h2 { color: #fff; margin-bottom: .5rem; }
.doctor-cta-card p  { color: rgba(255,255,255,.8); font-size: .9rem; margin-bottom: 1.25rem; }

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.qa-card {
  background: #fff;
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  border-left: 4px solid var(--blue-600);
}
.qa-card h3 { font-size: .95rem; margin-bottom: .35rem; }
.qa-card p  { font-size: .82rem; color: var(--color-muted); margin-bottom: .85rem; }

/* ---------- Notification Badge ---------- */
.badge {
  display: inline-block;
  background: #dc2626;
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  padding: .1rem .4rem;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
}

/* ---------- Telegram Status (from recent PR) ---------- */
.tg-status {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .82rem;
  padding: .3rem .75rem;
  border-radius: 99px;
  font-weight: 600;
}
.tg-status.connected    { background: var(--emerald-100); color: var(--emerald-800); }
.tg-status.disconnected { background: #fef2f2; color: #991b1b; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
  .wizard-body { padding: 1.25rem 1rem; }
  .wizard-footer { padding: 1rem; flex-direction: column; }
  .wizard-footer .btn-group { width: 100%; }
  .wizard-footer .btn-group .btn { flex: 1; }
  .stepper { padding: 1rem; gap: 0; }
  .step-label { display: none; }
  .pulse-quality-grid { grid-template-columns: repeat(2, 1fr); }
  .rec-grid { grid-template-columns: 1fr 1fr; }
  .auth-card { padding: 1.75rem 1.25rem; }
  .dashboard-hero { padding: 1.25rem; }
  .summary-grid { grid-template-columns: 1fr; }
  .hero-actions { flex-direction: column; align-items: center; }
}

@media (max-width: 400px) {
  .stepper { display: none; }
  .step-dot { width: 24px; height: 24px; font-size: .65rem; }
}

/* ---------- Scroll to Wizard ---------- */
#wizard-section { scroll-margin-top: 70px; }

/* ---------- Misc helpers ---------- */
.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 1.25rem 0;
}
.tag {
  display: inline-block;
  background: var(--stone-100);
  color: var(--stone-600);
  font-size: .75rem;
  font-weight: 600;
  padding: .15rem .55rem;
  border-radius: 6px;
}
