/* Future Flow design system (future-flow/src/app/globals.css) — same tokens for Zima Blue dashboard. */

:root {
  --background: #000000;
  --foreground: #f5f5f7;
  --surface-raised: #0b0b0e;
  --text-secondary: rgba(245, 245, 247, 0.6);
  --text-tertiary: rgba(245, 245, 247, 0.4);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --card-bg: rgba(255, 255, 255, 0.04);
  --accent: #0a84ff;
  --accent-hover: #409cff;
  --accent-pressed: #0071e3;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius-sm: 10px;
  --radius: 20px;
  --radius-lg: 20px;
  --font-sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, Menlo, Consolas, monospace;
  --shadow-card:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 24px 48px -24px rgba(0, 0, 0, 0.5);
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

.site-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-color: #000;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.06) 1px, transparent 0);
  background-size: 32px 32px;
}

.site-bg::before,
.site-bg::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  animation: drift 24s ease-in-out infinite alternate;
}

.site-bg::before {
  width: min(60vw, 520px);
  height: min(60vw, 520px);
  top: -10%;
  left: -5%;
  background: radial-gradient(circle, #0a84ff 0%, transparent 70%);
}

.site-bg::after {
  width: min(50vw, 440px);
  height: min(50vw, 440px);
  bottom: 10%;
  right: -5%;
  background: radial-gradient(circle, #5ac8fa 0%, transparent 70%);
  animation-delay: -12s;
}

@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(40px, -30px) scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  .site-bg::before,
  .site-bg::after { animation: none; }
}

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 272px 1fr;
  grid-template-rows: 1fr;
  height: 100vh;
  height: 100dvh;
}

.mobile-top, .mobile-tabs { display: none; }

.sidebar {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  gap: 28px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0a84ff 0%, #5ac8fa 100%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
}
.brand-name {
  font-weight: 600;
  letter-spacing: -0.02em;
  font-size: 15px;
}
.brand-sub {
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-top: 2px;
}

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: transparent;
  color: var(--text-secondary);
  border: 0;
  cursor: pointer;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--foreground);
}
.nav-item.active {
  background: rgba(255, 255, 255, 0.07);
  color: var(--foreground);
  box-shadow: inset 0 0 0 1px var(--border-subtle);
}
.nav-item.active .nav-ico { color: var(--accent); }
.nav-ico {
  width: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--text-tertiary);
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.epigraph {
  margin: 0;
  padding: 12px 12px 12px 14px;
  border-left: 2px solid var(--accent);
  background: linear-gradient(90deg, rgba(10, 132, 255, 0.08), transparent);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-style: italic;
  line-height: 1.55;
}
.epigraph cite {
  display: block;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.chat-hello {
  margin: auto;
  max-width: 420px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.65;
}

.health {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.health .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
}
.health.ok .dot {
  background: var(--good);
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.55);
}
.health.down .dot { background: var(--bad); }

.docs-link {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
}
.docs-link:hover { color: var(--accent-hover); }

/* Main content */
.main {
  overflow-y: auto;
  padding: 32px 40px 40px;
}

.view { display: none; animation: view-in 0.28s ease; }
.view.active { display: block; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 12px;
}

