/* ParkView Residence — premium intelligence design system */

:root {
  color-scheme: dark;

  --font-sans: "DM Sans", "Segoe UI", system-ui, sans-serif;
  --font-display: "Fraunces", Georgia, serif;

  --bg: #070d12;
  --bg-elevated: #0c141c;
  --bg-mesh:
    radial-gradient(ellipse 90% 60% at 10% -10%, rgba(26, 107, 90, 0.18), transparent 55%),
    radial-gradient(ellipse 70% 50% at 95% 5%, rgba(201, 162, 39, 0.12), transparent 50%),
    radial-gradient(ellipse 50% 40% at 50% 100%, rgba(26, 107, 90, 0.08), transparent 45%);

  --surface: rgba(14, 22, 32, 0.72);
  --surface-solid: #0e1620;
  --surface-2: rgba(18, 28, 40, 0.85);
  --surface-3: rgba(24, 36, 50, 0.9);
  --glass: rgba(12, 20, 30, 0.55);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.04);

  --text: #e8edf2;
  --text-secondary: #a8b8c8;
  --muted: #6b7d8f;

  --accent: #1a6b5a;
  --accent-hover: #228a74;
  --accent-soft: rgba(26, 107, 90, 0.18);
  --accent-glow: rgba(26, 107, 90, 0.35);

  --gold: #c9a227;
  --gold-hover: #dbb43a;
  --gold-soft: rgba(201, 162, 39, 0.14);
  --gold-glow: rgba(201, 162, 39, 0.4);

  --danger: #e85d4a;
  --ok: #3dba7a;
  --warn: #e0a030;

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  --shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 4px 20px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 40px 80px rgba(0, 0, 0, 0.55);
  --shadow-glow: 0 0 40px rgba(26, 107, 90, 0.15);

  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --radius-pill: 999px;

  --sidebar-w: 280px;
  --sidebar-collapsed: 72px;
  --topbar-h: 3.5rem;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition: 0.22s var(--ease);

  --blur: blur(20px);
  --blur-heavy: blur(40px);
}

[data-theme="light"] {
  color-scheme: light;

  --bg: #f4f1ea;
  --bg-elevated: #ffffff;
  --bg-mesh:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(26, 107, 90, 0.1), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(201, 162, 39, 0.08), transparent 50%);

  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --surface-2: #f8f6f2;
  --surface-3: #ebe6dc;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(15, 26, 34, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.6);

  --text: #0f1a22;
  --text-secondary: #3d4f5c;
  --muted: #5f6d78;

  --accent: #1a6b5a;
  --accent-hover: #145a4b;
  --accent-soft: rgba(26, 107, 90, 0.12);
  --accent-glow: rgba(26, 107, 90, 0.2);

  --gold: #a8831f;
  --gold-hover: #c9a227;
  --gold-soft: rgba(201, 162, 39, 0.12);
  --gold-glow: rgba(201, 162, 39, 0.25);

  --danger: #b42318;
  --ok: #1a6b3f;
  --warn: #9a5b13;

  --border: #e0dbd2;
  --border-strong: #cfc8bc;

  --shadow: 0 20px 50px rgba(15, 26, 34, 0.1);
  --shadow-sm: 0 4px 16px rgba(15, 26, 34, 0.06);
  --shadow-lg: 0 32px 64px rgba(15, 26, 34, 0.14);
  --shadow-glow: 0 0 40px rgba(26, 107, 90, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  background-image: var(--bg-mesh);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--gold); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--gold-hover); }

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

.icon {
  display: inline-flex;
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
}
.icon svg { width: 100%; height: 100%; }

/* ── Ambient orbs ─────────────────────────────────── */

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  will-change: transform;
}

.ambient-orb-1 {
  width: 520px;
  height: 520px;
  top: -12%;
  left: -8%;
  background: radial-gradient(circle, rgba(26, 107, 90, 0.55) 0%, transparent 70%);
  animation: orbFloat1 22s ease-in-out infinite;
}

.ambient-orb-2 {
  width: 420px;
  height: 420px;
  top: 35%;
  right: -10%;
  background: radial-gradient(circle, rgba(201, 162, 39, 0.35) 0%, transparent 70%);
  animation: orbFloat2 28s ease-in-out infinite;
}

.ambient-orb-3 {
  width: 360px;
  height: 360px;
  bottom: -8%;
  left: 30%;
  background: radial-gradient(circle, rgba(26, 80, 120, 0.4) 0%, transparent 70%);
  animation: orbFloat3 25s ease-in-out infinite;
}

