@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap");

:root {
  --bg: #e8ecef;
  --bg-deep: #dce3e8;
  --surface: #ffffff;
  --ink: #0c1014;
  --muted: #5a6773;
  --line: #cfd8df;
  --line-strong: #a8b4bf;
  --accent: #0f766e;
  --accent-hover: #0d5f59;
  --accent-soft: rgba(15, 118, 110, 0.11);
  --accent-ink: #ffffff;
  --ink-btn: #0c1014;
  --warn: #b42318;
  --ok: #0f766e;
  --lf: #c2410c;
  --mf: #0f766e;
  --hf: #1d4ed8;
  --sum: #0c1014;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --display: "Space Grotesk", "IBM Plex Sans", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 6px;
  --radius-sm: 4px;
  --shadow: 0 1px 0 rgba(12, 16, 20, 0.04);
  --shadow-lg: 0 18px 48px rgba(12, 16, 20, 0.08);
  --header-h: 56px;
  --pad: clamp(1rem, 2.5vw, 1.5rem);
  --max: 1120px;
  --max-tool: 1360px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 0.15em; }

.brand {
  margin: 0;
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.045em;
}

.brand-link { display: inline-block; color: var(--ink); text-decoration: none; }
.brand-link:hover { color: var(--accent); text-decoration: none; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 0.55rem 0.95rem;
  font: 600 0.875rem/1.2 var(--font);
  cursor: pointer;
  transition: background .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease), transform .18s var(--ease);
  white-space: nowrap;
}

.btn:hover { border-color: var(--line-strong); background: #f3f6f8; }
.btn:active { background: #e8eef2; transform: translateY(1px); }

.btn-primary {
  background: var(--ink-btn);
  border-color: var(--ink-btn);
  color: #fff;
}
.btn-primary:hover { background: #1a2229; border-color: #1a2229; filter: none; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover { background: rgba(14, 18, 22, 0.05); border-color: transparent; }

.btn-danger {
  color: var(--warn);
  border-color: #f0c7c2;
  background: #fff8f7;
}

.page-landing .landing,
.page-auth .auth-card {
  max-width: 400px;
  margin: 10vh auto;
  padding: 1.75rem 1.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: none;
}

.landing h1,
.auth-card h1 {
  margin: 0.85rem 0 0.4rem;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.035em;
}

.lead, .muted, .hint { color: var(--muted); }
.cta-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.25rem; }
.stack { display: grid; gap: 0.8rem; margin: 1.15rem 0; }

label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
  font: 500 0.9rem/1.2 var(--font);
  color: var(--ink);
  background: #fff;
}

input:focus, select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.form-error {
  color: var(--warn);
  margin: 0;
  font-size: 0.88rem;
}

/* —— App shell —— */

.page-app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: var(--header-h) 1fr;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0 1.1rem;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.header-left, .header-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.project-name {
  min-width: 240px;
  font-weight: 600;
  border: none;
  background: transparent;
  border-bottom: 1px dashed var(--line-strong);
  border-radius: 0;
  padding: 0.35rem 0.2rem;
}
.project-name:focus {
  border-bottom-style: solid;
  border-bottom-color: var(--accent);
  outline: none;
}

.user-email {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0 0.35rem;
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 0;
  height: calc(100vh - var(--header-h));
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  padding: 0.9rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.main-pane {
  padding: 1rem 1.1rem 1.4rem;
  display: grid;
  gap: 0.9rem;
  overflow: auto;
  align-content: start;
}

.panel, .chart-panel, .results-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.95rem 1.05rem 1.05rem;
  box-shadow: 0 1px 0 rgba(21, 32, 43, 0.03);
}

.sidebar .panel {
  box-shadow: none;
  background: transparent;
  border: 1px solid var(--line);
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 1rem;
  margin-bottom: 0.75rem;
}

.panel h2, .chart-panel h2, .results-panel h2, .panel-head h2 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel-sub {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 500;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0 0 0.65rem;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  background: #f3f6f8;
  border: 1px solid var(--line);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
}

.legend-chip i {
  width: 14px;
  height: 3px;
  border-radius: 2px;
  display: inline-block;
}

.legend-chip.is-sum {
  background: #15202b;
  border-color: #15202b;
  color: #fff;
}
.legend-chip.is-sum i { background: #fff !important; height: 3px; }

.chart-wrap {
  position: relative;
  width: 100%;
  height: 220px;
  background:
    linear-gradient(180deg, #fbfcfd 0%, #f5f8fa 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.45rem 0.2rem;
}

.chart-wrap-hero { height: 340px; }
.chart-wrap-phase { height: 210px; }

.chart-wrap canvas {
  display: block;
  max-width: 100%;
}

.chart-panel-hero {
  box-shadow: var(--shadow);
}

.band-panel {
  position: relative;
  overflow: hidden;
}

.band-panel::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--band, var(--accent));
}

.band-panel[data-band="lf"] { --band: var(--lf); }
.band-panel[data-band="mf"] { --band: var(--mf); }
.band-panel[data-band="hf"] { --band: var(--hf); }

.band-panel h2 {
  color: var(--band, var(--ink));
  letter-spacing: 0.06em;
}

.band-grid {
  display: grid;
  gap: 0.7rem;
  padding-left: 0.35rem;
}

.cut-block {
  display: grid;
  gap: 0.35rem;
  padding: 0.55rem 0.6rem;
  background: #f5f8fa;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.cut-block.is-off {
  opacity: 0.55;
}

.cut-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.check-inline {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
}

.check-inline input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.cut-freq {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem;
  align-items: center;
}

.cut-freq .unit {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.cut-freq input:disabled {
  opacity: 0.5;
  background: #eef2f5;
}

.phase-hint {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--ink);
}

.hint-panel {
  margin-top: auto;
  background: var(--accent-soft) !important;
  border-color: rgba(11, 110, 99, 0.2) !important;
}

.components-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.components-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.84rem;
}

