@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

/* ── TOKENS ─────────────────────────────────────────────── */
:root {
  --bg:       #0d1219;
  --bg2:      #111a24;
  --bg3:      #16202c;
  --bg4:      #1b2736;
  --border:   rgba(90,160,230,0.09);
  --border2:  rgba(90,160,230,0.18);
  --border3:  rgba(90,160,230,0.32);
  --text:     #cce4f8;
  --text2:    #6a90b0;
  --text3:    #385470;
  --accent:   #4ab4f0;
  --green:    #3edc6e;
  --amber:    #f5a623;
  --red:      #f05f6e;
  --radius:   6px;
  --shadow:   0 4px 20px rgba(0,12,30,0.55);
}

/* ── RESET ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  /* prevent horizontal scroll from tooltips */
  overflow-x: hidden;
}

/* ── HEADER ─────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1rem 2rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--border2);
}
.header-left h1 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
  margin-bottom: 1px;
}
.header-left p {
  font-size: 11px;
  font-weight: 400;
  color: var(--text3);
}
.framework-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  padding: 4px 12px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--accent);
  background: rgba(74,180,240,0.06);
  letter-spacing: 0.05em;
}

/* ── LAYOUT ─────────────────────────────────────────────── */
.main {
  padding: 1.5rem 2rem;
  max-width: 1280px;
}

/* ── INPUT PANEL ────────────────────────────────────────── */
.input-panel {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}
.input-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 0.5rem;
}
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  padding: 10px 12px;
  resize: vertical;
  min-height: 56px;
  letter-spacing: 0.04em;
  outline: none;
  transition: border-color 0.18s;
}
textarea:focus { border-color: var(--accent); }
textarea::placeholder { color: var(--text3); }

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 0.75rem;
  align-items: center;
}
.btn-analyze {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 7px 22px;
  background: var(--accent);
  color: #0a1018;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  /* NO transform on hover - causes layout shift */
  transition: opacity 0.15s;
}
.btn-analyze:hover { opacity: 0.87; }

.examples-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text3);
  margin: 0 2px 0 6px;
}
.ex-btn {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text2);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.ex-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(74,180,240,0.07);
}
.error {
  color: var(--red);
  font-size: 12px;
  font-weight: 500;
  margin-top: 0.5rem;
  min-height: 16px;
}

/* ── SECTIONS ───────────────────────────────────────────── */
.sec { margin-bottom: 1.75rem; }
.sec-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text2);
  margin-bottom: 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

/* ── SEQUENCE DISPLAY ───────────────────────────────────── */
.seq-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.9;
  word-break: break-all;
  padding: 12px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ── SUMMARY / METRICS ──────────────────────────────────── */
.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 0.75rem;
}
.metric {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  min-width: 88px;
  flex: 1;
  max-width: 200px;
}
.metric-val {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 3px;
  color: var(--text);
}
.metric-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text3);
  letter-spacing: 0.02em;
}

/* ── VISUALIZATION ──────────────────────────────────────── */
.viz-panel {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 1.25rem;
  /* FIXED height prevents jumping when content swaps */
  min-height: 340px;
  margin-bottom: 0.6rem;
  overflow-x: auto;
  overflow-y: hidden;
  /* contain so internal position:absolute tooltips don't bleed */
  position: relative;
}
.viz-caption {
  font-size: 11px;
  font-weight: 500;
  color: var(--text3);
  margin-bottom: 0.6rem;
  /* fixed height so it doesn't push content when text changes */
  height: 16px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.hover-hint {
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 0.5rem;
}
/* overlay is unused but must not affect layout */
.viz-overlay {
  display: none !important;
  pointer-events: none;
}

/* VIZ PICKER — fixed height row, no reflow */
.viz-picker {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 2px;
}
.viz-card {
  flex: 0 0 auto;
  min-width: 110px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 13px;
  cursor: pointer;
  /* NO transform, NO box-shadow change — causes reflow */
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.viz-card:hover {
  border-color: var(--accent);
  background: rgba(74,180,240,0.06);
}
.viz-card.active {
  border-color: var(--accent);
  background: rgba(74,180,240,0.11);
}
.viz-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap;
}
.viz-sub {
  font-size: 10px;
  color: var(--text3);
  white-space: nowrap;
}
.viz-card.active .viz-title { color: var(--accent); }
.viz-card.active .viz-sub   { color: var(--text2); }

/* STAGE HEADER */
.stage-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.stage-kicker {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  margin-bottom: 3px;
}
.stage-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.stage-sub {
  font-size: 12px;
  color: var(--text2);
  max-width: 580px;
  line-height: 1.6;
}
.stage-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  color: var(--text3);
  white-space: nowrap;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

/* SIGNAL GRID */
.signal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.signal-card {
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 14px;
  overflow: hidden;
}
.stack-lane-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* COMPRESSION BAND — fixed height container, bars grow upward */
.compression-band {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 180px;        /* FIXED — no reflow on hover */
  padding-bottom: 4px;
  overflow: hidden;
}
.compression-cell {
  flex: 1;
  min-width: 5px;
  border-radius: 3px 3px 0 0;
  position: relative;
  cursor: default;
  /* opacity only — no size/position change */
  transition: opacity 0.15s;
}
.compression-cell:hover { opacity: 0.78; }
.compression-cell.exact {
  box-shadow: 0 0 14px rgba(255,75,151,0.55), 0 0 28px rgba(255,75,151,0.22);
}
.compression-cell.imperfect {
  box-shadow: 0 0 11px rgba(255,154,72,0.45), 0 0 22px rgba(255,154,72,0.18);
}
.spark {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  border-radius: 3px 3px 0 0;
  opacity: 0.38;
  pointer-events: none;
}
.core {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: rgba(255,255,255,0.22);
  border-radius: 0 0 2px 2px;
  pointer-events: none;
}

/* WAVE */
.wave-panel { width: 100%; overflow: hidden; }
.wave-svg {
  width: 100%;
  height: 72px;
  display: block;
  filter: drop-shadow(0 0 7px rgba(74,180,240,0.28));
}

/* HEAT CELLS — scale only, no layout change */
.heat-large {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}
.heat-cell {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  cursor: default;
  /* transform:scale doesn't affect layout */
  transition: transform 0.12s, opacity 0.12s;
  flex-shrink: 0;
}
.heat-cell:hover {
  transform: scale(1.25);
  opacity: 1 !important;
  position: relative;
  z-index: 2;
}

/* MODE LEGEND */
.mode-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 10px 0;
}
.mode-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text2);
}
.mode-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* BLOCK ROW / BIG BLOCKS */
.block-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.big-block {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.92);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 3px 10px rgba(0,0,0,0.35);
}

