/* ───────────────────────────────────────────────────────────────
   FMAutoScript — Design tokens
   2 directions (console/atelier) × 2 themes (light/dark) × 4 accents
─────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
}

/* ────────── Defaults: Direction "console" + light + terracotta accent ────────── */
:root {
  --font-sans: "Inter Tight", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Inter Tight", "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  /* Surfaces */
  --bg:           oklch(0.992 0.003 85);
  --bg-elevated:  oklch(1 0 0);
  --bg-sunken:    oklch(0.97 0.004 85);
  --surface:      oklch(0.975 0.004 85);
  --surface-hover:oklch(0.955 0.005 85);
  --code-bg:      oklch(0.16 0.008 270);     /* code editor stays dark even in light mode */
  --code-fg:      oklch(0.93 0.005 270);

  /* Lines + text */
  --border:        oklch(0.92 0.006 85);
  --border-strong: oklch(0.85 0.008 85);
  --fg:            oklch(0.20 0.008 280);
  --fg-muted:      oklch(0.50 0.008 280);
  --fg-faint:      oklch(0.68 0.008 280);
  --fg-on-accent:  oklch(0.99 0 0);

  /* Accent (terracotta default) */
  --accent:        oklch(0.62 0.16 40);
  --accent-hover:  oklch(0.56 0.16 40);
  --accent-soft:   oklch(0.95 0.04 50);
  --accent-soft-fg:oklch(0.42 0.13 40);
  --accent-ring:   oklch(0.62 0.16 40 / 0.35);

  /* Semantic */
  --success: oklch(0.62 0.13 150);
  --danger:  oklch(0.58 0.20 25);
  --warning: oklch(0.72 0.14 75);
  --info:    oklch(0.60 0.13 240);

  /* Radii (Direction "console" = tight) */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius:    8px;
  --radius-lg: 10px;
  --radius-xl: 14px;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-8: 48px;
  --space-10:64px;

  /* Density */
  --control-h: 32px;
  --control-h-lg: 38px;
  --control-px: 12px;

  /* Shadow */
  --shadow-sm: 0 1px 0 oklch(0 0 0 / 0.04);
  --shadow:    0 1px 2px oklch(0 0 0 / 0.06), 0 0 0 1px oklch(0 0 0 / 0.04);
  --shadow-lg: 0 12px 32px -8px oklch(0 0 0 / 0.18), 0 0 0 1px oklch(0 0 0 / 0.06);

  /* Sidebar */
  --sidebar-w: 232px;
  --topbar-h: 48px;
}

/* ────────── Theme: dark ────────── */
body.theme-dark {
  --bg:           oklch(0.16 0.006 270);
  --bg-elevated:  oklch(0.20 0.007 270);
  --bg-sunken:    oklch(0.13 0.006 270);
  --surface:      oklch(0.18 0.007 270);
  --surface-hover:oklch(0.22 0.008 270);
  --code-bg:      oklch(0.12 0.008 270);
  --code-fg:      oklch(0.93 0.005 270);

  --border:        oklch(0.27 0.008 270);
  --border-strong: oklch(0.35 0.010 270);
  --fg:            oklch(0.96 0.004 270);
  --fg-muted:      oklch(0.66 0.010 270);
  --fg-faint:      oklch(0.45 0.010 270);

  --accent-soft:   oklch(0.30 0.06 50 / 0.50);
  --accent-soft-fg:oklch(0.82 0.10 50);

  --shadow-sm: 0 1px 0 oklch(0 0 0 / 0.4);
  --shadow:    0 1px 2px oklch(0 0 0 / 0.5), 0 0 0 1px oklch(0 0 0 / 0.3);
  --shadow-lg: 0 18px 48px -10px oklch(0 0 0 / 0.6), 0 0 0 1px oklch(0 0 0 / 0.4);
}

/* ────────── Accents ────────── */
body.accent-terracotta {
  --accent:        oklch(0.62 0.16 40);
  --accent-hover:  oklch(0.56 0.16 40);
  --accent-soft:   oklch(0.95 0.04 50);
  --accent-soft-fg:oklch(0.42 0.13 40);
  --accent-ring:   oklch(0.62 0.16 40 / 0.35);
}
body.theme-dark.accent-terracotta {
  --accent-soft:   oklch(0.32 0.07 50 / 0.6);
  --accent-soft-fg:oklch(0.82 0.10 50);
}

