/* Cuegent AI — design system.
   White, vibrant, professional. One stylesheet for the whole platform. */

:root {
  /* Surfaces */
  --bg:           #f6f7fb;   /* app canvas */
  --surface:      #ffffff;   /* cards, top bar */
  --surface-2:    #f1f3f9;   /* subtle fill, hover */
  --surface-3:    #eceff7;   /* inputs, deeper fill */

  /* Borders */
  --border:       #e3e6ef;
  --border-soft:  #eef0f6;
  --border-strong:#d4d8e6;

  /* Text */
  --text:         #1a1d29;
  --text-muted:   #5b6172;
  --text-dim:     #8a90a3;

  /* Brand / accents */
  --primary:      #111418;   /* ink */
  --primary-hover:#454B54;   /* body */
  --primary-soft: #F6F7F9;
  --accent:       var(--primary);
  --primary-grad: #111418;
  --brand-grad-text: #111418;

  /* Status */
  --success:      #10b981;
  --success-soft: #e7f8f1;
  --warning:      #f59e0b;
  --warning-soft: #fef3e2;
  --danger:       #ef4444;
  --danger-soft:  #fdecec;

  /* Shape */
  --radius:       14px;
  --radius-sm:    9px;
  --radius-xs:    6px;
  --shadow-sm:    0 1px 2px rgba(16,24,40,.05);
  --shadow:       0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow-rest:  0 1px 2px rgba(16,24,40,.04), 0 4px 16px -8px rgba(16,24,40,.12);
  --shadow-md:    0 4px 12px rgba(16,24,40,.08);
  --shadow-lg:    0 12px 32px rgba(16,24,40,.12);
  --shadow-glow:  0 8px 24px -6px rgba(99,102,241,.35);

  /* Sidebar width + topbar height (shared across layout) */
  --sidebar-w:    260px;
  --topbar-h:     62px;

  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter Tight", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; font-weight: 680; letter-spacing: -0.012em; color: var(--text); }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.08rem; }
h4 { font-size: .98rem; }
p  { margin: 0 0 1em; }

.muted  { color: var(--text-muted); }
.dim    { color: var(--text-dim); }
.small  { font-size: .84rem; }
.num    { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Icon system ---------- */
/* SVG icons inherit color via currentColor and scale to font-size. The sprite
   is injected by static/js/icons.js; references use <svg><use href="#i-x"/>. */
.icon {
  display: inline-block;
  width: 1em; height: 1em;
  vertical-align: -0.15em;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}
.icon-md { font-size: 1rem; }
.icon-lg { font-size: 1.5rem; }
.icon-sm { font-size: .9rem; }

code { font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: .85em;
       background: var(--surface-3); padding: 1px 6px; border-radius: 4px; }

/* ---------- App shell layout ---------- */
.app-body { background: var(--bg); }

/* Fixed full-height sidebar */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--surface) 0%, color-mix(in srgb, var(--surface) 96%, var(--bg)) 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  z-index: 30;
  overflow-y: auto;
}

