/* Same light chrome as the sibling tools (anarci-wasm, platereader-clustering-wasm):
   #f5f5f5 page, white cards on #ddd borders, #2563eb accent, 4px radii.
   The tokens below are what app.js draws the charts with — the categorical slots
   carry family identity, the ramp carries magnitude. */
:root {
  --accent: #2563eb;
  --accent-dark: #1d4ed8;

  --surface-1: #fff;
  --plane: #f6f8fa;
  --text-primary: #333;
  --text-secondary: #666;
  --text-muted: #888;
  --grid: #eee;
  --axis: #ccc;
  --border: #ddd;

  --series-1: #2563eb;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --series-other: #94a3b8;

  /* one-hue sequential ramp for magnitude */
  --seq-100: #cde2fb; --seq-200: #9ec5f4; --seq-300: #6da7ec; --seq-400: #3987e5;
  --seq-500: #256abf; --seq-600: #184f95; --seq-700: #0d366b;

  --critical: #dc2626;
  --success-text: #16a34a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, monospace;
  background: #f5f5f5;
  color: var(--text-primary);
}

.wrap { max-width: 1200px; margin: 0 auto; padding: 20px; }

/* ---------------------------------------------------------------- header */
h1 { font-size: 1.5em; margin-bottom: 4px; }
.subtitle { color: var(--text-secondary); margin-bottom: 20px; font-size: 0.9em; max-width: 90ch; }

button, .btn {
  font: inherit; font-size: 0.9em; font-weight: 600;
  padding: 8px 12px; border: none; border-radius: 4px;
  background: #64748b; color: #fff; cursor: pointer;
}
button:hover:not(:disabled), .btn:hover { background: #475569; }
button:disabled { background: #94a3b8; cursor: not-allowed; }
button.primary { background: var(--accent); }
button.primary:hover:not(:disabled) { background: var(--accent-dark); }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 4px; padding: 16px; margin-bottom: 16px;
}
.card > h2 { font-size: 1em; margin-bottom: 4px; }
.card > h2 + .sub { margin-bottom: 12px; color: var(--text-secondary); font-size: 0.85em; }

/* ---------------------------------------------------------------- inputs */
.drops { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; }
@media (max-width: 760px) { .drops { grid-template-columns: 1fr; } }

.drop {
  border: 2px dashed var(--axis); border-radius: 4px;
  padding: 20px; text-align: center; color: var(--text-muted); cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--accent); color: var(--accent); }
.drop.filled { border-style: solid; border-color: var(--success-text); color: var(--text-muted); }
.drop .big { font-weight: 600; font-size: 0.95em; color: var(--text-primary); margin-bottom: 4px; }
.drop .hint { font-size: 0.8em; line-height: 1.5; }
.drop .file { color: var(--success-text); font-size: 0.8em; margin-top: 8px; font-weight: 600; word-break: break-all; }
.drop input[type=file] { display: none; }
.pill-row { display: flex; gap: 6px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.pill {
  font-size: 0.8em; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--plane); color: var(--text-secondary);
}
.pill:hover { border-color: var(--accent); color: var(--accent); }

