@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600;700&family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ══════════════════════════════════════════════════════════════
   DESIGN TOKENS — Cabinet de Psychiatrie Dr Khilaji Safae
   Palette : Navy profond + Or prestige + Blanc clinique
══════════════════════════════════════════════════════════════ */
:root {
  /* ── Brand navy ── */
  --navy-950: #060F18;
  --navy-900: #0A1A27;
  --navy-800: #0F2637;
  --navy-700: #173348;
  --navy-600: #1F4260;
  --navy-500: #285177;
  --navy-400: #3A6B8E;
  --navy-300: #6290A8;
  --navy-200: #9BBCCC;
  --navy-100: #C8DCE6;
  --navy-50:  #EBF3F7;

  /* ── Gold accent ── */
  --gold-700: #7A520A;
  --gold-600: #9B6C12;
  --gold-500: #C9953D;
  --gold-400: #D9AE62;
  --gold-300: #E8CA92;
  --gold-200: #F2DFBE;
  --gold-100: #F9EFDA;
  --gold-50:  #FDF7EE;

  /* ── Neutral surface ── */
  --ink-900: #0A1823;
  --ink-700: #1E3340;
  --ink-500: #3A5568;
  --ink-400: #52697A;
  --ink-300: #6D8796;
  --ink-200: #9DB4BE;
  --ink-100: #C6D5DC;
  --ink-50:  #EDF2F4;

  /* ── Semantic ── */
  --success-dark: #0E4A3A;
  --success:      #1A7A62;
  --success-light:#E4F5F0;
  --danger-dark:  #7C1E14;
  --danger:       #C0402F;
  --danger-light: #FDECEA;
  --warn-dark:    #6B3D06;
  --warn:         #C9953D;
  --warn-light:   #FEF4E0;

  /* ── Surfaces ── */
  --bg:           #F0F4F7;
  --bg-alt:       #E8EEF3;
  --surface:      #FFFFFF;
  --surface-alt:  #FAFCFD;

  /* ── Borders ── */
  --border:       #D0DCE3;
  --border-light: #E4EDF2;
  --border-strong:#B0C4CE;

  /* ── Effects ── */
  --shadow-xs: 0 1px 2px rgba(10,24,39,.06);
  --shadow-sm: 0 1px 4px rgba(10,24,39,.08), 0 1px 2px rgba(10,24,39,.04);
  --shadow:    0 2px 8px rgba(10,24,39,.10), 0 1px 3px rgba(10,24,39,.06);
  --shadow-md: 0 4px 16px rgba(10,24,39,.12), 0 2px 6px rgba(10,24,39,.06);
  --shadow-lg: 0 8px 32px rgba(10,24,39,.14), 0 3px 8px rgba(10,24,39,.08);
  --shadow-gold: 0 3px 12px rgba(201,149,61,.30);

  /* ── Motion ── */
  --ease: cubic-bezier(.4,0,.2,1);
  --ease-out: cubic-bezier(0,0,.2,1);
  --t-fast: 100ms;
  --t:      180ms;
  --t-slow: 300ms;

  /* ── Radii ── */
  --r-xs: 4px;
  --r-sm: 6px;
  --r:    8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
}

/* ══════════════════════════════════════════════════════════════
   RESET & BASE
══════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 14px;
  color: var(--ink-700);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { cursor: pointer; }
a { text-decoration: none; }

/* ══════════════════════════════════════════════════════════════
   APP SHELL
══════════════════════════════════════════════════════════════ */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ══════════════════════════════════════════════════════════════
   SIDEBAR — Navy prestige
══════════════════════════════════════════════════════════════ */
.sidebar {
  width: 268px;
  flex-shrink: 0;
  background: var(--navy-800);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  box-shadow: 2px 0 16px rgba(10,24,39,.18);
}

/* Gold top border accent */
.sidebar::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--gold-500) 30%,
    var(--gold-300) 50%,
    var(--gold-500) 70%,
    transparent 100%);
}

/* ── Cabinet branding ── */
.cabinet-brand {
  padding: 22px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.cabinet-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.cabinet-logo-wrap {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: var(--r-md);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(201,149,61,.25);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.cabinet-logo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.cabinet-logo-wrap .logo-fallback {
  font-size: 24px;
  line-height: 1;
}

.cabinet-text { flex: 1; min-width: 0; }

.cabinet-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--gold-400);
  line-height: 1.35;
  letter-spacing: .01em;
}

.cabinet-role {
  font-size: 9.5px;
  font-weight: 400;
  color: rgba(255,255,255,.35);
  margin-top: 3px;
  letter-spacing: .03em;
}

