:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1c2430;
  --muted: #5b6675;
  --accent: #0f6a4f;
  --accent-ink: #ffffff;
  --line: #dde2e8;
  --dominant: #dcf5e7;
  --highlight: #eef6ff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181e;
    --card: #1d232c;
    --ink: #e8ecf1;
    --muted: #9aa5b1;
    --accent: #35b58c;
    --accent-ink: #0d1117;
    --line: #313a45;
    --dominant: #1e3a2e;
    --highlight: #1e2a3a;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
header { padding: 2.2rem 1.5rem 0.5rem; max-width: 860px; margin: 0 auto; }
.home-link { text-decoration: none; color: inherit; display: inline-block; }
h1 { margin: 0; font-size: 2rem; letter-spacing: 0.01em; }
.tagline { color: var(--muted); margin: 0.25rem 0 0; }
.prefs { margin-top: 0.6rem; font-size: 0.9rem; color: var(--muted); }
.prefs label { display: inline-flex; align-items: center; gap: 0.35rem; }
.prefs select { width: auto; padding: 0.2rem 0.4rem; }
.cur { color: var(--muted); font-size: 0.82em; margin-right: 1px; font-weight: 400; }
main { max-width: 860px; margin: 0 auto; padding: 1rem 1.5rem 3rem; display: grid; gap: 1rem; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.1rem 1.25rem 1.25rem;
}
.card h2 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.step {
  display: inline-block; width: 1.5rem; height: 1.5rem; line-height: 1.5rem;
  text-align: center; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-size: 0.9rem; margin-right: 0.4rem;
}
.hint { color: var(--muted); font-size: 0.9rem; margin: 0.25rem 0 0.75rem; }
textarea, select, input[type="file"] {
  width: 100%; font: inherit; color: inherit;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 0.6rem;
}
textarea { resize: vertical; font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem; }
.row { display: flex; gap: 0.75rem; align-items: center; margin-top: 0.9rem; flex-wrap: wrap; }
.row label { flex: 1; min-width: 180px; font-size: 0.9rem; color: var(--muted); }
.row select { margin-top: 0.25rem; }
button, .button {
  font: inherit; padding: 0.55rem 1.1rem; border-radius: 8px; display: inline-block;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer;
  text-decoration: none;
}
.row button { margin-left: auto; }
button.primary, .button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:hover, .button:hover { filter: brightness(1.05); }
table { border-collapse: collapse; width: 100%; margin-top: 0.5rem; font-variant-numeric: tabular-nums; }
th, td { border: 1px solid var(--line); padding: 0.45rem 0.6rem; text-align: right; }
th:first-child, td:first-child { text-align: left; }
thead th { background: var(--highlight); }
.stats-row { display: flex; gap: 1.5rem; flex-wrap: wrap; margin: 0.25rem 0 0.75rem; }
.stat b { display: block; font-size: 1.35rem; }
.stat span { color: var(--muted); font-size: 0.85rem; }
#grid-table td.phrase { background: var(--highlight); }
#grid-table tr.standard td { background: var(--dominant); }
.k-label { display: flex; align-items: center; gap: 0.5rem; }
input[type="range"] { width: 160px; }
output { font-size: 1.3rem; font-weight: 600; }
.hidden { display: none; }
footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 1rem; }

/* ---- instrument shell ---- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.tool-card {
  position: relative; display: block;
  border: 1px solid var(--line); border-radius: 10px; padding: 0.9rem 1rem;
  background: var(--bg); color: inherit; text-decoration: none;
}
.tool-card:hover { border-color: var(--accent); }
.tool-card h3 { margin: 0 0 0.3rem; font-size: 1rem; }
.tool-card p { margin: 0; color: var(--muted); font-size: 0.85rem; }
.tool-card.soon { opacity: 0.72; }
.tool-card .badge {
  position: absolute; top: 0.6rem; right: 0.6rem;
  font-size: 0.68rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 0.05rem 0.45rem;
}
.affordances { justify-content: flex-start; gap: 0.6rem; }
.affordances button, .affordances .button { margin-left: 0; }
.sendto {
  display: inline-flex; align-items: center; gap: 0.4rem;
  flex: 0 0 auto; min-width: 0;
  font-size: 0.9rem; color: var(--muted);
}
.sendto select { width: auto; margin: 0; }

/* ---- Coverage explorer ---- */
#cov-chart {
  width: 100%; height: auto; margin-top: 0.5rem;
  touch-action: none; cursor: ew-resize; user-select: none;
}
.cov-grid { stroke: var(--line); stroke-width: 1; }
.cov-axis { fill: var(--muted); font-size: 11px; }
.cov-area { fill: var(--accent); opacity: 0.12; }
.cov-line { stroke: var(--accent); stroke-width: 2; }
.cov-guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.cov-dot { fill: var(--accent); stroke: var(--card); stroke-width: 2; }
.cov-controls { display: flex; gap: 1.5rem; flex-wrap: wrap; margin-top: 0.75rem; }
.cov-field { flex: 1; min-width: 220px; }
.cov-field label { color: var(--muted); font-size: 0.9rem; }
.cov-field input { width: 100%; margin-top: 0.25rem; }
.cov-field output { font-size: 1.1rem; font-weight: 600; }
.cov-check { display: inline-flex; align-items: center; gap: 0.4rem; flex: 0 0 auto; font-size: 0.9rem; color: var(--muted); }
.cov-check input { width: auto; }

/* ---- Resample histogram ---- */
.hist-bar { fill: var(--accent); opacity: 0.55; }
.hist-ci { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 4 3; }
.hist-est { stroke: var(--accent); stroke-width: 2; }

/* ---- Stats Panel ---- */
.stat-checks {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.35rem 1rem; margin: 0.5rem 0 0.25rem;
}
.stat-check { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; }
.stat-check input { width: auto; }
#stats-table td:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- Pareto sets ---- */
#pareto-table tr.pareto-dominant td { background: var(--dominant); }
#pareto-table tr.pareto-prominent td { background: var(--highlight); }
