/* ══════════════════════════════════════════════════════════════════════════
   PROMPT OPTIMIZER — "LAGOON & EMBER"
   Design system + application shell.

   House rules (enforced throughout):
   · No Inter, no Arial, no system-font fallback as the primary voice.
   · No pure #000 and no untinted grey — every neutral carries a teal or
     warm cast so the surface has a temperature.
   · No purple→blue gradient. Accent is ember orange against lagoon ink.
   · No cards nested inside cards. Depth comes from rules, spacing and
     a single elevation step.
   · No bounce / elastic easing. Motion is ease-out and short.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── 1. TOKENS ─────────────────────────────────────────────────────────── */

:root {
  /* Lagoon ink — teal-tinted darks, never neutral grey */
  --ink-990: #08100F;
  --ink-950: #0B1517;
  --ink-900: #0E1A1D;
  --ink-850: #122125;
  --ink-800: #16272B;
  --ink-750: #1B3035;
  --ink-700: #21393E;
  --ink-600: #2B4A50;

  /* Hairlines */
  --line:        #1F3438;
  --line-soft:   #17282C;
  --line-strong: #2F5057;

  /* Fog — warm/green tinted lights, never #FFF or #888 */
  --fog-050: #F6F2E9;
  --fog-100: #E9E3D6;
  --fog-200: #CFCCC0;
  --fog-300: #A6B2AF;
  --fog-400: #82918F;
  --fog-500: #61716F;

  /* Ember — the signature */
  --ember-700: #A33F16;
  --ember-600: #C44E1E;
  --ember-500: #E4622B;
  --ember-400: #F07C46;
  --ember-300: #F79C6E;

  /* Support hues */
  --saffron: #F0A93C;
  --jade:    #35B98C;
  --jade-dim:#1F6E56;
  --rose:    #E05263;
  --clay:    #B98A5E;

  /* Semantic surfaces */
  --bg:            var(--ink-990);
  --surface:       var(--ink-900);
  --surface-raised:var(--ink-850);
  --surface-sunken:var(--ink-950);
  --surface-input: #101E21;

  --text:          var(--fog-050);
  --text-muted:    var(--fog-300);
  --text-faint:    var(--fog-400);
  --accent:        var(--ember-500);
  --accent-hover:  var(--ember-400);
  --accent-ink:    #1A0C05;

  /* Type */
  --font-display: 'Bricolage Grotesque', 'Instrument Sans', Georgia, serif;
  --font-body:    'Instrument Sans', 'Bricolage Grotesque', Helvetica, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;
  /* Retained aliases so inline styles authored against the old sheet resolve */
  --font-swiss:   var(--font-display);
  --swiss-black:  var(--ink-750);

  /* Scale — 4px base */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  /* Radii — restrained */
  --r-sm: 4px; --r-md: 8px; --r-lg: 12px; --r-xl: 18px;

  /* Motion — ease-out only */
  --ease:      cubic-bezier(.22, .61, .36, 1);
  --ease-firm: cubic-bezier(.65, .05, .36, 1);
  --t-fast: 130ms;
  --t-base: 200ms;
  --t-slow: 340ms;

  /* One elevation step. That's it. */
  --lift: 0 1px 0 rgba(246,242,233,.04) inset,
          0 18px 40px -24px rgba(0, 0, 0, .9);

  --rail-w: 248px;
}

/* ── 2. RESET & BASE ───────────────────────────────────────────────────── */

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  font-feature-settings: 'ss01' 1, 'cv05' 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

/* Atmosphere: two ember/jade washes + a fine grain. Not a gradient banner. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(760px 520px at 12% -8%,  rgba(228, 98, 43, .16), transparent 62%),
    radial-gradient(680px 480px at 96% 6%,   rgba(53, 185, 140, .09), transparent 60%),
    radial-gradient(900px 620px at 74% 108%, rgba(240, 169, 60, .07), transparent 62%);
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .038;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.022em;
  margin: 0;
  color: var(--text);
}

p { margin: 0; }

a { color: var(--ember-300); text-decoration: none; }
a:hover { color: var(--ember-400); }

::selection { background: var(--ember-600); color: var(--fog-050); }

/* Scrollbars, tinted to match */
* { scrollbar-width: thin; scrollbar-color: var(--ink-700) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--ink-700);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--ink-600); background-clip: content-box; }

