:root {
  --ink-950: #0d0f14;
  --ink-900: #191d29;
  --ink-800: #232837;
  --ink-700: #2e3446;
  --ink-600: #454d66;
  --ink-500: #5b6480;
  --line: #313852;
  --text-hi: #f1f3fb;
  --text-mid: #aab0c4;
  --text-low: #6b7288;

  --accent: #fc0944;
  --accent-strong: #d1073a;
  --accent-soft: rgba(252, 9, 68, 0.14);
  --accent-contrast: var(--ink-950);

  /* Reserved exclusively for indicating a nature's boosted/lowered stat (radar chart
     labels + accent dot) — never used for card/section/panel identity, buttons, or tabs. */
  --orange: #fd7c00;
  --orange-strong: #e06e00;
  --orange-soft: rgba(253, 124, 0, 0.14);
  --lavender: #646efc;
  --lavender-strong: #4d57e0;
  --lavender-soft: rgba(100, 110, 252, 0.14);

  /* Used only for the "Pokémon to compare" card's edge + title label. */
  --compare: #4f6fd9;

  /* Defenses tab survival chart, HP axis: green = HP gained (bigger step = "more
     gained"), purple = HP lost (bigger step = "avoids losing more") — deliberately not
     blue/orange, which read too close to --lavender/--orange (nature indicator) and to
     each other. -dim = exactly one checked "HP% breakpoints" row matches that Stat
     Point, full = 2+ rows match it, --hp-mixed = a gain row and a loss row both match
     the same point. Each dim/full pair shares a hue, varying mainly in saturation, so
     the two read as one continuum rather than unrelated colors. */
  --hp-gain: #35d485;
  --hp-gain-dim: #57a880;
  --hp-loss: #b067e4;
  --hp-loss-dim: #9268b1;
  --hp-mixed: #ae987a;

  /* Independent from --orange on purpose: this is a generic "heads up" color (import
     warnings, chart threshold marker), not a nature indicator. */
  --warn: #e6b325;
  --warn-soft: rgba(230, 179, 37, 0.14);
  --danger: #ff6b81;
  --danger-soft: rgba(255, 107, 129, 0.14);
  --success: #7fd894;
  --success-soft: rgba(120, 200, 120, 0.14);

  --grid-line: #232937;

  --zone-header-bg: #120c0f;
  --zone-tabs-bg: var(--ink-900);

  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 16px;

  --font-display: ui-sans-serif, "Segoe UI Semibold", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-body: ui-sans-serif, "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;

  /* Brand wordmark only ("PokéSpread" in the header) — kept separate from
     --font-display, which stays on the system stack for panel/modal headings
     so small dense UI text keeps maximum legibility. */
  --font-brand: "Chakra Petch", ui-sans-serif, "Segoe UI Semibold", "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* Self-hosted — avoids a request to fonts.googleapis.com (and the GDPR/consent
   question that comes with it). Only the Bold weight is loaded since the
   wordmark is the sole thing using --font-brand. */
@font-face {
  font-family: "Chakra Petch";
  src: url("assets/fonts/ChakraPetch-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink-950);
  color: var(--text-hi);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
}

body {
  background-image:
    radial-gradient(circle at 12% -10%, rgba(252, 9, 68, 0.08), transparent 40%),
    radial-gradient(circle at 90% 0%, rgba(253, 124, 0, 0.05), transparent 35%);
}

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

a { color: var(--accent); }

/* ---------- header ---------- */
.app-header {
  padding: 20px 24px 16px;
  background: var(--zone-header-bg);
}
.app-header-inner {
  max-width: 1180px;
  margin: 0 auto;
}
.app-header h1 {
  font-family: var(--font-brand);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
  padding-bottom: 10px;
  color: var(--text-hi);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-bottom: 2px solid var(--accent);
}
.logo-mark {
  height: 30px;
  width: auto;
  display: block;
  transform: translateY(-1px);
}
.subtitle {
  margin: 0;
  color: var(--text-low);
  font-size: 12.5px;
  max-width: 640px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ---------- footer ---------- */
.app-footer {
  background: var(--zone-tabs-bg);
  border-top: 1px solid var(--ink-600);
  padding: 32px 24px 40px;
}
.app-footer-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}
.support-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.support-pitch {
  margin: 0;
  font-weight: 700;
  font-size: 16px;
  color: var(--text-hi);
}
.support-sub {
  margin: 0;
  max-width: 640px;
  white-space: nowrap;
  color: var(--text-mid);
  font-size: 13px;
  line-height: 1.5;
}
.support-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-m);
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  transition: background 0.12s ease, transform 0.12s ease;
}
.support-link:hover { background: var(--accent-strong); transform: translateY(-1px); }
.support-icon { font-size: 16px; line-height: 1; }
.app-disclaimer {
  margin: 0;
  max-width: 560px;
  color: var(--text-low);
  font-size: 12px;
  line-height: 1.6;
}