[data-theme="light"] .ambient-orb { opacity: 0.25; filter: blur(100px); }

@keyframes orbFloat1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, 30px) scale(1.05); }
  66% { transform: translate(-20px, 50px) scale(0.95); }
}

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

@keyframes orbFloat3 {
  0%, 100% { transform: translate(0, 0); }
  40% { transform: translate(30px, -25px); }
  80% { transform: translate(-35px, 15px); }
}

/* ── Glass utility ────────────────────────────────── */

.glass {
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  box-shadow:
    var(--shadow-sm),
    inset 0 1px 0 var(--glass-highlight);
}

/* ── App shell ──────────────────────────────────────── */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 12, 0.65);
  backdrop-filter: blur(6px);
  z-index: 40;
  opacity: 0;
  transition: opacity var(--transition);
}

.nav-open .sidebar-backdrop {
  display: block;
  opacity: 1;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: rgba(8, 14, 22, 0.65);
  backdrop-filter: var(--blur-heavy);
  -webkit-backdrop-filter: var(--blur-heavy);
  color: #fff;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 50;
  overflow: hidden;
  transition: width 0.35s var(--ease), box-shadow var(--transition);
}

[data-theme="light"] .sidebar {
  background: rgba(12, 22, 32, 0.92);
  color: #fff;
}

.sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(201, 162, 39, 0.06) 0%, transparent 35%),
    radial-gradient(circle at 0% 0%, rgba(26, 107, 90, 0.15), transparent 55%);
  pointer-events: none;
}

.sidebar::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(180deg, rgba(201, 162, 39, 0.3), transparent 40%, rgba(26, 107, 90, 0.2));
  pointer-events: none;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1.25rem 1.15rem 0.85rem;
  color: inherit;
  text-decoration: none;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.sidebar-brand:hover { text-decoration: none; color: inherit; }

.logo {
  width: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--gold) 0%, #8a6a18 100%);
  color: #0a0804;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  box-shadow: 0 4px 20px var(--gold-glow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
}

.brand-text strong,
.brand-text small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-text strong {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
}

.brand-text small {
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.72rem;
  margin-top: 0.12rem;
}

.sidebar-new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  margin: 0 0.85rem 0.65rem;
  padding: 0.72rem 1rem;
  background: linear-gradient(135deg, rgba(201, 162, 39, 0.2) 0%, rgba(26, 107, 90, 0.25) 100%);
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: transform 0.15s var(--ease), box-shadow var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

.sidebar-new-chat:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(201, 162, 39, 0.25);
  border-color: rgba(201, 162, 39, 0.55);
}

.sidebar-new-chat:active { transform: scale(0.98); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.35rem 0.65rem;
  position: relative;
  z-index: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.sidebar-group { margin-bottom: 1.1rem; }

.sidebar-group-label {
  display: block;
  padding: 0 0.6rem;
  margin-bottom: 0.35rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.38);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.58rem 0.7rem;
  margin-bottom: 0.12rem;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition), transform 0.15s;
  white-space: nowrap;
}

.sidebar-link .icon { opacity: 0.72; transition: opacity var(--transition), color var(--transition); }

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  text-decoration: none;
}

.sidebar-link.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--gold);
}

.sidebar-link.active .icon { opacity: 1; color: var(--gold); }

.sidebar-footer {
  padding: 0.85rem 0.65rem 1.15rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.sidebar-project { margin-bottom: 0.75rem; }

.sidebar-project select {
  width: 100%;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  border-radius: var(--radius-xs);
  padding: 0.52rem 0.6rem;
  font-size: 0.86rem;
}

.sidebar-project select option { color: var(--text); background: var(--surface-solid); }

.sidebar-cmd {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.58rem 0.7rem;
  margin-bottom: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.7);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.sidebar-cmd:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.sidebar-cmd span { flex: 1; text-align: left; }

.sidebar-cmd kbd,
.cmd-trigger kbd,
.command-input-wrap kbd {
  font-family: inherit;
  font-size: 0.68rem;
  padding: 0.15rem 0.4rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  color: rgba(255, 255, 255, 0.55);
  margin-left: auto;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.user-avatar {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold);
  border: 1px solid rgba(201, 162, 39, 0.35);
  flex-shrink: 0;
}

.user-meta strong {
  display: block;
  font-size: 0.86rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 150px;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.15rem;
}

.user-meta .link-btn {
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.78rem;
  padding: 0;
  min-height: auto;
}

.user-meta .link-btn:hover { color: #fff; }

/* Collapsible sidebar feel (desktop hover expand hint) */
@media (min-width: 1100px) {
  .app {
    transition: grid-template-columns 0.35s var(--ease);
  }
}

.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Topbar ─────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: var(--topbar-h);
  padding: 0 1.5rem;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-minimal {
  background: transparent;
  border-bottom: none;
  padding: 0.65rem 1rem;
  min-height: auto;
}

.topbar-minimal .nav-toggle {
  border-color: var(--border);
  background: var(--glass);
  backdrop-filter: var(--blur);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0.4rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}

.topbar-title h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar-spacer { flex: 1; }

.cmd-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.8rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition), box-shadow var(--transition);
}