/* App badge */
.app-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: rgba(201,149,61,.12);
  border: 1px solid rgba(201,149,61,.2);
  border-radius: 100px;
}

.app-badge-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--gold-400);
  animation: pulse-dot 2.5s ease-in-out infinite;
}

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

.app-badge-text {
  font-size: 9px;
  font-weight: 700;
  color: var(--gold-300);
  text-transform: uppercase;
  letter-spacing: .1em;
}

/* ── New conversation button ── */
.sb-actions { padding: 14px 16px 10px; }

.btn-new {
  width: 100%;
  padding: 10px 13px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.11);
  border-radius: var(--r);
  color: rgba(255,255,255,.82);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--t) var(--ease);
  font-family: 'Inter', sans-serif;
}

.btn-new:hover {
  background: rgba(255,255,255,.13);
  border-color: rgba(255,255,255,.2);
  transform: translateY(-1px);
}

.btn-new-plus {
  width: 20px; height: 20px;
  border-radius: var(--r-xs);
  background: rgba(201,149,61,.25);
  border: 1px solid rgba(201,149,61,.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; line-height: 1;
  flex-shrink: 0;
  color: var(--gold-300);
}

/* ── Mode selector ── */
.sb-mode { padding: 4px 16px 8px; }

.sb-section-label {
  font-size: 9px;
  font-weight: 700;
  color: rgba(255,255,255,.25);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 6px;
}

.mode-select {
  width: 100%;
  padding: 8px 32px 8px 10px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.11);
  border-radius: var(--r);
  color: rgba(255,255,255,.82);
  font-size: 12px;
  font-weight: 400;
  font-family: 'Inter', sans-serif;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,.35)' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: all var(--t) var(--ease);
}

.mode-select:focus {
  outline: none;
  border-color: rgba(201,149,61,.45);
  box-shadow: 0 0 0 3px rgba(201,149,61,.1);
}

/* Options du dropdown — fond navy opaque, texte lisible */
.mode-select option {
  background: #173348;          /* navy-700 — opaque, pas de transparence */
  color: rgba(255,255,255,.88);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  padding: 6px 10px;
}

/* Option sélectionnée / survolée — accent or */
.mode-select option:checked,
.mode-select option:hover {
  background: #D9AE62;          /* gold-400 */
  color: #0F2637;               /* navy-800 */
  font-weight: 500;
}

/* ── History list ── */
.sb-hist-wrap { flex: 1; overflow-y: auto; padding: 4px 10px; }
.sb-hist-wrap::-webkit-scrollbar { width: 3px; }
.sb-hist-wrap::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.hist-date {
  font-size: 9px;
  font-weight: 700;
  color: rgba(255,255,255,.2);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 12px 8px 4px;
}

.hist-item {
  padding: 9px 10px;
  border-radius: var(--r);
  cursor: pointer;
  margin-bottom: 2px;
  transition: all var(--t-fast) var(--ease);
  position: relative;
  overflow: visible;
}

.hist-item::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 2px;
  background: var(--gold-500);
  border-radius: 1px;
  transform: scaleY(0);
  transition: transform var(--t) var(--ease);
}

.hist-item:hover { background: rgba(255,255,255,.06); }
.hist-item.active { background: rgba(255,255,255,.09); }
.hist-item.active::before { transform: scaleY(1); }

/* Delete button — visible on hover */
.hist-del {
  position: absolute;
  right: 4px; top: 50%;
  transform: translateY(-50%);
  width: 20px; height: 20px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: rgba(255,255,255,.25);
  font-size: 11px; line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center; justify-content: center;
  transition: all var(--t-fast) var(--ease);
  flex-shrink: 0;
}
.hist-item:hover .hist-del { display: flex; }
.hist-del:hover { background: rgba(192,64,47,.25); color: #FF9090; }

.hist-title {
  font-size: 11.5px;
  color: rgba(255,255,255,.75);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-weight: 400;
  padding-right: 22px; /* space for delete button */
}

.hist-meta { font-size: 9.5px; color: rgba(255,255,255,.28); margin-top: 2px; }

.hist-empty {
  font-size: 11px;
  color: rgba(255,255,255,.2);
  text-align: center;
  padding: 32px 16px;
  line-height: 1.8;
}

/* ── Sidebar footer ── */
.sb-footer {
  padding: 8px 12px 12px;
  border-top: 1px solid rgba(255,255,255,.06);
}

.sb-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: rgba(255,255,255,.35);
  padding: 7px 9px;
  border-radius: var(--r-sm);
  transition: all var(--t-fast) var(--ease);
  cursor: pointer;
  background: none;
  border: none;
  font-family: 'Inter', sans-serif;
  width: 100%;
  text-align: left;
}