/* Content column fills the rest of the viewport, right of the sidebar */
.app-column {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Sidebar content ---------- */
.sidebar-brand {
  display: flex; gap: 12px; align-items: center;
  padding: 4px 8px 18px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 14px;
}
.sidebar-brand-icon {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 11px;
  border: 1px solid var(--border);
  font-size: 1.2rem;
}
.sidebar-brand-text { min-width: 0; }
.sidebar-name { font-weight: 720; font-size: 1rem; letter-spacing: -0.012em; }
.sidebar-tag {
  font-size: .74rem; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.sidebar-section { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.sidebar-section-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-dim); font-weight: 600;
  padding: 8px 10px 6px;
}
.sidebar-item {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: .9rem; font-weight: 540;
  transition: background .14s ease, color .14s ease, box-shadow .14s ease;
}
/* Left accent bar for the active item (per-product accent set inline in _sidebar) */
.sidebar-item::before {
  content: ""; position: absolute; left: 4px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 0; border-radius: 2px; background: transparent;
  transition: height .18s ease;
}
.sidebar-item.is-active::before { height: 18px; }
.sidebar-item:hover { background: var(--surface-2); color: var(--text); }
.sidebar-item.is-active {
  background: var(--primary-soft);
  color: var(--primary-hover);
  font-weight: 640;
  padding-left: 14px;
}
.sidebar-item.is-active .sidebar-item-icon { filter: none; }
.sidebar-item-icon { font-size: 1rem; width: 20px; display: inline-flex; justify-content: center; color: var(--text-dim); }
.sidebar-item.is-active .sidebar-item-icon { color: inherit; }
.sidebar-item-label { flex: 1; }

.sidebar-footer { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.sidebar-item--muted { color: var(--text-dim); font-size: .82rem; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  background: rgba(255,255,255,.78);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 1px 3px rgba(16,24,40,.03);
}
.topbar-inner {
  height: 100%;
  padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 740; letter-spacing: -0.014em; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; line-height: 0; }
.brand-mark svg { width: 26px; height: 26px; display: block; }
.brand-name { font-size: 1.02rem; letter-spacing: -0.018em; }
.brand-center { justify-content: center; margin-bottom: 8px; }
.topnav { display: flex; align-items: center; gap: 12px; }
.eyebrow .brand-mark { width: 16px; height: 16px; margin-right: 4px; vertical-align: -3px; }
.eyebrow .brand-mark svg { width: 16px; height: 16px; }
.eyebrow { display: inline-flex; align-items: center; gap: 2px; }
footer .brand-mark { width: 15px; height: 15px; margin-right: 3px; vertical-align: -3px; }
footer .brand-mark svg { width: 15px; height: 15px; }
.user-pill {
  color: var(--text-muted); font-size: .82rem; font-weight: 540;
  padding: 6px 11px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text);
  font: inherit; font-weight: 580;
  cursor: pointer;
  transition: transform .05s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--primary); border-color: transparent; color: #fff;
  box-shadow: none;
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: transparent;
  box-shadow: none;
}
.btn-primary:active { box-shadow: none; }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-lg { padding: 12px 22px; font-size: 1rem; }
.btn-sm { padding: 6px 12px; font-size: .82rem; }
.btn-block { width: 100%; }

/* ---------- Generic page (landing/auth fallbacks) ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 48px 28px 96px; }
.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 18px 28px;
}
.footer-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  color: var(--text-dim); font-size: .84rem;
}

/* ---------- App main content ---------- */
.app-main {
  flex: 1;
  padding: 32px 36px 64px;
}
.page-pad { max-width: 1280px; margin: 0 auto; }

/* ---------- Reusable bits ---------- */
.eyebrow {
  display: inline-block;
  color: var(--primary); font-size: .76rem; font-weight: 660;
  letter-spacing: .09em; text-transform: uppercase; margin-bottom: 10px;
}
.hero-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.hero-row h2 { margin: 0; }
.hero-row p { margin: 6px 0 0; }
.link-more { color: var(--primary); font-size: .85rem; font-weight: 560; }
.link-more:hover { color: var(--primary-hover); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-rest);
  margin-bottom: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h3 { margin: 0; }

.link-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 8px; }
.link-list a { color: var(--primary); font-weight: 540; }

/* Stat + metric cards */
.stat-grid, .dash-metrics, .metric-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 22px;
}
.stat-card, .dash-metric, .metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-rest);
  transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card:hover, .dash-metric:hover, .metric-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.stat-num, .dash-metric-value, .metric-value {
  font-size: 1.8rem; font-weight: 740; letter-spacing: -0.025em; margin: 4px 0;
}
.stat-label, .dash-metric-label, .metric-label {
  color: var(--text-dim); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
}
.dash-metric-delta, .metric-delta { font-size: .82rem; font-weight: 620; }
.dash-metric-delta.pos, .metric-delta.pos { color: var(--success); }
.dash-metric-delta.neg, .metric-delta.neg { color: var(--danger); }
.metric-explain { margin: 10px 0 0; }

/* Badges */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 620; letter-spacing: .01em;
  border: 1px solid transparent;
}
.badge-success { background: var(--success-soft); color: #047857; border-color: rgba(16,185,129,.25); }
.badge-warning { background: var(--warning-soft); color: #b45309; border-color: rgba(245,158,11,.25); }
.badge-muted   { background: var(--surface-3); color: var(--text-muted); border-color: var(--border); }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: .9rem; }
.data-table th, .data-table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border-soft); }
.data-table th { color: var(--text-dim); font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; background: var(--surface-2); }
.data-table th:first-child { border-top-left-radius: var(--radius-sm); }
.data-table th:last-child  { border-top-right-radius: var(--radius-sm); }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ---------- Landing hero + product grid ---------- */
.hero {
  padding: 56px 28px 32px;
  background: var(--bg);
}
.hero-inner { max-width: 1200px; margin: 0 auto; }
.hero h1, .hero-h1 {
  margin-bottom: 18px;
  color: var(--text);
}
.lead { font-size: 1.15rem; color: var(--text-muted); max-width: 640px; margin-bottom: 26px; }
.cta-row { display: flex; gap: 12px; flex-wrap: wrap; }

