/* sqep.css — SQEP-Zero Design System v2
   Unified stylesheet for all sqep.ai pages.
   ================================================================ */

/* ══════════════════════════════════════════════════════════════
   1. DESIGN TOKENS
   ══════════════════════════════════════════════════════════════ */
:root {
  /* Colors — Light (default) */
  --bg:               #fafbfe;
  --bg-subtle:        #f3f5fb;
  --bg-gradient:      linear-gradient(160deg, #f0f2ff 0%, #faf5ff 40%, #f0fdf4 100%);
  --surface:          #ffffff;
  --surface-elevated: #ffffff;
  --surface-glass:    rgba(255, 255, 255, 0.72);
  --text:             #0c0e16;
  --text-secondary:   #3b3f51;
  --text-muted:       #6b7084;
  --text-accent:      #5046e5;

  --border:           rgba(15, 23, 42, 0.07);
  --border-strong:    rgba(15, 23, 42, 0.12);
  --border-hover:     rgba(79, 70, 229, 0.3);

  --accent:           #5046e5;
  --accent-light:     #7c6cff;
  --accent-subtle:    #a78bfa;
  --accent-bg:        rgba(80, 70, 229, 0.06);
  --accent-glow:      rgba(80, 70, 229, 0.12);

  --success:          #10b981;
  --warning:          #f59e0b;
  --error:            #ef4444;

  /* Shadows */
  --shadow-xs:        0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-sm:        0 1px 3px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.02);
  --shadow-md:        0 4px 16px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.03);
  --shadow-lg:        0 12px 48px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.04);
  --shadow-xl:        0 24px 64px rgba(15, 23, 42, 0.10), 0 8px 24px rgba(15, 23, 42, 0.05);
  --shadow-glow:      0 0 40px var(--accent-glow);
  --shadow-float:     0 10px 40px -10px rgba(15, 23, 42, 0.08);

  /* Radii */
  --radius-xs:        6px;
  --radius-sm:        8px;
  --radius-md:        12px;
  --radius-lg:        16px;
  --radius-xl:        20px;
  --radius-2xl:       24px;
  --radius-full:      999px;

  /* Layout */
  --max-w:            1200px;
  --max-w-narrow:     840px;
  --header-h:         56px;
  --spacing-page:     24px;

  /* Typography */
  --font-sans:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:        'SF Mono', Monaco, 'Cascadia Code', 'Fira Code', monospace;

  /* Transitions */
  --ease-out:         cubic-bezier(0.23, 1, 0.32, 1);
  --ease-spring:      cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast:    0.15s;
  --duration-normal:  0.25s;
  --duration-slow:    0.4s;

  /* Compat aliases */
  --panel:            var(--surface);
  --panel-2:          var(--surface-elevated);
  --muted:            var(--text-muted);
  --hair:             var(--border);
  --ring:             var(--accent-glow);
  --glass:            var(--surface-glass);
}

/* Dark theme */
:root[data-theme="dark"] {
  --bg:               #08090f;
  --bg-subtle:        #0e1017;
  --bg-gradient:      linear-gradient(160deg, #0c0d1a 0%, #08090f 40%, #0a0f0e 100%);
  --surface:          #111318;
  --surface-elevated: #1a1c24;
  --surface-glass:    rgba(17, 19, 24, 0.72);
  --text:             #eef0f6;
  --text-secondary:   #b8bdd0;
  --text-muted:       #7a7f96;
  --text-accent:      #a5b4fc;

  --border:           rgba(255, 255, 255, 0.06);
  --border-strong:    rgba(255, 255, 255, 0.10);
  --border-hover:     rgba(165, 180, 252, 0.3);

  --accent:           #818cf8;
  --accent-light:     #a5b4fc;
  --accent-subtle:    #6366f1;
  --accent-bg:        rgba(129, 140, 248, 0.08);
  --accent-glow:      rgba(129, 140, 248, 0.15);

  --shadow-xs:        0 1px 2px rgba(0, 0, 0, 0.15);
  --shadow-sm:        0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md:        0 4px 16px rgba(0, 0, 0, 0.25);
  --shadow-lg:        0 12px 48px rgba(0, 0, 0, 0.35);
  --shadow-xl:        0 24px 64px rgba(0, 0, 0, 0.4);
  --shadow-glow:      0 0 60px rgba(129, 140, 248, 0.15);
  --shadow-float:     0 10px 40px -10px rgba(0, 0, 0, 0.35);

  --panel:            var(--surface);
  --panel-2:          var(--surface-elevated);
  --muted:            var(--text-muted);
  --hair:             var(--border);
  --ring:             rgba(129, 140, 248, 0.4);
  --glass:            var(--surface-glass);
}

/* ══════════════════════════════════════════════════════════════
   2. RESET / BASE
   ══════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--duration-normal) ease, color var(--duration-normal) ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--bg-gradient);
  opacity: 0.5;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: none; }
img, video { max-width: 100%; height: auto; }

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

/* ══════════════════════════════════════════════════════════════
   3. TYPOGRAPHY
   ══════════════════════════════════════════════════════════════ */
h1, h2, h3, h4 {
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.25;
  color: var(--text);
}

h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); font-weight: 700; }
h2 { font-size: clamp(1.25rem, 3vw, 1.75rem); }
h3 { font-size: 1.1rem; }
h4 { font-size: 0.95rem; }

