/* ================================================================
   The Black Room Content — Design System
   Aligné sur https://theblackroom.io (stylenew.css)
   Tokens : Funnel Display (heading) + DM Sans (body), accent rouge #FB0000.
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Funnel+Display:wght@300;400;500;600;700;800&family=DM+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* TBR primary accent */
  --primary:        #FB0000;
  --primary-hover:  #e00000;
  --primary-soft:   rgba(251, 0, 0, 0.12);
  --primary-glow:   rgba(251, 0, 0, 0.35);
  --primary-blend:  #af4949;

  /* TBR neutrals */
  --black:        #000000;
  --near-black:   #050505;
  --raisin:       #1a1a1a;
  --dark-grey:    #2A2A2A;
  --mid-grey:     #606060;
  --light-grey:   #9A9A9A;
  --lighter-grey: #CCCCCC;
  --offwhite:     #f5f5f5;

  /* Status accents (kept) */
  --green-500: #22C55E;
  --red-500:   #FB0000;

  /* Semantic aliases used across components */
  --bg:          var(--near-black);
  --fg:          var(--offwhite);
  --fg-muted:    rgba(245, 245, 245, 0.70);
  --fg-subtle:   rgba(245, 245, 245, 0.50);
  --fg-faint:    rgba(245, 245, 245, 0.32);
  --fg-ghost:    rgba(245, 245, 245, 0.20);

  --surface-1:   rgba(255, 255, 255, 0.02);
  --surface-2:   rgba(255, 255, 255, 0.04);
  --surface-3:   rgba(255, 255, 255, 0.06);
  --surface-4:   rgba(255, 255, 255, 0.10);
  --border-1:    rgba(255, 255, 255, 0.05);
  --border-2:    rgba(255, 255, 255, 0.08);
  --border-3:    rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.20);
  --border-focus: rgba(251, 0, 0, 0.55);

  --grad-brand:  linear-gradient(135deg, var(--primary) 0%, #c00000 60%, var(--primary-blend) 100%);
  --grad-bar:    linear-gradient(90deg, var(--primary), #c00000);
  --grad-text:   linear-gradient(135deg, var(--primary), #ffffff);

  --shadow-glow-brand:        0 4px 24px var(--primary-glow);
  --shadow-glow-brand-strong: 0 8px 32px rgba(251, 0, 0, 0.50);

  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 14px;
  --radius-2xl: 16px;
  --radius-3xl: 20px;
  --radius-full: 9999px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);

  --font-display: 'Funnel Display', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-body:    'DM Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono:    'Courier New', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Legacy aliases (kept so older rules still resolve) */
  --indigo-400: var(--primary);
  --indigo-500: var(--primary);
  --indigo-600: var(--primary);
  --indigo-700: var(--primary-hover);
  --purple-500: var(--primary-blend);
  --purple-600: var(--primary-hover);
  --purple-700: var(--primary-hover);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  font-weight: 400;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

a { color: var(--primary); text-decoration: none; transition: color 150ms var(--ease); }
a:hover { color: var(--primary-hover); }

button { font-family: var(--font-body); }
input, textarea, select { font-family: var(--font-body); }

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* ── Background atmosphere : un halo rouge + un voile gris foncé ── */
.orb {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  border-radius: 50%;
  filter: blur(140px);
}
.orb-1 {
  width: 620px; height: 620px;
  background: var(--primary);
  opacity: 0.10;
  top: -240px; right: -120px;
}
.orb-2 {
  width: 420px; height: 420px;
  background: var(--dark-grey);
  opacity: 0.35;
  bottom: -120px; left: -160px;
}

/* ── Nav ── */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; height: 56px;
  background: rgba(5, 5, 5, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-2);
}
.nav-brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; font-weight: 700; color: var(--fg);
  letter-spacing: -0.02em;
}
.nav-anchor {
  width: 28px; height: 28px;
  background: var(--grad-brand);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.nav-anchor svg { width: 16px; height: 16px; color: white; }
.nav-sep { color: rgba(255, 255, 255, 0.2); margin: 0 4px; font-weight: 300; }
.nav-subtitle { color: var(--fg-subtle); font-weight: 500; }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-link {
  padding: 6px 14px; border-radius: 8px;
  font-size: 13.5px; font-weight: 500;
  color: rgba(236, 234, 248, 0.5);
  border: none; background: transparent; cursor: pointer;
  text-decoration: none;
  transition: color 150ms var(--ease), background 150ms var(--ease);
}
.nav-link:hover { color: var(--fg); background: rgba(255, 255, 255, 0.06); }
.nav-link.active { color: var(--fg); background: rgba(255, 255, 255, 0.08); }

/* ── Page wrapper ── */
.page {
  flex: 1;
  position: relative; z-index: 1;
  max-width: 1280px; margin: 0 auto; width: 100%;
  padding: 48px 32px 96px;
}
.page-narrow { max-width: 720px; }

/* Hero header */
.page-header { display: flex; flex-direction: column; gap: 6px; margin-bottom: 40px; }
.page-eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--fg-faint);
}
.page-title {
  font-size: 30px; font-weight: 800; letter-spacing: -0.03em;
  line-height: 1.15; color: var(--fg);
}
.page-title-small { font-size: 22px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.2; }
.page-lead { color: var(--fg-muted); font-size: 14px; line-height: 1.55; max-width: 60ch; }