.cmd-trigger:hover {
  border-color: var(--gold);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.topbar-new {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  background: linear-gradient(135deg, var(--gold) 0%, #a8831f 100%);
  border-radius: var(--radius-pill);
  color: #0a0804;
  font-size: 0.86rem;
  font-weight: 700;
  transition: transform 0.15s, box-shadow var(--transition);
}

.topbar-new:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--gold-glow);
  color: #0a0804;
  text-decoration: none;
}

.search-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-shortcut:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}

.search-shortcut kbd {
  font-family: inherit;
  font-size: 0.72rem;
  padding: 0.15rem 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
}

.page-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1320px;
  width: 100%;
  animation: fadeUp 0.4s var(--ease);
}

.immersive .page-content {
  padding: 0;
  max-width: none;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--topbar-h));
}

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

/* ── Theme toggle ─────────────────────────────────── */

.theme-toggle {
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  min-height: auto;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background var(--transition), border-color var(--transition), transform 0.15s;
}

.topbar .theme-toggle {
  background: var(--surface-2);
  border-color: var(--border);
}

.theme-toggle::before,
.theme-toggle::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease-spring);
}

.theme-toggle::before {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 12px var(--gold-glow);
  opacity: 1;
  transform: scale(1);
}

.theme-toggle::after {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: transparent;
  box-shadow: inset -3px -2px 0 0 var(--text-secondary);
  opacity: 0;
  transform: scale(0.5) rotate(-30deg);
}

[data-theme="light"] .theme-toggle::before {
  opacity: 0;
  transform: scale(0.5);
}

[data-theme="light"] .theme-toggle::after {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.theme-toggle:hover { transform: scale(1.06); }

/* ── Command palette ────────────────────────────────── */

.command-palette {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 1rem 2rem;
}

.command-palette[hidden] { display: none; }

.command-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 12, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: fadeIn 0.2s var(--ease);
}

.command-dialog {
  position: relative;
  width: min(640px, 100%);
  background: var(--surface-2);
  backdrop-filter: var(--blur-heavy);
  -webkit-backdrop-filter: var(--blur-heavy);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.04);
  overflow: hidden;
  animation: cmdSlide 0.28s var(--ease-spring);
}

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

@keyframes cmdSlide {
  from { opacity: 0; transform: translateY(-12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.command-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
}

.command-input-wrap .icon {
  color: var(--muted);
  width: 1.25rem;
  height: 1.25rem;
}

.command-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 0;
  font-size: 1rem;
  color: var(--text);
  box-shadow: none;
}

.command-input-wrap input:focus {
  outline: none;
  box-shadow: none;
}

.command-input-wrap kbd {
  background: var(--surface-3);
  border-color: var(--border);
  color: var(--muted);
}

.command-body {
  max-height: 50vh;
  overflow-y: auto;
  padding: 0.65rem;
}

.command-section { margin-bottom: 0.5rem; }

.command-section-label {
  display: block;
  padding: 0.35rem 0.65rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.command-list { display: grid; gap: 0.15rem; }

.cmd-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  padding: 0.7rem 0.85rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  min-height: auto;
  transition: background var(--transition);
}

.cmd-item:hover,
.cmd-item:focus-visible {
  background: var(--accent-soft);
  outline: none;
}

.cmd-icon {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-xs);
  background: var(--gold-soft);
  color: var(--gold);
  flex-shrink: 0;
}

.cmd-text { min-width: 0; }

.cmd-text strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
}

.cmd-text small {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 0.1rem;
}

body.cmd-open { overflow: hidden; }

/* ── Intelligence studio ──────────────────────────── */

.intelligence-studio {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 300px;
  flex: 1;
  min-height: calc(100vh - 3.5rem);
  height: 100%;
}

