/* ═══════════════════════════════════════════════════════════════
   ARYBIT LEGAL INTELLIGENCE — PRODUCTION CSS v2.0
   Dark-first + Light mode · Outfit + JetBrains Mono + Fraunces
   Full responsive: 320px → 2560px
═══════════════════════════════════════════════════════════════ */

/* ── DESIGN TOKENS ───────────────────────────────────────────── */
:root {
  /* Brand Palette — Deep Legal Indigo x Electric Violet */
  --brand-900:     #1a0533;
  --brand-800:     #2d0a52;
  --brand-700:     #4c1480;
  --brand-600:     #6b21a8;
  --brand-500:     #9333ea;
  --brand-400:     #a855f7;
  --brand-300:     #c084fc;
  --brand-200:     #d8b4fe;
  --brand-glow:    rgba(147, 51, 234, 0.25);
  --brand-glow-lg: rgba(147, 51, 234, 0.12);

  /* Surface Hierarchy — Cool Obsidian */
  --surface-root:    #070b13;
  --surface-base:    #0c1220;
  --surface-card:    #111827;
  --surface-raised:  #172135;
  --surface-hover:   #1e2d45;
  --surface-overlay: rgba(7, 11, 19, 0.85);

  /* Borders */
  --border-subtle:   rgba(255, 255, 255, 0.055);
  --border-mid:      rgba(255, 255, 255, 0.1);
  --border-strong:   rgba(255, 255, 255, 0.18);
  --border-brand:    rgba(147, 51, 234, 0.35);

  /* Text */
  --text-primary:    #f0f4ff;
  --text-secondary:  #8892aa;
  --text-tertiary:   #505870;
  --text-brand:      #c084fc;
  --text-inverse:    #070b13;

  /* Semantic Colors */
  --success:     #22c55e;
  --success-bg:  rgba(34, 197, 94, 0.1);
  --success-border: rgba(34, 197, 94, 0.25);
  --warn:        #f59e0b;
  --warn-bg:     rgba(245, 158, 11, 0.1);
  --warn-border: rgba(245, 158, 11, 0.3);
  --danger:      #ef4444;
  --danger-bg:   rgba(239, 68, 68, 0.1);
  --danger-border: rgba(239, 68, 68, 0.25);
  --info:        #38bdf8;
  --info-bg:     rgba(56, 189, 248, 0.1);
  --info-border: rgba(56, 189, 248, 0.25);

  /* Layout */
  --sidebar-w:      272px;
  --inspector-w:    300px;
  --header-h:       56px;

  /* Radius */
  --r-xs:    4px;
  --r-sm:    6px;
  --r-md:    10px;
  --r-lg:    14px;
  --r-xl:    20px;
  --r-full:  9999px;

  /* Typography */
  --font-ui:      'Outfit', system-ui, sans-serif;
  --font-serif:   'Fraunces', Georgia, serif;
  --font-mono:    'JetBrains Mono', 'Cascadia Code', monospace;

  /* Motion */
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-spring:    cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast:   140ms;
  --t-mid:    240ms;
  --t-slow:   380ms;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.3);
  --shadow-lg:  0 12px 40px rgba(0,0,0,0.5), 0 4px 12px rgba(0,0,0,0.3);
  --shadow-brand: 0 8px 32px var(--brand-glow);
}

/* ── LIGHT MODE ──────────────────────────────────────────────── */
[data-theme="light"] {
  --surface-root:    #f4f6fb;
  --surface-base:    #ffffff;
  --surface-card:    #f8fafd;
  --surface-raised:  #edf0f7;
  --surface-hover:   #e5eaf5;
  --surface-overlay: rgba(244, 246, 251, 0.9);

  --border-subtle:   rgba(15, 23, 42, 0.06);
  --border-mid:      rgba(15, 23, 42, 0.1);
  --border-strong:   rgba(15, 23, 42, 0.18);
  --border-brand:    rgba(107, 33, 168, 0.22);

  --text-primary:    #0d1321;
  --text-secondary:  #4a5568;
  --text-tertiary:   #718096;
  --text-brand:      #7c3aed;
  --text-inverse:    #f0f4ff;

  --brand-glow:    rgba(107, 33, 168, 0.15);
  --brand-glow-lg: rgba(107, 33, 168, 0.07);

  --shadow-sm:  0 1px 3px rgba(15,23,42,0.08), 0 1px 2px rgba(15,23,42,0.06);
  --shadow-md:  0 4px 16px rgba(15,23,42,0.1), 0 2px 6px rgba(15,23,42,0.06);
  --shadow-lg:  0 12px 40px rgba(15,23,42,0.12), 0 4px 12px rgba(15,23,42,0.08);
}

