/* ── Design tokens ──────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #f6f8fc;
  --bg-subtle:    #eef1f8;
  --surface:      #ffffff;
  --sidebar-bg:   #ffffff;

  --hero-bg:      linear-gradient(160deg, #f0f2ff 0%, #e8ecff 45%, #f4f0ff 100%);
  --hero-border:  rgba(99, 102, 241, 0.18);
  --hero-glow:    rgba(79, 70, 229, 0.08);

  --primary:      #4f46e5;
  --primary-h:    #4338ca;
  --primary-soft: #eef2ff;
  --primary-mid:  #c7d2fe;

  --text:         #0f172a;
  --text-2:       #475569;
  --text-3:       #94a3b8;

  --border:       #e2e8f0;
  --border-soft:  #f1f5f9;

  --green:        #059669;
  --green-bg:     #ecfdf5;
  --green-bd:     #a7f3d0;

  --amber:        #d97706;
  --amber-bg:     #fffbeb;
  --amber-bd:     #fde68a;

  --red:          #dc2626;
  --red-bg:       #fef2f2;
  --red-bd:       #fecaca;

  --blue-tip-bg:  #eff6ff;
  --blue-tip-bd:  #bfdbfe;
  --blue-tip-tx:  #1d4ed8;

  --radius-sm:    10px;
  --radius:       14px;
  --radius-lg:    20px;
  --radius-xl:    24px;

  --shadow-xs:    0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm:    0 2px 8px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md:    0 8px 24px rgba(15, 23, 42, 0.07), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-lg:    0 16px 40px rgba(79, 70, 229, 0.12);

  --sidebar-w:    248px;
  --panel-w:      300px;

  --ease:         cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  overflow-x: hidden;
  max-width: 100%;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  letter-spacing: -0.011em;
  overflow-x: hidden;
  max-width: 100vw;
}

/* ── App shell ──────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--panel-w);
  min-height: 100vh;
  max-width: 100vw;
  overflow-x: hidden;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 90;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.visible {
  display: block;
}

/* ── Sidebar ────────────────────────────────── */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 10px 28px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  color: var(--primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
  border: 1px solid rgba(99, 102, 241, 0.12);
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  text-align: left;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}

.nav-item:hover:not(.disabled) { background: var(--bg-subtle); color: var(--text); }
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.1);
}
.nav-item.disabled { opacity: 0.5; cursor: default; }
.nav-item.subtle { color: var(--text-3); }

.nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.85;
}
.nav-item.active .nav-icon { opacity: 1; }

.badge-soon {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--bg-subtle);
  color: var(--text-3);
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.sidebar-footer { margin-top: auto; }

.disclaimer-card {
  margin-top: 14px;
  padding: 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.55;
}

.disclaimer-card strong {
  display: block;
  color: var(--text-2);
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 600;
}

/* ── Main column ────────────────────────────── */
.main {
  padding: 0 36px 48px;
  max-width: 760px;
  width: 100%;
  min-width: 0;
  justify-self: center;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 0 16px;
  position: sticky;
  top: 0;
  background: rgba(246, 248, 252, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 40;
}

.menu-btn {
  display: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  color: var(--text-2);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  flex: 1;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-xs);
  max-width: fit-content;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.25);
}

.status-dot.ready {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.2);
}

.status-dot.listening {
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
  animation: pulse-dot 1.4s ease-in-out infinite;
}

.status-dot.thinking {
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.2);
  animation: pulse-dot 0.7s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.88); }
}

.topbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-2);
  box-shadow: var(--shadow-xs);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.topbar-btn:hover {
  background: var(--bg-subtle);
  border-color: var(--primary-mid);
  color: var(--primary);
}

/* ── Critical banner ────────────────────────── */
.critical-banner {
  background: var(--red-bg);
  border: 1px solid var(--red-bd);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--red);
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.08);
  animation: slideUp 0.3s var(--ease);
}

.closure-banner {
  background: var(--green-bg);
  border: 1px solid var(--green-bd);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--green);
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.08);
  animation: slideUp 0.3s var(--ease);
}