.studio-threads,
.studio-sources {
  display: flex;
  flex-direction: column;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-color: var(--border);
  overflow: hidden;
}

.studio-threads {
  border-right: 1px solid var(--border);
}

.studio-sources {
  border-left: 1px solid var(--border);
}

.studio-threads-head,
.studio-sources-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.studio-threads-head h2,
.studio-sources-head h2 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  transition: background var(--transition), border-color var(--transition);
}

.icon-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.studio-threads .session-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.studio-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}

.studio-stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
}

.studio-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  scroll-behavior: smooth;
}

.composer-dock {
  padding: 0.75rem 1.25rem 1.25rem;
  background: linear-gradient(180deg, transparent 0%, var(--bg) 35%);
  flex-shrink: 0;
}

.composer {
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}

.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 0.65rem;
  padding: 0.65rem 0.65rem 0.65rem 1rem;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm), var(--shadow-glow);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.composer-inner:focus-within {
  border-color: rgba(201, 162, 39, 0.45);
  box-shadow: var(--shadow-sm), 0 0 0 3px var(--gold-soft);
}

.composer-inner textarea {
  flex: 1;
  background: transparent;
  border: none;
  padding: 0.45rem 0;
  resize: none;
  min-height: 1.5rem;
  max-height: 200px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
  box-shadow: none;
}

.composer-inner textarea:focus {
  outline: none;
  box-shadow: none;
}

.composer-send {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  min-height: auto;
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, var(--gold) 0%, #a8831f 100%);
  border: none;
  color: #0a0804;
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow var(--transition);
}

.composer-send svg { width: 1.15rem; height: 1.15rem; }

.composer-send:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px var(--gold-glow);
}

.composer-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.composer.sending .composer-send {
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.composer-hint {
  margin: 0.55rem 0 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}

.sources-count {
  display: grid;
  place-items: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.4rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
}

.studio-sources-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
}

.sources-placeholder {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.6;
}

.sources-placeholder p { margin: 0; }

/* ── Chat welcome ───────────────────────────────────── */

.chat-welcome {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 3rem 1.5rem 2rem;
  max-width: 720px;
  margin: auto;
  animation: fadeUp 0.5s var(--ease);
}

.welcome-glow {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(201, 162, 39, 0.2) 0%, transparent 70%);
  filter: blur(40px);
  pointer-events: none;
}

.welcome-brand {
  position: relative;
  width: 3.5rem;
  height: 3.5rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--gold-soft) 0%, var(--accent-soft) 100%);
  border: 1px solid rgba(201, 162, 39, 0.3);
  color: var(--gold);
  margin-bottom: 1.25rem;
  animation: welcomePulse 3s ease-in-out infinite;
}

.welcome-brand .icon { width: 1.5rem; height: 1.5rem; }

@keyframes welcomePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 162, 39, 0.2); }
  50% { box-shadow: 0 0 0 12px rgba(201, 162, 39, 0); }
}

.chat-welcome h2 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 600;
  margin: 0 0 0.65rem;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text) 0%, var(--gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.chat-welcome p {
  margin: 0 0 2rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
  max-width: 42ch;
  line-height: 1.65;
}

.chat-welcome em {
  color: var(--gold);
  font-style: normal;
  font-weight: 600;
}

.welcome-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  width: 100%;
}

.welcome-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 1rem 1.1rem;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  min-height: auto;
  transition: transform 0.2s var(--ease), border-color var(--transition), box-shadow var(--transition);
  animation: fadeUp 0.4s var(--ease) both;
}

.welcome-card:hover {
  transform: translateY(-3px);
  border-color: rgba(201, 162, 39, 0.4);
  box-shadow: var(--shadow-sm), 0 0 24px rgba(201, 162, 39, 0.08);
}

.welcome-card-icon {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-xs);
  background: var(--gold-soft);
  color: var(--gold);
}

.welcome-card strong {
  font-size: 0.9rem;
  font-weight: 600;
}