/* ── RESET + BASE ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  height: 100%;
  background: var(--surface-root);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'kern' 1, 'liga' 1;
}

/* ── SCROLLBAR ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ── FOCUS ───────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--brand-400);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ── SKIP LINK ───────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 10000;
  padding: 8px 16px;
  background: var(--brand-600);
  color: white;
  border-radius: 0 0 var(--r-md) var(--r-md);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: top var(--t-fast);
}
.skip-link:focus { top: 0; }

/* ══════════════════════════════════════════
   APP SHELL — 3-column grid
══════════════════════════════════════════ */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--inspector-w);
  grid-template-rows: var(--header-h) 1fr;
  height: 100vh;
  max-height: 100dvh;
}

/* ══════════════════════════════════════════
   HEADER
══════════════════════════════════════════ */
.app-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: var(--surface-base);
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
  z-index: 200;
  height: var(--header-h);
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.header-right { gap: 6px; }

/* Brand */
.header-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  border-radius: var(--r-md);
  padding: 4px 6px;
  transition: background var(--t-fast);
}
.header-brand:hover { background: var(--surface-raised); }

.brand-mark {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--brand-800), var(--brand-700));
  border: 1px solid var(--border-brand);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 20px var(--brand-glow);
  flex-shrink: 0;
}

.brand-wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.brand-name {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.4px;
}
.brand-sub {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-brand);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.brand-sub sup { font-size: 7px; vertical-align: super; }

/* System Status */
.header-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}
.system-status {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-full);
  pointer-events: auto;
}
.status-pulse {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse-ring 2s var(--ease-out-quart) infinite;
}
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
  60%  { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
.status-pulse[data-state="warn"]    { background: var(--warn); animation: none; }
.status-pulse[data-state="offline"] { background: var(--danger); animation: none; }
.status-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Header Buttons */
.icon-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: 15px;
  cursor: pointer;
  transition: all var(--t-fast);
  flex-shrink: 0;
}
.icon-btn:hover {
  background: var(--surface-raised);
  border-color: var(--border-mid);
  color: var(--text-primary);
}

.menu-toggle-btn { display: none; }

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-link-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-ui);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--t-fast);
}
.nav-link-btn:hover {
  background: var(--surface-raised);
  color: var(--text-primary);
  border-color: var(--border-mid);
}
.nav-link-btn i { font-size: 13px; }

.upgrade-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  background: linear-gradient(135deg, var(--brand-700), var(--brand-600));
  border: 1px solid var(--brand-border, var(--border-brand));
  border-radius: var(--r-md);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-ui);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--t-fast);
  box-shadow: 0 4px 16px var(--brand-glow);
}
.upgrade-btn:hover {
  background: linear-gradient(135deg, var(--brand-600), var(--brand-500));
  box-shadow: 0 6px 24px var(--brand-glow);
  transform: translateY(-1px);
}
.upgrade-btn i { font-size: 11px; }

.auth-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border-mid);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-ui);
  text-decoration: none;
  transition: all var(--t-fast);
}
.auth-btn:hover { background: var(--surface-raised); color: var(--text-primary); }
.auth-btn--primary {
  background: var(--brand-700);
  border-color: var(--border-brand);
  color: #fff;
}
.auth-btn--primary:hover { background: var(--brand-600); color: #fff; }

.is-hidden { display: none !important; }

.user-avatar {
  position: relative;
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--brand-700), var(--brand-600));
  border: 1.5px solid var(--border-brand);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: all var(--t-fast);
  flex-shrink: 0;
}
.user-avatar:hover { border-color: var(--brand-400); box-shadow: 0 0 0 3px var(--brand-glow); }
.user-avatar.grace-mode {
  background: linear-gradient(135deg, var(--warn), #fb923c);
  border-color: rgba(245,158,11,0.6);
  box-shadow: 0 0 0 3px rgba(245,158,11,0.2);
}
#avatarInitials { pointer-events: none; }

.avatar-status-dot {
  position: absolute;
  bottom: 0; right: 0;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--surface-base);
  display: none;
}
.avatar-status-dot.is-visible { display: block; }