body.accent-indigo {
  --accent:        oklch(0.56 0.19 268);
  --accent-hover:  oklch(0.50 0.19 268);
  --accent-soft:   oklch(0.95 0.03 270);
  --accent-soft-fg:oklch(0.40 0.16 268);
  --accent-ring:   oklch(0.56 0.19 268 / 0.35);
}
body.theme-dark.accent-indigo {
  --accent-soft:   oklch(0.30 0.10 268 / 0.6);
  --accent-soft-fg:oklch(0.82 0.12 268);
}

body.accent-green {
  --accent:        oklch(0.60 0.15 152);
  --accent-hover:  oklch(0.54 0.15 152);
  --accent-soft:   oklch(0.95 0.04 152);
  --accent-soft-fg:oklch(0.38 0.13 152);
  --accent-ring:   oklch(0.60 0.15 152 / 0.35);
}
body.theme-dark.accent-green {
  --accent-soft:   oklch(0.30 0.07 152 / 0.6);
  --accent-soft-fg:oklch(0.82 0.10 152);
}

body.accent-cyan {
  --accent:        oklch(0.62 0.13 220);
  --accent-hover:  oklch(0.55 0.14 220);
  --accent-soft:   oklch(0.94 0.04 220);
  --accent-soft-fg:oklch(0.38 0.11 220);
  --accent-ring:   oklch(0.62 0.13 220 / 0.35);
}
body.theme-dark.accent-cyan {
  --accent-soft:   oklch(0.30 0.07 220 / 0.6);
  --accent-soft-fg:oklch(0.82 0.10 220);
}

/* ────────── Direction: Atelier (cream, more expressive, comfier) ────────── */
body.dir-atelier {
  --font-sans:    "Inter Tight", "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-display: "Fraunces", "Inter Tight", Georgia, serif; /* no - replace */
  /* Atelier uses bolder display: use Inter Display weight via heavier weights */
  --font-display: "Inter Tight", "Inter", ui-sans-serif, system-ui, sans-serif;

  --bg:           oklch(0.97 0.012 82);
  --bg-elevated:  oklch(0.99 0.008 82);
  --bg-sunken:    oklch(0.945 0.014 82);
  --surface:      oklch(0.945 0.015 82);
  --surface-hover:oklch(0.925 0.018 82);
  --border:        oklch(0.86 0.020 80);
  --border-strong: oklch(0.78 0.025 75);
  --fg:            oklch(0.22 0.012 50);
  --fg-muted:      oklch(0.48 0.014 50);
  --fg-faint:      oklch(0.65 0.014 50);

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --control-h: 36px;
  --control-h-lg: 44px;
  --control-px: 14px;

  --shadow-sm: 0 1px 0 oklch(0 0 0 / 0.05);
  --shadow:    0 2px 6px -2px oklch(0.4 0.05 60 / 0.12), 0 0 0 1px oklch(0 0 0 / 0.05);
  --shadow-lg: 0 24px 48px -16px oklch(0.4 0.05 60 / 0.22), 0 0 0 1px oklch(0 0 0 / 0.06);
}
body.dir-atelier.theme-dark {
  --bg:           oklch(0.17 0.014 60);
  --bg-elevated:  oklch(0.22 0.014 60);
  --bg-sunken:    oklch(0.14 0.012 60);
  --surface:      oklch(0.20 0.014 60);
  --surface-hover:oklch(0.24 0.015 60);
  --border:        oklch(0.30 0.015 60);
  --border-strong: oklch(0.40 0.018 60);
  --fg:            oklch(0.95 0.010 80);
  --fg-muted:      oklch(0.68 0.012 60);
  --fg-faint:      oklch(0.48 0.012 60);
}