.welcome-card small {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Messages ───────────────────────────────────────── */

.message {
  display: flex;
  gap: 0.85rem;
  max-width: min(820px, 92%);
  animation: fadeUp 0.35s var(--ease);
}

.message-user {
  align-self: flex-end;
  flex-direction: row-reverse;
  margin-left: auto;
}

.message-avatar {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  flex-shrink: 0;
}

.message-assistant .message-avatar {
  background: linear-gradient(145deg, var(--gold) 0%, #8a6a18 100%);
  color: #0a0804;
  box-shadow: 0 4px 12px var(--gold-glow);
}

.message-user .message-avatar {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(26, 107, 90, 0.3);
}

.message-content { min-width: 0; flex: 1; }

.message-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.message-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.message-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
}

.message-badge.live {
  background: var(--gold-soft);
  color: var(--gold);
  animation: pulse 1.5s ease-in-out infinite;
}

.message-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.message-user .message-label { text-align: right; }

.bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.95rem 1.1rem;
  white-space: pre-wrap;
  font-size: 0.94rem;
  line-height: 1.65;
  color: var(--text);
}

.message-user .bubble {
  background: linear-gradient(135deg, var(--accent) 0%, #145a4b 100%);
  color: #fff;
  border-color: transparent;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.message-assistant .bubble {
  border-bottom-left-radius: 4px;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.bubble.streaming::after {
  content: "▋";
  animation: blink 1s step-end infinite;
  margin-left: 2px;
  color: var(--gold);
}

@keyframes blink { 50% { opacity: 0; } }

.message-sources { margin-top: 0.85rem; }

.sources-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  background: var(--gold-soft);
  border: 1px solid rgba(201, 162, 39, 0.25);
  border-radius: var(--radius-pill);
  color: var(--gold);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  min-height: auto;
  transition: background var(--transition);
}

.sources-toggle:hover { background: rgba(201, 162, 39, 0.22); }

.sources-inline {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.65rem;
}

.source-card {
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  transition: border-color var(--transition);
}

.source-card:hover { border-color: rgba(201, 162, 39, 0.35); }

.source-card.rail-card {
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.source-card-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.45rem;
}

.source-card-head strong {
  flex: 1;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-num {
  width: 1.35rem;
  height: 1.35rem;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: #0a0804;
  border-radius: 50%;
  font-size: 0.68rem;
  font-weight: 800;
  flex-shrink: 0;
}

.source-score {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

.source-card p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Bento dashboard ────────────────────────────────── */

.bento-dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  animation: fadeUp 0.45s var(--ease);
}

.bento-hero {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr);
  gap: 2rem;
  align-items: center;
  padding: 2rem 2.25rem;
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}

.bento-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 90% 15%, rgba(201, 162, 39, 0.15), transparent 45%),
    radial-gradient(circle at 5% 85%, rgba(26, 107, 90, 0.12), transparent 40%);
  pointer-events: none;
}

.bento-hero > * { position: relative; z-index: 1; }

.bento-hero-content h1 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.25rem);
  margin-bottom: 0.5rem;
}

.bento-hero-content p {
  color: var(--text-secondary);
  margin: 0 0 1.25rem;
  max-width: 48ch;
}

.hero-search-inline {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  max-width: 480px;
}

.hero-search-inline input {
  background: var(--surface-2);
  border-color: var(--border);
}

.hero-search-inline button {
  background: linear-gradient(145deg, var(--gold) 0%, #a8831f 100%);
  border-color: transparent;
  color: #0a0804;
  font-weight: 700;
  white-space: nowrap;
}

.hero-search-inline button:hover {
  box-shadow: 0 6px 20px var(--gold-glow);
}

.bento-hero-stats {
  display: grid;
  gap: 0.65rem;
}

.bento-hero-stats .stat-card {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .bento-hero-stats .stat-card {
  background: var(--surface);
}

.bento-stats {
  grid-column: span 3;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.bento-tile {
  padding: 1.25rem 1.35rem;
  border-radius: var(--radius);
  transition: transform 0.2s var(--ease), box-shadow var(--transition);
  animation: fadeUp 0.4s var(--ease) both;
  text-decoration: none;
  color: inherit;
  display: block;
}

.bento-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
}

.bento-tile.span-2 { grid-column: span 2; }

.bento-tile h3 {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.85rem;
  font-size: 0.95rem;
  font-weight: 650;
}

.bento-tile-accent {
  grid-row: span 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 220px;
  background:
    linear-gradient(160deg, rgba(26, 107, 90, 0.35) 0%, rgba(201, 162, 39, 0.15) 100%),
    var(--glass) !important;
  border-color: rgba(201, 162, 39, 0.25) !important;
  position: relative;
  overflow: hidden;
}

.bento-tile-accent::after {
  content: "";
  position: absolute;
  top: -30%;
  right: -20%;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(201, 162, 39, 0.25), transparent 70%);
  pointer-events: none;
}

.bento-tile-icon {
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--gold-soft);
  color: var(--gold);
  margin-bottom: 1rem;
}