/* ══════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════ */
.app-sidebar {
  background: var(--surface-base);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--t-mid) var(--ease-out-quart);
}

.sidebar-top {
  padding: 14px 14px 0;
  flex-shrink: 0;
}

.new-matter-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--brand-800), var(--brand-700));
  border: 1px solid var(--border-brand);
  border-radius: var(--r-lg);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  box-shadow: var(--shadow-brand);
  position: relative;
}
.new-matter-btn:hover {
  background: linear-gradient(135deg, var(--brand-700), var(--brand-600));
  transform: translateY(-1px);
  box-shadow: 0 12px 32px var(--brand-glow);
}
.new-matter-btn i { font-size: 15px; flex-shrink: 0; }
.new-matter-btn span { flex: 1; text-align: left; }

.shortcut-badge {
  font-size: 9px;
  font-family: var(--font-mono);
  background: rgba(255,255,255,0.12);
  padding: 2px 5px;
  border-radius: var(--r-xs);
  color: rgba(255,255,255,0.7);
  border: none;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0;
}

.sidebar-section {
  padding: 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.sidebar-section:last-child { border-bottom: none; }
.sidebar-section--flex {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-bottom: none;
}
.sidebar-section--flex .conv-list {
  flex: 1;
  overflow-y: auto;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}
.section-label i { font-size: 11px; }

/* Status Cards */
.status-stack { display: flex; flex-direction: column; gap: 5px; }

.status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  transition: all var(--t-fast);
}
.status-card:hover { border-color: var(--border-mid); background: var(--surface-raised); }

.status-card-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-orb {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-tertiary);
  flex-shrink: 0;
  transition: background var(--t-fast), box-shadow var(--t-fast);
}
.status-orb[data-state="ok"]       { background: var(--success); box-shadow: 0 0 6px rgba(34,197,94,0.5); }
.status-orb[data-state="bad"]      { background: var(--danger);  box-shadow: 0 0 6px rgba(239,68,68,0.5); }
.status-orb[data-state="warn"]     { background: var(--warn);    box-shadow: 0 0 6px rgba(245,158,11,0.5); }
.status-orb[data-state="checking"] { background: var(--text-tertiary); animation: blink 1s ease infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

.status-info { display: flex; flex-direction: column; }
.status-name { font-size: 11px; font-weight: 600; color: var(--text-primary); line-height: 1.2; }
.status-detail { font-size: 10px; color: var(--text-tertiary); line-height: 1; }

.status-chip {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--r-full);
  background: var(--surface-raised);
  color: var(--text-tertiary);
  white-space: nowrap;
  transition: all var(--t-fast);
}
.status-chip[data-state="ok"]   { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.status-chip[data-state="bad"]  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-border); }
.status-chip[data-state="warn"] { background: var(--warn-bg);    color: var(--warn);    border: 1px solid var(--warn-border); }

/* Quota Widget */
.quota-widget { display: flex; flex-direction: column; gap: 8px; }

.quota-bar-track {
  height: 5px;
  background: var(--surface-raised);
  border-radius: var(--r-full);
  overflow: hidden;
}
.quota-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--success), #16a34a);
  border-radius: var(--r-full);
  transition: width 0.6s var(--ease-out-quart), background 0.4s;
}
.quota-bar-fill[data-level="warn"]   { background: linear-gradient(90deg, var(--warn), #d97706); }
.quota-bar-fill[data-level="danger"] { background: linear-gradient(90deg, var(--danger), #dc2626); }

.quota-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-tertiary);
}
.quota-labels strong { color: var(--text-secondary); font-weight: 600; }

.unlock-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  background: var(--surface-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
}
.unlock-btn:hover {
  background: var(--brand-800);
  border-color: var(--border-brand);
  color: var(--text-primary);
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.metric-tile {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 10px;
  text-align: center;
  transition: all var(--t-fast);
}
.metric-tile:hover { border-color: var(--border-mid); }
.metric-num {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 3px;
}
.metric-num.success { color: var(--success); }
.metric-num.info    { color: var(--info); }
.metric-num.warn    { color: var(--warn); }
.metric-desc {
  font-size: 10px;
  color: var(--text-tertiary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Model Picker */
.model-picker { display: flex; flex-direction: column; gap: 7px; }

.model-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.model-select-icon {
  position: absolute;
  left: 10px;
  font-size: 12px;
  color: var(--text-tertiary);
  pointer-events: none;
  z-index: 1;
}
.model-select-arrow {
  position: absolute;
  right: 10px;
  font-size: 11px;
  color: var(--text-tertiary);
  pointer-events: none;
  z-index: 1;
}
#modelSelect {
  width: 100%;
  padding: 9px 32px 9px 30px;
  background: var(--surface-card);
  color: var(--text-primary);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-md);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  transition: border-color var(--t-fast);
}
#modelSelect:focus { border-color: var(--brand-400); }
#modelSelect:hover { border-color: var(--border-strong); }
#modelSelect option { background: var(--surface-card); }

.model-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  font-size: 10px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}
.model-badge i { font-size: 10px; color: var(--success); }

/* Conversation List */
.conv-list { display: flex; flex-direction: column; gap: 2px; }

.conv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast);
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}
.conv-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--brand-500);
  opacity: 0;
  border-radius: 0 2px 2px 0;
  transition: opacity var(--t-fast);
}
.conv-item:hover { background: var(--surface-raised); border-color: var(--border-subtle); }
.conv-item.active { background: var(--brand-glow-lg); border-color: var(--border-brand); }
.conv-item.active::before { opacity: 1; }