/* ── Generic field ── */
.field-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--fg-faint);
  display: block;
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: var(--radius-lg);
  font-size: 14px; font-weight: 600; letter-spacing: -0.01em;
  border: 1px solid transparent; cursor: pointer;
  transition: opacity 200ms var(--ease), transform 150ms var(--ease),
              border-color 200ms var(--ease), color 200ms var(--ease),
              background 200ms var(--ease), box-shadow 200ms var(--ease);
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn svg { width: 16px; height: 16px; }
.btn-primary {
  background: var(--grad-brand); color: white;
  box-shadow: var(--shadow-glow-brand);
  position: relative; overflow: hidden;
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-glow-brand-strong); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary svg { width: 18px; height: 18px; }
.btn-large { padding: 14px 28px; font-size: 15px; font-weight: 700; }
.btn-secondary {
  background: transparent; color: var(--fg-muted);
  border-color: var(--border-3);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-2); color: var(--fg); border-color: var(--border-strong);
}
.btn-ghost {
  background: transparent; color: var(--fg-subtle); border: none;
  padding: 6px 12px;
}
.btn-ghost:hover:not(:disabled) { color: var(--fg); background: var(--surface-3); }

/* ── Inputs ── */
.input,
.textarea,
.select {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-3);
  border-radius: var(--radius-md);
  font-size: 14px; font-weight: 400; color: var(--fg);
  outline: none;
  transition: border-color 200ms var(--ease), background 200ms var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--fg-ghost); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--border-focus);
  background: var(--primary-soft);
}
.textarea { min-height: 80px; resize: vertical; line-height: 1.5; }

/* URL hero input */
.url-input-wrap {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-2xl);
  transition: border-color 200ms var(--ease), background 200ms var(--ease);
}
.url-input-wrap:focus-within {
  border-color: var(--border-focus);
  background: var(--primary-soft);
}
.url-input {
  width: 100%; padding: 20px 24px;
  background: transparent; border: none; outline: none;
  font-family: inherit; font-size: 16px; font-weight: 500;
  color: var(--fg); letter-spacing: -0.01em;
}
.url-input::placeholder { color: var(--fg-ghost); }

/* ── Surface (generic dark card) ── */
.surface {
  background: var(--surface-1);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-3xl);
  padding: 24px;
}
.surface-sm { padding: 16px; border-radius: var(--radius-xl); }

/* ── Mode cards ── */
.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mode-card {
  position: relative; overflow: hidden;
  padding: 20px 22px; border-radius: var(--radius-2xl);
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  cursor: pointer; user-select: none;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color 200ms var(--ease), background 200ms var(--ease), transform 150ms var(--ease);
}
.mode-card:hover { background: var(--surface-3); transform: translateY(-1px); }
.mode-card.selected { border-color: var(--border-focus); background: var(--primary-soft); }
.mode-card.selected .mode-glow { opacity: 1; }
.mode-glow {
  position: absolute; inset: 0; pointer-events: none;
  opacity: 0; transition: opacity 300ms var(--ease);
  background: radial-gradient(ellipse at top left, rgba(251, 0, 0, 0.18) 0%, transparent 70%);
}
.mode-card-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.mode-icon-wrap {
  width: 36px; height: 36px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  transition: background 200ms var(--ease);
}
.mode-card.selected .mode-icon-wrap { background: rgba(251, 0, 0, 0.22); }
.mode-icon-wrap svg { width: 18px; height: 18px; color: var(--fg-muted); }
.mode-card.selected .mode-icon-wrap svg { color: var(--indigo-400); }
.mode-info { flex: 1; }
.mode-name { font-size: 14px; font-weight: 700; color: var(--fg); letter-spacing: -0.02em; margin-bottom: 4px; }
.mode-desc { font-size: 12px; color: var(--fg-faint); line-height: 1.5; }
.mode-check {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
  transition: border-color 200ms var(--ease), background 200ms var(--ease);
  display: flex; align-items: center; justify-content: center;
}
.mode-card.selected .mode-check {
  background: var(--grad-brand);
  border-color: transparent;
}
.mode-check-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: white; opacity: 0;
}
.mode-card.selected .mode-check-dot { opacity: 1; }