.bento-tile-accent h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.bento-tile-accent p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin: 0 0 1rem;
}

.bento-tile-cta {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.02em;
}

.bento-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

/* ── Typography ─────────────────────────────────────── */

h1, h2, h3, h4 {
  margin-top: 0;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3.5vw, 2.5rem);
  font-weight: 600;
}

h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: 0.98rem; font-weight: 600; }

.muted, .hint, .page-desc { color: var(--muted); }
.hint, .page-desc { font-size: 0.92rem; }
.page-desc { margin: 0.35rem 0 0; max-width: 56ch; }

.eyebrow {
  color: var(--gold);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  margin: 0 0 0.5rem;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-header-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ── Panels & cards ─────────────────────────────────── */

.panel {
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  box-shadow: var(--shadow-sm);
}

.panel-elevated { box-shadow: var(--shadow); }

.panel-header {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr);
  gap: 2rem;
  align-items: center;
  margin-bottom: 1.5rem;
  padding: 2rem 2.25rem;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #0a1420 0%, #122838 50%, #1a4d3e 100%);
  color: #fff;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.hero-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 90% 10%, rgba(201, 162, 39, 0.22), transparent 40%),
    radial-gradient(circle at 10% 90%, rgba(255, 255, 255, 0.04), transparent 35%);
  pointer-events: none;
}

.hero-panel > * { position: relative; z-index: 1; }
.hero-panel h1 { color: #fff; margin-bottom: 0.5rem; }
.hero-panel .muted { color: rgba(255, 255, 255, 0.72); }

.hero-search {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  padding: 1rem;
  backdrop-filter: blur(8px);
}

.hero-search label {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.82rem;
  margin-bottom: 0.5rem;
  display: block;
}

.quick-ask {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

.hero-panel input {
  background: rgba(255, 255, 255, 0.96);
  border-color: transparent;
  color: var(--text);
}

.hero-panel button {
  background: var(--gold);
  border-color: var(--gold);
  color: #0a0804;
  font-weight: 700;
  white-space: nowrap;
}

.hero-panel button:hover {
  background: var(--gold-hover);
  border-color: var(--gold-hover);
}

/* ── Stats ──────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-link {
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.15s var(--ease);
}

.stat-link:hover {
  transform: translateY(-2px);
  text-decoration: none;
  color: inherit;
}

.stat-card {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-color var(--transition), transform 0.15s;
  animation: fadeUp 0.4s var(--ease) both;
}

.stat-link:hover .stat-card,
.stat-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}

.stat-icon {
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
}

.stat-icon .icon { width: 1.25rem; height: 1.25rem; }

.stat-value {
  display: block;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.1;
  color: var(--text);
}

.stat-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.stat-warn .stat-icon { background: rgba(224, 160, 48, 0.15); color: var(--warn); }
.stat-ok .stat-icon { background: rgba(61, 186, 122, 0.15); color: var(--ok); }
.stat-gold .stat-icon { background: var(--gold-soft); color: var(--gold); }

.stat {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}
.stat span { display: block; font-size: 1.6rem; font-weight: 800; color: var(--accent); }
.stat small { color: var(--muted); font-size: 0.82rem; }

/* ── Quick actions & prompts ────────────────────────── */

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.quick-action {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  transition: border-color var(--transition), box-shadow var(--transition), transform 0.15s;
}

.quick-action:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
  text-decoration: none;
  color: inherit;
}

.quick-action-icon {
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
}

.quick-action-text { flex: 1; min-width: 0; }
.quick-action-text strong { display: block; font-size: 0.95rem; }
.quick-action-text small { color: var(--muted); font-size: 0.82rem; }

.quick-action-arrow {
  color: var(--muted);
  opacity: 0.5;
  width: 1rem;
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.prompt-chip {
  display: inline-block;
  padding: 0.45rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 0.84rem;
  color: var(--text);
  transition: background var(--transition), border-color var(--transition);
}

.prompt-chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* ── Activity feed ──────────────────────────────────── */

.dashboard-grid,
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.1rem;
  margin-bottom: 1rem;
}

.panel h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.15rem;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.activity-item:hover { background: var(--surface-2); }

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  margin-top: 0.45rem;
  flex-shrink: 0;
  box-shadow: 0 0 8px var(--gold-glow);
}

.activity-body { flex: 1; min-width: 0; }
.activity-body strong {
  display: block;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.activity-badge { flex-shrink: 0; }

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
}