.muted    { color: var(--text-muted); }
.accent   { color: var(--text-accent); }
.lead     { color: var(--text-secondary); margin: 8px 0 0; line-height: 1.7; font-size: 1.05rem; }
.mono     { font-family: var(--font-mono); font-size: 0.9em; }

blockquote {
  margin: 12px 0;
  padding: 14px 18px;
  border-left: 3px solid var(--accent);
  background: var(--surface-elevated);
  border-radius: var(--radius-sm);
  font-style: normal;
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--accent-bg);
  padding: 2px 7px;
  border-radius: 5px;
  letter-spacing: -0.01em;
}

/* ══════════════════════════════════════════════════════════════
   4. TOPBAR
   ══════════════════════════════════════════════════════════════ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--spacing-page);
  background: var(--surface-glass);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1rem;
}

.brand .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  box-shadow: 0 0 10px var(--accent-glow);
  animation: sqep-pulse 2.5s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes sqep-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

.brand-tag {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 2px;
  letter-spacing: 0.01em;
}

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

.only-mobile { display: none; }

/* ══════════════════════════════════════════════════════════════
   5. BUTTONS
   ══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  white-space: nowrap;
  letter-spacing: -0.01em;
  user-select: none;
}

.btn:hover {
  border-color: var(--border-hover);
  background: var(--accent-bg);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

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

.btn.small {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: var(--radius-xs);
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border: none;
  color: white;
  font-weight: 600;
  box-shadow: var(--shadow-sm), 0 0 20px var(--accent-glow);
  letter-spacing: -0.01em;
}

.btn.primary:hover {
  filter: brightness(1.08);
  box-shadow: var(--shadow-md), 0 0 32px var(--accent-glow);
  transform: translateY(-2px);
}

.btn.primary:active {
  transform: translateY(0);
  filter: brightness(0.95);
}

.btn.block { width: 100%; }

.btn.ghost {
  border: none;
  background: transparent;
  color: var(--text-muted);
}

.btn.ghost:hover {
  background: var(--accent-bg);
  color: var(--text);
}

/* ══════════════════════════════════════════════════════════════
   6. SEGMENTED CONTROLS
   ══════════════════════════════════════════════════════════════ */
.segmented {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  background: var(--accent-bg);
  border-radius: var(--radius-sm);
}

.segmented select {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 12px;
  font-family: var(--font-sans);
  padding: 4px 6px;
  cursor: pointer;
}

.segmented select:focus { outline: none; }

/* ══════════════════════════════════════════════════════════════
   7. LAYOUT
   ══════════════════════════════════════════════════════════════ */
.container,
.wrap {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--spacing-page);
}

.wrap-narrow {
  max-width: var(--max-w-narrow);
  margin: 0 auto;
  padding: 0 var(--spacing-page);
}

/* ══════════════════════════════════════════════════════════════
   8. CARDS
   ══════════════════════════════════════════════════════════════ */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all var(--duration-normal) var(--ease-out);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  background: linear-gradient(135deg, var(--accent-bg), transparent 60%);
  transition: opacity var(--duration-normal) ease;
  pointer-events: none;
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  transform: translateY(-3px);
}