:focus-visible {
  outline: 2px solid var(--ember-500);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ── 3. SHELL ──────────────────────────────────────────────────────────── */

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

/* Legacy container hook — the shell supersedes it but keep it inert. */
.container { display: contents; }

/* ── 3a. LEFT RAIL ─────────────────────────────────────────────────────── */

.rail {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: linear-gradient(180deg, var(--ink-950), var(--ink-990));
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s5) var(--s5) var(--s4);
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line-strong), 0 8px 20px -12px rgba(228,98,43,.8);
}
.brand-mark svg { display: block; width: 100%; height: 100%; }

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

.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.02rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fog-400);
  margin-top: 3px;
}

.rail-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--s2) var(--s3) var(--s5);
}

.rail-group-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fog-500);
  padding: var(--s4) var(--s3) var(--s2);
}

.nav-tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Rail item. One surface, no nested box. */
.tab-btn {
  position: relative;
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  padding: 9px var(--s3);
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--fog-300);
  font-family: var(--font-body);
  font-size: 0.855rem;
  font-weight: 500;
  letter-spacing: -0.008em;
  text-align: left;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease);
}

.tab-btn .tab-glyph {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  color: var(--fog-400);
  transition: color var(--t-fast) var(--ease), transform var(--t-base) var(--ease);
}
.tab-btn .tab-glyph svg { width: 17px; height: 17px; display: block; }

.tab-btn .tab-copy { min-width: 0; }
.tab-btn .tab-label { display: block; }
.tab-btn .tab-hint {
  display: block;
  font-size: 0.68rem;
  line-height: 1.25;
  color: var(--fog-500);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-btn:hover:not(.active) {
  background: var(--ink-900);
  color: var(--fog-100);
}
.tab-btn:hover:not(.active) .tab-glyph { color: var(--ember-400); }

.tab-btn.active {
  background: var(--ink-850);
  color: var(--fog-050);
  box-shadow: inset 0 0 0 1px var(--line);
}
.tab-btn.active .tab-glyph { color: var(--ember-500); }
.tab-btn.active .tab-hint { color: var(--fog-400); }

/* Active marker — a rule, not a pill */
.tab-btn.active::before {
  content: '';
  position: absolute;
  left: calc(var(--s3) * -1 + 5px);
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  border-radius: 0 3px 3px 0;
  background: var(--ember-500);
}

.tab-badge {
  justify-self: end;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-ink);
  background: var(--saffron);
  padding: 2px 5px;
  border-radius: 3px;
}

.rail-foot {
  padding: var(--s3) var(--s5) var(--s5);
  border-top: 1px solid var(--line-soft);
  font-size: 0.7rem;
  color: var(--fog-500);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
}

.rail-foot a { color: var(--fog-300); }
.rail-foot a:hover { color: var(--ember-400); }

.api-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.api-dot::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--jade);
  box-shadow: 0 0 0 3px rgba(53,185,140,.14);
}
.api-dot.is-down::before { background: var(--rose); box-shadow: 0 0 0 3px rgba(224,82,99,.14); }

/* ── 3b. WORK AREA ─────────────────────────────────────────────────────── */

main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* Each generator is a two-pane workspace: controls left, orchestration right. */
.section { display: none; min-height: 0; }

.section.active {
  display: grid;
  grid-template-columns: minmax(340px, 30%) 1fr;
  min-height: 0;
  height: 100%;
  animation: pane-in var(--t-slow) var(--ease) both;
}

@keyframes pane-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* Left pane — the control panel */
.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: var(--s6) var(--s5) var(--s7);
  background: var(--surface);
  border-right: 1px solid var(--line);
}