/* ── Views ──────────────────────────────────── */
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.35s var(--ease); }

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

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

.greeting {
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 28px;
  line-height: 1.3;
  letter-spacing: -0.03em;
  max-width: 28ch;
}
.feedback-line {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 28px;
  line-height: 1.5;
  max-width: 48ch;
}

.feedback-line a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

.feedback-line a:hover {
  border-bottom-color: var(--primary);
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 22px;
}

/* ── Hero card ──────────────────────────────── */
.hero-card {
  position: relative;
  background: var(--hero-bg);
  border: 1px solid var(--hero-border);
  border-radius: var(--radius-xl);
  padding: 36px 28px 28px;
  text-align: center;
  margin-bottom: 32px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.3s var(--ease), border-color 0.3s var(--ease);
}

.hero-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(255,255,255,0.7) 0%, transparent 70%);
  pointer-events: none;
}

.hero-card.recording {
  border-color: rgba(79, 70, 229, 0.35);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(79, 70, 229, 0.08);
}

.hero-card h2 {
  position: relative;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
}

.hero-sub {
  position: relative;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  margin-top: 6px;
}

.mic-area {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 32px 0 14px;
  height: 110px;
}

.waveform-track {
  position: relative;
  width: min(100%, 440px);
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mic-btn {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, #5b52f0 0%, #4338ca 100%);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 8px 24px rgba(79, 70, 229, 0.45),
    0 2px 6px rgba(79, 70, 229, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
  z-index: 3;
  flex-shrink: 0;
}

.mic-btn:hover {
  transform: scale(1.05);
  box-shadow:
    0 12px 32px rgba(79, 70, 229, 0.5),
    0 4px 8px rgba(79, 70, 229, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.mic-btn:active { transform: scale(0.97); }

.mic-ring {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid rgba(79, 70, 229, 0.25);
  opacity: 0;
  transition: opacity 0.3s;
}

@keyframes ring-pulse {
  0%   { transform: scale(1);   opacity: 0.6; }
  100% { transform: scale(1.35); opacity: 0; }
}

#listenBtn.recording {
  background: linear-gradient(145deg, #ef4444 0%, #dc2626 100%);
  box-shadow:
    0 8px 24px rgba(220, 38, 38, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

#listenBtn.recording .mic-ring {
  opacity: 1;
  animation: ring-pulse 1.8s ease-out infinite;
}

.mic-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.hero-label {
  position: relative;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
}

.privacy-note {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 22px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  background: rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.8);
}

.privacy-note svg { color: var(--primary); opacity: 0.7; }

/* ── Waveform ───────────────────────────────── */
.waveform {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 72px;
  padding: 0 12px;
  z-index: 1;
  pointer-events: none;
}

.waveform .bar {
  flex: 1;
  max-width: 6px;
  min-width: 3px;
  height: var(--h, 8px);
  background: linear-gradient(180deg, #c7d2fe 0%, #818cf8 55%, #6366f1 100%);
  border-radius: 4px;
  opacity: 0.55;
  transform-origin: center center;
  transition: height 0.08s ease-out, opacity 0.2s;
  animation: wave-idle 2.4s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

/* Stagger idle animation per bar */
.waveform .bar:nth-child(odd)  { animation-duration: 2.1s; }
.waveform .bar:nth-child(3n)   { animation-duration: 2.6s; }
.waveform .bar:nth-child(5n)   { animation-duration: 1.9s; }

@keyframes wave-idle {
  0%, 100% { transform: scaleY(0.45); opacity: 0.4; }
  50%      { transform: scaleY(1);    opacity: 0.65; }
}

/* Live listening — brighter, taller, audio-driven heights override CSS */
.waveform.active .bar {
  opacity: 0.85;
  animation: none;
  background: linear-gradient(180deg, #a5b4fc 0%, #6366f1 50%, #4f46e5 100%);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.35);
}

.waveform.active .bar.loud {
  opacity: 1;
  background: linear-gradient(180deg, #c4b5fd 0%, #7c3aed 50%, #5b21b6 100%);
}

/* Fade bars near center so mic button stays clear */
.waveform .bar:nth-child(12),
.waveform .bar:nth-child(13),
.waveform .bar:nth-child(14),
.waveform .bar:nth-child(15) {
  opacity: 0.15;
  max-width: 4px;
}
.waveform.active .bar:nth-child(12),
.waveform.active .bar:nth-child(13),
.waveform.active .bar:nth-child(14),
.waveform.active .bar:nth-child(15) {
  opacity: 0.25;
}

/* ── Pipeline ───────────────────────────────── */
.pipeline {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  margin-bottom: 24px;
  padding: 8px 0;
}

.pipe-step {
  text-align: center;
  flex: 0 0 auto;
  width: 108px;
  opacity: 0.38;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}

.pipe-step.active {
  opacity: 1;
  transform: translateY(-2px);
}

.pipe-step.done { opacity: 0.72; }

.pipe-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
  box-shadow: var(--shadow-xs);
  color: var(--text-3);
  transition: background 0.25s, border-color 0.25s, box-shadow 0.25s, color 0.25s;
}

.pipe-step.active .pipe-icon {
  background: var(--primary-soft);
  border-color: var(--primary-mid);
  color: var(--primary);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}

.pipe-step.done .pipe-icon {
  background: var(--green-bg);
  border-color: var(--green-bd);
  color: var(--green);
}

.pipe-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.pipe-desc {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  margin-top: 3px;
  line-height: 1.35;
}

.pipe-arrow {
  color: var(--border);
  font-size: 20px;
  font-weight: 300;
  padding: 14px 2px 0;
  user-select: none;
}

/* ── Tip banner ─────────────────────────────── */
.tip-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--blue-tip-bg);
  border: 1px solid var(--blue-tip-bd);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 13px;
  color: var(--blue-tip-tx);
  margin-bottom: 32px;
  line-height: 1.5;
}

.tip-icon { font-size: 16px; flex-shrink: 0; line-height: 1.4; }
.tip-banner strong { font-weight: 600; }

/* ── Section headers ────────────────────────── */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-head h3 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-head.compact { margin-bottom: 12px; }

.link-btn {
  border: none;
  background: none;
  color: var(--primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  transition: opacity 0.15s;
}

.link-btn:hover { opacity: 0.75; text-decoration: underline; }

/* ── Recent cases ───────────────────────────── */
.recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.recent-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
  box-shadow: var(--shadow-xs);
}

.recent-card:hover {
  border-color: var(--primary-mid);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.recent-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}

.recent-wave {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 20px;
  flex: 1;
}

.recent-wave span {
  flex: 1;
  max-width: 3px;
  height: 4px;
  background: var(--primary-mid);
  border-radius: 2px;
  opacity: 0.6;
}

.recent-wave span:nth-child(3n)  { height: 10px; opacity: 0.8; }
.recent-wave span:nth-child(5n)  { height: 14px; }
.recent-wave span:nth-child(7n)  { height: 8px; }

.recent-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-meta {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
}

.priority-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 20px;
  flex-shrink: 0;
}

.priority-tag.Routine  { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-bd); }
.priority-tag.Urgent   { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-bd); }
.priority-tag.Critical { background: var(--red-bg);   color: var(--red);   border: 1px solid var(--red-bd); }

.recent-empty, .empty-state {
  color: var(--text-3);
  font-size: 13px;
  font-weight: 500;
  padding: 32px 20px;
  text-align: center;
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Case panel ─────────────────────────────── */
.case-panel {
  margin-top: 12px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  animation: slideUp 0.35s var(--ease);
}

.case-transcript-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}

.card-label-sm {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 10px;
}

#transcript {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  line-height: 1.65;
  min-height: 44px;
  white-space: pre-wrap;
  word-break: break-word;
  font-style: italic;
}

.assessment-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.assess-card {
  border-radius: var(--radius);
  padding: 16px 18px;
  border: 1px solid;
  box-shadow: var(--shadow-xs);
}

.assess-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 8px;
}