details.settings { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
details.settings summary {
  cursor: pointer; font-size: 0.85em; font-weight: 600; color: #555; user-select: none;
  list-style: none; display: flex; align-items: center; gap: 6px;
}
details.settings summary::-webkit-details-marker { display: none; }
details.settings summary::before { content: "▸"; transition: transform .15s; display: inline-block; }
details.settings[open] summary::before { transform: rotate(90deg); }

.params { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 12px; margin-top: 16px; }
.param label { display: block; font-size: 0.8em; color: #555; margin-bottom: 4px; }
.param label b { font-weight: 600; }
.param input, .param select {
  width: 100%; font: inherit; font-size: 0.9em; padding: 6px 10px;
  border: 1px solid var(--axis); border-radius: 4px;
  background: #fff; color: var(--text-primary);
}
.param .note { font-size: 0.75em; color: var(--text-muted); margin-top: 4px; line-height: 1.4; }

.actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- progress */
.bar { height: 5px; border-radius: 3px; background: var(--grid); overflow: hidden; flex: 1; min-width: 160px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .2s; }
.log {
  font: 0.75em/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text-secondary); background: var(--plane);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 8px 12px; max-height: 180px; overflow-y: auto; margin-top: 12px;
  white-space: pre-wrap;
}
.err {
  background: #ffecec; border: 1px solid #f99; color: #a00;
  padding: 10px 14px; border-radius: 4px; margin-top: 12px; font-size: 0.85em;
}
.err b { display: block; margin-bottom: 3px; }

/* ---------------------------------------------------------------- stats */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.tile { background: var(--plane); border: 1px solid var(--border); border-radius: 4px; padding: 12px 14px; }
.tile .v { font-size: 1.6em; font-weight: 700; line-height: 1.15; }
.tile .k { font-size: 0.8em; color: var(--text-secondary); margin-top: 2px; }

/* ---------------------------------------------------------------- charts */
.chart-wrap { overflow-x: auto; }
svg { display: block; max-width: 100%; }
svg text { fill: var(--text-secondary); font-size: 11px; }
svg text.axis-title { fill: var(--text-muted); font-size: 11px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 0.8em; align-items: center; }
.legend .item { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.legend .swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.scale { display: flex; align-items: center; gap: 8px; font-size: 0.8em; color: var(--text-secondary); margin-top: 12px; }
.scale .ramp { display: flex; border-radius: 3px; overflow: hidden; }
.scale .ramp i { width: 22px; height: 11px; }

#tip {
  position: fixed; pointer-events: none; z-index: 50; opacity: 0;
  background: #fff; color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 4px;
  box-shadow: 0 2px 8px rgb(0 0 0 / 12%);
  padding: 8px 11px; font-size: 0.8em; line-height: 1.5; max-width: 300px;
  transition: opacity .1s;
}
#tip b { font-weight: 600; }
#tip .dim { color: var(--text-secondary); }

/* ---------------------------------------------------------------- tables */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 4px; }
table { border-collapse: collapse; width: 100%; font-size: 0.85em; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th {
  background: var(--plane); font-weight: 600; color: #555;
  position: sticky; top: 0; cursor: pointer; user-select: none;
}
th:hover { color: var(--text-primary); }
th.sorted::after { content: " ▾"; color: var(--accent); }
th.sorted.asc::after { content: " ▴"; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
td.wrap-cell { white-space: normal; min-width: 240px; color: var(--text-secondary); }
.scroll-y { max-height: 480px; overflow-y: auto; }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.95em; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--plane); color: var(--text-primary);
}
.tag i { width: 8px; height: 8px; border-radius: 50%; flex: none; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input[type=search], .toolbar select {
  font: inherit; font-size: 0.85em; padding: 6px 10px; border-radius: 4px;
  border: 1px solid var(--axis); background: #fff; color: var(--text-primary);
}
.toolbar input[type=search] { min-width: 220px; }
.count { color: var(--text-secondary); font-size: 0.8em; }
.count input[type=checkbox] { accent-color: var(--accent); cursor: pointer; vertical-align: middle; margin-right: 4px; }

.dl-row { display: flex; flex-wrap: wrap; gap: 8px; }

.hidden { display: none !important; }
.note-line { font-size: 0.8em; color: var(--text-secondary); margin-top: 12px; }
.note-line code { font-size: 0.95em; background: var(--plane); padding: 1px 5px; border-radius: 4px; }

/* ---------------------------------------------------------------- credits */
.credits { margin-top: 24px; padding-top: 12px; border-top: 1px solid #e5e7eb; font-size: 0.8em; color: var(--text-secondary); }
.credits a { color: var(--accent); text-decoration: none; }
.credits a:hover { text-decoration: underline; }