/* Right pane — orchestration */
.stage {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--surface-sunken);
}

.stage-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--ink-900), var(--ink-950));
}

.stage-title {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fog-400);
}

.stage-pulse {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fog-400);
}

.stage-pulse .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ink-600);
  transition: background var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease);
}
.stage-pulse.is-live .dot {
  background: var(--ember-500);
  box-shadow: 0 0 0 4px rgba(228,98,43,.16);
  animation: pulse 1.5s var(--ease) infinite;
}
.stage-pulse.is-done .dot { background: var(--jade); box-shadow: 0 0 0 4px rgba(53,185,140,.16); }

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

.stage-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s5);
}

/* Empty state — the pane before a run */
.stage-empty {
  margin: auto;
  max-width: 380px;
  text-align: center;
  padding: var(--s6) var(--s4);
  color: var(--fog-400);
}
.stage-empty svg { width: 84px; height: 84px; opacity: .55; margin-bottom: var(--s4); }
.stage-empty h4 {
  font-size: 1.02rem;
  color: var(--fog-200);
  margin-bottom: var(--s2);
  letter-spacing: -0.02em;
}
.stage-empty p { font-size: 0.85rem; line-height: 1.6; }

/* ── 4. PANEL CONTENT ──────────────────────────────────────────────────── */

.section-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin-bottom: var(--s2);
}

.section-head .motif {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line-strong);
}

.section-head h2 {
  font-size: 1.34rem;
  letter-spacing: -0.032em;
  line-height: 1.15;
}

.section-desc {
  color: var(--text-muted);
  font-size: 0.855rem;
  line-height: 1.6;
  margin-bottom: var(--s5);
  max-width: 52ch;
}

/* Section rule with a label — replaces sub-cards */
.field-label,
.panel-rule {
  display: flex;
  align-items: center;
  gap: var(--s3);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fog-500);
  margin: var(--s5) 0 var(--s3);
}
.field-label::after,
.panel-rule::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}
.panel-rule:first-of-type { margin-top: var(--s2); }

/* Inputs */
.input-group { margin-bottom: var(--s4); }

.input-group label,
.toolbar label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--fog-200);
  margin-bottom: var(--s2);
}

textarea,
input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-input);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: 0.875rem;
  line-height: 1.5;
  transition: border-color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}

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

textarea::placeholder,
input::placeholder { color: var(--fog-500); }

textarea:hover,
input[type="text"]:hover,
input[type="number"]:hover,
select:hover { border-color: var(--line-strong); }

textarea:focus,
input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--ember-500);
  background: var(--ink-850);
  box-shadow: 0 0 0 3px rgba(228, 98, 43, .16);
}

select {
  appearance: none;
  padding-right: 32px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%23A6B2AF' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 11px;
}
select option { background: var(--ink-850); color: var(--text); }

input[type="range"] {
  width: 100%;
  height: 22px;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 99px;
  background: var(--ink-700);
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 15px; height: 15px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--ember-500);
  border: 2px solid var(--ink-950);
  transition: transform var(--t-fast) var(--ease);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.14); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 99px; background: var(--ink-700); }
input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--ember-500); border: 2px solid var(--ink-950);
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s3);
  margin-top: var(--s4);
}

.toolbar label { margin-bottom: 0; align-self: center; }

.toolbar select {
  width: auto;
  min-width: 148px;
  flex: 1 1 148px;
}

/* Buttons */
.action-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 10px 18px;
  border-radius: var(--r-md);
  background: var(--ember-500);
  color: var(--accent-ink);
  font-family: var(--font-body);
  font-size: 0.83rem;
  font-weight: 700;
  letter-spacing: 0.005em;
  line-height: 1.3;
  box-shadow: 0 10px 22px -14px rgba(228, 98, 43, .95);
  transition: background var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