/* ── Keywords accordion ── */
.kw-section { display: flex; flex-direction: column; gap: 0; }
.kw-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-radius: var(--radius-lg);
  cursor: pointer; user-select: none;
  background: var(--surface-1);
  border: 1px solid var(--border-2);
  transition: background 150ms var(--ease);
}
.kw-toggle:hover { background: var(--surface-2); }
.kw-toggle.open { border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-bottom-color: transparent; }
.kw-toggle-left { display: flex; align-items: center; gap: 10px; }
.kw-toggle-label { font-size: 13px; font-weight: 600; color: var(--fg-muted); }
.kw-optional-tag {
  font-size: 10px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--fg-faint);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px; border-radius: var(--radius-full);
}
.kw-chevron { width: 16px; height: 16px; color: var(--fg-faint); transition: transform 200ms var(--ease); }
.kw-toggle.open .kw-chevron { transform: rotate(180deg); }
.kw-body {
  border: 1px solid var(--border-2); border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--surface-1);
  padding: 16px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
}
.kw-col { display: flex; flex-direction: column; gap: 8px; }
.kw-col:first-child { padding-right: 12px; border-right: 1px solid var(--border-1); }
.kw-col:last-child { padding-left: 12px; }
.kw-col-label {
  font-size: 11px; font-weight: 600; color: var(--fg-faint);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.kw-textarea {
  width: 100%; min-height: 80px; resize: none;
  background: var(--surface-2); border: 1px solid var(--border-3);
  border-radius: var(--radius-md); padding: 12px 14px;
  font-family: inherit; font-size: 13px; font-weight: 400;
  color: var(--fg); line-height: 1.5; outline: none;
  transition: border-color 200ms var(--ease);
}
.kw-textarea::placeholder { color: var(--fg-ghost); }
.kw-textarea:focus { border-color: var(--border-focus); }
.kw-hint { font-size: 11px; color: var(--fg-faint); line-height: 1.5; }

/* ── Options row ── */
.options-row {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 16px 20px; border-radius: var(--radius-lg);
  background: var(--surface-1); border: 1px solid var(--border-2);
}
.opt-group { display: flex; align-items: center; gap: 10px; }
.opt-label {
  font-size: 12px; font-weight: 600; color: var(--fg-faint);
  letter-spacing: 0.05em; text-transform: uppercase; white-space: nowrap;
}
.opt-input {
  width: 60px; padding: 6px 10px; text-align: center;
  background: var(--surface-3); border: 1px solid var(--border-3);
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
  color: var(--fg); outline: none;
  transition: border-color 200ms var(--ease);
}
.opt-input:focus { border-color: var(--border-focus); }
.opt-sep { width: 1px; height: 20px; background: var(--border-2); }
.opt-info { font-size: 12px; color: var(--fg-faint); }

/* Mode toggle inline (inside options-row for small selectors) */
.opt-toggle { display: inline-flex; border: 1px solid var(--border-3); border-radius: var(--radius-sm); overflow: hidden; }
.opt-toggle-item {
  padding: 6px 12px; font-size: 12px; font-weight: 600; color: var(--fg-faint);
  background: transparent; border: none; cursor: pointer;
  transition: color 150ms var(--ease), background 150ms var(--ease);
}
.opt-toggle-item:hover { color: var(--fg); }
.opt-toggle-item.active {
  color: white;
  background: var(--grad-brand);
}

/* ── Action bar ── */
.action-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.action-bar .btn-primary { flex: 1; min-width: 200px; }

/* ── Right info panel ── */
.layout-2col {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 0;
}
.form-panel { padding-right: 56px; display: flex; flex-direction: column; gap: 32px; }
.info-panel {
  border-left: 1px solid var(--border-1);
  padding-left: 40px;
  display: flex; flex-direction: column; gap: 24px;
}

/* ── Sitemap HUD ── */
.sitemap-hud {
  background: var(--surface-1);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-3xl);
  padding: 24px;
  display: flex; flex-direction: column; gap: 20px;
}
.hud-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.hud-stat-big { display: flex; flex-direction: column; gap: 2px; }
.hud-number {
  font-size: 40px; font-weight: 800; letter-spacing: -0.04em;
  line-height: 1; color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.hud-number-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--fg-faint);
}
.hud-refresh {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--radius-sm);
  background: var(--surface-3); border: 1px solid var(--border-3);
  cursor: pointer; font-size: 12px; font-weight: 500;
  color: var(--fg-faint);
  transition: color 150ms var(--ease), background 150ms var(--ease);
  white-space: nowrap;
}
.hud-refresh:hover { color: var(--fg-muted); background: var(--surface-4); }
.hud-refresh svg { width: 13px; height: 13px; }