/* ---------- panels ---------- */
.panel {
  background: var(--ink-900);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 22px 24px 26px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 16px 32px -16px rgba(0, 0, 0, 0.6);
}
#panel-defender {
  /* No identity color: this is the tool's default entity, not a special one. */
}

.tabs-zone {
  background: var(--zone-tabs-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 16px 32px -16px rgba(0, 0, 0, 0.6);
}
.panel-head { margin-bottom: 16px; }
.panel-head h2 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-hi);
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.panel-hint {
  margin: 0;
  color: var(--text-low);
  font-size: 13px;
}

/* ---------- fields ---------- */
.preset-save-row {
  display: flex;
  align-items: flex-end;
  gap: 14px;
}
.preset-save-row .field { flex: 1 1 auto; max-width: 460px; }
.preset-save-actions {
  display: flex;
  gap: 8px;
  padding-bottom: 1px;
  flex: none;
}
.preset-alert {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--danger);
  display: none;
}
.preset-alert.visible { display: block; }
.defender-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px 18px;
}
.field-wide { grid-column: span 2; }
/* Forces a field onto its own full-width row regardless of column count — used where
   fields need to stack top to bottom instead of flowing into the grid's columns. */
.field-full { grid-column: 1 / -1; }
/* A row of side-by-side columns, each stacking its own fields top to bottom — e.g. one
   column of moves next to a column of Atk SP/stage next to a column of SpA SP/stage. */
.field-columns { display: flex; gap: 18px; }
.field-column { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.field-checkboxes {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.field-note { text-transform: none; font-weight: 400; color: var(--text-low); letter-spacing: 0; }

input[type="text"],
input[type="number"],
select {
  width: 100%;
  background: var(--ink-800);
  border: 1px solid var(--line);
  color: var(--text-hi);
  border-radius: var(--radius-s);
  padding: 9px 10px;
  font-size: 14px;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.12s ease, background 0.12s ease;
}
input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  border-color: var(--accent);
  background: var(--ink-700);
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-low) 50%), linear-gradient(135deg, var(--text-low) 50%, transparent 50%); background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 28px; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-mid);
  cursor: pointer;
}
.checkbox-label input { accent-color: var(--accent); width: 15px; height: 15px; }

/* search-select combo */
.search-select { position: relative; }
.search-select.is-disabled input { opacity: .6; cursor: not-allowed; background: var(--bg-inset, rgba(255,255,255,.03)); }
.search-select-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  background: var(--ink-700);
  border: 1px solid var(--ink-600);
  border-radius: var(--radius-s);
  box-shadow: 0 12px 28px rgba(0,0,0,0.45);
  z-index: 40;
  display: none;
}
.search-select.open .search-select-options { display: block; }
.search-select-option {
  padding: 8px 11px;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--text-mid);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.search-select-option:hover,
.search-select-option.active {
  background: var(--ink-600);
  color: var(--text-hi);
}
.search-select-option .opt-sub { color: var(--text-low); font-size: 11.5px; }
.search-select-empty { padding: 10px 11px; color: var(--text-low); font-size: 13px; }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
  background: var(--ink-800);
  color: var(--text-hi);
  padding: 9px 16px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}
.btn:hover { background: var(--ink-700); border-color: var(--ink-500); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: var(--ink-500); color: var(--text-mid); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn-add {
  width: 100%;
  border-style: dashed;
  color: var(--text-mid);
  padding: 11px 16px;
}
.btn-add:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* ---------- tabs ---------- */
.tabs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: var(--ink-800);
  border: 1px solid var(--ink-600);
  border-radius: var(--radius-m);
  padding: 6px;
}
.tab-btn {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text-low);
  background: transparent;
  border: none;
  border-radius: var(--radius-s);
  padding: 9px 16px;
  cursor: pointer;
  transition: color 0.12s ease, background 0.12s ease;
}
.tab-btn:hover { color: var(--text-mid); background: rgba(255,255,255,0.03); }
.tab-btn.active { color: var(--accent-contrast); background: var(--accent); }
.tab-btn.active:hover { color: var(--accent-contrast); background: var(--accent); }
.tab-btn:disabled { color: var(--ink-500); cursor: default; }
.tab-btn:disabled:hover { color: var(--ink-500); background: transparent; }

.tab-panel { display: flex; flex-direction: column; gap: 22px; }
.tab-panel.hidden { display: none; }