.action-btn:hover { background: var(--ember-400); box-shadow: 0 12px 26px -13px rgba(240,124,70,.95); }
.action-btn:active { transform: translateY(1px); box-shadow: none; }
.action-btn:disabled {
  background: var(--ink-700);
  color: var(--fog-500);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.action-btn.secondary {
  background: transparent;
  color: var(--fog-100);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.action-btn.secondary:hover {
  background: var(--ink-800);
  color: var(--fog-050);
  box-shadow: inset 0 0 0 1px var(--ember-600);
}

.action-btn.wide { width: 100%; text-align: center; }

/* Inline run status */
.inline-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--fog-400);
  padding: 0 2px;
  align-self: center;
}
.inline-status::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--ink-600);
}
.inline-status.running::before { background: var(--ember-500); animation: pulse 1.4s var(--ease) infinite; }

/* Choice chips — replaces the old card grids (no card-in-card) */
.category-grid,
.skill-type-grid,
.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-bottom: var(--s4);
}

.category-card,
.chip {
  padding: 7px 13px;
  border-radius: 99px;
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--fog-300);
  font-size: 0.79rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
.category-card:hover,
.chip:hover { color: var(--fog-050); background: var(--ink-800); }

.category-card.selected,
.chip.selected {
  background: var(--ember-500);
  color: var(--accent-ink);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--ember-400);
}

/* Skill-type picker — a list of rows on one surface, not four cards */
.skill-type-grid { flex-direction: column; gap: 0; }

.skill-type-card {
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  gap: var(--s3);
  padding: 10px var(--s3);
  border-radius: var(--r-md);
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.skill-type-card:last-child { border-bottom: 0; }
.skill-type-card:hover { background: var(--ink-850); }
.skill-type-card.selected {
  background: var(--ink-800);
  box-shadow: inset 0 0 0 1px var(--ember-600);
}

.skill-type-icon { font-size: 1.15rem; line-height: 1; text-align: center; }
.skill-type-name {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--fog-100);
}
.skill-type-card.selected .skill-type-name { color: var(--fog-050); }
.skill-type-desc {
  grid-column: 2;
  font-size: 0.72rem;
  color: var(--fog-500);
  line-height: 1.35;
}

/* Checkboxes */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  margin: var(--s3) 0 var(--s4);
}
.checkbox-group label {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--fog-200);
  cursor: pointer;
  margin: 0;
}
.checkbox-group input[type="checkbox"] {
  appearance: none;
  width: 16px; height: 16px;
  flex: none;
  border-radius: var(--r-sm);
  background: var(--surface-input);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.checkbox-group input[type="checkbox"]:checked {
  background: var(--ember-500) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10' fill='none' stroke='%231A0C05' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 5.2 4.3 8.6 11 1.6'/%3E%3C/svg%3E") center / 10px no-repeat;
  box-shadow: inset 0 0 0 1px var(--ember-400);
}

/* ── 5. ORCHESTRATION OUTPUT ───────────────────────────────────────────── */

/* One surface. Content inside is separated by rules, not by more boxes. */
.result-area {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s5);
  box-shadow: var(--lift);
  animation: pane-in var(--t-slow) var(--ease) both;
}

.result-area h3 {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fog-400);
  padding-bottom: var(--s3);
  margin-bottom: var(--s4);
  border-bottom: 1px solid var(--line);
}

.result-area > .copy-btn { position: absolute; top: var(--s4); right: var(--s4); }

#optimized-output {
  font-family: var(--font-mono);
  font-size: 0.83rem;
  line-height: 1.72;
  color: var(--fog-100);
  white-space: pre-wrap;
  outline: none;
  border-radius: var(--r-md);
  padding: var(--s2);
  margin: 0 calc(var(--s2) * -1);
  transition: background var(--t-fast) var(--ease);
}
#optimized-output:focus { background: var(--ink-850); }

#generated-answer {
  margin-top: var(--s4);
  padding-top: var(--s4);
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
  line-height: 1.72;
  color: var(--fog-100);
  white-space: pre-wrap;
}