.hud-cats { display: flex; flex-direction: column; gap: 8px; }
.hud-cat { display: flex; align-items: center; gap: 10px; }
.hud-cat-name {
  font-size: 12px; font-weight: 500; color: var(--fg-faint);
  width: 130px; flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.hud-bar-track { flex: 1; height: 4px; background: var(--surface-3); border-radius: var(--radius-full); overflow: hidden; }
.hud-bar-fill { height: 100%; border-radius: var(--radius-full); background: var(--grad-bar); }
.hud-cat-val {
  font-size: 11px; font-weight: 600; color: var(--fg-faint);
  width: 40px; text-align: right; font-variant-numeric: tabular-nums;
}

/* Model badge */
.model-badge {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-radius: var(--radius-xl);
  background: var(--surface-1); border: 1px solid var(--border-2);
}
.model-left { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.model-eyebrow {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--fg-faint);
}
.model-name {
  font-size: 13px; font-weight: 700; color: var(--fg-muted);
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
}
.model-link { font-size: 11px; color: var(--primary); }
.model-link:hover { color: var(--indigo-400); }
.model-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green-500);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
  flex-shrink: 0;
}

/* URL patterns */
.patterns-block { display: flex; flex-direction: column; gap: 10px; }
.patterns-header { display: flex; align-items: center; justify-content: space-between; }
.patterns-toggle-btn {
  font-size: 11px; font-weight: 600; color: var(--primary);
  background: none; border: none; cursor: pointer; padding: 0;
  transition: color 150ms var(--ease);
}
.patterns-toggle-btn:hover { color: var(--indigo-400); }
.patterns-list {
  display: flex; flex-direction: column; gap: 4px;
  overflow: hidden;
  transition: max-height 250ms var(--ease);
}
.pattern-item {
  font-size: 11px; font-weight: 500; color: var(--fg-faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 5px 10px; border-radius: 6px;
  background: var(--surface-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Footer ── */
.footer-note {
  position: fixed; bottom: 0; left: 0; right: 0;
  text-align: center; padding: 10px;
  font-size: 11px; color: var(--fg-ghost);
  background: rgba(5, 5, 5, 0.85);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-1);
  z-index: 10;
}

/* ── Flash messages ── */
.flash {
  margin-bottom: 16px; padding: 12px 16px;
  border-radius: var(--radius-md); font-size: 13px;
  border: 1px solid transparent;
}
.flash-error { background: rgba(239, 68, 68, 0.10); color: #FCA5A5; border-color: rgba(239, 68, 68, 0.25); }
.flash-ok { background: rgba(34, 197, 94, 0.10); color: #86EFAC; border-color: rgba(34, 197, 94, 0.25); }

/* ── Generating overlay ── */
.gen-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 5, 5, 0.94);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  align-items: center;
  /* safe center : centre verticalement si le contenu rentre, sinon part du haut
     pour permettre le scroll. Fallback : flex-start côté navigateurs anciens. */
  justify-content: flex-start;
  justify-content: safe center;
  gap: 32px;
  overflow-y: auto;
  padding: 48px 16px 64px;
}
.gen-content { display: flex; flex-direction: column; align-items: center; gap: 20px; max-width: 480px; text-align: center; padding: 0 24px; }
.gen-warn {
  margin-top: 8px; padding: 12px 16px;
  border-radius: var(--radius-md);
  background: rgba(250, 204, 21, 0.08); border: 1px solid rgba(250, 204, 21, 0.2);
  color: #FDE68A; font-size: 12.5px; line-height: 1.5;
  max-width: 420px;
}
.gen-spinner {
  width: 64px; height: 64px; border-radius: 50%;
  border: 2px solid var(--surface-4);
  border-top-color: var(--indigo-600);
  border-right-color: var(--purple-600);
  animation: spin 1s linear infinite;
}
.gen-title { font-size: 22px; font-weight: 800; letter-spacing: -0.03em; color: var(--fg); }
.gen-url { font-size: 13px; color: var(--fg-faint); font-family: ui-monospace, monospace; word-break: break-all; }
.gen-steps { display: flex; flex-direction: column; gap: 10px; width: 340px; max-width: calc(100vw - 48px); }
.gen-step {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius-lg);
  background: var(--surface-2); border: 1px solid var(--border-2);
  font-size: 13px; font-weight: 500; color: var(--fg-subtle);
  transition: all 200ms var(--ease);
}
.gen-step.done { color: var(--fg-muted); }
.gen-step.active { color: var(--fg); border-color: var(--border-focus); background: var(--primary-soft); }
.gen-step-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: rgba(255, 255, 255, 0.15); }
.gen-step.done .gen-step-dot { background: var(--green-500); }
.gen-step.active .gen-step-dot {
  background: var(--indigo-400);
  box-shadow: 0 0 10px var(--primary-glow);
  animation: pulse 1s var(--ease) infinite;
}