.components-table th,
.components-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0.7rem;
  text-align: left;
  white-space: nowrap;
}

.components-table th {
  color: var(--muted);
  font-weight: 600;
  font-family: var(--font);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #f7f9fb;
}

.components-table tr:last-child td { border-bottom: none; }
.components-table tr:hover td { background: rgba(11, 110, 99, 0.04); }

.band-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
}

.schematic {
  margin-top: 0.15rem;
}

.schematic-grid {
  display: grid;
  gap: 1rem;
}

.schematic-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fafbfc;
}

.schematic-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.schematic-card-head strong {
  font-size: 0.95rem;
  font-weight: 700;
}

.schematic-card-head span {
  font-size: 0.82rem;
  color: var(--muted);
  font-family: var(--mono);
}

.schematic-card-unified {
  border-top: none;
}

.schematic-scroll {
  overflow-x: auto;
}

.schematic-svg {
  display: block;
  width: 100%;
  height: auto;
  background: #fafbfc;
}

.schematic-note {
  margin: 0;
  padding: 0.65rem 0.9rem;
  font-size: 0.88rem;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: #f7f9fb;
}

.projects-list {
  display: grid;
  gap: 0.5rem;
  max-height: 50vh;
  overflow: auto;
}

.project-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}

.project-row strong { display: block; }
.project-row small { color: var(--muted); }
.project-row-actions { display: flex; gap: 0.4rem; }

dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  width: min(520px, 92vw);
  box-shadow: var(--shadow);
  background: var(--surface);
}

dialog::backdrop { background: rgba(21, 32, 43, 0.4); }

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.dialog-head h2 { margin: 0; font-size: 1.1rem; }

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
    height: auto;
  }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: none;
  }
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    height: auto;
    padding: 0.7rem 1rem;
  }
  .page-app { grid-template-rows: auto 1fr; }
  .chart-wrap-hero { height: 280px; }
}

/* —— Car-audio processor —— */

.page-app {
  --bg: #e8ecef;
  --bg-deep: #dce3e8;
  --surface: #ffffff;
  --ink: #0c1014;
  --muted: #5a6773;
  --line: #cfd8df;
  --line-strong: #a8b4bf;
  --accent: #0f766e;
  --accent-soft: rgba(15, 118, 110, 0.11);
  --accent-ink: #ffffff;
  --warn: #b42318;
  --lf: #c2410c;
  --mf: #0f766e;
  --hf: #1d4ed8;
  --sum: #0c1014;
  --shadow: 0 1px 0 rgba(12, 16, 20, 0.04);
  background:
    radial-gradient(900px 420px at 80% -10%, rgba(15, 118, 110, 0.07), transparent 55%),
    var(--bg);
  color: var(--ink);
}