.conv-item .delete-conv {
  opacity: 0;
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 3px 5px;
  border-radius: var(--r-sm);
  font-size: 12px;
  transition: all var(--t-fast);
  flex-shrink: 0;
}
.conv-item:hover .delete-conv { opacity: 1; }
.conv-item .delete-conv:hover { color: var(--danger); background: var(--danger-bg); }

.conv-icon {
  width: 26px; height: 26px;
  border-radius: var(--r-sm);
  background: var(--surface-raised);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  color: var(--text-tertiary);
  flex-shrink: 0;
  transition: all var(--t-fast);
}
.conv-item.active .conv-icon { background: var(--brand-700); color: #fff; }

.conv-text { flex: 1; overflow: hidden; min-width: 0; }
.conv-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.conv-meta {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-top: 1px;
}

/* Placeholder shimmer */
.conv-placeholder { padding: 6px 0; }
.placeholder-shimmer {
  height: 10px;
  background: linear-gradient(90deg, var(--surface-raised) 25%, var(--surface-hover) 50%, var(--surface-raised) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease infinite;
  border-radius: var(--r-sm);
  margin-bottom: 8px;
}
.placeholder-shimmer.short { width: 60%; }
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* Utility labels */
.empty-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: center;
  padding: 16px 0;
}
.text-warn { color: var(--warn); }
.text-muted { color: var(--text-tertiary); }

/* ══════════════════════════════════════════
   MAIN CHAT AREA
══════════════════════════════════════════ */
.app-main {
  display: flex;
  flex-direction: column;
  background: var(--surface-root);
  overflow: hidden;
  position: relative;
}

/* Chat Bar */
.chat-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: var(--surface-base);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  min-height: 52px;
}
.chat-bar-left { flex: 1; min-width: 0; }
.chat-title-group { min-width: 0; }
.chat-title {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-subtitle { font-size: 11px; color: var(--text-tertiary); font-weight: 400; }

.chat-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.trust-chips {
  display: flex;
  gap: 5px;
}
.trust-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  border-radius: var(--r-full);
  font-size: 10px;
  color: var(--success);
  font-weight: 500;
  white-space: nowrap;
}
.trust-chip i { font-size: 9px; }

.action-chips { display: flex; gap: 4px; }
.action-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
}
.action-chip:hover { background: var(--surface-hover); border-color: var(--border-mid); color: var(--text-primary); }
.action-chip--danger:hover { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.action-chip-label { display: block; }

/* Messages Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 28px 28px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* ── WELCOME STATE ─────────────────────── */
.welcome-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  gap: 32px;
  animation: fadeUp 0.5s var(--ease-out-quart) both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.welcome-hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px; }

.welcome-glyph {
  width: 72px; height: 72px;
  background: linear-gradient(145deg, var(--brand-800), var(--brand-700));
  border: 1px solid var(--border-brand);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 48px var(--brand-glow), 0 16px 40px rgba(0,0,0,0.3);
  position: relative;
}
.welcome-glyph::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 21px;
  background: linear-gradient(135deg, var(--brand-500), transparent);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 1px;
  opacity: 0.4;
}

.welcome-title {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1.2;
  max-width: 420px;
}
.welcome-description {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 480px;
  line-height: 1.75;
}

.suggestions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 560px;
}