.card:hover::before { opacity: 1; }

.card h3 { margin: 0; font-size: 1.05rem; position: relative; }
.card p   { margin: 0; color: var(--text-muted); flex: 1; position: relative; line-height: 1.65; }
.card .actions { margin-top: auto; position: relative; }
.card ul  { margin: 8px 0 8px 18px; position: relative; }
.card li  { margin: 4px 0; line-height: 1.6; }

/* Card lite — lighter variant for explainer sections */
.card-lite {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color var(--duration-fast) ease;
}

.card-lite:hover { border-color: var(--border-hover); }
.card-lite h3 { margin: 4px 0 12px; }
.card-lite ul { margin: 12px 0 12px 20px; }
.card-lite li { margin: 6px 0; line-height: 1.6; }

/* Pillar card — compact info card */
.pillar-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--surface);
  transition: all var(--duration-fast) ease;
}

.pillar-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

.pillar-card h3 { margin: 0 0 6px; font-size: 14px; }
.pillar-card p  { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-muted); }

/* ══════════════════════════════════════════════════════════════
   9. SECTIONS / PANELS
   ══════════════════════════════════════════════════════════════ */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  padding: 32px;
  margin: 32px 0;
}

.section h2 { margin: 0 0 8px; }
.section ul, .section ol { margin: 16px 0; padding-left: 24px; }
.section li { margin: 8px 0; }

/* Panel — for tool forms (SZ encrypt/decrypt/wrap) */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin: 16px 0;
  transition: border-color var(--duration-fast) ease;
}

.panel:hover { border-color: var(--border-hover); }
.panel h2 { margin: 0 0 12px; font-size: 1.1rem; }

/* ══════════════════════════════════════════════════════════════
   10. BADGES & PILLS
   ══════════════════════════════════════════════════════════════ */
.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-sans);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  white-space: nowrap;
  letter-spacing: -0.01em;
  transition: all var(--duration-fast) ease;
}

.badge:hover {
  border-color: var(--border-hover);
  background: var(--accent-bg);
}

.badge .dot,
.badge i.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* Pill — smaller tag-style badges */
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 6px;
}

.pill {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  color: var(--text-muted);
  letter-spacing: -0.01em;
}

/* ══════════════════════════════════════════════════════════════
   11. DETAILS / FAQ / MANIFESTO
   ══════════════════════════════════════════════════════════════ */
details.drop {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin: 8px 0;
  overflow: hidden;
  transition: border-color var(--duration-fast) ease;
}

details.drop:hover { border-color: var(--border-hover); }

details.drop summary {
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background var(--duration-fast) ease;
  user-select: none;
}

details.drop summary::-webkit-details-marker { display: none; }

details.drop summary::before {
  content: "\25B8";
  font-size: 11px;
  color: var(--text-muted);
  transition: transform var(--duration-fast) ease;
  flex-shrink: 0;
}

details.drop[open] summary::before { transform: rotate(90deg); }
details.drop summary:hover { background: var(--accent-bg); }
details.drop .content { padding: 0 18px 18px; }
details.drop p { margin: 6px 0; color: var(--text-muted); line-height: 1.7; }

/* Manifesto collapsible */
details.manifesto {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 8px 12px;
}

details.manifesto[open] { padding-bottom: 14px; }

details.manifesto > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  padding: 8px 4px;
  user-select: none;
}

details.manifesto > summary::-webkit-details-marker { display: none; }
.chev { transition: transform var(--duration-fast) ease; }
details[open] .chev { transform: rotate(90deg); }

/* ══════════════════════════════════════════════════════════════
   12. FORMS
   ══════════════════════════════════════════════════════════════ */
input[type="file"],
input[type="password"],
input[type="text"],
input[type="email"],
textarea,
select {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text);
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

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

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

/* Config dialog */
dialog {
  border: none;
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text);
  padding: 24px;
  max-width: min(480px, 90vw);
  box-shadow: var(--shadow-xl);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
}