/* Copy buttons */
.copy-btn,
.copy-btn-small {
  appearance: none;
  border: 0;
  cursor: pointer;
  background: var(--ink-800);
  color: var(--fog-200);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 5px 10px;
  transition: background var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
.copy-btn:hover,
.copy-btn-small:hover {
  background: var(--ember-500);
  color: var(--accent-ink);
  box-shadow: inset 0 0 0 1px var(--ember-400);
}
.copy-btn.copied { background: var(--jade); color: var(--accent-ink); }

/* Agent result rows */
.agent-section {
  position: relative;
  padding: var(--s4) 0;
  border-bottom: 1px solid var(--line-soft);
}
.agent-section:last-of-type { border-bottom: 0; padding-bottom: 0; }

.agent-section h4 {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fog-500);
  margin-bottom: var(--s2);
}

.agent-section .copy-btn-small { position: absolute; top: var(--s4); right: 0; }

.content-box {
  font-size: 0.875rem;
  line-height: 1.68;
  color: var(--fog-100);
  white-space: pre-wrap;
  padding-right: 76px;
}

.content-box.code-block {
  font-family: var(--font-mono);
  font-size: 0.79rem;
  line-height: 1.72;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s4);
  margin-top: var(--s2);
  max-height: 420px;
  overflow: auto;
  color: var(--fog-100);
}

/* File / output tab strip */
.skill-file-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1);
  padding-bottom: var(--s3);
  border-bottom: 1px solid var(--line);
  margin-bottom: 0;
}

.skill-file-tab,
.out-tab {
  appearance: none;
  border: 0;
  cursor: pointer;
  background: transparent;
  color: var(--fog-400);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 6px 11px;
  border-radius: var(--r-sm);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.skill-file-tab:hover,
.out-tab:hover { background: var(--ink-850); color: var(--fog-100); }

.skill-file-tab.active,
.out-tab.active {
  background: var(--ember-500);
  color: var(--accent-ink);
  font-weight: 700;
}

/* A strip-level copy button rides in the tab row so it can never land on
   top of the first line of output. */
.skill-file-tabs .copy-btn { margin-left: auto; align-self: center; }

.skill-file-display {
  position: relative;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  overflow: hidden;
}
.skill-file-display .copy-btn { position: absolute; top: var(--s3); right: var(--s3); z-index: 3; }

#anthropic-skill-preview,
#loop-output-text,
.output-pre {
  margin: 0;
  padding: var(--s5);
  padding-right: 92px;
  max-height: 58vh;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.79rem;
  line-height: 1.75;
  color: var(--fog-100);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Analysis / critic content */
.analysis-content { font-size: 0.86rem; line-height: 1.7; color: var(--fog-200); }

.analysis-item { padding: var(--s3) 0; border-bottom: 1px solid var(--line-soft); }
.analysis-item:last-child { border-bottom: 0; padding-bottom: 0; }
.analysis-item strong { color: var(--fog-050); font-weight: 600; }
.analysis-item ul,
.analysis-item ol { margin: var(--s2) 0 0; padding-left: 1.15rem; }
.analysis-item li { margin-bottom: 4px; }

/* Critic findings */
.critic-finding { padding: var(--s3) 0; border-bottom: 1px solid var(--line-soft); }
.critic-finding:last-child { border-bottom: 0; }
.critic-finding-head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-bottom: 4px;
}
.critic-finding-head strong { color: var(--fog-050); font-size: 0.88rem; font-weight: 600; }
.critic-fix { color: var(--fog-300); font-size: 0.82rem; line-height: 1.6; }
.critic-approved {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  color: var(--jade);
  font-weight: 600;
  font-size: 0.88rem;
}

.severity-tag {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  flex: none;
}
.severity-tag.high   { background: rgba(224,82,99,.16);  color: #F5909C; box-shadow: inset 0 0 0 1px rgba(224,82,99,.4); }
.severity-tag.medium { background: rgba(240,169,60,.15); color: var(--saffron); box-shadow: inset 0 0 0 1px rgba(240,169,60,.38); }
.severity-tag.low    { background: rgba(53,185,140,.14); color: var(--jade); box-shadow: inset 0 0 0 1px rgba(53,185,140,.35); }

/* Loop type badge */
.loop-type-row { display: flex; align-items: center; gap: var(--s3); }
.loop-type-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-ink);
  background: var(--saffron);
  padding: 5px 11px;
  border-radius: var(--r-sm);
  font-weight: 700;
}