.tab-stat-row {
  background: var(--ink-900);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 16px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px 18px;
  align-items: flex-start;
}
.tab-stat-row .field { max-width: 220px; }
/* "My stages" / "Replace opponent stage" columns (Defenses tab): each stacks two
   label+select rows under one shared column title instead of two separate
   side-by-side .field elements. Each row's own sub-label ("Def"/"SpD"/"Atk"/"SpA")
   sits above its select rather than beside it, to keep the column narrow — this is
   what actually frees up enough width for the "Replace opponent stage" and
   "Critical hits" columns to fit on one line. align-items: flex-start (rather than
   the flex column default of stretch) lets the title wrap or not on its own terms
   instead of being forced as wide as its select. */
.stage-group { gap: 6px; align-items: flex-start; }
.stage-group > label { white-space: nowrap; }
.stage-group-rows { display: flex; flex-direction: column; gap: 8px; }
.stage-row { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.stage-row-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-low);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
/* Shared width across every "stage" select in Defenses (My stages, Replace opponent
   stage) and the attack tabs (My Atk/SpA stage, Replace opponent Def/SpD stage) — wide
   enough to show "0 (neutral)" / "Not replaced" in full, and explicitly identical
   rather than left to each field's own auto-sizing. */
.stage-row select,
[data-role="stat-boost"],
[data-role="def-stage-force"] {
  width: 124px;
  padding: 6px 22px 6px 8px;
  font-size: 13px;
}
/* "Nature impact" (Defenses tab): "Def nature impact" and "SpD nature impact" merged
   under one shared title, each column getting the same small sub-label treatment as
   "My stages" / "Replace opponent stage" above instead of repeating "nature impact" in
   its own title — narrower than two separate side-by-side fields. */
.nature-impact-cols { display: flex; gap: 10px; }
.nature-impact-col { display: flex; flex-direction: column; gap: 4px; }
.nature-impact-col .checkbox-label { white-space: nowrap; }
.field-checkbox-inline { align-self: flex-end; }
.field-checkbox-inline label.checkbox-label {
  height: 37px;
  display: flex;
  align-items: center;
  white-space: nowrap;
}
.speed-checkbox-stack {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  max-width: none;
}
.speed-checkbox-stack .checkbox-label {
  display: flex;
  align-items: center;
  white-space: nowrap;
}
.tab-stat-row .field.hp-pct-field { max-width: none; }
.hp-pct-field { flex: 0 0 auto; }
.hp-pct-row {
  display: flex;
  flex-wrap: wrap;
  width: fit-content;
  max-width: 100%;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--ink-800);
  overflow: hidden;
}
.hp-pct-row .hp-pct-input, input[type="number"].hp-pct-input {
  flex: none;
  width: 228px;
  border: none;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  -moz-appearance: textfield;
  appearance: textfield;
}
/* Defenses tab has two extra "Nature impact" fields, plus (as of the opponent-stage-
   force + critical-hit columns) two more, crowding the same row — its HP%-remaining
   input needs to be noticeably narrower to keep everything on one line. Reduced a
   further ~30% (90px -> 63px) from its already-reduced base width to make room. The
   Physical/Special attack tabs gained the same two extra columns (opponent-stage-force
   + critical hits), so their HP%-dealt input gets the same treatment/width. */
[data-tab-panel="defenses"] .hp-pct-row .hp-pct-input,
[data-tab-panel="defenses"] input[type="number"].hp-pct-input,
[data-tab-panel="physical-attack"] .hp-pct-row .hp-pct-input,
[data-tab-panel="physical-attack"] input[type="number"].hp-pct-input,
[data-tab-panel="special-attack"] .hp-pct-row .hp-pct-input,
[data-tab-panel="special-attack"] input[type="number"].hp-pct-input {
  width: 63px;
}
.hp-pct-input::-webkit-inner-spin-button,
.hp-pct-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.hp-pct-input:focus { background: var(--ink-700); border-color: var(--line); }
.hp-pct-spin {
  display: flex;
  flex-direction: column;
  flex: none;
  width: 22px;
  border-right: 1px solid var(--line);
}
.hp-pct-spin button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-mid);
  font-size: 8px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.hp-pct-spin button:first-child { border-bottom: 1px solid var(--line); }
.hp-pct-spin button:hover { background: var(--ink-700); color: var(--text-hi); }
.hko-btn-group { display: flex; flex: none; }
.hko-btn-group button {
  flex: none;
  width: 57px;
  border: none;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--text-mid);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 0 2px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.hko-btn-group button:last-child { border-right: none; }