.suggestion-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: all var(--t-mid) var(--ease-out-quart);
  position: relative;
  overflow: hidden;
}
.suggestion-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, var(--brand-glow-lg));
  opacity: 0;
  transition: opacity var(--t-mid);
}
.suggestion-card:hover {
  background: var(--surface-raised);
  border-color: var(--border-brand);
  color: var(--text-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.suggestion-card:hover::after { opacity: 1; }
.suggestion-card:active { transform: translateY(0); }

.suggestion-icon {
  width: 34px; height: 34px;
  border-radius: var(--r-md);
  background: var(--brand-glow-lg);
  border: 1px solid var(--border-brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  color: var(--text-brand);
  flex-shrink: 0;
  z-index: 1;
}
.suggestion-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 1;
}
.suggestion-body strong { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.suggestion-body span  { font-size: 11px; color: var(--text-tertiary); }
.suggestion-arrow {
  font-size: 12px;
  color: var(--text-tertiary);
  z-index: 1;
  transition: transform var(--t-fast), color var(--t-fast);
}
.suggestion-card:hover .suggestion-arrow { transform: translateX(3px); color: var(--text-brand); }

/* ── MESSAGE GROUPS ─────────────────────── */
.msg-group {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: msgIn 0.22s var(--ease-out-quart) both;
}
.msg-group.user { flex-direction: row-reverse; }

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
  margin-top: 4px;
  transition: transform var(--t-fast);
}
.msg-avatar.ai {
  background: linear-gradient(135deg, var(--brand-700), var(--brand-600));
  border: 1.5px solid var(--border-brand);
  color: #fff;
}
.msg-avatar.user {
  background: var(--info-bg);
  border: 1.5px solid var(--info-border);
  color: var(--info);
}

.msg-content { max-width: 74%; display: flex; flex-direction: column; gap: 3px; }
.msg-group.user .msg-content { align-items: flex-end; }

.msg-bubble {
  padding: 11px 16px;
  border-radius: var(--r-xl);
  font-size: 13.5px;
  line-height: 1.7;
  word-break: break-word;
  transition: box-shadow var(--t-fast);
}

.msg-group.ai .msg-bubble {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-top-left-radius: var(--r-xs);
  box-shadow: var(--shadow-sm);
}
.msg-group.ai:hover .msg-bubble { box-shadow: var(--shadow-md); border-color: var(--border-mid); }

.msg-group.user .msg-bubble {
  background: linear-gradient(135deg, var(--brand-700), var(--brand-600));
  border: 1px solid var(--border-brand);
  border-top-right-radius: var(--r-xs);
  color: #fff;
  box-shadow: var(--shadow-brand);
}

.message-error { color: var(--danger); font-style: italic; }

.msg-meta {
  font-size: 10px;
  color: var(--text-tertiary);
  padding: 0 4px;
  font-family: var(--font-mono);
}

.msg-actions {
  display: flex;
  gap: 3px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity var(--t-fast);
}
.msg-group:hover .msg-actions { opacity: 1; }

.msg-action-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-tertiary);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 7px;
  border-radius: var(--r-sm);
  transition: all var(--t-fast);
  font-family: var(--font-ui);
}
.msg-action-btn:hover {
  background: var(--surface-raised);
  border-color: var(--border-mid);
  color: var(--text-primary);
}

/* Markdown Content */
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 {
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--text-primary);
  margin: 14px 0 6px;
  line-height: 1.3;
}
.msg-bubble h1 { font-size: 18px; }
.msg-bubble h2 { font-size: 16px; }
.msg-bubble h3 { font-size: 14px; }
.msg-bubble p  { margin-bottom: 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { padding-left: 18px; margin-bottom: 8px; }
.msg-bubble li { margin-bottom: 3px; }
.msg-bubble strong { font-weight: 600; color: var(--text-primary); }
.msg-bubble em { font-style: italic; }
.msg-bubble blockquote {
  border-left: 3px solid var(--border-brand);
  padding: 6px 12px;
  background: var(--brand-glow-lg);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  margin: 10px 0;
  font-style: italic;
  color: var(--text-secondary);
}
.msg-bubble a {
  color: var(--text-brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.msg-bubble a:hover { color: var(--brand-300); }
.msg-bubble code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  padding: 1px 5px;
  border-radius: var(--r-xs);
  color: var(--success);
}
.msg-bubble pre {
  position: relative;
  background: var(--surface-base);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin: 10px 0;
  overflow-x: auto;
}
.msg-bubble pre::before {
  content: attr(data-lang);
  position: absolute;
  top: 8px;
  left: 12px;
  font-size: 9px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.msg-bubble pre::after {
  content: "COPY";
  position: absolute;
  top: 8px; right: 10px;
  font-size: 9px;
  font-family: var(--font-ui);
  font-weight: 700;
  padding: 2px 8px;
  background: var(--surface-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  color: var(--text-tertiary);
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: all var(--t-fast);
}
.msg-bubble pre:hover::after {
  background: var(--brand-700);
  color: #fff;
  border-color: var(--border-brand);
}
.msg-bubble pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.6;
}
.msg-group.user .msg-bubble code {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.9);
}

/* Typing Indicator */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 18px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  border-top-left-radius: var(--r-xs);
}
.typing-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: bounce 1.3s ease infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-6px) scale(1.1); }
}