.sb-link:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.65); }

/* ══════════════════════════════════════════════════════════════
   MAIN AREA
══════════════════════════════════════════════════════════════ */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }

/* ── Top bar ── */
.main-top {
  padding: 0 20px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
  z-index: 10;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px 5px 10px;
  background: var(--navy-50);
  border: 1px solid var(--navy-100);
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  color: var(--navy-700);
  box-shadow: var(--shadow-xs);
}

.top-actions { display: flex; align-items: center; gap: 8px; }

.top-btn {
  padding: 6px 13px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-400);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all var(--t) var(--ease);
  font-family: 'Inter', sans-serif;
  box-shadow: var(--shadow-xs);
}

.top-btn:hover {
  border-color: var(--navy-200);
  color: var(--navy-700);
  background: var(--navy-50);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

/* ══════════════════════════════════════════════════════════════
   CHAT AREA
══════════════════════════════════════════════════════════════ */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-area::-webkit-scrollbar { width: 4px; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.chat-area::-webkit-scrollbar-track { background: transparent; }

/* ── Messages ── */
.msg {
  display: flex;
  gap: 10px;
  max-width: 87%;
  animation: msgIn var(--t-slow) var(--ease-out) both;
}

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

@media (prefers-reduced-motion: reduce) {
  .msg { animation: fadeIn var(--t) var(--ease); }
  @keyframes fadeIn { from { opacity: 0; } }
}

.msg.user { align-self: flex-end; flex-direction: row-reverse; }

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
  flex-shrink: 0; margin-top: 2px;
  letter-spacing: -.03em;
}

.avatar.ai {
  background: var(--navy-50);
  color: var(--navy-700);
  border: 1.5px solid var(--navy-100);
  font-size: 11px;
}

.avatar.user {
  background: var(--navy-800);
  color: var(--gold-300);
  font-size: 9.5px;
}

.bubble {
  padding: 11px 15px;
  font-size: 13px;
  line-height: 1.68;
  word-break: break-word;
  max-width: 100%;
}

.msg.ai .bubble {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 2px 12px 12px 12px;
  box-shadow: var(--shadow-sm);
  color: var(--ink-700);
}

.msg.user .bubble {
  background: var(--navy-800);
  color: rgba(255,255,255,.92);
  border-radius: 12px 2px 12px 12px;
  box-shadow: var(--shadow-sm);
}

.bubble strong { font-weight: 600; }
.bubble em     { font-style: italic; opacity: .8; }
.bubble ul, .bubble ol { padding-left: 18px; margin: 6px 0; }
.bubble li     { margin-bottom: 3px; }
.bubble p      { margin-bottom: 7px; }
.bubble p:last-child { margin-bottom: 0; }

.bubble code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: var(--navy-800);
  color: var(--gold-400);
  padding: 2px 6px;
  border-radius: var(--r-xs);
  font-weight: 500;
  letter-spacing: .02em;
}

.msg.user .bubble code {
  background: rgba(255,255,255,.1);
  color: var(--gold-200);
}

/* ── Typing indicator ── */
.typing-indicator {
  display: flex; align-items: center; gap: 5px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 2px 12px 12px 12px;
  box-shadow: var(--shadow-sm);
  max-width: 76px;
}

.typing-dot {
  width: 6px; height: 6px;
  background: var(--navy-300);
  border-radius: 50%;
  animation: td 1s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: .15s; }
.typing-dot:nth-child(3) { animation-delay: .30s; }

@keyframes td {
  0%,80%,100% { transform: translateY(0); opacity: .55; }
  40%          { transform: translateY(-6px); opacity: 1; }
}

/* ══════════════════════════════════════════════════════════════
   INPUT AREA
══════════════════════════════════════════════════════════════ */
.input-wrap {
  padding: 14px 20px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
  box-shadow: 0 -2px 12px rgba(10,24,39,.05);
}

.input-row { display: flex; gap: 10px; align-items: flex-end; }

.input-textarea {
  flex: 1;
  min-height: 62px; max-height: 150px;
  padding: 12px 15px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg);
  font-size: 13px; line-height: 1.6;
  resize: none;
  color: var(--ink-700);
  font-family: 'Inter', sans-serif;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease), background var(--t) var(--ease);
}