.page-app .app-header {
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  justify-content: space-between;
}

.page-app .brand-link { color: var(--ink); }
.page-app .brand-link:hover { color: var(--accent); }

.page-app .project-name {
  color: var(--ink);
  border-bottom-color: var(--line-strong);
  background: transparent;
}

.page-app .btn {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}
.page-app .btn:hover { background: #f3f6f8; border-color: var(--line-strong); }
.page-app .btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.page-app .btn-primary:hover { filter: none; background: #1a2229; border-color: #1a2229; }
.page-app .btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.page-app .btn-ghost:hover { background: rgba(12, 16, 20, 0.05); color: var(--ink); }
.page-app .btn-danger {
  color: var(--warn);
  border-color: #f0c7c2;
  background: #fff8f7;
}

.page-app .workspace {
  display: block;
  height: auto;
  min-height: calc(100vh - var(--header-h));
}

.page-app .main-pane {
  width: 100%;
  max-width: none;
  padding: 0.75rem 0.85rem 1.25rem;
  gap: 0.85rem;
}

.page-app .screen,
.page-app .results-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.page-app .screen { padding: 0.85rem 0.9rem 0.7rem; }

.screen-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.55rem;
  padding: 0 0.25rem;
}

.screen-head h2 {
  margin: 0 0 0.2rem;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.page-app .phase-hint {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  margin: 0;
  padding: 0.8rem 0.9rem;
  background: #fff8eb;
  border: 1px solid #f0d9a8;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: #5c4810;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.45;
}

.page-app .phase-hint[hidden] { display: none; }

.page-app .phase-hint[data-tone="ok"] {
  background: var(--accent-soft);
  border-color: rgba(15, 118, 110, 0.35);
  color: #0c4a45;
}

.phase-hint-mark {
  display: block;
  flex: none;
  width: 1.35rem;
  height: 1.35rem;
  margin-top: 0.05rem;
  color: var(--accent);
}

.page-app .phase-hint[data-tone="ok"] .phase-hint-mark { color: var(--mf); }

.phase-hint-mark svg { display: block; width: 100%; height: 100%; }

.phase-hint .is-ok { display: none; }

.page-app .phase-hint[data-tone="ok"] .is-warn { display: none; }

.page-app .phase-hint[data-tone="ok"] .is-ok { display: block; }

.page-app .phase-hint p {
  margin: 0;
  white-space: pre-line;
}

.page-app .chart-wrap {
  background: #f7f9fb;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.35rem 0.15rem;
}

.page-app .chart-wrap-hero { height: 380px; }

.page-app #mag-chart,
.page-app #phase-chart { touch-action: none; cursor: default; }

.page-app .chart-edit {
  position: absolute;
  z-index: 4;
  left: 0;
  top: 0;
  transform: translate(-50%, calc(-100% - 14px));
  pointer-events: none;
  padding: 0.18rem 0.45rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font: 600 0.75rem/1.2 "IBM Plex Mono", ui-monospace, monospace;
  white-space: nowrap;
}

.page-app .chart-edit[hidden] { display: none; }

.page-app .chart-grab {
  position: absolute;
  z-index: 3;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--accent);
}

.page-app .chart-grab[hidden] { display: none; }

.page-app .chart-wrap-phase {
  height: 220px;
  margin-top: 0;
  position: relative;
}

.channel-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.75rem;
}

.channel-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 0.75rem 0.85rem;
  display: grid;
  gap: 0.7rem;
}

.channel-card[data-band="lf"] { box-shadow: inset 3px 0 0 var(--lf); }
.channel-card[data-band="mf"] { box-shadow: inset 3px 0 0 var(--mf); }
.channel-card[data-band="hf"] { box-shadow: inset 3px 0 0 var(--hf); }

.channel-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.channel-head h2 {
  margin: 0;
  display: flex;
  align-items: center;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}