/* ── COMPOSER ──────────────────────────── */
.composer-shell {
  padding: 12px 20px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--surface-base);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.attachment-preview {
  margin-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  animation: fadeIn 0.2s ease both;
}
.attachment-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--surface-card);
  border: 1px solid var(--border-brand);
  border-radius: var(--r-md);
  font-size: 12px;
  color: var(--text-primary);
  max-width: 280px;
}
.attachment-chip i { color: var(--text-brand); flex-shrink: 0; }
.attachment-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attachment-remove {
  background: none; border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px 3px;
  font-size: 14px;
  transition: color var(--t-fast);
  flex-shrink: 0;
  display: flex; align-items: center;
}
.attachment-remove:hover { color: var(--danger); }

.composer-status {
  font-size: 11px;
  color: var(--text-tertiary);
  min-height: 18px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: opacity var(--t-fast);
}
.composer-status:empty { margin-bottom: 0; }
.composer-status.loading { color: var(--info); }
.composer-status.error   { color: var(--danger); }
.status-spinner {
  width: 10px; height: 10px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  display: inline-flex;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.composer-box {
  background: var(--surface-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-xl);
  overflow: hidden;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.composer-box:focus-within {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

.composer-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px 6px;
  border-bottom: 1px solid var(--border-subtle);
}
.composer-toolbar-spacer { flex: 1; }

.composer-tool {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 9px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--text-tertiary);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
}
.composer-tool:hover {
  background: var(--surface-raised);
  border-color: var(--border-mid);
  color: var(--text-secondary);
}
.composer-tool i { font-size: 12px; }

.char-counter {
  font-size: 10px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  transition: color var(--t-fast);
}
.char-counter.near-limit { color: var(--warn); }
.char-counter.at-limit   { color: var(--danger); }

.composer-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px;
}

.composer-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.6;
  resize: none;
  min-height: 24px;
  max-height: 160px;
  overflow-y: auto;
  field-sizing: content;
}
.composer-textarea::placeholder { color: var(--text-tertiary); }

.composer-send {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--brand-700), var(--brand-600));
  border: 1px solid var(--border-brand);
  border-radius: var(--r-md);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-spring);
  flex-shrink: 0;
  font-size: 13px;
  box-shadow: var(--shadow-brand);
}
.composer-send:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--brand-600), var(--brand-500));
  transform: scale(1.06);
  box-shadow: 0 6px 20px var(--brand-glow);
}
.composer-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.composer-footer {
  padding: 6px 14px 10px;
  border-top: 1px solid var(--border-subtle);
}
.composer-hint {
  font-size: 10px;
  color: var(--text-tertiary);
  margin: 0;
}
.composer-hint kbd {
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 1px 5px;
  background: var(--surface-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-xs);
  color: var(--text-secondary);
}

/* ══════════════════════════════════════════
   RIGHT INSPECTOR
══════════════════════════════════════════ */
.app-inspector {
  background: var(--surface-base);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.inspector-rail {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 4px;
  background: var(--surface-card);
  flex-shrink: 0;
}
.inspector-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 6px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-tertiary);
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all var(--t-fast);
  margin-bottom: -1px;
}
.inspector-tab i { font-size: 15px; }
.inspector-tab:hover { color: var(--text-secondary); }
.inspector-tab.active { color: var(--text-brand); border-bottom-color: var(--brand-500); }

.inspector-body {
  flex: 1;
  overflow: hidden;
  position: relative;
}
.inspector-panel {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast);
}
.inspector-panel.active { opacity: 1; pointer-events: auto; }