/* ── Animations ── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.animate-in { animation: fadeIn 300ms var(--ease-out) both; }
.delay-1 { animation-delay: 60ms; }
.delay-2 { animation-delay: 120ms; }
.delay-3 { animation-delay: 180ms; }
.delay-4 { animation-delay: 240ms; }
.delay-5 { animation-delay: 300ms; }

/* ── Tables ── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table thead th {
  text-align: left; font-size: 11px; font-weight: 600;
  color: var(--fg-faint); letter-spacing: 0.06em; text-transform: uppercase;
  padding: 10px 12px; border-bottom: 1px solid var(--border-2);
}
.table tbody td { padding: 12px; border-bottom: 1px solid var(--border-1); color: var(--fg-muted); }
.table tbody tr:hover td { background: var(--surface-1); }
.code-pill {
  font-family: ui-monospace, monospace; font-size: 11px;
  padding: 2px 7px; border-radius: 6px;
  background: var(--surface-3); color: var(--fg-muted);
}

/* ── Badges & status ── */
.tag-ok { color: #86EFAC; }
.tag-err { color: #FCA5A5; }
.tag-mode {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius-full);
  background: var(--surface-3); color: var(--fg-muted);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}

/* ── Generated content prose ── */
.prose {
  color: var(--fg-muted); font-size: 15px; line-height: 1.7;
}
.prose h1 {
  color: var(--fg); font-family: var(--font-display); font-size: 30px;
  font-weight: 800; letter-spacing: -0.025em; margin: 0 0 16px; line-height: 1.15;
}
.prose h2 {
  color: var(--fg); font-family: var(--font-display);
  font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
  margin: 32px 0 12px; line-height: 1.25;
  padding-left: 12px; border-left: 3px solid var(--primary);
}
.prose h3 {
  color: var(--fg); font-family: var(--font-display);
  font-size: 17px; font-weight: 600; margin: 24px 0 8px;
}
.prose p { margin: 12px 0; }
.prose strong { color: var(--fg); font-weight: 600; }
.prose a { color: var(--primary); text-decoration: underline; text-decoration-color: rgba(251, 0, 0, 0.45); text-underline-offset: 3px; }
.prose a:hover { color: var(--primary-hover); text-decoration-color: var(--primary-hover); }
.prose ul, .prose ol { margin: 12px 0; padding-left: 22px; }
.prose li { margin: 6px 0; }
.prose code {
  background: var(--surface-3); color: var(--fg);
  font-size: 0.9em; padding: 2px 6px; border-radius: 4px;
  font-family: ui-monospace, monospace;
}
.prose pre {
  background: rgba(0, 0, 0, 0.4); border: 1px solid var(--border-2);
  border-radius: var(--radius-lg); padding: 16px;
  overflow-x: auto; font-size: 13px;
}
.prose blockquote {
  border-left: 3px solid var(--indigo-500); padding-left: 16px;
  color: var(--fg-subtle); margin: 16px 0;
}
.prose table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; }
.prose th, .prose td { border: 1px solid var(--border-2); padding: 8px 12px; }
.prose hr { border: 0; border-top: 1px solid var(--border-2); margin: 24px 0; }