.product-grid {
  max-width: 1200px; margin: 40px auto 0; padding: 0 28px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px;
}
.product-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow-rest);
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
  overflow: hidden;
}
.product-card::after {
  content: none;
}
.product-card > * { position: relative; z-index: 1; }
.product-card-head { display: flex; align-items: center; gap: 12px; }
.product-card-icon {
  font-size: 1.5rem; width: 46px; height: 46px;
  display: grid; place-items: center; border-radius: 12px;
  color: white;
  background: var(--primary);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}
.product-card-head .tag { font-weight: 680; letter-spacing: -0.01em; }
.product-card h3 { margin: 0; }
.product-card--link:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, white);
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(16,24,40,.08), 0 16px 36px -10px color-mix(in srgb, var(--accent) 35%, transparent);
}
.feature-list { list-style: none; padding: 0; margin: 4px 0 8px; display: flex; flex-direction: column; gap: 7px; }
.feature-list li { position: relative; padding-left: 24px; color: var(--text-muted); font-size: .9rem; }
.feature-list li::before { content: "✓"; position: absolute; left: 0; top: 0; color: var(--accent); font-weight: 700; }

/* ---------- Launcher / dashboard ---------- */
.launcher { max-width: 1200px; margin: 0 auto; padding: 16px 28px 80px; }
.launcher-head { margin-bottom: 28px; }
.launcher-head h1 { font-size: 2rem; margin: 6px 0 0; }
.launcher-head p { margin: 8px 0 0; }

.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 26px; }
.dash-head h1 { font-size: 1.85rem; margin: 4px 0 0; }
.dash-head p { margin: 6px 0 0; }

.dash-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; margin-bottom: 20px; }

.activity-list, .template-list, .brief-list, .anomaly-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.activity-item { display: flex; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border-soft); }
.activity-item:last-child { border-bottom: none; }
.activity-avatar {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: .82rem; font-weight: 680; color: white;
  background: linear-gradient(140deg, color-mix(in srgb, var(--a) 85%, white), color-mix(in srgb, var(--a) 70%, black));
  box-shadow: 0 2px 6px -2px color-mix(in srgb, var(--a) 55%, transparent);
}
.activity-body { flex: 1; min-width: 0; }
.activity-text { font-size: .9rem; }
.activity-product { font-weight: 620; color: var(--text); }
.activity-product:hover { color: var(--primary); }
.activity-time { margin-top: 2px; }

.template-item { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border-soft); }
.template-item:last-child { border-bottom: none; }
.template-icon { font-size: 1.05rem; }
.template-body { flex: 1; min-width: 0; }
.template-name { font-weight: 620; font-size: .9rem; }

.product-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.product-strip-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s ease, transform .15s ease, background .15s ease;
}
.product-strip-card:hover { border-color: color-mix(in srgb, var(--accent) 50%, white); transform: translateY(-1px); background: var(--surface); box-shadow: var(--shadow-rest); }
.product-strip-icon {
  font-size: 1.2rem; width: 36px; height: 36px; flex-shrink: 0;
  display: grid; place-items: center; border-radius: 10px; color: white;
  background: linear-gradient(140deg, color-mix(in srgb, var(--accent) 88%, white), color-mix(in srgb, var(--accent) 72%, black));
  box-shadow: 0 3px 8px -3px color-mix(in srgb, var(--accent) 55%, transparent);
}
.product-strip-card .name { font-weight: 640; }

/* ---------- Auth ---------- */
.auth-body { background: var(--bg); min-height: 100vh; }
.auth-shell { max-width: 430px; margin: 7vh auto; padding: 24px; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px;
  box-shadow: var(--shadow-lg);
}
.auth-card h1 { font-size: 1.55rem; margin-bottom: 20px; }
.auth-card label { display: block; margin-bottom: 14px; font-size: .86rem; color: var(--text-muted); font-weight: 540; }
.auth-card input {
  display: block; width: 100%; margin-top: 6px;
  padding: 10px 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: inherit; transition: border-color .15s ease, box-shadow .15s ease;
}
.auth-card input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.auth-card .btn { margin-top: 6px; }
.auth-switch { margin-top: 18px; text-align: center; }
.auth-switch a { color: var(--primary); font-weight: 540; }