.input-textarea:focus {
  outline: none;
  border-color: var(--navy-400);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(42,75,106,.09);
}

.input-textarea::placeholder { color: var(--ink-200); }

.input-btns { display: flex; flex-direction: column; gap: 7px; }

/* ── PRIMARY CTA — ANALYSER — gold, unmissable ── */
.btn-analyze {
  padding: 12px 18px;
  background: linear-gradient(135deg, var(--gold-500) 0%, #D4A453 100%);
  border: none;
  border-radius: var(--r-md);
  color: var(--navy-950);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
  letter-spacing: .02em;
  box-shadow: var(--shadow-gold);
  transition: all var(--t) var(--ease);
  position: relative;
  overflow: hidden;
}

.btn-analyze::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.0);
  transition: background var(--t-fast) var(--ease);
}

.btn-analyze:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(201,149,61,.40);
}
.btn-analyze:hover::before { background: rgba(255,255,255,.08); }
.btn-analyze:active { transform: translateY(0); box-shadow: var(--shadow-gold); }

/* ── SECONDARY — ENVOYER ── */
.btn-send {
  padding: 12px 15px;
  background: var(--navy-800);
  border: 1px solid var(--navy-700);
  border-radius: var(--r-md);
  color: rgba(255,255,255,.9);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  font-family: 'Inter', sans-serif;
  transition: all var(--t) var(--ease);
}

.btn-send:hover {
  background: var(--navy-700);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

/* ══════════════════════════════════════════════════════════════
   WARNING BANNER
══════════════════════════════════════════════════════════════ */
.warn-banner {
  padding: 7px 20px;
  background: var(--warn-light);
  border-top: 1px solid var(--gold-200);
  display: flex; align-items: center; gap: 8px;
  font-size: 10.5px;
  color: var(--warn-dark);
  flex-shrink: 0;
}

.warn-banner strong { font-weight: 600; }

/* ══════════════════════════════════════════════════════════════
   ANALYSIS PANEL
══════════════════════════════════════════════════════════════ */
.analysis-panel {
  width: 354px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border-light);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: width var(--t-slow) var(--ease);
  box-shadow: -4px 0 20px rgba(10,24,39,.07);
}

.analysis-panel.hidden { width: 0; border-left: none; box-shadow: none; }

/* Panel header */
.ap-top {
  padding: 0 15px;
  height: 56px;
  background: var(--surface);
  border-bottom: 2px solid var(--gold-200);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
  position: relative;
}

.ap-top::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-400), transparent);
}

.ap-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--navy-800);
  display: flex; align-items: center; gap: 8px;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.ap-title-icon {
  width: 24px; height: 24px;
  border-radius: var(--r-xs);
  background: var(--navy-800);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

.ap-actions { display: flex; gap: 5px; }

.ap-btn {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 10.5px; font-weight: 500;
  color: var(--ink-400);
  cursor: pointer;
  display: flex; align-items: center; gap: 4px;
  font-family: 'Inter', sans-serif;
  transition: all var(--t-fast) var(--ease);
  box-shadow: var(--shadow-xs);
}

.ap-btn:hover {
  border-color: var(--navy-200);
  color: var(--navy-700);
  background: var(--navy-50);
  box-shadow: var(--shadow-sm);
}

/* Empty state */
.ap-empty {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 36px 24px;
  text-align: center;
}

.ap-empty-icon { font-size: 44px; margin-bottom: 16px; opacity: .25; }

.ap-empty p { font-size: 12.5px; line-height: 1.75; color: var(--ink-300); }
.ap-empty strong { font-weight: 600; color: var(--ink-300); }

/* Loading */
.ap-loading {
  display: flex; align-items: center; gap: 12px;
  padding: 28px 20px;
  font-size: 12.5px;
  color: var(--ink-400);
  font-weight: 500;
}

/* Analysis body */
.ap-body { flex: 1; overflow-y: auto; padding: 14px 14px 20px; }
.ap-body::-webkit-scrollbar { width: 3px; }
.ap-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Report header (auto-generated) */
.ap-report-header {
  padding: 12px 14px;
  background: var(--navy-50);
  border: 1px solid var(--navy-100);
  border-radius: var(--r-md);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ap-report-title {
  font-family: 'Playfair Display', serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--navy-800);
}

.ap-report-meta { font-size: 10px; color: var(--ink-400); margin-top: 2px; }

/* Section headings */
.ap-body h2 {
  font-size: 9px;
  font-weight: 700;
  color: var(--ink-300);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin: 16px 0 7px;
  display: flex; align-items: center; gap: 6px;
}

.ap-body h2:first-child { margin-top: 0; }

.ap-body h2::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

/* Section content */
.ap-section {
  font-size: 12px;
  color: var(--ink-700);
  line-height: 1.68;
  padding: 11px 13px;
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--navy-300);
  border-radius: 0 var(--r) var(--r) 0;
  margin-bottom: 6px;
  box-shadow: var(--shadow-xs);
}