.config-form { display: flex; flex-direction: column; gap: 16px; }
.config-form h3 { margin: 0 0 8px; }
.config-form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--text-muted); }
.config-form input { padding: 12px 14px; }
.config-form .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ══════════════════════════════════════════════════════════════
   13. GRID LAYOUTS
   ══════════════════════════════════════════════════════════════ */
.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* Two-column explainer */
.explain {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr 1fr;
  margin: 24px 0 16px;
}

/* Two-column grid */
.grid-2 {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 16px;
  margin-top: 12px;
}

/* Three-column grid */
.columns-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

/* Manifesto bilingual grid */
.manifest-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr 1fr;
}

.manifest-grid article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.manifest-grid h3 { margin: 6px 0 8px; }
.manifest-grid h4 { margin: 8px 0 10px; color: var(--text-muted); }
.manifest-grid p  { margin: 10px 0; line-height: 1.6; }
.manifest-grid ul { margin: 8px 0 8px 18px; }
.manifest-grid li { margin: 4px 0; }

.manifest-grid blockquote {
  margin: 12px 0;
  padding: 10px 14px;
  border-left: 3px solid var(--accent);
  background: var(--surface-elevated);
  border-radius: var(--radius-sm);
}

/* Pillar list grid */
.pillars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 16px 0;
}

.pillars li {
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.5;
  transition: all var(--duration-fast) ease;
}

.pillars li:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

/* Feature grid */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.feature {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--surface);
  transition: all var(--duration-fast) ease;
}

.feature:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

.feature h3 { margin: 0 0 6px; }
.feature p  { margin: 0; color: var(--text-muted); line-height: 1.5; }

/* Diagram list (Zoe) */
.diagram-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  font-size: 13px;
}

.diagram-list li { margin: 3px 0; }

/* ══════════════════════════════════════════════════════════════
   14. NOTICE / HINTS / RESULT
   ══════════════════════════════════════════════════════════════ */
.notice     { font-size: 13px; color: var(--text-muted); margin: 8px 0; }
.hint       { font-size: 12px; color: var(--text-muted); }
.result     { font-size: 13px; margin: 8px 0; }
.subheading { font-size: 14px; font-weight: 600; margin: 16px 0 8px; }

/* ══════════════════════════════════════════════════════════════
   15. HOMEPAGE
   ══════════════════════════════════════════════════════════════ */
.hero { margin: 40px auto 20px; }
.hero h1 { margin: 12px 0 16px; }
.cta { display: flex; gap: 10px; flex-wrap: wrap; margin: 24px 0 8px; }

/* Matrix banner */
.matrix-banner {
  position: relative;
  width: 100%;
  height: clamp(120px, 22vh, 240px);
  background: var(--bg);
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}

.matrix-banner canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.matrix-banner::before,
.matrix-banner::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 50px;
  pointer-events: none;
  z-index: 1;
}

.matrix-banner::before { top: 0; background: linear-gradient(var(--bg), transparent); }
.matrix-banner::after  { bottom: 0; background: linear-gradient(transparent, var(--bg)); }

/* ══════════════════════════════════════════════════════════════
   16. CHAT — Quaggy
   ══════════════════════════════════════════════════════════════ */

/* Chat page body layout */
body.chat-page {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Chat header */
.chat-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-glass);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border-bottom: 1px solid var(--border);
}

.chat-brand { display: flex; align-items: center; gap: 12px; }

.chat-logo {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #ec4899);
  color: white;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-size: 15px;
  box-shadow: 0 2px 10px var(--accent-glow);
  position: relative;
  flex-shrink: 0;
}

.chat-titles h1 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.chat-titles p  { margin: 0; font-size: 11px; color: var(--text-muted); }

/* Chat status dot overlay (class set by app.js) */
.status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff5252;
  border: 2px solid var(--surface-glass);
  transition: background var(--duration-fast) ease;
}