.alert { padding: 10px 12px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: .86rem; }
.alert-error { background: var(--danger-soft); border: 1px solid rgba(239,68,68,.3); color: #b91c1c; }

/* ---------- Product switcher dropdown ---------- */
.product-switcher { position: relative; }
.switcher-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit; font-weight: 600; font-size: .88rem;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.switcher-trigger:hover { border-color: var(--primary); background: var(--surface-2); }
.switcher-icon { font-size: 1rem; line-height: 1; display: inline-flex; align-items: center; color: var(--primary); }
.switcher-caret { color: var(--text-dim); transition: transform .15s ease; }
.switcher-trigger[aria-expanded="true"] .switcher-caret { transform: rotate(180deg); }

.switcher-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 300px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px; z-index: 50;
  animation: switcher-in .12s ease;
}
@keyframes switcher-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.switcher-menu-head { padding: 7px 10px 5px; color: var(--text-dim); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.switcher-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
  transition: background .12s ease;
}
.switcher-item:hover { background: var(--surface-2); border-left-color: var(--accent); }
.switcher-item.is-active { background: var(--surface-2); border-left-color: var(--accent); }
.switcher-item-icon {
  font-size: 1rem; width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px; color: white;
  background: linear-gradient(140deg, color-mix(in srgb, var(--accent) 88%, white), color-mix(in srgb, var(--accent) 72%, black));
  box-shadow: 0 2px 6px -2px color-mix(in srgb, var(--accent) 55%, transparent);
}
.switcher-item-body { display: flex; flex-direction: column; flex: 1; }
.switcher-item-name { font-weight: 600; font-size: .9rem; }
.switcher-item-tag { color: var(--text-dim); font-size: .76rem; }
.switcher-item-check { color: var(--accent); font-size: .9rem; display: inline-flex; }
.switcher-item-check .icon { font-size: 1em; }

/* ---------- Cuestudio composer ---------- */
.composer-canvas {
  display: flex; align-items: stretch; gap: 10px; flex-wrap: wrap;
  padding: 26px;
  background:
    var(--surface),
    repeating-linear-gradient(0deg, transparent 0 19px, var(--border-soft) 19px 20px),
    repeating-linear-gradient(90deg, transparent 0 19px, var(--border-soft) 19px 20px);
  background-blend-mode: normal, screen, screen;
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.composer-node {
  flex: 1 1 160px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 14px; min-height: 82px;
  box-shadow: var(--shadow-sm);
}
.composer-node--input  { border-left: 3px solid var(--success); }
.composer-node--output { border-left: 3px solid var(--warning); }
.composer-node p { margin: 6px 0 0; }
.composer-arrow { align-self: center; color: var(--text-dim); font-size: 1.2rem; }

/* ---------- Cuestudio engine embed (Orchestrate) ---------- */
.orchestrate-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 16px;
}
.orchestrate-head h2 { margin: 0; }
.orchestrate-head p { margin: 6px 0 0; }

.engine-frame {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  height: calc(100vh - 230px);
  min-height: 420px;
  overflow: hidden;
}
.engine-iframe {
  width: 100%; height: 100%;
  border: 0;
  display: block;
}
.engine-loading, .engine-down {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px;
}
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.engine-down-card {
  max-width: 460px;
  text-align: center;
  padding: 28px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.engine-down-icon { font-size: 2rem; margin-bottom: 6px; }
.engine-down-card h3 { margin: 0 0 8px; }
.engine-down-card pre {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 12px 0;
  overflow-x: auto;
}
.engine-down-card code { background: none; padding: 0; }

/* ---------- Cuesearch ---------- */
.search-form { display: flex; gap: 10px; margin-bottom: 20px; }
.search-form input {
  flex: 1; padding: 13px 16px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: inherit; font-size: 1rem;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.search-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.answer-card .answer-head { display: flex; align-items: center; justify-content: space-between; }
.citation-list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 10px; }
.citation-list li { padding-left: 14px; border-left: 2px solid var(--border); }
.cite-title { color: var(--primary); font-weight: 560; }

/* ---------- Cuepulse ---------- */
.anomaly-list li { padding: 11px 0 11px 14px; border-left: 2px solid var(--warning); border-bottom: 1px solid var(--border-soft); }
.anomaly-list li:last-child { border-bottom: none; }
.anomaly-metric { font-weight: 620; }
.anomaly-root { margin-top: 4px; }

.brief-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.brief-title { font-weight: 640; }
.brief-card p { margin: 8px 0 0; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: translateX(0); }
  .app-column { margin-left: 0; }
  .dash-grid { grid-template-columns: 1fr; }
  .app-main { padding: 24px 18px 56px; }
  h1 { font-size: 1.7rem; }
}