.assess-value {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

.assess-card.diagnosis { background: #eff6ff; border-color: #bfdbfe; }
.assess-card.diagnosis .assess-label { color: #2563eb; }
.assess-card.diagnosis .assess-value { color: #1e3a8a; font-weight: 600; font-size: 16px; }

.assess-card.next { background: var(--green-bg); border-color: var(--green-bd); }
.assess-card.next .assess-label { color: var(--green); }
.assess-card.next .assess-value { color: #064e3b; }

.assess-card.target { background: var(--amber-bg); border-color: var(--amber-bd); }
.assess-card.target .assess-label { color: var(--amber); }
.assess-card.target .assess-value { color: #78350f; font-size: 14px; }

.diff-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}

.hypothesis {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}

.hypothesis:last-child { border-bottom: none; padding-bottom: 0; }

.hyp-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.hyp-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.hyp-prob {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 20px;
}

.hyp-prob.high   { background: var(--red-bg); color: var(--red); }
.hyp-prob.medium { background: var(--amber-bg); color: var(--amber); }
.hyp-prob.low    { background: var(--bg-subtle); color: var(--text-2); }

.hyp-detail {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  line-height: 1.55;
}

.case-details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}

.case-details summary {
  padding: 15px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-2);
  list-style: none;
  user-select: none;
}

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

.details-body { padding: 0 18px 18px; }

.reasoning-trace {
  font-size: 11px;
  font-family: "SF Mono", ui-monospace, monospace;
  color: var(--text-3);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 14px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  white-space: pre-wrap;
  margin-bottom: 16px;
}

/* ── Forms ──────────────────────────────────── */
.priority-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.pri-btn {
  padding: 10px 6px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-2);
  transition: all 0.15s var(--ease);
}

.pri-btn.active[data-p="Routine"]  { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.pri-btn.active[data-p="Urgent"]   { border-color: var(--amber); background: var(--amber-bg); color: var(--amber); }
.pri-btn.active[data-p="Critical"] { border-color: var(--red);   background: var(--red-bg);   color: var(--red); }

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

.form-grid .span-2 { grid-column: span 2; }

.field label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 5px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

textarea { min-height: 72px; resize: vertical; line-height: 1.5; }

/* ── Right panel ────────────────────────────── */
.right-panel {
  padding: 28px 24px 48px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.panel-card h3 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
  color: var(--text);
}

.how-list {
  list-style: none;
  counter-reset: steps;
}

.how-list li {
  counter-increment: steps;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  line-height: 1.55;
  padding-left: 32px;
  position: relative;
  margin-bottom: 16px;
}

.how-list li:last-child { margin-bottom: 0; }

.how-list li::before {
  content: counter(steps);
  position: absolute;
  left: 0;
  top: 1px;
  width: 22px;
  height: 22px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(79, 70, 229, 0.12);
}

.how-list strong {
  color: var(--text);
  font-weight: 600;
}

.example-card .example-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  font-style: italic;
  line-height: 1.6;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--primary-mid);
}

.btn-demo {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}

.btn-demo:hover {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

/* ── Buttons ──────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(145deg, #5b52f0, #4338ca);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}

.btn-ghost {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-2);
  transition: border-color 0.15s, color 0.15s;
}

.btn-ghost:hover { border-color: var(--primary-mid); color: var(--primary); }
.btn-ghost.full { width: 100%; margin-top: 10px; }

/* ── Settings modal ───────────────────────── */
.settings-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 300;
  align-items: flex-end;
  justify-content: center;
}

.settings-overlay.open {
  display: flex;
  animation: fadeOverlay 0.25s var(--ease);
}

@keyframes fadeOverlay {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.settings-panel {
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 12px 24px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 -8px 40px rgba(15, 23, 42, 0.12);
  animation: sheetUp 0.3s var(--ease);
}

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 20px;
}

.settings-panel h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.close-btn {
  cursor: pointer;
  color: var(--text-3);
  font-size: 20px;
  line-height: 1;
  padding: 4px;
}

/* ── Help AI Assistant ────────────────────── */
.help-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.help-header .page-title { margin-bottom: 4px; }

.help-sub {
  font-size: 14px;
  color: var(--text-3);
  font-weight: 500;
}

.help-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.help-chip {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  box-shadow: var(--shadow-xs);
}

.help-chip:hover {
  border-color: var(--primary-mid);
  background: var(--primary-soft);
  color: var(--primary);
}

.help-chat {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 320px;
  max-height: calc(100vh - 340px);
  overflow-y: auto;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

.help-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  max-width: 92%;
  animation: fadeIn 0.25s var(--ease);
}

.help-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
  max-width: 85%;
}