/* ────────── Reset + base elements ────────── */
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
input:focus, textarea:focus, select:focus, button:focus { outline: none; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
::selection { background: var(--accent-ring); }

/* ────────── Typography utilities ────────── */
.mono { font-family: var(--font-mono); font-feature-settings: "ss03", "calt"; }
.display { font-family: var(--font-display); letter-spacing: -0.02em; }

/* ────────── Scrollbars (subtle) ────────── */
.scroll, body { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll::-webkit-scrollbar-track { background: transparent; }
.scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
.scroll::-webkit-scrollbar-thumb:hover { background: var(--fg-faint); border: 2px solid transparent; background-clip: padding-box; }

/* ────────── Layout primitives ────────── */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-5 { gap: 24px; } .gap-6 { gap: 32px; }
.grow { flex: 1; min-width: 0; min-height: 0; }
.center { display: flex; align-items: center; justify-content: center; }

/* ────────── Buttons ────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--control-h); padding: 0 var(--control-px);
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.06s;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: translateY(0.5px); }
.btn-lg { height: var(--control-h-lg); padding: 0 18px; font-size: 14px; border-radius: var(--radius); }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; border-radius: var(--radius-xs); }
.btn-icon { width: var(--control-h); padding: 0; }
.btn-icon.btn-sm { width: 26px; }

.btn-primary { background: var(--accent); color: var(--fg-on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg-elevated); color: var(--fg);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { background: var(--surface-hover); }

.btn-ghost { background: transparent; color: var(--fg); }
.btn-ghost:hover { background: var(--surface-hover); }

.btn-danger { background: var(--danger); color: oklch(0.99 0 0); }

.btn-soft { background: var(--accent-soft); color: var(--accent-soft-fg); }
.btn-soft:hover { filter: brightness(0.96); }

/* ────────── Inputs ────────── */
.field {
  width: 100%;
  display: flex; align-items: center;
  height: var(--control-h-lg);
  padding: 0 var(--control-px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.field:focus-within, .field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.field input, .field select { flex: 1; background: transparent; border: 0; height: 100%; min-width: 0; }
.field input::placeholder { color: var(--fg-faint); }

textarea.field {
  height: auto; padding: 10px var(--control-px); resize: vertical; line-height: 1.55;
}

label.label {
  display: block; font-size: 12px; font-weight: 500; color: var(--fg-muted);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* ────────── Card / panel ────────── */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

/* ────────── Badge / Kbd ────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px; font-weight: 500;
  background: var(--surface); color: var(--fg-muted);
  border: 1px solid var(--border);
}
.badge-accent { background: var(--accent-soft); color: var(--accent-soft-fg); border-color: transparent; }
.badge-success { background: oklch(0.95 0.04 150); color: oklch(0.36 0.12 150); border-color: transparent; }
body.theme-dark .badge-success { background: oklch(0.30 0.07 150 / 0.6); color: oklch(0.82 0.10 150); }
.badge-danger { background: oklch(0.95 0.04 25); color: oklch(0.42 0.16 25); border-color: transparent; }
body.theme-dark .badge-danger { background: oklch(0.30 0.10 25 / 0.6); color: oklch(0.82 0.10 25); }

.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  font-family: var(--font-mono); font-size: 11px;
  background: var(--bg-elevated); color: var(--fg-muted);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
}

/* ────────── Sidebar nav ────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 12px 10px;
  gap: 4px;
}
.sb-brand {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.sb-section {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-faint);
  padding: 12px 10px 4px;
  font-weight: 600;
}
.sb-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--fg-muted);
  cursor: pointer;
  font-weight: 500;
  transition: background 0.1s, color 0.1s;
}
.sb-item:hover { background: var(--surface-hover); color: var(--fg); }
.sb-item.active { background: var(--bg-elevated); color: var(--fg); box-shadow: var(--shadow-sm); }
.sb-item.active svg { color: var(--accent); }
.sb-item .sb-icon { width: 16px; height: 16px; flex-shrink: 0; }
.sb-item .sb-count { margin-left: auto; font-size: 11px; color: var(--fg-faint); }

/* ────────── App shell ────────── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }
.app-main  { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.app-content { flex: 1; overflow: auto; }

/* ────────── Code editor styling ────────── */
.code-editor {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
}
.code-mirror {
  position: absolute; inset: 0;
  padding: 12px 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}
.code-line {
  display: flex;
  align-items: flex-start;
  padding: 0 14px 0 0;
}
.code-line-invalid {
  background: color-mix(in oklch, var(--danger) 10%, transparent);
}
.code-line-invalid .code-ln {
  color: var(--danger);
}
.code-line-cont .code-ln {
  color: transparent;
}
.code-error-icon {
  flex-shrink: 0;
  font-size: 12px;
  line-height: 1;
  margin-left: 6px;
  color: var(--danger);
  opacity: 0.8;
}
.code-ln {
  flex-shrink: 0;
  width: 44px;
  padding: 0 10px 0 14px;
  text-align: right;
  color: oklch(0.55 0.01 270);
  user-select: none;
  font-variant-numeric: tabular-nums;
  background: var(--code-bg);
}
.code-text {
  flex: 1;
  min-width: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  padding-left: 14px;
  tab-size: 2;
}
.code-ta {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  padding: 12px 14px 12px 58px;
  margin: 0;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  background: transparent;
  border: 0;
  color: transparent;
  caret-color: var(--accent);
  resize: none;
  outline: none;
  z-index: 2;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: auto;
  tab-size: 2;
}
.code-ta::selection { background: var(--accent-ring); color: transparent; }

/* Syntax highlight tokens — light, just enough to make scripts readable */
.tok-step    { color: oklch(0.78 0.13 60); font-weight: 500; }   /* warm yellow for action names */
.tok-keyword { color: oklch(0.72 0.14 320); font-weight: 600; }  /* magenta for control flow */
.tok-string  { color: oklch(0.78 0.13 145); }                    /* green for strings */
.tok-number  { color: oklch(0.78 0.13 220); }                    /* cyan numbers */
.tok-comment { color: oklch(0.55 0.01 270); font-style: italic; }
.tok-bracket { color: oklch(0.70 0.01 270); }
.tok-field   { color: oklch(0.78 0.10 280); }                    /* light purple for fields */

/* Atelier softens the dark editor a touch */
body.dir-atelier .code-editor { border-radius: var(--radius-lg); }

/* ────────── Marketing layouts ────────── */
.market-shell { min-height: 100vh; display: flex; flex-direction: column; }
.market-nav {
  height: 64px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklch, var(--bg) 70%, transparent);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 10;
}
.market-content { flex: 1; }
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 32px; }
.container-narrow { width: 100%; max-width: 720px; margin: 0 auto; padding: 0 32px; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500;
  color: var(--accent-soft-fg);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.hero-title {
  font-size: clamp(40px, 5.5vw, 72px);
  line-height: 1.02;
  letter-spacing: -0.035em;
  font-weight: 600;
}
body.dir-atelier .hero-title { font-weight: 700; }

.hero-sub {
  font-size: 18px;
  color: var(--fg-muted);
  line-height: 1.55;
  max-width: 600px;
}

/* Mocked window for screenshots */
.window-mock {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.window-mock-bar {
  height: 32px;
  display: flex; align-items: center; gap: 6px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.window-mock-bar .dot { width: 10px; height: 10px; border-radius: 999px; background: var(--border-strong); }

/* Divider */
.hr { height: 1px; background: var(--border); border: 0; margin: 0; }

/* Auth card */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 600px at 50% -20%, color-mix(in oklch, var(--accent) 14%, transparent), transparent 60%),
    var(--bg);
  padding: 32px;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

/* Feature grid items */
.feature {
  padding: 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color 0.15s, transform 0.15s;
}
.feature:hover { border-color: var(--border-strong); }
.feature-icon {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-soft-fg);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}
body.dir-atelier .feature-icon { border-radius: var(--radius); }

/* Numbered step circle */
.step-num {
  width: 28px; height: 28px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: var(--fg-on-accent);
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
}

/* Tags */
.tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px; color: var(--fg-muted);
  font-family: var(--font-mono);
}

/* Companion status bar */
.companion-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.companion-bar .dot {
  width: 7px; height: 7px; border-radius: 999px;
  background: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--danger) 30%, transparent);
}
.companion-bar.ok .dot { background: var(--success); box-shadow: 0 0 0 3px color-mix(in oklch, var(--success) 30%, transparent); }

/* Logo */
.logo-mark {
  width: 22px; height: 22px;
  background: var(--accent);
  color: var(--fg-on-accent);
  border-radius: 5px;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 10px;
  letter-spacing: -0.05em;
  flex-shrink: 0;
}
body.dir-atelier .logo-mark { border-radius: 7px; }
.logo-text {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  font-size: 15px;
}

/* History list */
.hist-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: 16px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.hist-row:hover { background: var(--surface-hover); }
.hist-row:last-child { border-bottom: 0; }

/* Tabs */
.tabbar { display: flex; gap: 2px; padding: 0 4px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 10px 14px;
  font-size: 13px; font-weight: 500;
  color: var(--fg-muted);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 0.12s, border-color 0.12s;
}
.tab:hover { color: var(--fg); }
.tab.active { color: var(--fg); border-bottom-color: var(--accent); }
.tab .count { margin-left: 6px; color: var(--fg-faint); font-size: 11px; }

/* Floating CTA on extension banner */
.banner-ext {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px;
  padding: 20px 24px;
  background: linear-gradient(135deg,
    color-mix(in oklch, var(--accent) 14%, var(--bg-elevated)),
    var(--bg-elevated));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
}

/* 404 */
.fourofour-num {
  font-family: var(--font-mono);
  font-size: clamp(80px, 18vw, 200px);
  font-weight: 600;
  line-height: 0.9;
  letter-spacing: -0.05em;
  color: var(--accent);
}

/* Atelier accent: subtle paper grain */
body.dir-atelier {
  background-image:
    radial-gradient(oklch(0.5 0.02 60 / 0.025) 1px, transparent 1px);
  background-size: 18px 18px;
}
body.dir-atelier.theme-dark {
  background-image:
    radial-gradient(oklch(1 0 0 / 0.015) 1px, transparent 1px);
  background-size: 18px 18px;
}

/* Direction visual differences */
body.dir-atelier h1, body.dir-atelier h2 { letter-spacing: -0.025em; }
body.dir-atelier .btn { letter-spacing: 0.005em; }
body.dir-atelier .hero-title { line-height: 1.0; }

/* Console direction explicit class (default already applied) */

/* ────────── Mobile menu button ────────── */
.mobile-menu-btn {
  display: none;
  align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: none; border: 0;
  color: var(--fg);
  cursor: pointer;
  flex-shrink: 0;
}

/* ────────── Sidebar overlay (mobile) ────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: oklch(0 0 0 / 0.45);
  z-index: 90;
}
.sidebar-overlay.open { display: block; }

/* ────────── Responsive ────────── */
@media (max-width: 768px) {
  /* Sidebar: off-canvas drawer on mobile */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 260px;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }

  .mobile-menu-btn { display: flex; }

  /* Topbar */
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .badge { display: none; }

  /* App content padding */
  .app-content { padding: 16px !important; }

  /* ScriptsPage: stack header row */
  .scripts-header { flex-direction: column; }
  .scripts-header > div[style*="width: 280"] { width: 100% !important; }

  /* Code editor min-height */
  .code-editor { min-height: 240px; }

  /* AIHelperBar: stack */
  .ai-helper-bar { flex-direction: column; align-items: stretch !important; }
  .ai-helper-bar > span[style*="flex: 1"] { display: none; }

  /* Scripts action row */
  .scripts-actions { flex-direction: column; gap: 8px !important; }
  .scripts-actions > .row { justify-content: center; }

  /* HistoryPage: stat cards stack */
  .stats-grid { grid-template-columns: 1fr !important; }

  /* History row: simplify */
  .hist-row {
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    padding: 10px 12px;
  }
  .hist-row .hist-date { display: none; }

  /* ProfilePage */
  .profile-fields-row { flex-direction: column; }
  .profile-fields-row > div { flex: unset !important; }

  /* Profile subscription card */
  .sub-card-inner { flex-direction: column; }

  /* SettingsPage: language cards */
  .lang-row { flex-direction: column; }
  .lang-row > label { flex: unset !important; }

  /* FieldsPage: stack grid */
  .fields-grid { grid-template-columns: 1fr !important; }

  /* Modules grid: single column */
  .modules-grid { grid-template-columns: 1fr !important; }

  /* CompanionBar: wrap command */
  .companion-bar-cmd { flex-direction: column; }

  /* Topbar search field */
  .topbar-search { width: 140px !important; }

  /* Container padding */
  .container, .container-narrow { padding: 0 16px; }

  /* Market nav */
  .market-nav { padding: 0 16px; }
}
body.dir-console .hero-title { font-weight: 600; }