.status-dot.online {
  background: #4bd37b;
  animation: chatDotPulse 2.2s ease-out infinite;
}
.status-dot.connecting { background: #f6c546; }
.status-dot.offline    { background: #ff5252; }
.status-dot.error      { background: #ff6b7d; }

@keyframes chatDotPulse {
  0%   { box-shadow: 0 0 0 0 rgba(75,211,123,0); }
  60%  { box-shadow: 0 0 0 6px rgba(75,211,123,.2); }
  100% { box-shadow: 0 0 0 8px rgba(75,211,123,0); }
}

.chat-controls { display: flex; gap: 6px; align-items: center; }

.chat-controls button,
.chat-controls select {
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 5px 10px;
  border-radius: var(--radius-full);
  transition: all var(--duration-fast) ease;
}
.chat-controls button:hover,
.chat-controls select:hover {
  background: var(--accent-bg);
  border-color: var(--border-hover);
}
.chat-controls button:active { transform: scale(0.96); }

.chat-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* Chat main area */
.chat-main {
  flex: 1;
  width: 100%;
  max-width: var(--max-w-narrow);
  margin: 0 auto;
  padding: 20px 20px 130px;
  display: flex;
  flex-direction: column;
}

.chat-intro {
  text-align: center;
  margin: 40px 0;
  opacity: 0;
  animation: chatFadeIn 0.8s forwards;
}

/* Chat messages */
.chat { display: flex; flex-direction: column; gap: 16px; padding: 20px 0; }

.msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 85%;
  animation: chatFadeSlide 0.3s var(--ease-out) forwards;
}

.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.bot  { align-self: flex-start; align-items: flex-start; }

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

@keyframes chatFadeIn { to { opacity: 1; } }

.msg .meta {
  font-size: 10px;
  color: var(--text-muted);
  margin: 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
}

.msg .bubble {
  padding: 12px 18px;
  border-radius: 18px;
  line-height: 1.6;
  font-size: 15px;
  box-shadow: var(--shadow-xs);
  word-break: break-word;
  position: relative;
}
.msg.user .bubble { white-space: pre-wrap; }

.msg.user .bubble {
  background: var(--text);
  color: var(--bg);
  border-bottom-right-radius: 4px;
}

.msg.bot .bubble {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg .bubble code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
}

:root[data-theme="dark"] .msg .bubble code { background: rgba(255, 255, 255, 0.08); }

/* Rendered markdown inside bot bubbles */
.msg.bot .bubble p { margin: 0.4em 0; }
.msg.bot .bubble p:first-child { margin-top: 0; }
.msg.bot .bubble p:last-child { margin-bottom: 0; }
.msg.bot .bubble h3, .msg.bot .bubble h4, .msg.bot .bubble h5, .msg.bot .bubble h6 {
  margin: 0.8em 0 0.3em; font-size: 1em; font-weight: 600;
}
.msg.bot .bubble h3 { font-size: 1.1em; }
.msg.bot .bubble ul { margin: 0.4em 0; padding-left: 1.4em; }
.msg.bot .bubble li { margin: 0.2em 0; }
.msg.bot .bubble pre {
  background: rgba(0,0,0,0.06); border-radius: 8px; padding: 10px 14px;
  overflow-x: auto; margin: 0.6em 0; font-size: 0.88em;
}
:root[data-theme="dark"] .msg.bot .bubble pre { background: rgba(255,255,255,0.06); }
.msg.bot .bubble pre code { background: none; padding: 0; }
.msg.bot .bubble strong { font-weight: 600; }
.msg.bot .bubble br { display: block; content: ""; margin: 0.2em 0; }

/* Chat embed (labs) */
.msg.embed { max-width: 100%; width: 100%; padding: 0; }

.embed-wrap {
  width: 100%;
  max-width: 750px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  margin-top: 8px;
  box-shadow: var(--shadow-float);
}

.embed-header {
  background: var(--bg-subtle);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-muted);
  font-weight: 500;
}

.embed-wrap iframe {
  width: 100%;
  height: 450px;
  border: none;
  display: block;
  background: var(--surface);
}

/* Chat composer (floating pill) */
.composer-container {
  position: fixed;
  bottom: 20px;
  left: 0;
  right: 0;
  padding: 0 20px;
  display: flex;
  justify-content: center;
  z-index: 100;
}

form.composer {
  width: 100%;
  max-width: var(--max-w-narrow);
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  padding: 5px;
  border-radius: 22px;
  display: flex;
  gap: 6px;
  align-items: flex-end;
  box-shadow: var(--shadow-float);
  transition: all var(--duration-fast) ease;
}

form.composer:focus-within {
  box-shadow: 0 0 0 2px var(--accent-glow), var(--shadow-float);
  border-color: var(--accent);
  transform: translateY(-2px);
}

/* Old-style static composer (homepage) */
.composer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  gap: 12px;
  padding: 16px var(--spacing-page) calc(16px + env(safe-area-inset-bottom));
  background: var(--surface-glass);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(20px);
}