.hko-btn-group button:hover { background: var(--ink-700); color: var(--text-hi); }
.hko-btn-group button.active { background: var(--accent); color: var(--accent-contrast); }
/* Same crowding as the HP% input above: shave ~10% (57px -> 51px) off the four
   1/2/3/4OHKO buttons — in Defenses and, for the same reason, the attack tabs too. */
[data-tab-panel="defenses"] .hko-btn-group button,
[data-tab-panel="physical-attack"] .hko-btn-group button,
[data-tab-panel="special-attack"] .hko-btn-group button { width: 51px; }
.field-hint { grid-column: 1 / -1; margin: 4px 0 0; font-size: 11px; color: var(--text-low); max-width: 320px; }
/* The HP%-row (input + round-to-whole spinner + 1/2/3/4OHKO buttons) is only ~291px
   wide (63 + 22 + 4x51 + borders) — cap this specific hint to that same width so it
   wraps within the row's own footprint instead of stretching the whole column wider. */
.hp-pct-field .field-hint { max-width: 291px; }
.extra-point-hint { color: var(--accent); max-width: none; margin: 6px 0 0; }
.extra-point-hint.hidden { display: none; }
.hp-breakpoint-hint { max-width: none; margin: 4px 0 0; }
.hp-breakpoint-hint.hidden { display: none; }
.hp-breakpoints-intro { max-width: none; }
.link-btn {
  background: none; border: none; padding: 0; margin: 6px 0 0;
  font-family: var(--font-body); font-size: 12px; color: var(--text-mid);
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:hover { color: var(--text-hi); }

.tab-placeholder {
  background: var(--ink-900);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 60px 24px;
  text-align: center;
  color: var(--text-low);
  font-size: 13.5px;
}
.tab-placeholder strong { color: var(--text-mid); display: block; margin-bottom: 6px; font-size: 14.5px; }

.condition-side-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 16px;
}
.condition-side h4 {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-low);
  margin: 0 0 8px;
}
.condition-side .field-checkboxes { gap: 8px; }

/* ---------- attack-tab KO table ---------- */
.ko-table-wrap {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  position: relative;
}
.ko-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 12.5px;
}
.ko-table th, .ko-table td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 4px 8px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: break-word;
}
.ko-table th:last-child, .ko-table td:last-child { border-right: none; }
/* Fixed height, ~7 chips' worth — a cell landing many "to compare" entries on the same
   SP threshold (very common for the Always/Never guarantee-KO rows) scrolls internally
   instead of blowing out the whole table's row height. The scrollbar itself stays
   essentially invisible until hovered, and thin, since these columns are already narrow
   (especially with 4 of them side by side). */
.ko-cell-scroll {
  max-height: 232px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  /* Reclaim the width the scrollbar track would otherwise steal from the (already
     narrow) column text, by extending into the cell's own right padding and letting
     the (transparent, hover-only) scrollbar overlap the content instead. */
  margin-right: -8px;
  padding-right: 8px;
  box-sizing: border-box;
}
.ko-cell-scroll:hover { scrollbar-color: rgba(255, 255, 255, 0.35) transparent; }
.ko-cell-scroll::-webkit-scrollbar { width: 5px; }
.ko-cell-scroll::-webkit-scrollbar-track { background: transparent; }
.ko-cell-scroll::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
.ko-cell-scroll:hover::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.35); }
.ko-table thead th {
  position: sticky;
  top: 0;
  background: var(--ink-800);
  z-index: 5;
  padding: 8px;
}
.ko-table thead th.ko-corner {
  left: 0;
  z-index: 6;
  width: 84px;
}
.ko-add-col { width: 34px !important; text-align: center; padding: 4px !important; }
.ko-add-col-btn {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-s);
  border: 1px dashed var(--ink-500);
  background: transparent;
  color: var(--text-mid);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.ko-add-col-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.ko-col-head { display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.ko-col-remove {
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-low);
  cursor: pointer;
  border-radius: 4px;
}
.ko-col-remove:hover { color: var(--danger); background: var(--danger-soft); }
.ko-table tbody th {
  position: sticky;
  left: 0;
  background: var(--ink-900);
  color: var(--text-mid);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 11.5px;
  white-space: normal;
  line-height: 1.25;
  width: 84px;
}
.ko-table tbody tr:nth-child(odd) td,
.ko-table tbody tr:nth-child(odd) th { background-color: rgba(255,255,255,0.015); }
.ko-table tbody tr.ko-row-edge th { color: var(--text-low); font-style: italic; }
.ko-table tbody th.extra-point-row { color: var(--accent); font-weight: 700; cursor: help; }
.ko-table .ko-move-select { width: 100%; }
.ko-table .ko-move-select input { font-size: 12px; padding: 6px 8px; }