.ap-section:hover { border-left-color: var(--gold-500); }

.ap-section ul { padding-left: 16px; margin: 5px 0; }
.ap-section li { margin-bottom: 3px; }
.ap-section p  { margin-bottom: 5px; }
.ap-section p:last-child { margin-bottom: 0; }
.ap-section strong { font-weight: 600; color: var(--navy-800); }

/* DSM / ICD code badges */
.ap-section code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 500;
  background: var(--navy-800);
  color: var(--gold-400);
  padding: 2px 7px;
  border-radius: var(--r-xs);
  letter-spacing: .03em;
  white-space: nowrap;
}

/* Confidence bars */
.conf-row { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.conf-label { font-size: 11px; color: var(--ink-400); flex: 1; font-weight: 500; }

.conf-track {
  width: 110px; height: 5px;
  background: var(--border-light);
  border-radius: 100px;
  overflow: hidden; flex-shrink: 0;
}

.conf-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--navy-500), var(--gold-500));
  border-radius: 100px;
  width: 0;
  transition: width .9s cubic-bezier(.4,0,.2,1) .1s;
}

.conf-value {
  font-size: 12px; font-weight: 700;
  color: var(--navy-800);
  min-width: 36px; text-align: right;
  font-family: 'JetBrains Mono', monospace;
}

/* ══════════════════════════════════════════════════════════════
   SHARED UTILITY CLASSES
══════════════════════════════════════════════════════════════ */
.btn-primary {
  padding: 10px 18px;
  background: linear-gradient(135deg, var(--gold-500), #D4A453);
  border: none; border-radius: var(--r-md);
  color: var(--navy-950);
  font-size: 12.5px; font-weight: 700;
  cursor: pointer; font-family: 'Inter', sans-serif;
  box-shadow: var(--shadow-gold);
  transition: all var(--t) var(--ease);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 5px 18px rgba(201,149,61,.38); }

.btn-secondary {
  padding: 9px 14px;
  background: var(--surface);
  border: 1.5px solid var(--navy-300);
  border-radius: var(--r-md);
  color: var(--navy-700);
  font-size: 12px; font-weight: 500;
  cursor: pointer; font-family: 'Inter', sans-serif;
  transition: all var(--t) var(--ease);
}

.btn-secondary:hover { background: var(--navy-50); border-color: var(--navy-400); }

.btn-danger {
  padding: 9px 14px;
  background: var(--surface);
  border: 1.5px solid var(--danger-dark);
  border-radius: var(--r-md);
  color: var(--danger);
  font-size: 12px; font-weight: 500;
  cursor: pointer; font-family: 'Inter', sans-serif;
  transition: all var(--t) var(--ease);
}

.btn-danger:hover { background: var(--danger-light); }

/* Form elements */
.form-label {
  display: block;
  font-size: 11px; font-weight: 600;
  color: var(--ink-500);
  margin-bottom: 5px;
  letter-spacing: .02em;
}

.form-hint { font-size: 10px; color: var(--ink-300); margin-top: 3px; line-height: 1.5; }

.form-input {
  padding: 9px 11px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-alt);
  font-size: 12.5px; color: var(--ink-700);
  font-family: 'Inter', sans-serif;
  transition: all var(--t) var(--ease);
  width: 100%;
}

.form-input:focus {
  outline: none;
  border-color: var(--navy-400);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(42,75,106,.08);
}

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236d8796' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

textarea.form-input { resize: vertical; min-height: 88px; line-height: 1.6; }
textarea.form-input.tall { min-height: 300px; }

/* Toast notification */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 11px 18px;
  border-radius: var(--r-md);
  font-size: 12.5px; font-weight: 500;
  pointer-events: none; opacity: 0;
  transition: all .25s var(--ease);
  z-index: 9999;
  box-shadow: var(--shadow-md);
}

.toast.ok  { background: var(--success-light); color: var(--success-dark); border: 1px solid rgba(26,122,98,.2); }
.toast.err { background: var(--danger-light);  color: var(--danger-dark);  border: 1px solid rgba(192,64,47,.2); }
.toast.show { opacity: 1; pointer-events: auto; transform: translateY(-4px); }