/* Chatbot launchers */
.chatbot-links {
  margin-top: var(--s4);
  padding-top: var(--s4);
  border-top: 1px solid var(--line);
}
.chatbot-links-title {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fog-500);
  margin-bottom: var(--s3);
}
.chatbot-links-row { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chatbot-link-btn {
  padding: 7px 13px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--fog-100);
  background: var(--ink-800);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  transition: background var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
.chatbot-link-btn:hover { color: var(--fog-050); background: var(--ink-750); }
.chatbot-link-btn.chatgpt:hover { box-shadow: inset 0 0 0 1px var(--jade); }
.chatbot-link-btn.claude:hover  { box-shadow: inset 0 0 0 1px var(--ember-500); }
.chatbot-link-btn.gemini:hover  { box-shadow: inset 0 0 0 1px var(--saffron); }
.chatbot-link-btn:active { transform: translateY(1px); }
.chatbot-link-hint {
  margin-top: var(--s3);
  font-size: 0.72rem;
  color: var(--fog-500);
  line-height: 1.5;
}

/* ── 6. PLUGIN GRAPH ───────────────────────────────────────────────────── */

.plugin-graph { display: flex; flex-direction: column; gap: var(--s4); }

.graph-center { display: flex; flex-direction: column; align-items: center; }

.graph-node-main {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-ink);
  background: var(--ember-500);
  padding: 9px 20px;
  border-radius: var(--r-md);
  box-shadow: 0 14px 30px -18px rgba(228,98,43,1);
}

.graph-connector {
  width: 1px;
  height: 26px;
  background: linear-gradient(var(--ember-600), var(--line));
}

.graph-spoke {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
  gap: var(--s2);
}

.graph-node {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 11px var(--s3);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
.graph-node:hover { background: var(--ink-850); transform: translateY(-1px); box-shadow: inset 0 0 0 1px var(--line-strong); }
.graph-node.active {
  background: var(--ink-800);
  box-shadow: inset 0 0 0 1px var(--ember-500);
}

.graph-node-icon { font-size: 1rem; line-height: 1; }
.graph-node-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--fog-200);
}
.graph-node.active .graph-node-label { color: var(--fog-050); }

.node-cards-area {
  display: none;
  flex-direction: column;
  gap: var(--s3);
}
.node-cards-area.visible { display: flex; animation: pane-in var(--t-base) var(--ease) both; }

.node-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.node-card-header {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 10px var(--s4);
  border-bottom: 1px solid var(--line);
  background: var(--ink-850);
}
.node-card-title {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--fog-050);
}
.node-card-type {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ember-300);
}
.node-card-content {
  margin: 0;
  padding: var(--s4);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.7;
  color: var(--fog-200);
  white-space: pre-wrap;
  max-height: 320px;
  overflow: auto;
}

/* ── 7. LOADERS, MERMAID, TOAST ────────────────────────────────────────── */

.loader {
  width: 30px;
  height: 30px;
  margin: 0 auto;
  border-radius: 50%;
  border: 2px solid var(--ink-700);
  border-top-color: var(--ember-500);
  animation: spin .78s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.thinking {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fog-400);
}

.mermaid-container {
  padding: var(--s5);
  background: var(--fog-050);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  overflow: auto;
}
.mermaid-container svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }

.toast {
  position: fixed;
  bottom: var(--s5);
  left: 50%;
  transform: translate(-50%, 14px);
  z-index: 90;
  padding: 11px 20px;
  border-radius: var(--r-md);
  background: var(--ink-800);
  color: var(--fog-050);
  border: 1px solid var(--line-strong);
  box-shadow: 0 20px 44px -22px rgba(0,0,0,.95);
  font-size: 0.82rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Legacy nodes kept inert so old markup can't leak a stray banner */
.warli-mural, .warli-divider, .swiss-rule { display: none; }

/* ── 8. RESPONSIVE ─────────────────────────────────────────────────────── */

@media (max-width: 1180px) {
  .section.active { grid-template-columns: minmax(320px, 38%) 1fr; }
}

@media (max-width: 960px) {
  body { overflow: auto; }
  .app { grid-template-columns: 1fr; height: auto; }

  .rail {
    position: sticky;
    top: 0;
    z-index: 40;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: var(--ink-990);
  }
  .brand { padding: var(--s4) var(--s4) var(--s3); }
  .rail-scroll {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--s1);
    padding: 0 var(--s4) var(--s3);
    overflow-x: auto;
    overflow-y: hidden;
  }
  .rail-group-label { display: none; }
  .tab-badge { display: none; }
  .nav-tabs { flex: none; flex-direction: row; gap: var(--s1); }
  .tab-btn {
    grid-template-columns: 20px auto;
    width: auto;
    white-space: nowrap;
    padding: 8px 12px;
  }
  .tab-btn .tab-hint { display: none; }
  .tab-btn.active::before { display: none; }
  .tab-btn.active { box-shadow: inset 0 0 0 1px var(--ember-600); }
  .rail-foot { display: none; }

  .section.active { grid-template-columns: minmax(0, 1fr); height: auto; }
  .panel { border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; padding: var(--s5) var(--s4); min-width: 0; }
  .stage { overflow: visible; min-width: 0; }
  .stage-body { overflow: visible; padding: var(--s4); }
  main { overflow: visible; }
}

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

/* ── 9. GOAL ENGINEERING ───────────────────────────────────────────────── */

.ge-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 14px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  background: var(--surface-sunken);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.ge-toggle:hover { border-color: var(--line-strong); background: var(--ink-850); }
.ge-toggle input {
  flex: none;
  width: 15px;
  height: 15px;
  margin-top: 1px;
  accent-color: var(--ember-500);
}
.ge-toggle strong {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--fog-050);
  letter-spacing: 0.01em;
}
.ge-toggle em {
  display: block;
  margin-top: 2px;
  font-style: normal;
  font-size: 0.7rem;
  line-height: 1.45;
  color: var(--text-faint);
}
.ge-optional {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 99px;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  vertical-align: 1px;
}

.ge-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-soft);
}
.ge-result-actions .action-btn {
  padding: 8px 12px;
  font-size: 0.72rem;
}

.ge-dossier { max-width: 960px; min-width: 0; }
.ge-split, .ge-block, .ge-table-wrap { min-width: 0; }
#ge-result, #ge-output, #goal-engineering .stage-body { min-width: 0; }
.ge-identity {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.ge-deva {
  font-family: var(--font-display);
  font-size: 1.4rem;
  line-height: 1;
  color: var(--saffron);
  margin-bottom: 6px;
}
.ge-dossier .ge-name {
  font-family: var(--font-display);
  font-size: 2.35rem;
  line-height: 1.02;
  letter-spacing: -0.025em;
  margin: 0;
  padding-bottom: 0;
  border-bottom: 0;
  color: var(--fog-050);
  font-weight: 500;
  text-transform: none;
}
.ge-meaning {
  margin-top: 6px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--text-muted);
}
.ge-role {
  margin-top: 10px;
  max-width: 60ch;
  font-size: 0.84rem;
  line-height: 1.6;
  color: var(--text-muted);
}
.ge-domain { flex: none; text-align: right; }
.ge-domain .tag {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--fog-200);
  font-weight: 500;
}
.ge-domain-note {
  margin-bottom: 7px;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.ge-summary {
  margin: 20px 0 4px;
  max-width: 70ch;
  font-size: 0.92rem;
  line-height: 1.75;
  color: var(--fog-100);
}
.ge-block { margin-top: 24px; }
.ge-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 9px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--saffron);
}
.ge-label-note {
  font-family: var(--font-body);
  font-size: 0.62rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--text-faint);
}
.ge-statement {
  max-width: 72ch;
  font-family: var(--font-display);
  font-size: 1.32rem;
  line-height: 1.42;
  letter-spacing: -0.012em;
  color: var(--fog-050);
}
.ge-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-top: 2px;
}
.ge-list { list-style: none; margin: 0; padding: 0; }
.ge-list li {
  position: relative;
  padding-left: 14px;
  margin: 6px 0;
  font-size: 0.83rem;
  line-height: 1.58;
  color: var(--fog-100);
}
.ge-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.58em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ember-500);
}
.ge-list-muted li::before { background: var(--fog-500); }
.ge-muted {
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text-faint);
}