.ko-cell-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  background: var(--ink-800);
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--text-mid);
  margin: 1px 3px 3px 0;
  cursor: pointer;
  max-width: 100%;
}
.ko-cell-chip-line1 { display: flex; align-items: center; gap: 5px; max-width: 100%; }
.ko-cell-chip:hover { color: var(--text-hi); }
.ko-cell-chip .chip-swatch { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.ko-cell-chip-info { color: var(--text-low); font-family: var(--font-mono); font-size: 10.5px; white-space: normal; }

.ko-row-gap th, .ko-row-gap td {
  padding: 2px 8px;
  color: var(--text-low);
  text-align: center;
  border-right: 1px solid var(--line);
  background: transparent;
}
.ko-row-gap th { text-align: left; }
.ko-table-toggles { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin-bottom: 4px; }
.ko-table-toggle {
  display: inline-flex;
  margin-bottom: 0;
  font-size: 12.5px;
}
.dedupe-hint { margin: 0 0 10px; max-width: none; }
.dedupe-hint.hidden { display: none; }

.attack-target-col { min-width: 0; }
.attack-table-col { min-width: 0; }

/* ---------- speed tab chart ---------- */
.speed-axis-line { stroke: var(--ink-500); stroke-width: 1.5; }
.speed-center-grid { stroke: var(--grid-line); stroke-width: 1; stroke-dasharray: 2 3; }
.speed-connector { stroke: var(--text-low); stroke-width: 1; stroke-dasharray: 1.5 2; opacity: 0.6; }
.speed-tick { stroke: var(--ink-500); stroke-width: 1; }
.speed-tick-extra { stroke: var(--accent); stroke-width: 2; }
.speed-label-left { fill: var(--text-mid); font-family: var(--font-mono); font-size: 9px; }
.speed-label-left-extra { fill: var(--accent); font-weight: 700; }
.speed-label-right { fill: var(--text-hi); font-family: var(--font-body); font-size: 12px; font-weight: 600; }
.speed-label-right-val { fill: var(--text-low); font-family: var(--font-mono); font-size: 10.5px; font-weight: 400; }
.speed-center-label { fill: var(--text-low); font-family: var(--font-mono); font-size: 10px; }
.speed-marker { stroke: var(--ink-900); stroke-width: 1.5; }
.speed-marker-extra { r: 4.5; stroke-width: 2; }
.speed-analyzed-dot { fill: var(--accent); }
.speed-axis-caption { fill: var(--text-mid); font-family: var(--font-body); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.speed-range-boundary { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 5 3; opacity: 0.85; }
.speed-range-boundary-label { fill: var(--warn); font-family: var(--font-body); font-size: 10px; font-weight: 600; }

/* ---------- import / export tab ---------- */
.ie-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 20px;
  row-gap: 0;
}
.ie-cell {
  padding: 10px 22px;
  background: var(--ink-800);
}
.ie-cell-head { padding-top: 20px; border-top: 4px solid transparent; border-top-left-radius: var(--radius-l); border-top-right-radius: var(--radius-l); }
.ie-cell-last { padding-bottom: 20px; border-bottom-left-radius: var(--radius-l); border-bottom-right-radius: var(--radius-l); }
.ie-cell:not(.ie-cell-head):not(.ie-cell-last) { border-top: 1px solid var(--ink-600); border-bottom: 1px solid var(--ink-600); margin-top: -1px; }
.ie-cell-analyzed.ie-cell-head { border-top-color: var(--accent); }
.ie-cell-compare.ie-cell-head { border-top-color: var(--compare); }
.ie-cell-analyzed.ie-cell-head .panel-head h2 { color: var(--accent); }
.ie-cell-compare.ie-cell-head .panel-head h2 { color: var(--compare); }
.ie-sub-head {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-mid);
  margin: 0 0 6px;
}
.import-textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  background: var(--ink-700);
  border: 1px solid var(--line);
  color: var(--text-hi);
  border-radius: var(--radius-m);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  outline: none;
}
.import-textarea:focus { border-color: var(--accent); }
.import-textarea[data-role="analyzed-import-textarea"],
.import-textarea[data-role="import-textarea"] {
  min-height: 260px;
}
.import-actions { display: flex; gap: 10px; margin-top: 14px; }
.import-log { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.import-log-line {
  font-size: 13px;
  padding: 9px 12px;
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
}
.import-log-ok { background: var(--success-soft); border-color: var(--success); color: var(--text-hi); }
.import-log-warn { background: var(--warn-soft); border-color: var(--warn); color: var(--text-hi); }
.import-log-line strong { color: var(--accent); }

/* ---------- notes subsection ---------- */
.notes-grid {
  display: grid;
  grid-template-columns: 0.85fr 0.8fr 1fr;
  gap: 18px;
  align-items: stretch;
}
.notes-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 14px;
  align-content: start;
}
.notes-radar {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink-900);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 2px;
  min-height: 180px;
  position: relative;
}
.stat-meta { display: inline; font-size: 9.5px; font-weight: 400; white-space: nowrap; margin-left: 3px; }
.notes-radar svg { width: 100%; height: 100%; }
.notes-stats .field label { white-space: nowrap; }
.notes-remaining {
  grid-column: 1 / -1;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mid);
  background: var(--ink-700);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 8px 12px;
}
.notes-remaining.over-budget { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.notes-freeform { display: flex; flex-direction: column; }
.notes-freeform textarea {
  flex: 1;
  min-height: 140px;
  resize: vertical;
  background: var(--ink-800);
  border: 1px solid var(--line);
  color: var(--text-hi);
  border-radius: var(--radius-s);
  padding: 10px 11px;
  font-size: 13.5px;
  font-family: var(--font-body);
  line-height: 1.5;
  outline: none;
}
.notes-freeform textarea:focus { border-color: var(--accent); background: var(--ink-700); }

/* ---------- subsections ---------- */
.subsection {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.subsection-head { margin-bottom: 14px; }
.subsection-head h3 {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-mid);
  margin: 0 0 4px;
}
.subsection-modal { margin-top: 8px; padding-top: 16px; }
.subsection-modal .panel-hint { font-size: 12px; }

.modal-grid-name { display: flex; align-items: end; gap: 16px; margin-bottom: 2px; }
.field-color { width: 78px; flex: none; }
.field-color input[type="color"] {
  width: 100%;
  height: 37px;
  padding: 3px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  cursor: pointer;
}

/* ---------- middle: chart + pills ---------- */
.middle-grid {
  display: grid;
  grid-template-columns: 1fr 1.55fr;
  gap: 26px;
}
.middle-grid-attack { grid-template-columns: 0.8fr 1.75fr; }
.chart-col, .pills-col { min-width: 0; }

.chart-wrap { width: 100%; position: relative; }
#chart, [data-role="chart"] { width: 100%; height: auto; display: block; cursor: crosshair; }

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--ink-700);
  border: 1px solid var(--ink-500);
  border-radius: var(--radius-s);
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text-hi);
  box-shadow: 0 10px 24px rgba(0,0,0,0.4);
  white-space: nowrap;
  z-index: 30;
  transform: translate(-50%, -100%);
  margin-top: -10px;
}
.chart-tooltip.hidden { display: none; }
.chart-tooltip .tt-name { font-weight: 700; margin-bottom: 2px; }
.chart-tooltip .tt-coords { color: var(--text-mid); font-family: var(--font-mono); font-size: 11.5px; }
.chart-tooltip.tt-extra-point { border-color: var(--accent); }
.chart-tooltip.tt-extra-point .tt-coords { color: var(--accent); font-weight: 700; }

