:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #16191d;
  --muted: #5d6570;
  --border: #dde1e6;
  --accent: #e8590c;
  --accent-text: #ffffff;
  --accent-soft: #fde7da;
  --ok: #1f8a4c;
  --danger: #c92a2a;
  --grid: #e3e6ea;
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1c2027;
    --surface-2: #252a33;
    --text: #e8eaed;
    --muted: #9aa3ae;
    --border: #2f3540;
    --accent: #ff7a33;
    --accent-text: #14171c;
    --accent-soft: #3a2619;
    --ok: #4cc27f;
    --danger: #ff6b6b;
    --grid: #2a3039;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* Component display rules (buttons, grids) would otherwise override the hidden attribute */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 17px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 650; margin-bottom: 14px; }
a { color: var(--accent); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand, .conn { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 6px; }

main { max-width: 1040px; margin: 0 auto; padding: 16px; }

.panels {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
@media (min-width: 720px) {
  .panels { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); }
}
.panels .eq, .panels .advanced { grid-column: 1 / -1; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.hero { max-width: 560px; margin: 8vh auto 0; }
.hero p { color: var(--muted); }
.notice { border-color: var(--danger); margin-bottom: 16px; }
.banner {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { margin: 0; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 14px; }

button, .button {
  font: inherit;
  font-weight: 550;
  border-radius: 8px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.ghost { background: transparent; }
.small { padding: 4px 10px; font-size: 13px; }
.danger { background: transparent; border-color: var(--danger); color: var(--danger); }

.chip {
  font-size: 13px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}
.chip.on { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }

.hint, .meta { font-size: 13px; color: var(--muted); margin: 6px 0 0; }

.stats { margin: 0; display: grid; gap: 10px; }
.stats div { display: flex; justify-content: space-between; gap: 12px; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; text-align: right; display: flex; align-items: center; gap: 8px; }
.meter { width: 64px; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--ok); transition: width 0.3s; }

.field { display: block; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.label { display: flex; justify-content: space-between; margin-bottom: 6px; font-weight: 550; }
.label output { color: var(--muted); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
select, input[type="text"], input:not([type]), input[type="number"] {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
}
.field select { width: 100%; }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 3px; }
.segmented button { border: 0; background: transparent; padding: 5px 14px; font-weight: 550; color: var(--muted); }
.segmented button[aria-checked="true"], .segmented button[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.12);
}

.eq-toolbar { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.eq-toolbar label { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.eq-toolbar input { width: 220px; max-width: 100%; }

.eq-plot { width: 100%; height: auto; aspect-ratio: 3 / 1; display: block; background: var(--surface-2); border-radius: 8px; }
.eq-plot .grid { stroke: var(--grid); stroke-width: 1; }
.eq-plot .zero { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.eq-plot .curve { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.eq-plot .axis { fill: var(--muted); font-size: 10px; }

.table-wrap { overflow-x: auto; margin-top: 12px; }
.filters { width: 100%; border-collapse: collapse; min-width: 480px; }
.filters th { text-align: left; font-size: 12px; font-weight: 550; color: var(--muted); padding: 4px 6px; }
.filters td { padding: 3px 6px; }
.filters input[type="number"] { width: 92px; }
.filters input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.filters tr.off td:not(:first-child) { opacity: 0.4; }

.advanced summary { cursor: pointer; font-weight: 650; }
.advanced[open] summary { margin-bottom: 14px; }
.danger-zone { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  background: var(--text);
  color: var(--bg);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 14px;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 480px) {
  .hero { margin-top: 16px; }
  .eq-toolbar label { width: 100%; }
  .eq-toolbar input, .eq-toolbar select { flex: 1; }
}