/* SEQUENCE RUNES */
.sequence-runes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.sequence-rune {
  padding: 8px 12px;
  border-radius: var(--radius);
  min-width: 82px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.rune-base {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,0.95);
  margin-bottom: 3px;
}
.rune-sub {
  font-size: 9px;
  font-weight: 500;
  color: rgba(255,255,255,0.5);
  line-height: 1.3;
}

/* ARCH GRID */
.arch-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.arch-panel { overflow-y: auto; max-height: 320px; }
.arch-list { display: flex; flex-direction: column; gap: 8px; }
.arch-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
}
.arch-item strong {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  display: block;
  margin-bottom: 2px;
}
.arch-item span { font-size: 10px; color: var(--text3); }

.contour-field { width: 100%; min-height: 180px; }
.contour-field svg { width: 100%; height: 180px; }
.contour-glow { opacity: 0.18; }

/* COMPARE COLUMNS */
.compare-columns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.compare-tower h4 {
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}
.tower-stack {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}
.tower-bar {
  width: 44px;
  border-radius: 4px 4px 0 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  flex-shrink: 0;
}
.tower-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--text3);
  margin-top: 4px;
  text-align: center;
  width: 44px;
  word-break: break-all;
}

/* STACK LANES */
.stack-lanes { display: flex; flex-direction: column; gap: 12px; }

/* ── RUN BLOCKS ─────────────────────────────────────────── */
.run-blocks-wrap {
  padding: 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  line-height: 2.4;
  /* contain tooltip overflow */
  position: relative;
}
.run-block {
  display: inline-block;
  padding: 4px 9px;
  border: 1px solid;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  cursor: default;
  position: relative;
  margin: 2px;
  /* opacity only — no size or position change */
  transition: opacity 0.15s;
}
.run-block:hover { opacity: 0.7; }
.run-block:hover .run-tip { display: block; }

/* TOOLTIP — absolutely positioned, completely out of flow */
.run-tip {
  display: none;
  position: absolute;
  z-index: 100;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  /* prevent tooltip from causing any layout shift */
  pointer-events: none;
  white-space: nowrap;
  /* visual */
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text);
  line-height: 1.8;
  box-shadow: 0 8px 28px rgba(0,0,0,0.65);
}

/* ── TABLES ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.res {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
  /* table-layout fixed prevents column width changes on hover */
  table-layout: auto;
}
table.res th {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border2);
  text-align: left;
  white-space: nowrap;
  background: var(--bg2);
}
table.res td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  /* no transition — prevents row height animation */
}
/* row hover: background only, no size change */
table.res tbody tr:hover td {
  background: rgba(74,180,240,0.04);
}
.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.risk-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* ── ALERTS ─────────────────────────────────────────────── */
.alert-box {
  border: 1px solid;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
  font-size: 12px;
  line-height: 1.7;
}
.alert-box strong {
  font-size: 12px;
  font-weight: 600;
  display: block;
  margin-bottom: 3px;
}

/* RISK BAR */
.risk-bar {
  height: 8px;
  border-radius: 4px;
  display: flex;
  overflow: hidden;
  margin: 6px 0;
}
.risk-seg { height: 100%; }

/* MINI NOTE */
.mini-note {
  font-size: 11px;
  color: var(--text3);
  font-style: italic;
}

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 800px) {
  .main            { padding: 1rem; }
  .header          { padding: 0.9rem 1rem; }
  .arch-grid       { grid-template-columns: 1fr; }
  .compare-columns { grid-template-columns: 1fr; }
  .signal-grid     { grid-template-columns: 1fr; }
  .metric          { max-width: none; }
  .viz-picker      { flex-wrap: wrap; }
  .viz-card        { flex: 1 1 auto; }
}