/* Tabs (used on result page) */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-2); margin-bottom: 24px; }
.tab {
  padding: 10px 16px; font-size: 13px; font-weight: 600; color: var(--fg-faint);
  background: transparent; border: none; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 150ms var(--ease), border-color 150ms var(--ease);
}
.tab:hover { color: var(--fg-muted); }
.tab.active { color: var(--fg); border-bottom-color: var(--indigo-400); }

/* Code block (markdown raw) */
.code-block {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 20px;
  font-family: ui-monospace, monospace; font-size: 12.5px;
  line-height: 1.65; color: var(--fg-muted);
  white-space: pre-wrap; word-break: break-word;
  max-height: 70vh; overflow-y: auto;
}

/* Progress bar */
.progress-track { height: 6px; background: var(--surface-3); border-radius: var(--radius-full); overflow: hidden; }
.progress-fill { height: 100%; background: var(--grad-bar); border-radius: var(--radius-full); transition: width 400ms var(--ease); }

/* Preview block */
.preview-block { display: none; flex-direction: column; gap: 12px; padding-top: 8px; }
.preview-block.open { display: flex; }
.preview-target {
  background: var(--surface-1); border: 1px solid var(--border-2);
  border-radius: var(--radius-md); padding: 14px; font-size: 13px;
  color: var(--fg-muted);
}
.preview-target div { padding: 2px 0; }
.preview-target b { color: var(--fg); font-weight: 600; }
.preview-target code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.preview-link {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  border-radius: 6px; font-size: 12.5px; color: var(--fg-muted);
}
.preview-link:hover { background: var(--surface-2); }
.preview-link .score { color: var(--indigo-400); font-weight: 600; font-variant-numeric: tabular-nums; min-width: 24px; }
.preview-link .anchor { color: var(--fg); flex: 1; }
.preview-link .type { color: var(--fg-faint); font-family: monospace; font-size: 11px; }

/* Onboarding */
.onboard-card {
  max-width: 520px; margin: 0 auto;
  background: var(--surface-1); border: 1px solid var(--border-2);
  border-radius: var(--radius-3xl); padding: 32px;
  display: flex; flex-direction: column; gap: 20px;
}
.onboard-form { display: flex; flex-direction: column; gap: 16px; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-faint); }
.form-row .hint { font-size: 12px; color: var(--fg-faint); }

/* ── Responsive ── */
@media (max-width: 900px) {
  .layout-2col { grid-template-columns: 1fr; }
  .form-panel { padding-right: 0; }
  .info-panel { border-left: none; border-top: 1px solid var(--border-1); padding-left: 0; padding-top: 32px; }
  .nav { padding: 0 16px; }
  .page { padding: 32px 16px 96px; }
  .nav-subtitle, .nav-sep { display: none; }
}

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