.ge-table-wrap { overflow-x: auto; margin-top: 4px; }
.ge-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: 0.77rem;
  line-height: 1.45;
}
.ge-table th {
  padding: 8px 10px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
.ge-table td {
  padding: 10px;
  vertical-align: top;
  border-top: 1px solid var(--line-soft);
  color: var(--text-muted);
}
.ge-table tr:first-child td { border-top: 0; }
.ge-table .ge-criterion { font-weight: 600; color: var(--fog-050); width: 23%; }
.ge-table .ge-num { width: 86px; white-space: nowrap; font-family: var(--font-mono); font-size: 0.7rem; color: var(--fog-200); }
.ge-weight {
  height: 3px;
  margin-bottom: 5px;
  border-radius: 99px;
  overflow: hidden;
  background: var(--ink-700);
}
.ge-weight span {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--ember-600), var(--saffron));
}

.ge-details {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.ge-details summary {
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.63rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.ge-details summary:hover { color: var(--saffron); }
.ge-code {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  background: var(--ink-950);
  font-family: var(--font-mono);
  font-size: 0.73rem;
  line-height: 1.65;
  color: var(--fog-100);
  white-space: pre-wrap;
  overflow: auto;
}

.ge-inline-panel { margin-bottom: 20px; }
.ge-inline {
  padding: 14px 18px 16px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
}
.ge-inline-summary {
  list-style: none;
  cursor: pointer;
  outline: none;
}
.ge-inline-summary::-webkit-details-marker { display: none; }
.ge-inline-summary::after {
  content: '▸ Show evidence + non-goals';
  display: block;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.ge-inline[open] .ge-inline-summary::after { content: '▾ Hide details'; }
.ge-inline-summary:hover::after { color: var(--saffron); }
.ge-inline-body { margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.ge-inline-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.ge-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--saffron);
}
.ge-inline-head strong {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 500;
  color: var(--fog-050);
}
.ge-inline-deva { color: var(--text-muted); font-size: 0.9rem; }
.ge-inline-statement {
  margin: 4px 0 0;
  font-size: 0.84rem;
  line-height: 1.6;
  color: var(--fog-100);
}
.ge-inline-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.ge-inline-label {
  margin-bottom: 4px;
  font-family: var(--font-mono);
  font-size: 0.57rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fog-300);
}
.ge-inline .ge-list li { margin: 3px 0; font-size: 0.73rem; line-height: 1.5; }
.ge-inline .ge-muted { font-size: 0.72rem; }

@media (max-width: 720px) {
  .ge-split, .ge-inline-grid { grid-template-columns: 1fr; gap: 16px; }
  .ge-identity { flex-direction: column; gap: 14px; }
  .ge-domain { text-align: left; }
  .ge-dossier .ge-name { font-size: 1.85rem; }
  .ge-statement { font-size: 1.16rem; }
  .ge-result-actions .action-btn { flex: 1 1 calc(50% - 8px); }
  .ge-table { min-width: 560px; }
}

@media (max-width: 560px) {
  .ge-result-actions { gap: 6px; }
  .ge-result-actions .action-btn { flex: 1 1 100%; min-width: 0; }
  .ge-table { min-width: 520px; }
}