.text-gradient-accent,
.text-gradient {
  background: linear-gradient(135deg, #0a84ff 0%, #5ac8fa 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.focus-ring:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.view-head h1 {
  margin: 0 0 8px;
  font-size: clamp(1.65rem, 2.5vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.12;
}

.muted {
  color: var(--text-secondary);
  margin: 0;
  font-size: 15px;
  max-width: 52ch;
  line-height: 1.55;
}

.card-surface,
.card,
.stat,
.table-wrap,
.modal,
.drawer,
.chat {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.stack-panel {
  background: linear-gradient(
    165deg,
    rgba(255, 255, 255, 0.07) 0%,
    rgba(255, 255, 255, 0.02) 45%,
    rgba(10, 132, 255, 0.04) 100%
  );
}

.card.pad { padding: 20px; }

/* Buttons & inputs */
.btn {
  background: rgba(255, 255, 255, 0.06);
  color: var(--foreground);
  border: 1px solid var(--border-subtle);
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.14);
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:active { background: var(--accent-pressed); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.icon-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
}
.icon-btn:hover {
  color: var(--foreground);
  background: rgba(255, 255, 255, 0.08);
}

input, select, textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  color: var(--foreground);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(10, 132, 255, 0.45);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.12);
}
textarea { resize: vertical; }
label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
label input { margin-top: 6px; }

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.stat { padding: 18px 20px; }
.stat .v {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.04em;
}
.stat .k {
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-top: 4px;
}

/* Persona grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.persona-card {
  padding: 20px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s, background 0.15s;
}
.persona-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
}

.pc-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  flex: none;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 13px;
  color: #fff;
  background: linear-gradient(135deg, #0a84ff 0%, #5ac8fa 100%);
  box-shadow: 0 4px 16px rgba(10, 132, 255, 0.25);
}
.pc-name { font-weight: 600; font-size: 15px; letter-spacing: -0.02em; }
.pc-slug {
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  font-size: 11px;
  margin-top: 2px;
}

.pc-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.mini {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
}
.mini .mv { font-weight: 600; font-size: 15px; }
.mini .mk {
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.badge {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.2);
  letter-spacing: 0.04em;
  text-transform: lowercase;
}
.badge.living { color: var(--good); border-color: rgba(52, 211, 153, 0.35); }
.badge.deceased { color: var(--text-tertiary); }
.badge.composite { color: var(--accent-hover); border-color: rgba(10, 132, 255, 0.35); }
.badge.kind-feature { color: #c4b5fd; }
.badge.kind-rule { color: #fca5a5; }
.badge.kind-skill { color: var(--accent-hover); }
.badge.kind-playbook { color: var(--warn); }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; background: transparent; border: 0; box-shadow: none; }
.table th, .table td {
  text-align: left;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
}
.table th {
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  font-weight: 500;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }

.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filters select, .filters input { width: auto; min-width: 0; flex: 1 1 140px; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card.pad h3 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.card.pad textarea, .card.pad input { margin-bottom: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch; }
.row > * { flex: 1 1 140px; min-width: 0; }
.row .btn { flex: 0 0 auto; }

.results { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.result-item {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.score-bar {
  height: 6px;
  border-radius: 4px;
  background: linear-gradient(90deg, #0a84ff, #5ac8fa);
}
.score-track {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
}

.empty {
  color: var(--text-secondary);
  text-align: center;
  padding: 64px 24px;
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--card-bg);
}

/* Modal & drawer */
.modal-backdrop, .drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  display: grid;
  z-index: 50;
}
.modal-backdrop { place-items: center; padding: 16px; }
.modal {
  width: 480px;
  max-width: 92vw;
  max-height: 90dvh;
  overflow: auto;
}
.modal-head, .modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
}
.modal-head { border-bottom: 1px solid var(--border-subtle); }
.modal-foot {
  border-top: 1px solid var(--border-subtle);
  gap: 10px;
  justify-content: flex-end;
}
.modal-body { padding: 22px; }
.modal-body h2, .modal-head h2 { margin: 0; font-size: 18px; letter-spacing: -0.02em; }
.req { color: var(--bad); }
.hint { color: var(--text-tertiary); font-size: 12px; margin: 4px 0 0; line-height: 1.5; }

.drawer-backdrop { justify-items: end; }
.drawer {
  width: 640px;
  max-width: 96vw;
  height: 100%;
  border-left: 1px solid var(--border-subtle);
  border-radius: 0;
  display: flex;
  flex-direction: column;
  animation: drawer-in 0.22s ease;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(16px);
}
@keyframes drawer-in {
  from { transform: translateX(24px); opacity: 0.7; }
  to { transform: none; opacity: 1; }
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 22px;
  border-bottom: 1px solid var(--border-subtle);
}
.drawer-head h2 { margin: 0; font-size: 20px; letter-spacing: -0.03em; }

.drawer-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}
.tab {
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.tab:hover { color: var(--foreground); background: rgba(255, 255, 255, 0.06); }
.tab.active {
  color: var(--foreground);
  background: rgba(10, 132, 255, 0.15);
  box-shadow: inset 0 0 0 1px rgba(10, 132, 255, 0.25);
}

.drawer-body { padding: 22px; overflow-y: auto; flex: 1; }
.detail-section { margin-bottom: 24px; }
.detail-section h4 {
  font-family: var(--font-mono);
  margin: 0 0 12px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-tertiary);
}
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.card-md {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 16px;
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
  max-height: 60vh;
  overflow: auto;
  color: var(--text-secondary);
}