/* ── Keyword categories grid ── */
.kw-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.kw-cat {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px; border-radius: var(--radius-md);
  background: var(--surface-2); border: 1px solid var(--border-2);
}
.kw-cat-head {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.kw-cat-name {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--fg-muted);
}
.kw-cat-pill {
  font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: var(--radius-full);
}
.kw-pill-indispensable { background: rgba(251, 0, 0, 0.22); color: #ffb3b3; }
.kw-pill-essential     { background: rgba(251, 0, 0, 0.12); color: #ff7d7d; }
.kw-pill-secondary     { background: rgba(204, 204, 204, 0.12); color: var(--lighter-grey); }
.kw-pill-longtail      { background: rgba(34, 197, 94, 0.14); color: #86EFAC; }
.kw-pill-rare          { background: rgba(250, 204, 21, 0.14); color: #FDE68A; }
.kw-cat textarea {
  width: 100%; min-height: 64px; resize: vertical;
  background: var(--surface-1); border: 1px solid var(--border-3);
  border-radius: var(--radius-sm); padding: 8px 10px;
  font-family: inherit; font-size: 12.5px; color: var(--fg);
  outline: none; line-height: 1.4;
  transition: border-color 200ms var(--ease);
}
.kw-cat textarea:focus { border-color: var(--border-focus); }
.kw-cat textarea::placeholder { color: var(--fg-ghost); font-size: 11.5px; }

/* Highlighted keyword in prose result */
mark.kw-hl {
  background: transparent;
  padding: 1px 2px; border-radius: 2px;
  border-bottom: 2px solid;
  color: inherit;
}
mark.kw-hl-indispensable { border-color: #EF4444; }
mark.kw-hl-essential { border-color: var(--primary); }
mark.kw-hl-secondary { border-color: var(--lighter-grey); }
mark.kw-hl-longtail { border-color: #34D399; }
mark.kw-hl-rare { border-color: #FACC15; }

/* Title regenerator output box */
.title-output {
  margin-top: 12px; padding: 16px;
  background: var(--surface-1); border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  font-size: 13px; line-height: 1.65; color: var(--fg-muted);
}
.title-output h2 {
  font-size: 12px; font-weight: 600; color: var(--fg-faint);
  letter-spacing: 0.08em; text-transform: uppercase;
  margin-top: 12px; margin-bottom: 6px;
}
.title-output h2:first-child { margin-top: 0; }
.title-output ol { padding-left: 22px; margin: 0; }
.title-output li { margin: 4px 0; color: var(--fg); }

/* Disclosure section (Plan / Contexte / URL ext, etc.) */
.disclosure {
  border: 1px solid var(--border-2); border-radius: var(--radius-lg);
  background: var(--surface-1);
}
.disclosure-summary {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; cursor: pointer; user-select: none;
  list-style: none;
}
.disclosure-summary::-webkit-details-marker { display: none; }
.disclosure-summary:hover { background: var(--surface-2); border-radius: var(--radius-lg); }
.disclosure[open] .disclosure-summary {
  border-bottom: 1px solid var(--border-2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.disclosure-summary .chev {
  width: 14px; height: 14px; transition: transform 200ms var(--ease);
  color: var(--fg-faint);
}
.disclosure[open] .disclosure-summary .chev { transform: rotate(180deg); }
.disclosure-body {
  padding: 14px 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.disclosure-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 600; color: var(--fg-muted);
}

/* Toolbar inline (label + select + actions) */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .select { width: auto; min-width: 200px; flex: 1; padding: 8px 10px; font-size: 12.5px; }
.toolbar .btn { padding: 8px 14px; font-size: 12.5px; }

/* Library list */
.library-section { display: flex; flex-direction: column; gap: 12px; margin-bottom: 32px; }
.library-section h2 {
  font-size: 14px; font-weight: 700; color: var(--fg);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.library-card {
  padding: 14px 16px; border-radius: var(--radius-md);
  background: var(--surface-2); border: 1px solid var(--border-2);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.library-card-body { flex: 1; min-width: 0; }
.library-card-title { font-size: 13px; font-weight: 600; color: var(--fg); margin-bottom: 4px; }
.library-card-content {
  font-size: 12px; color: var(--fg-faint); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  white-space: pre-wrap;
}

/* ── Semantic optimisation viz ────────────────────────────── */
.sem-panel {
  background: var(--surface-1);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-2xl);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sem-scores {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.sem-score-card {
  padding: 14px 16px;
  background: var(--surface-2);
  border: 2px solid var(--border-2);
  border-radius: var(--radius-xl);
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px;
  transition: border-color 200ms var(--ease);
}
.sem-score-card.in-range  { border-color: rgba(34, 197, 94, 0.55); }
.sem-score-card.out-range { border-color: rgba(239, 68, 68, 0.55); }
.sem-score-left { display: flex; flex-direction: column; gap: 2px; }
.sem-score-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--fg-faint);
}
.sem-score-hint { font-size: 11px; color: var(--fg-faint); }
.sem-score-value {
  font-family: var(--font-display);
  font-size: 36px; font-weight: 800; letter-spacing: -0.02em;
  line-height: 1; color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.sem-score-card.in-range .sem-score-value  { color: #86EFAC; }
.sem-score-card.out-range .sem-score-value { color: #FCA5A5; }

.sem-status {
  font-size: 11.5px; color: var(--fg-faint);
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
}

/* Term rows */
.sem-terms {
  display: flex; flex-direction: column;
  gap: 4px;
  max-height: 560px; overflow-y: auto;
  padding-right: 4px;
}
.sem-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.5fr) 2.5fr auto;
  gap: 12px; align-items: center;
  padding: 6px 8px; border-radius: 6px;
  font-size: 12.5px;
  transition: background 150ms var(--ease);
}
.sem-row:hover { background: var(--surface-2); }
.sem-row-term {
  color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; gap: 6px;
}
.sem-row-term .expr { color: var(--fg); font-weight: 600; }
.sem-row.is-seed { background: rgba(251, 0, 0, 0.06); border-left: 2px solid var(--primary); padding-left: 6px; }
.sem-row.is-seed .sem-row-term { color: var(--fg); font-weight: 600; }
.sem-row-seed-badge {
  font-size: 9px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; padding: 1px 6px;
  border-radius: 999px;
  background: rgba(251, 0, 0, 0.25); color: #ffb3b3;
  flex-shrink: 0;
}
.sem-row.is-gsc { background: rgba(124, 58, 237, 0.05); border-left: 2px solid #C4B5FD; padding-left: 6px; }
.sem-row.is-gsc .sem-row-term { color: var(--fg); }
.sem-row-gsc-badge {
  font-size: 9px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; padding: 1px 6px;
  border-radius: 999px;
  background: rgba(124, 58, 237, 0.20); color: #C4B5FD;
  flex-shrink: 0;
}
.sem-row-bar {
  position: relative;
  height: 18px; border-radius: 4px; overflow: hidden;
  display: grid;
  grid-template-columns: var(--w-under, 1fr) var(--w-normal, 1fr) var(--w-strong, 1fr) var(--w-over, 1fr);
}
.sem-row-bar .seg-under  { background: rgba(96, 165, 250, 0.45); }
.sem-row-bar .seg-normal { background: rgba(34, 197, 94, 0.55); }
.sem-row-bar .seg-strong { background: rgba(250, 204, 21, 0.55); }
.sem-row-bar .seg-over   { background: rgba(239, 68, 68, 0.55); }
.sem-row-bar .seg { height: 100%; }
.sem-row-marker {
  position: absolute; top: -2px; bottom: -2px;
  width: 3px; background: var(--fg); border-radius: 2px;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.35);
  left: 50%;
  transition: left 200ms var(--ease);
}
.sem-row-count {
  font-variant-numeric: tabular-nums; font-size: 11.5px;
  color: var(--fg-muted); white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.sem-row-zone-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.zone-dot-under  { background: #60A5FA; }
.zone-dot-normal { background: #22C55E; }
.zone-dot-strong { background: #FACC15; }
.zone-dot-over   { background: #EF4444; }

.sem-legend {
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
  font-size: 11px; color: var(--fg-faint); padding-top: 6px;
  border-top: 1px solid var(--border-2);
}
.sem-legend .swatch {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 2px; margin-right: 4px; vertical-align: middle;
}

/* Term chips (suggestions to add to extra_terms) */
.chip-cloud {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 12px;
  max-height: 220px; overflow-y: auto;
  background: var(--surface-1);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
}
.chip-filters {
  display: inline-flex; gap: 4px;
  background: var(--surface-1); border: 1px solid var(--border-2);
  border-radius: var(--radius-sm); padding: 2px;
}
.chip-filter {
  font-size: 11px; padding: 4px 10px; border-radius: 4px;
  background: transparent; border: none; cursor: pointer;
  color: var(--fg-faint); font-family: inherit;
  transition: color 150ms var(--ease), background 150ms var(--ease);
}
.chip-filter:hover { color: var(--fg); }
.chip-filter.active { color: var(--fg); background: var(--primary-soft); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; cursor: pointer; user-select: none;
  background: var(--surface-3); border: 1px solid var(--border-2);
  color: var(--fg-muted); white-space: nowrap;
  transition: all 150ms var(--ease);
}
.chip:hover {
  background: var(--surface-4); color: var(--fg);
  transform: translateY(-1px);
}
.chip.added {
  background: var(--primary-soft);
  border-color: var(--border-focus);
  color: var(--fg);
}
.chip.added::after {
  content: "✓";
  font-size: 11px;
  color: var(--primary);
}
.chip-dot {
  width: 7px; height: 7px; border-radius: 50%;
  flex-shrink: 0;
}
.chip.zone-under  .chip-dot { background: #60A5FA; }
.chip.zone-normal .chip-dot { background: #22C55E; }
.chip.zone-strong .chip-dot { background: #FACC15; }
.chip.zone-over   .chip-dot { background: #EF4444; }
.chip-count {
  font-size: 10px; color: var(--fg-faint);
  padding-left: 6px; border-left: 1px solid var(--border-2);
  margin-left: 2px;
  font-variant-numeric: tabular-nums;
}
.chip.seed {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary-soft);
}

/* ── Selection ── */
::selection { background: var(--primary); color: white; }

/* ── Scrollbar (subtle) ── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-4); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.15); }