.help-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
  color: var(--primary);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(79, 70, 229, 0.15);
}

.help-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  font-weight: 500;
}

.help-msg.assistant .help-bubble {
  background: var(--bg-subtle);
  color: var(--text);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
}

.help-msg.user .help-bubble {
  background: linear-gradient(145deg, #5b52f0, #4338ca);
  color: white;
  border-top-right-radius: 4px;
}

.help-msg.typing .help-bubble { padding: 14px 18px; }

.typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 16px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

.help-input-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 6px 6px 18px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.help-input-row:focus-within {
  border-color: var(--primary-mid);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.help-input-row input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 0;
  font-size: 14px;
  outline: none;
  box-shadow: none;
}

.help-input-row input:focus {
  box-shadow: none;
  border: none;
}

.help-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, #5b52f0, #4338ca);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.help-send:hover { transform: scale(1.05); }
.help-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.help-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, #5b52f0, #4338ca);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.45);
  z-index: 200;
  transition: transform 0.2s var(--ease), opacity 0.2s;
}

.help-fab:hover { transform: scale(1.08); }
.help-fab.hidden { opacity: 0; pointer-events: none; transform: scale(0.8); }

/* ── Debug ────────────────────────────────── */
.debug-drawer {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-w);
  right: var(--panel-w);
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 11px;
  z-index: 20;
  box-shadow: 0 -4px 12px rgba(15, 23, 42, 0.04);
}