.panel-header {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}
.panel-header i { font-size: 13px; color: var(--text-brand); }

.inspector-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 32px 16px;
  text-align: center;
}
.inspector-empty i { font-size: 28px; color: var(--text-tertiary); opacity: 0.5; }
.inspector-empty p { font-size: 12px; color: var(--text-tertiary); line-height: 1.5; }

/* Citation Items */
.citation-list, .risk-list { display: flex; flex-direction: column; gap: 8px; }

.citation-item {
  padding: 11px 13px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  transition: all var(--t-fast);
  animation: fadeUp 0.3s var(--ease-out-quart) both;
}
.citation-item:hover { border-color: var(--border-brand); background: var(--surface-raised); }
.citation-title { font-size: 12px; font-weight: 600; color: var(--text-primary); margin-bottom: 3px; }
.citation-meta  { font-size: 10px; color: var(--text-tertiary); margin-bottom: 6px; font-family: var(--font-mono); }
.citation-excerpt { font-size: 11px; color: var(--text-secondary); line-height: 1.5; }

/* Risk Items */
.risk-item {
  padding: 11px 13px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--border-mid);
  border-radius: var(--r-md);
  transition: all var(--t-fast);
  animation: fadeUp 0.3s var(--ease-out-quart) both;
}
.risk-item:hover { background: var(--surface-raised); }
.risk-item.risk-high   { border-left-color: var(--danger); }
.risk-item.risk-medium { border-left-color: var(--warn); }
.risk-item.risk-low    { border-left-color: var(--info); }

.risk-badge {
  display: inline-flex;
  align-items: center;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: var(--r-xs);
  margin-bottom: 6px;
}
.risk-high   .risk-badge { background: var(--danger-bg);  color: var(--danger); }
.risk-medium .risk-badge { background: var(--warn-bg);    color: var(--warn); }
.risk-low    .risk-badge { background: var(--info-bg);    color: var(--info); }

/* Notes Panel */
.notes-area {
  display: flex;
  flex-direction: column;
  height: calc(100% - 50px);
  gap: 8px;
}
.notes-textarea {
  flex: 1;
  background: var(--surface-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-md);
  padding: 12px;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.6;
  resize: none;
  outline: none;
  transition: border-color var(--t-fast);
  min-height: 200px;
}
.notes-textarea:focus { border-color: var(--brand-500); }
.notes-textarea::placeholder { color: var(--text-tertiary); }
.notes-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.notes-save-status { font-size: 11px; color: var(--text-tertiary); }
.save-notes-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 12px;
  background: var(--surface-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
}
.save-notes-btn:hover { background: var(--brand-800); border-color: var(--border-brand); color: var(--text-primary); }

/* ══════════════════════════════════════════
   TOASTS
══════════════════════════════════════════ */
.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  background: var(--surface-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-lg);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  animation: toastSlide 0.28s var(--ease-out-quart) both;
  pointer-events: auto;
  min-width: 240px;
  max-width: 360px;
  backdrop-filter: blur(12px);
}
@keyframes toastSlide {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast-item.leaving {
  animation: toastLeave 0.25s var(--ease-out-quart) both;
}
@keyframes toastLeave {
  to { opacity: 0; transform: translateX(16px); }
}
.toast-icon { font-size: 15px; flex-shrink: 0; }
.toast-item.ok   .toast-icon { color: var(--success); }
.toast-item.bad  .toast-icon { color: var(--danger); }
.toast-item.warn .toast-icon { color: var(--warn); }
.toast-item.info .toast-icon { color: var(--info); }

/* ══════════════════════════════════════════
   KYC GRACE BANNER
══════════════════════════════════════════ */
.kyc-grace-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 9px 16px;
  background: linear-gradient(90deg, var(--warn-bg), rgba(245,158,11,0.08));
  border-bottom: 1px solid var(--warn-border);
  backdrop-filter: blur(8px);
}
.kyc-grace-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.kyc-grace-icon { color: var(--warn); font-size: 14px; flex-shrink: 0; }
.kyc-grace-label { font-size: 12px; font-weight: 600; color: var(--warn); }
.kyc-grace-detail { font-size: 11px; color: var(--text-secondary); }
.kyc-grace-link {
  color: #fbbf24;
  font-size: 12px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-left: auto;
}
.kyc-grace-link:hover { color: #fde68a; }
.kyc-grace-close {
  background: none; border: none;
  color: var(--text-tertiary); font-size: 16px;
  cursor: pointer; padding: 2px 4px;
  transition: color var(--t-fast);
  display: flex; align-items: center;
}
.kyc-grace-close:hover { color: var(--text-primary); }

/* ══════════════════════════════════════════
   MOBILE INSPECTOR TOGGLE
══════════════════════════════════════════ */
.mobile-inspector-toggle {
  display: none;
  position: fixed;
  bottom: 80px;
  right: 16px;
  z-index: 300;
  width: 40px; height: 40px;
  background: var(--brand-700);
  border: 1px solid var(--border-brand);
  border-radius: 50%;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all var(--t-fast);
  align-items: center;
  justify-content: center;
}
.mobile-inspector-toggle:hover { background: var(--brand-600); transform: scale(1.05); }

/* ══════════════════════════════════════════
   DRAWER BACKDROP
══════════════════════════════════════════ */
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 150;
  background: var(--surface-overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease both;
}
.drawer-backdrop.active { display: block; }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }

/* ══════════════════════════════════════════
   UTILITY
══════════════════════════════════════════ */
.fading-out { opacity: 0 !important; transition: opacity 0.35s ease !important; pointer-events: none; }

/* ══════════════════════════════════════════
   RESPONSIVE — 1440px and below
══════════════════════════════════════════ */
@media (max-width: 1280px) {
  :root {
    --inspector-w: 260px;
  }
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: var(--sidebar-w) 1fr;
  }
  .app-inspector { display: none; }
  .app-inspector.mobile-open {
    display: flex;
    position: fixed;
    right: 0; top: var(--header-h); bottom: 0;
    width: min(320px, 90vw);
    z-index: 160;
    box-shadow: var(--shadow-lg);
  }
  .mobile-inspector-toggle { display: flex; }
  .trust-chips { display: none; }
}

@media (max-width: 768px) {
  :root {
    --header-h: 52px;
    --sidebar-w: 100%;
  }

  .app-shell { grid-template-columns: 1fr; }
  .app-sidebar {
    display: flex;
    position: fixed;
    left: 0; top: var(--header-h); bottom: 0;
    width: min(var(--sidebar-w), 280px);
    z-index: 160;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .app-sidebar.open {
    transform: translateX(0);
  }

  .menu-toggle-btn { display: flex; }
  .header-center { display: none; }
  .brand-wordmark { display: none; }
  .nav-link-btn span { display: none; }
  .action-chip-label { display: none; }
  .upgrade-btn span { display: none; }
  .trust-chips { display: none; }

  .messages-container { padding: 16px 14px; gap: 14px; }
  .suggestions-grid { grid-template-columns: 1fr; max-width: 100%; }
  .suggestion-card { padding: 12px 14px; }
  .welcome-title { font-size: 20px; }
  .welcome-description { font-size: 12px; }
  .welcome-state { padding: 24px 16px; gap: 20px; }

  .composer-shell { padding: 10px 12px; }
  .composer-toolbar { padding: 8px 10px 6px; gap: 2px; }
  .composer-tool span { display: none; }
  .composer-input-row { padding: 8px 10px; }
  .composer-footer { padding: 6px 10px 8px; }

  .chat-bar { padding: 8px 14px; }
  .msg-content { max-width: 85%; }

  .toast-stack { bottom: 80px; right: 12px; left: 12px; }
  .toast-item { max-width: 100%; }

  .mobile-inspector-toggle { bottom: 72px; }
}

@media (max-width: 400px) {
  .chat-bar-right { gap: 4px; }
  .auth-btn span  { display: none; }
  .composer-send  { width: 32px; height: 32px; font-size: 11px; }
}

/* ══════════════════════════════════════════
   HIGH CONTRAST / REDUCED MOTION
══════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media (prefers-contrast: high) {
  :root {
    --border-subtle: rgba(255,255,255,0.2);
    --border-mid: rgba(255,255,255,0.35);
  }
}

/* ══════════════════════════════════════════
   PRINT
══════════════════════════════════════════ */
@media print {
  .app-sidebar, .app-inspector, .composer-shell, .chat-bar, .app-header { display: none !important; }
  .app-shell { display: block; height: auto; }
  .app-main  { overflow: visible; }
  .messages-container { overflow: visible; padding: 0; }
  .msg-bubble { box-shadow: none; border: 1px solid #ccc; }
}