.chat-textarea {
  flex: 1;
  border: none;
  background: transparent;
  padding: 12px 14px;
  font-size: 15px;
  color: var(--text);
  resize: none;
  max-height: 160px;
  min-height: 24px;
  font-family: var(--font-sans);
  line-height: 1.4;
}

.chat-textarea:focus { outline: none; }
.chat-textarea::placeholder { color: var(--text-muted); }

.chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border: none;
  color: white;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  padding: 0;
  margin-bottom: 2px;
  margin-right: 2px;
}

.chat-send:hover {
  transform: scale(1.06);
  filter: brightness(1.1);
  box-shadow: 0 2px 12px var(--accent-glow);
}

.chat-send svg { width: 18px; height: 18px; fill: currentColor; transform: translateX(1px); }

/* Copy button */
.copy-btn {
  opacity: 0;
  transition: opacity var(--duration-fast) ease;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 2px 8px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}

.msg:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: var(--surface); color: var(--text); }
.copy-wrap { display: flex; margin-top: 4px; }
.msg.user .copy-wrap { justify-content: flex-end; }
.msg.bot  .copy-wrap { justify-content: flex-start; }

/* Settings side panel */
.settings-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  z-index: 199;
  opacity: 0;
  transition: opacity var(--duration-normal) ease;
  pointer-events: none;
  backdrop-filter: blur(2px);
}
.settings-backdrop.open { opacity: 1; pointer-events: auto; }

.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  z-index: 200;
  background: var(--surface);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform var(--duration-normal) var(--ease-out);
  overflow-y: auto;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
}
.settings-panel.open { transform: translateX(0); }

.sp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
}

.sp-close {
  background: none;
  border: none;
  font-size: 20px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}
.sp-close:hover { background: var(--accent-bg); color: var(--text); }

.sp-section { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.sp-section:last-child { border-bottom: none; }

.sp-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
  transition: color var(--duration-fast) ease;
}

.sp-section-title:hover { color: var(--text); }
.sp-section-title .chevron { transition: transform var(--duration-fast) ease; font-size: 10px; }
.sp-section-title.collapsed .chevron { transform: rotate(-90deg); }

.sp-section-body { display: flex; flex-direction: column; gap: 10px; }
.sp-section-body.collapsed { display: none; }

.sp-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.sp-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

.sp-row select,
.sp-row input[type="text"] {
  padding: 5px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text);
  font-size: 12px;
  font-family: var(--font-sans);
}

.sp-row input[type="text"] { flex: 1; }

.sp-vision-inputs { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.sp-vision-inputs input,
.sp-vision-inputs textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-sans);
}
.sp-vision-inputs textarea { resize: none; }

.sp-tool-btn {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  font-family: var(--font-sans);
}
.sp-tool-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-accent);
  background: var(--accent-bg);
}

/* Auth dialog */
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form h3 { margin: 0; }
.auth-form label {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.auth-form select,
.auth-form input {
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  color: var(--text);
  font-family: var(--font-sans);
}
.auth-form input:focus,
.auth-form select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.auth-form .hint { font-size: 11px; color: var(--text-muted); margin: 0; }
.auth-form .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }

/* ══════════════════════════════════════════════════════════════
   17. ZOE
   ══════════════════════════════════════════════════════════════ */

/* Zoe hero layout */
.zoe-hero {
  margin: 18px auto 10px;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  align-items: flex-start;
}

.zoe-hero .hero-copy h1 {
  margin: 6px 0 8px;
  font-size: 28px;
  letter-spacing: 0.01em;
}
.zoe-hero .hero-copy .lead { color: var(--text-muted); margin: 6px 0 0; line-height: 1.6; }

/* Zoe console */
.zoe-console {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 16px;
  display: grid;
  gap: 10px;
  box-shadow: var(--shadow-md);
  transition: border-color var(--duration-fast) ease;
}