.channel-name {
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.channel-card.is-off .z-field {
  opacity: 0.42;
}

.channel-head span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.z-field {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}

.z-field span {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.82rem;
}

.z-field input {
  width: 4.2rem;
  padding: 0.35rem 0.45rem;
  text-align: right;
}

.cut-list {
  display: grid;
  gap: 0.35rem;
}

.cut {
  display: grid;
  grid-template-columns: 4.7rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.45rem;
  min-height: 2rem;
}

.cut-name {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--ink);
  white-space: nowrap;
}

.cut-check {
  position: absolute;
  left: 0.35rem;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  cursor: pointer;
}

.cut-check input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.cut-check i {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--line-strong);
  background: #fff;
  display: grid;
  place-items: center;
}

.cut-check i::after {
  content: '';
  width: 8px;
  height: 4px;
  border-left: 2px solid transparent;
  border-bottom: 2px solid transparent;
  transform: rotate(-45deg) translate(1px, -1px);
}

.cut-check input:checked + i {
  background: var(--accent);
  border-color: var(--accent);
}

.cut-check input:checked + i::after {
  border-color: #fff;
}

.cut-check input:focus-visible + i {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cut.is-off .cut-slider,
.cut.is-off .cut-hz input[type="number"],
.cut.is-off .cut-hz > span {
  opacity: 0.4;
}

.with-unit {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.with-unit input {
  width: 7.2rem;
  padding: 0.28rem 1.7rem 0.28rem 0.35rem;
  text-align: right;
}

.cut-hz.with-unit input {
  padding-left: 1.7rem;
}

.with-unit > span {
  position: absolute;
  right: 0.45rem;
  pointer-events: none;
  user-select: none;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.with-unit input::-webkit-outer-spin-button,
.with-unit input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.with-unit input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.channel-meta {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.4rem;
}

.channel-meta .channel-name {
  flex: 0 0 auto;
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
}

.channel-meta select {
  flex: 1 1 0;
  min-width: 0;
  width: 0;
}

.channel-meta select[data-field="invert"] {
  flex: 0 0 4.5rem;
  width: 4.5rem;
}

.channel-meta select {
  padding: 0.4rem 0.5rem;
  font-size: 0.82rem;
}

.freq-label { gap: 0.4rem; }

.freq-control { display: grid; gap: 0.4rem; }

.freq-read {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem;
  align-items: center;
}

.freq-read span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.page-app input,
.page-app select {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.page-app input:focus,
.page-app select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.page-app input:disabled {
  opacity: 0.55;
  background: #f3f6f8;
}

.page-app input[type="range"] {
  appearance: none;
  height: 22px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.page-app input[type="range"]:focus { outline: none; }

.page-app input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: #d5dde4;
}

.page-app input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 20px;
  margin-top: -8px;
  border-radius: 3px;
  border: 0;
  background: var(--ink);
  box-shadow: none;
}

.page-app input[type="range"]::-moz-range-track {
  height: 4px;
  border: none;
  border-radius: 999px;
  background: #d5dde4;
}

.page-app input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 20px;
  border: 0;
  border-radius: 3px;
  background: var(--ink);
}

.channel-meta select { min-width: 0; }

.page-app .results-panel { padding: 0.95rem 1.05rem 1.05rem; }

.page-app .components-table th,
.page-app .components-table td {
  border-bottom-color: var(--line);
}

.page-app .components-table th { background: #f7f9fb; }

.page-app .components-table tr:hover td { background: var(--accent-soft); }

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 500px;
  gap: 0.75rem;
  align-items: start;
}

.controls-col {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.readout {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 500px;
  min-width: 500px;
  position: sticky;
  top: 0;
}

.page-app .readout .schematic,
.page-app .parts-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.page-app .parts-card { padding: 0.55rem 0.55rem 0.4rem; }

.page-app #components-table { padding: 0; }

.page-app .components-table td:last-child,
.page-app .components-table th:last-child { white-space: nowrap; }

.page-app .schematic { padding: 0.25rem; }

.page-app .schematic-scroll {
  height: 340px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-in;
}

.page-app .schematic-svg {
  width: 100%;
  height: 340px;
  min-width: 0;
  display: block;
}

.schematic-zoom {
  background: #f4f7fb;
  padding: 1rem 1.15rem;
  border-radius: 12px;
}

.schematic-zoom svg {
  width: min(92vw, 1500px);
  height: auto;
  max-height: 84vh;
  display: block;
}

.page-app .chart-wrap-hero { height: 248px; }

.page-app .chart-wrap-phase { height: 220px; }


.trace-toggles {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  margin: 0 0 0.9rem;
}

.trace-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  user-select: none;
}

.trace-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.trace-switch i {
  width: 30px;
  height: 16px;
  border-radius: 999px;
  background: #d5dde4;
  position: relative;
  flex: none;
}

.trace-switch i::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  background: #fff;
  transition: transform 0.15s ease;
}

.trace-switch input:checked + i { background: var(--sw); }

.trace-switch input:checked + i::after {
  transform: translateX(14px);
  background: #fff;
}

.trace-switch input:focus-visible + i {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.trace-switch:has(input:not(:checked)) span { color: var(--muted); }

.page-app .components-table { font-size: 0.74rem; }

.page-app .components-table th,
.page-app .components-table td { padding: 0.28rem 0.4rem; }

.z-field {
  display: grid;
  grid-template-columns: 4.7rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}

.page-app .z-field input[type="range"] {
  width: 100%;
  padding: 0;
  text-align: left;
}

.page-app .z-field .with-unit input[type="number"] { width: 7.2rem; padding: 0.28rem 1.7rem 0.28rem 0.35rem; }

.channel-card { gap: 0.55rem; padding: 0.65rem 0.7rem 0.7rem; }

@media (max-width: 980px) {
  .stage { grid-template-columns: 1fr; }
  .readout { width: auto; min-width: 0; position: static; }
}

.page-app dialog {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.components-table tr.is-coil td.part-id { cursor: pointer; }
.components-table tr.is-coil td.part-id {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}
.page-app .components-table .nominal-edit input {
  width: 6.2rem;
  padding: 0.16rem 2.15rem 0.16rem 0.3rem;
  font-family: var(--mono);
  font-size: 0.74rem;
}
.page-app .components-table .nominal-edit.is-custom input { color: var(--accent); }

.wind-dialog { width: min(440px, 94vw); }
.wind-sub { margin: 0 0 0.7rem; color: var(--muted); font-size: 0.84rem; }
.wind-given,
.wind-result {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.28rem 0.85rem;
  margin: 0;
  font-size: 0.86rem;
}
.wind-given dt,
.wind-result dt { color: var(--muted); font-weight: 600; }
.wind-given dd,
.wind-result dd { margin: 0; font-variant-numeric: tabular-nums; }
.wind-fields { display: grid; gap: 0.5rem; margin: 0.9rem 0 0.7rem; }
.wind-dialog .wind-field {
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink);
}
.page-app .wind-dialog .with-unit input[type="number"],
.page-app .wind-dialog .wind-field > input[type="number"] {
  width: 6.6rem;
  padding: 0.35rem 0.45rem;
  text-align: right;
}
.page-app .wind-dialog .with-unit input[type="number"] {
  padding-right: 1.8rem;
}
.page-app .wind-dialog #wind-turns {
  color: var(--ink);
  cursor: default;
}
.wind-layers[hidden] { display: none; }
.wind-layers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-top: 0.85rem;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7f9fb;
}
.wind-stat {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.4rem;
  min-width: 0;
}
.wind-stat small { flex-basis: 100%; }
.wind-layers strong {
  font-size: 1.7rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.wind-layers span { font-weight: 700; }
.wind-layers .wind-error { font-weight: 600; color: var(--warn); }
.wind-layers small { color: var(--muted); font-weight: 600; }
.wind-result { margin-top: 0.75rem; }
.wind-hit { color: var(--ok); }
.wind-miss { color: var(--warn); }
.wind-note { margin: 0.75rem 0 0; color: var(--muted); font-size: 0.75rem; line-height: 1.4; }

.page-app .project-row {
  background: #fff;
  border-color: var(--line);
}

@media (max-width: 720px) {
  .page-app .chart-wrap-hero { height: 280px; }
}

/* Display type for product headings */
h1, h2, .brand { font-family: var(--display), var(--font); }