.chart-line-group.dimmed { opacity: 0.28; }
.chart-line-group.highlighted .chart-line { stroke-width: 3.6; }
.chart-line-marker { transform-box: fill-box; transform-origin: center; transition: transform 0.1s ease; stroke: var(--ink-900); stroke-width: 1; }
.chart-line-group.highlighted .chart-line-marker { transform: scale(1.35); }
.chart-hit-path { fill: none; stroke: transparent; stroke-width: 16px; pointer-events: stroke; }
.chart-guide-line {
  stroke: var(--text-low);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  pointer-events: none;
}
.chart-guide-line-extra { stroke: var(--accent); stroke-width: 1.5; }
.chart-hover-point {
  pointer-events: none;
  stroke: var(--ink-900);
  stroke-width: 1.5;
}
.chart-axis-tag { pointer-events: none; }
.chart-axis-tag-bg { fill: var(--ink-700); stroke: var(--ink-500); stroke-width: 1; }
.chart-axis-tag-text { fill: var(--text-hi); font-family: var(--font-mono); font-size: 11px; font-weight: 600; }
.chart-axis-tag.extra-point-tag .chart-axis-tag-bg { fill: var(--accent-soft); stroke: var(--accent); }
.chart-axis-tag.extra-point-tag .chart-axis-tag-text { fill: var(--accent); }
.chart-extra-hover-line { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 4; pointer-events: none; }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 14px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-mid);
}
.legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex: none;
}
.legend-line-swatch { width: 24px; height: 10px; flex: none; overflow: visible; }
.chart-axis-title-icon-physical { fill: var(--text-mid); }
.chart-axis-title-icon-special { fill: var(--text-mid); }