.comp-list { display: flex; flex-direction: column; gap: 8px; }
.comp-item {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.comp-item .ct { font-weight: 600; }
.comp-item .cb { color: var(--text-secondary); font-size: 12px; margin-top: 4px; line-height: 1.5; }

/* Chat */
.chat {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  overflow: hidden;
}
.chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.msg {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 18px;
  line-height: 1.55;
  font-size: 14px;
}
.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.msg.user:hover { background: var(--accent-hover); }
.msg.agent {
  align-self: flex-start;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-bottom-left-radius: 6px;
}
.msg .cites {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-subtle);
  padding-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cite-chip {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 10px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-input {
  display: flex;
  gap: 10px;
  padding: 16px 18px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.2);
}
.agent-select { width: 260px; }

/* Toasts */
.toasts {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
}
.toast {
  background: rgba(0, 0, 0, 0.92);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  box-shadow: var(--shadow-card);
  min-width: 260px;
  animation: view-in 0.2s ease;
  backdrop-filter: blur(12px);
}
.toast.error { border-left-color: var(--bad); }
.toast.success { border-left-color: var(--good); }
.toast .tt { font-weight: 600; margin-bottom: 2px; letter-spacing: -0.02em; }
.toast .tm { color: var(--text-secondary); font-size: 12px; }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent);
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ——— Responsive ——— */
@media (max-width: 920px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar { display: none; }

  .mobile-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .mobile-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
  #health-mobile { justify-content: flex-end; }
  .mobile-page {
    font-family: var(--font-mono);
    color: var(--text-tertiary);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-tabs {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
    padding: 8px 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-subtle);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
  }

  .mobile-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 52px;
    padding: 6px 4px;
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.04em;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-tab .nav-ico { font-size: 15px; }
  .mobile-tab.active {
    color: var(--accent);
    background: rgba(10, 132, 255, 0.12);
  }
  .mobile-tab.active .nav-ico { color: var(--accent); }

  .main {
    padding: 20px 16px calc(80px + env(safe-area-inset-bottom)) 16px;
    min-height: 0;
  }

  .view-head {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 20px;
  }

  .view-head .btn, .view-head .agent-select, .view-head .filters { width: 100%; }
  .view-head .filters { flex-direction: column; align-items: stretch; }
  .view-head .filters select, .view-head .filters input { width: 100%; flex: none; }

  .cols, .stats-row { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; }

  .chat {
    height: calc(100dvh - 230px);
    min-height: 320px;
  }

  .msg { max-width: 92%; }
  .agent-select { width: 100%; }

  .drawer-backdrop { justify-items: stretch; }
  .drawer {
    width: 100%;
    max-width: none;
    height: 100%;
    border-left: 0;
  }

  .modal-backdrop { place-items: end center; padding: 0; }
  .modal {
    width: 100%;
    max-width: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .toasts {
    left: 12px;
    right: 12px;
    bottom: max(80px, calc(72px + env(safe-area-inset-bottom)));
  }
  .toast { min-width: 0; width: 100%; }

  .btn, .nav-item, .icon-btn { min-height: 44px; }

  .table { min-width: 560px; }
  .kv { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .chat-input { flex-direction: column; }
  .chat-input .btn { width: 100%; }
}

@media (min-width: 921px) {
  .mobile-top, .mobile-tabs { display: none !important; }
}

.nav-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 16px 12px 6px;
  margin-top: 8px;
}

.nav-advanced { opacity: 0.92; }

.chat-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.council-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}

.advisor-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.advisor-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
  color: var(--foreground);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.advisor-chip:hover { background: rgba(255, 255, 255, 0.08); }
.advisor-chip.active {
  border-color: rgba(10, 132, 255, 0.45);
  background: rgba(10, 132, 255, 0.12);
}

.avatar.sm {
  width: 28px;
  height: 28px;
  font-size: 10px;
  border-radius: 8px;
}

.weak-banner {
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #fcd34d;
  font-size: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.confidence-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  margin-bottom: 8px;
  border: 1px solid var(--border-subtle);
}
.confidence-pill.strong { color: var(--good); border-color: rgba(52, 211, 153, 0.35); }
.confidence-pill.medium { color: var(--accent-hover); border-color: rgba(10, 132, 255, 0.35); }
.confidence-pill.weak { color: var(--warn); border-color: rgba(251, 191, 36, 0.35); }

.cite-meta {
  font-family: var(--font-mono);
  font-size: 8px;
  margin-right: 4px;
  color: var(--accent-hover);
}

.council-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.council-card {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 13px;
  line-height: 1.5;
}

.council-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.council-summary {
  margin-bottom: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.council-summary h4 {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  margin: 0 0 8px;
}

.trait-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.55;
}

.view-head-chat { align-items: flex-start; }

@media (max-width: 920px) {
  .chat-toolbar { width: 100%; justify-content: stretch; }
  .chat-toolbar .btn { flex: 1; }
}