.empty-icon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 0.75rem;
  color: var(--border-strong);
}

.empty-icon .icon { width: 100%; height: 100%; }
.empty-state h3 { color: var(--text); margin-bottom: 0.35rem; }
.empty-state p { margin: 0 0 1rem; font-size: 0.9rem; }

.clean-list {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.55rem;
}

/* ── Forms & buttons ────────────────────────────────── */

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.62rem 1.1rem;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: none;
  min-height: 2.5rem;
  transition: background var(--transition), transform 0.1s, box-shadow var(--transition);
}

button:hover, .button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  text-decoration: none;
}

button:active, .button:active { transform: scale(0.98); }

button.loading::after {
  content: "";
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-left: 0.35rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

button:disabled { opacity: 0.65; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-gold {
  background: linear-gradient(145deg, var(--gold) 0%, #a8831f 100%);
  border-color: transparent;
  color: #0a0804;
}

.small-btn { min-height: 2rem; padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.danger-btn { background: var(--danger); border-color: var(--danger); }
.link-btn {
  background: transparent;
  color: var(--gold);
  padding: 0;
  border: none;
  min-height: auto;
  font-weight: 600;
}
.link-btn:hover { background: transparent; color: var(--gold-hover); }
.link-btn.danger { color: var(--danger); }
.full-width { width: 100%; }

input, textarea, select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  font: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
}

.stack { display: grid; gap: 0.85rem; }
.compact-form { margin-top: 1rem; max-width: 720px; }

.form-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.form-card h2, .form-card h3 {
  margin-bottom: 0.85rem;
  font-size: 0.95rem;
}

/* ── Upload zone ────────────────────────────────────── */

.upload-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
  position: relative;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-zone.has-file {
  border-color: var(--ok);
  background: rgba(61, 186, 122, 0.12);
}

.upload-zone-inner .icon {
  width: 2.5rem;
  height: 2.5rem;
  margin: 0 auto 0.75rem;
  color: var(--accent);
}

.upload-zone input[type="file"] {
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

/* ── Chat (legacy layout) ───────────────────────────── */

.chat-page { display: flex; flex-direction: column; min-height: calc(100vh - var(--topbar-h) - 3rem); }

.chat-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1rem;
  flex: 1;
  min-height: 0;
}

.chat-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: calc(100vh - var(--topbar-h) - 4rem);
}

.chat-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
  flex: 1;
}

.session-link {
  display: block;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: inherit;
  transition: background var(--transition), border-color var(--transition);
  text-decoration: none;
}

.session-link:hover {
  background: var(--surface-2);
  text-decoration: none;
  color: inherit;
}

.session-link.active {
  background: var(--accent-soft);
  border-color: rgba(26, 107, 90, 0.3);
}

.session-title {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-date {
  font-size: 0.75rem;
  color: var(--muted);
}

.chat-main {
  display: flex;
  flex-direction: column;
  min-height: 520px;
  max-height: calc(100vh - var(--topbar-h) - 4rem);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 0.5rem 0.25rem 1rem;
  min-height: 300px;
}

.chat-composer {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: auto;
}

.chat-form {
  display: grid;
  gap: 0.65rem;
}

.chat-form textarea {
  resize: none;
  min-height: 3.5rem;
  max-height: 160px;
}

.chat-suggestions { margin-bottom: 1rem; }

.citations {
  margin-top: 0.75rem;
  padding: 0.9rem 1rem;
  background: var(--gold-soft);
  border: 1px solid rgba(201, 162, 39, 0.25);
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
}

.citations h4 {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gold);
}

.citations ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.65rem;
}

.citations li {
  display: flex;
  gap: 0.65rem;
}

.citation-num {
  width: 1.4rem;
  height: 1.4rem;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: #0a0804;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

.citation-score {
  font-size: 0.75rem;
  color: var(--muted);
  margin-left: 0.35rem;
}

.citations p { margin: 0.25rem 0 0; font-size: 0.82rem; }

/* ── Tables ─────────────────────────────────────────── */

.table-toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.table-search {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
  position: relative;
}

.table-search .icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.table-search input { padding-left: 2.5rem; }

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-weight: 650;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface-2);
  position: sticky;
  top: 0;
}

.data-table th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.data-table th:last-child { border-radius: 0 var(--radius-sm) 0 0; }

.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--surface-2); }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.inline-form {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Badges ─────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  white-space: nowrap;
}