.pills-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; overflow-y: auto; }

.pill-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.pill-row:hover { border-color: var(--ink-500); background: var(--ink-700); }
.pill-swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.pill-row-text { min-width: 0; flex: 1; }
.pill-row-title { font-size: 13.5px; font-weight: 600; color: var(--text-hi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill-row-sub { font-size: 12px; color: var(--text-low); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill-row-status {
  flex: none;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: 999px;
}
.status-curve { background: var(--accent-soft); color: var(--accent); }
.status-free { background: var(--success-soft); color: var(--success); }
.status-impossible { background: var(--danger-soft); color: var(--danger); }
.pill-row-inactive { opacity: 0.5; }
.pill-row-inactive:hover { opacity: 0.75; }

/* Per-pill show/hide eye toggle, and (Defenses only) the Always safe/Needs SP/Never
   safe status demoted to a small line underneath it. A fixed width (rather than
   shrink-to-fit) is what keeps the eye icon lined up from row to row — otherwise each
   row's box is only as wide as its own status text, so the icon drifts left/right
   depending on whether that row says "Needs SP" or the wider "Always safe". */
.pill-row-visibility { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: none; width: 72px; }
.pill-visibility-btn {
  background: none;
  border: none;
  padding: 3px;
  margin: 0;
  cursor: pointer;
  color: var(--text-mid);
  display: flex;
  border-radius: var(--radius-s);
}
.pill-visibility-btn:hover { background: var(--ink-600); color: var(--text-hi); }
.pill-visibility-btn.is-hidden { color: var(--text-low); }
.pill-row-status-small { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; text-align: center; }
.pill-row-status-small.status-curve { background: none; padding: 0; color: var(--accent); }
.pill-row-status-small.status-free { background: none; padding: 0; color: var(--success); }
.pill-row-status-small.status-impossible { background: none; padding: 0; color: var(--danger); }

/* "Hide all" / "Show all" pair under a pills-list subtitle. */
.bulk-visibility-row { display: flex; gap: 8px; margin: 2px 0 10px; }
.bulk-visibility-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 5px 10px;
  font-size: 11.5px;
  color: var(--text-mid);
  cursor: pointer;
}
.bulk-visibility-btn:hover { border-color: var(--ink-500); color: var(--text-hi); }

/* ---------- bottom ---------- */
.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 26px;
}
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 480px; /* roughly 10 rows of 2 (now 2-line) chips each */
  overflow-y: auto;
}
.chip {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12.5px;
  color: var(--text-mid);
  cursor: pointer;
}
.chip-list .chip { flex: 0 1 calc(50% - 4px); box-sizing: border-box; min-width: 0; }
.chip:hover { border-color: var(--ink-500); color: var(--text-hi); }
.chip-line1 { display: flex; align-items: center; gap: 7px; min-width: 0; }
.chip-swatch { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1 1 auto; }
.chip-info { color: var(--text-low); font-family: var(--font-mono); font-size: 10.5px; white-space: nowrap; padding-left: 15px; }

/* ---------- "Damage range" deep-dive section ---------- */
.violin-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 10px; }
.violin-controls-stacked { flex-direction: column; align-items: flex-start; gap: 10px; }
.violin-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.violin-group-label { font-size: 11px; font-weight: 700; color: var(--text-low); text-transform: uppercase; letter-spacing: .04em; }
.violin-fixed-field { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-mid); }
.violin-fixed-field input { width: 60px; }
.violin-fixed-field select { width: 90px; }
.pill-toggle-list { display: flex; flex-wrap: wrap; gap: 8px; }
/* Unselected chips here get no border at all (rather than the default --line one,
   which reads as a dim blue outline against the dark background) so the selected
   chip's accent border is the only one that stands out. Hover still shows a border,
   as a "you can click this" affordance. */
.chip.pill-toggle:not(.selected) { border-color: transparent; }
.chip.pill-toggle:not(.selected):hover { border-color: var(--ink-500); }
.chip.pill-toggle.selected { background: var(--accent-soft); border-color: var(--accent); color: var(--text-hi); }
.chip.chip-move { border-radius: 7px; border-color: var(--lavender-strong); }
.chip.chip-move.selected { background: var(--lavender-soft); border-color: var(--lavender); }
.violin-shape { opacity: 0.62; }
/* Same exact rolls as the SP row right below it — that extra SP bought nothing here.
   Dimmer than a normal violin but still visible (it's a real, reachable point). When
   also hover-dimmed, .violin-shape.dimmed's higher specificity takes over regardless. */