.zoe-console:focus-within {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md), 0 0 0 2px var(--accent-bg);
}

.zoe-console h2 { margin: 0 0 4px; font-size: 16px; }
.zoe-console p.helper { margin: 0; font-size: 13px; color: var(--text-muted); }

.zoe-input-wrap { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.zoe-input-wrap textarea {
  width: 100%;
  min-height: 90px;
  resize: vertical;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text);
  padding: 10px 12px;
  font: 400 13px/1.5 var(--font-sans);
}

.zoe-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
}
.zoe-controls .left { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.zoe-controls select {
  border-radius: var(--radius-full);
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 12px;
  padding: 4px 9px;
  font-family: var(--font-sans);
}
.zoe-meta { font-size: 11px; color: var(--text-muted); }

.zoe-output {
  margin-top: 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  padding: 12px;
  font-size: 13px;
  display: grid;
  gap: 4px;
}

.zoe-output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.zoe-risk {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  letter-spacing: 0.02em;
}

.zoe-risk[data-level="low"]    { color: var(--success); border-color: var(--success); }
.zoe-risk[data-level="medium"] { color: var(--warning); border-color: var(--warning); }
.zoe-risk[data-level="high"]   { color: var(--error);   border-color: var(--error); }

.zoe-output-main { margin-top: 2px; }

.zoe-halo {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light), #ec4899);
  margin: 2px 0 6px;
  opacity: 0.6;
}

/* Zoe gradient strip */
.zoe-strip {
  width: 100%;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(120% 220% at 0% 0%, rgba(80,70,229,0.10), transparent 45%),
    radial-gradient(120% 220% at 100% 0%, rgba(168,85,247,0.08), transparent 45%);
  height: 24px;
}

:root[data-theme="dark"] .zoe-strip {
  background:
    radial-gradient(120% 220% at 0% 0%, rgba(102,204,255,0.2), transparent 45%),
    radial-gradient(120% 220% at 100% 0%, rgba(255,153,255,0.15), transparent 45%);
  opacity: 0.7;
}

/* Zoe wider wrap */
.wrap-zoe { max-width: 1100px; }

/* ══════════════════════════════════════════════════════════════
   18. MOBILE MENU
   ══════════════════════════════════════════════════════════════ */
.mobile-menu {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 90;
  padding: 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.mobile-menu.hidden { display: none; }

/* ══════════════════════════════════════════════════════════════
   19. FOOTER
   ══════════════════════════════════════════════════════════════ */
.footer {
  text-align: center;
  padding: 40px var(--spacing-page) 60px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ══════════════════════════════════════════════════════════════
   20. ACCESSIBILITY
   ══════════════════════════════════════════════════════════════ */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden { display: none !important; }

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

/* ══════════════════════════════════════════════════════════════
   21. RESPONSIVE
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .explain        { grid-template-columns: 1fr; }
  .manifest-grid  { grid-template-columns: 1fr; }
  .grid-2         { grid-template-columns: 1fr; }
  .columns-3      { grid-template-columns: 1fr; }
  .zoe-hero       { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --spacing-page: 16px; }
  .topbar         { padding: 0 16px; }
  .top-actions    { display: none; }
  .only-mobile    { display: inline-flex; }
  .container,
  .wrap           { padding: 0 16px; }
  .section        { padding: 24px 18px; }
  .msg            { max-width: 92%; }
  .hero .cta      { flex-direction: column; }
  .hero           { margin: 24px auto 16px; }
  .settings-panel { width: 100%; }
}

@media (max-width: 600px) {
  .chat-main { padding-bottom: 110px; }
  .chat-header { padding: 0 16px; }
  .chat-intro { margin: 20px 0; }
  .composer-container { bottom: 12px; padding: 0 12px; }
  .desktop-only { display: none !important; }
  .mobile-only  { display: inline-flex !important; }
}

@media (max-width: 480px) {
  .cards          { grid-template-columns: 1fr; }
  .features       { grid-template-columns: 1fr; }
  .pillars        { grid-template-columns: 1fr; }
}

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

/* ══════════════════════════════════════════════════════════════
   22. UTILITY VISIBILITY
   ══════════════════════════════════════════════════════════════ */
.desktop-only { display: flex; }
.mobile-only  { display: none; }