.badge-indexed, .badge-ready, .badge-active, .badge-resolved, .badge-completed {
  background: rgba(61, 186, 122, 0.15);
  color: var(--ok);
}
.badge-queued, .badge-processing, .badge-new, .badge-acknowledged,
.badge-in-progress, .badge-waiting-vendor, .badge-open, .badge-planned {
  background: rgba(224, 160, 48, 0.15);
  color: var(--warn);
}
.badge-failed, .badge-rejected {
  background: rgba(232, 93, 74, 0.15);
  color: var(--danger);
}
.badge-inactive {
  background: var(--surface-2);
  color: var(--muted);
}

.severity-high, .severity-critical { color: var(--danger); font-weight: 600; }
.severity-medium, .severity-warn { color: var(--warn); }
.severity-low, .severity-info { color: var(--muted); }

/* ── Flash & config ─────────────────────────────────── */

.flash {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.flash-success {
  background: rgba(61, 186, 122, 0.12);
  color: var(--ok);
  border: 1px solid rgba(61, 186, 122, 0.25);
}
.flash-error {
  background: rgba(232, 93, 74, 0.12);
  color: var(--danger);
  border: 1px solid rgba(232, 93, 74, 0.25);
}

.config {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  overflow: auto;
  font-size: 0.84rem;
  font-family: ui-monospace, monospace;
}

.stack-list {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.45rem;
}

.project-switcher { display: none; }

/* ── Auth (legacy class compatibility) ──────────────── */

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
  background: linear-gradient(135deg, #070d12 0%, #122838 50%, #1a6b5a 100%);
}

.auth-shell {
  width: min(960px, 100%);
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.5s var(--ease);
}

.auth-brand {
  padding: 3rem 2.5rem;
  background: transparent;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.25rem;
  position: relative;
}

.auth-brand::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 80%, rgba(201, 162, 39, 0.2), transparent 50%);
}

.auth-brand > * { position: relative; }

.auth-brand .logo {
  width: 3.5rem;
  height: 3.5rem;
  font-size: 1rem;
}

.auth-brand h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  margin: 0;
}

.auth-brand .tagline {
  color: var(--gold);
  font-weight: 600;
  font-size: 1rem;
  margin: 0;
}

.auth-brand p {
  color: rgba(255, 255, 255, 0.75);
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.65;
  max-width: 36ch;
}

.auth-features {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.auth-features li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.8);
}

.auth-features li::before {
  content: "✓";
  color: var(--gold);
  font-weight: 700;
}

.auth-card {
  background: var(--surface-solid);
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
}

.auth-card h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0;
}

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  font-weight: 600;
}

.google-btn:hover {
  background: var(--surface-3);
  border-color: var(--text);
  color: var(--text);
}

/* ── Responsive ───────────────────────────────────── */

@media (max-width: 1200px) {
  .bento-dashboard { grid-template-columns: repeat(2, 1fr); }
  .bento-stats { grid-column: 1 / -1; grid-template-columns: repeat(3, 1fr); }
  .bento-tile.span-2 { grid-column: span 1; }
  .bento-tile-accent { grid-row: auto; min-height: 180px; }

  .intelligence-studio {
    grid-template-columns: 220px minmax(0, 1fr) 260px;
  }
}

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

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 0.35s var(--ease);
    box-shadow: var(--shadow-lg);
  }

  .nav-open .sidebar { transform: translateX(0); }

  .nav-toggle { display: flex; }

  .hero-panel { grid-template-columns: 1fr; padding: 1.5rem; }
  .chat-layout { grid-template-columns: 1fr; }
  .chat-sidebar { max-height: none; }
  .chat-main { max-height: none; }

  .intelligence-studio {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }

  .studio-threads {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 180px;
  }

  .studio-sources {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 220px;
  }

  .bento-hero { grid-template-columns: 1fr; padding: 1.5rem; }
}

@media (max-width: 768px) {
  .page-content { padding: 1rem; }
  .topbar { padding: 0 1rem; }
  .search-shortcut span,
  .search-shortcut kbd { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { padding: 2rem 1.5rem; }
  .quick-ask { grid-template-columns: 1fr; }

  .bento-dashboard { grid-template-columns: 1fr; }
  .bento-stats { grid-template-columns: 1fr; }
  .welcome-grid { grid-template-columns: 1fr; }

  .studio-messages { padding: 1rem 0.85rem; }
  .composer-dock { padding: 0.65rem 0.85rem 1rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .message { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  .ambient-orb { animation: none; }
}