.debug-drawer summary {
  padding: 8px 18px;
  cursor: pointer;
  color: var(--text-3);
  font-weight: 500;
}

.debug-drawer pre {
  padding: 8px 18px 14px;
  max-height: 120px;
  overflow-y: auto;
  white-space: pre-wrap;
  color: var(--text-2);
  font-family: ui-monospace, monospace;
}

/* ── Responsive ───────────────────────────── */
@media (max-width: 1180px) {
  .app { grid-template-columns: var(--sidebar-w) 1fr; }
  .right-panel { display: none; }
  .debug-drawer { right: 0; }
  .main { max-width: none; padding: 0 28px 48px; }
}

@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    left: -280px;
    width: 280px;
    height: 100vh;
    transition: left 0.28s var(--ease);
    box-shadow: var(--shadow-md);
  }

  .sidebar.open { left: 0; }

  .menu-btn { display: flex; align-items: center; justify-content: center; }

  .main { padding: 0 14px 32px; max-width: 100%; }

  .greeting { font-size: 20px; max-width: none; line-height: 1.3; }

  .hero-card {
    padding: 24px 16px 20px;
    border-radius: var(--radius-lg);
  }

  .waveform-track { max-width: 100%; }
  .pipeline {
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }
  .pipe-step { width: 72px; flex-shrink: 0; }
  .pipe-arrow { display: none; }
  .pipe-desc { display: none; }
  .pipe-icon { width: 40px; height: 40px; font-size: 16px; }

  .recent-grid { grid-template-columns: 1fr; }

  .assessment-grid { grid-template-columns: 1fr; }
  .assessment-grid .assess-card:first-child { grid-column: span 1; }

  .assess-value { word-break: break-word; }
  .hyp-detail { word-break: break-word; }

  .tip-banner { font-size: 13px; padding: 12px 14px; }

  .help-fab { bottom: 16px; right: 16px; }

  .debug-drawer { left: 0; }
}

@media (min-width: 640px) {
  .assessment-grid {
    grid-template-columns: 1fr 1fr;
  }
  .assessment-grid .assess-card:first-child {
    grid-column: span 2;
  }
}

@media (min-width: 900px) {
  .greeting { font-size: 28px; }
}