.violin-shape-dup { opacity: 0.28; }
.violin-shape.dimmed { opacity: 0.12; }
.violin-hover-guide { stroke: var(--text-low); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.violin-overflow-line { stroke: var(--warn); stroke-width: 1; stroke-dasharray: 5 3; opacity: 0.75; pointer-events: none; }
.chart-legend .chip { cursor: default; }

/* ---------- empty states ---------- */
.empty-state {
  color: var(--text-low);
  font-size: 13px;
  padding: 30px 10px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius-m);
}
.empty-state.small { padding: 8px 0; border: none; font-size: 12.5px; }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 9, 13, 0.68);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--ink-900);
  border: 1px solid var(--ink-600);
  border-radius: var(--radius-l);
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}
.modal.modal-wide { max-width: 800px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-family: var(--font-display); font-size: 16px; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-mid);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.modal-close:hover { color: var(--text-hi); }
.modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 14px 16px;
}
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
}
.modal-foot-right { display: flex; gap: 10px; margin-left: auto; }
.hidden { display: none !important; }

/* ---------- chart svg elements ---------- */
.chart-axis-line { stroke: var(--grid-line); stroke-width: 1; }
.chart-grid-line { stroke: var(--grid-line); stroke-width: 1; stroke-dasharray: 2 3; }
.chart-axis-label { fill: var(--text-low); font-size: 10.5px; font-family: var(--font-mono); }
.chart-axis-label-extra { fill: var(--accent); font-weight: 700; cursor: pointer; }

/* Defenses tab survival chart, HP axis: see HP% breakpoints modal / --hp-gain etc. */
.chart-axis-label-hp-gain-dim { fill: var(--hp-gain-dim); font-weight: 700; cursor: pointer; }
.chart-axis-label-hp-gain-strong { fill: var(--hp-gain); font-weight: 700; cursor: pointer; }
.chart-axis-label-hp-loss-dim { fill: var(--hp-loss-dim); font-weight: 700; cursor: pointer; }
.chart-axis-label-hp-loss-strong { fill: var(--hp-loss); font-weight: 700; cursor: pointer; }
.chart-axis-label-hp-mixed { fill: var(--hp-mixed); font-weight: 700; cursor: pointer; }
.chart-hp-hover-line { stroke: var(--text-low); stroke-width: 1.5; stroke-dasharray: 5 4; pointer-events: none; }

/* Defenses tab: "HP% breakpoints" modal */
.hp-breakpoints-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.hp-breakpoints-col h4 { margin: 0 0 8px; font-family: var(--font-display); font-size: 13px; color: var(--text-mid); display: flex; align-items: center; gap: 7px; }
.hp-breakpoint-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.hp-breakpoint-dot-gain { background: var(--hp-gain); }
.hp-breakpoint-dot-loss { background: var(--hp-loss); }
.hp-breakpoint-row { flex-wrap: wrap; padding: 5px 0; }
.hp-breakpoint-badge { font-size: 11px; color: var(--text-low); }

/* ---------- Defenses tab: (HP, Def/SpD) SP-spread deep dive modal ---------- */
.frontier-axis-label-extra { fill: var(--accent); font-weight: 700; }
.frontier-min-line { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 5 3; opacity: 0.85; }
.frontier-min-label { fill: var(--warn); font-family: var(--font-body); font-size: 11px; font-weight: 600; }
.frontier-point { stroke: var(--ink-900); stroke-width: 1; }
.chart-line-clickable { cursor: pointer; }
.chart-axis-title { fill: var(--text-mid); font-size: 11px; font-family: var(--font-body); font-weight: 600; }
.chart-line { fill: none; stroke-width: 2.4; stroke-linejoin: round; transition: opacity 0.1s ease, stroke-width 0.1s ease; }
.chart-point { stroke: var(--ink-900); stroke-width: 1; }

@media (max-width: 880px) {
  .defender-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .field-wide { grid-column: span 2; }
  .field-checkboxes { grid-column: span 2; }
  .field-columns { flex-direction: column; }
  .middle-grid { grid-template-columns: 1fr; }
  .bottom-grid { grid-template-columns: 1fr; }
  .modal-grid { grid-template-columns: 1fr; }
  .notes-grid { grid-template-columns: 1fr; }
  .ie-columns { display: flex; flex-direction: column; }
  .ie-cell { border-radius: 0 !important; }
  .preset-save-row { flex-direction: column; align-items: stretch; }
  .preset-save-row .field { max-width: none; }
}
