:root {
  --bg: oklch(99% 0 0);
  --surface: #fff;
  --ink: oklch(21% 0 0);
  --muted: oklch(52% 0 0);
  --line: oklch(93.5% 0 0);
  --accent: #1677ff;
  --accent-soft: #e8f1ff;
  --ok: #0f766e;
  --warn: #b91c1c;
  --readout: #1677ff;
  --rail: oklch(98% 0 0);
  --worked: oklch(98% 0 0);
  --formula-bg: oklch(98% 0 0);
  --formula-ink: oklch(21% 0 0);
  --formula-muted: oklch(52% 0 0);
  --on-accent: #fff;
  --shadow: rgba(15, 23, 42, 0.06);
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, monospace;
  --sans: "Inter", "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 6px;
  --header-h: 56px;
  --grid: transparent;
  --side: 16.5rem;
  --toc: 13.5rem;
  --content: 56rem;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0c0c0d;
  --surface: #18181b;
  --ink: #fafafa;
  --muted: #a1a1aa;
  --line: #27272a;
  --accent: #3b82f6;
  --accent-soft: #172554;
  --ok: #2dd4bf;
  --warn: #f87171;
  --readout: #93c5fd;
  --rail: #18181b;
  --worked: #27272a;
  --formula-bg: #27272a;
  --formula-ink: #fafafa;
  --formula-muted: #a1a1aa;
  --on-accent: #fff;
  --shadow: rgba(0, 0, 0, 0.45);
  --grid: transparent;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
}

body {
  font-family: var(--sans);
  font-weight: 400;
  color: var(--ink);
  background-color: var(--bg);
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select {
  font: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: var(--header-h);
  height: auto;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.02em;
  white-space: nowrap;
  text-decoration: none;
}

.logo:hover {
  text-decoration: none;
  color: var(--accent);
}

.logo span {
  color: var(--accent);
}

.nav-main {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav-main > a {
  color: var(--muted);
  padding: 6px 10px;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 0.95rem;
}

.nav-main > a:hover,
.nav-main > a.is-current {
  color: var(--ink);
  background: var(--accent-soft);
  text-decoration: none;
}

.nav-drop {
  position: relative;
}

.nav-drop > summary {
  list-style: none;
  cursor: pointer;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.nav-drop > summary::-webkit-details-marker {
  display: none;
}

.nav-drop > summary::after {
  content: " ▾";
  font-size: 0.7em;
}

.nav-drop[open] > summary,
.nav-drop.is-current > summary {
  color: var(--ink);
  background: var(--accent-soft);
}

.nav-drop-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  max-width: 320px;
  max-height: min(70vh, 420px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px var(--shadow);
  padding: 6px 0;
  z-index: 30;
}

.nav-drop-panel a {
  display: block;
  padding: 8px 12px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
}

.nav-drop-panel a:hover {
  background: var(--accent-soft);
}

.crumb {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 8px;
}

.article-sibs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 24px 0 0;
  font-size: 0.9rem;
}

.article-open {
  margin: 16px 0 0;
}

.table-wrap {
  overflow-x: auto;
  margin: 0 0 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.ref-table th,
.ref-table td {
  padding: 8px 10px;
  text-align: left;
  border-top: 1px solid var(--line);
  white-space: nowrap;
}

.ref-table thead th {
  border-top: 0;
  font-weight: 500;
  background: var(--rail);
}

.ref-table-wide {
  font-size: 0.8rem;
}

@media print {
  .nav-drop-panel,
  .header-search,
  .article-sibs {
    display: none;
  }
}

.header-search {
  position: relative;
  width: min(240px, 30vw);
}

.header-search input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0 10px;
  color: var(--ink);
}

.search-results {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px var(--shadow);
  max-height: 320px;
  overflow: auto;
}

.search-results.is-open {
  display: block;
}

.search-results a,
.search-results .soon {
  display: block;
  padding: 8px 12px;
  color: var(--ink);
  text-decoration: none;
}

.search-results a:hover {
  background: var(--accent-soft);
}

.search-results .soon {
  color: var(--muted);
}

.search-results .muted {
  font-size: 0.8rem;
  color: var(--muted);
}

.site-header {
  flex-shrink: 0;
}

main.page,
main.portal,
.docs-layout {
  flex: 1 0 auto;
  width: 100%;
}

.site-footer {
  border-top: 1px solid var(--line);
  margin-top: auto;
  padding: 24px 20px 40px;
  color: var(--muted);
  font-size: 0.9rem;
  flex-shrink: 0;
  width: 100%;
}

.footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.footer-links,
.footer-langs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.footer-links a,
.footer-langs a {
  color: var(--muted);
}

.footer-langs a.is-current {
  color: var(--ink);
  font-weight: 500;
}

.footer-copy {
  color: var(--muted);
}

.formula-group { margin: 28px 0; }
.formula-group h2 { font-size: 1.05rem; font-weight: 500; margin: 0 0 10px; }
.formula-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.formula-list li { display: grid; grid-template-columns: minmax(12rem, 1.4fr) 1fr auto; gap: 12px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); }
.formula-list li:first-child { border-top: 0; }
.formula-list code {
  font-family: "Cambria Math", "Latin Modern Math", "Times New Roman", serif;
  font-size: 0.95rem;
  background: var(--formula-bg);
  color: var(--formula-ink);
  padding: 8px 12px;
  border-radius: 8px;
  display: inline-block;
}
.formula-list span { color: var(--muted); font-size: 0.9rem; }
.formula-list a { white-space: nowrap; font-size: 0.9rem; }
@media (max-width: 720px) {
  .formula-list li { grid-template-columns: 1fr; gap: 4px; }
}

.worked-eq {
  background: var(--worked);
  border-radius: 10px;
  padding: 16px 20px;
  margin: 12px 0 14px;
  text-align: center;
  font-size: 1.12rem;
  overflow-x: auto;
  color: var(--ink);
}

.worked-eq.is-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.worked-eq var {
  font-family: "Cambria Math", "Latin Modern Math", "Times New Roman", serif;
  font-style: italic;
  font-weight: 500;
}

.info-sections {
  max-width: 1120px;
  margin: 36px auto 0;
  padding: 0 20px;
}

.info-sections h2 {
  font-size: 1.05rem;
  font-weight: 500;
  margin: 0 0 8px;
}

.info-sections h3 {
  font-size: 0.95rem;
  font-weight: 500;
  margin: 16px 0 6px;
}

.info-sections p,
.info-sections li {
  color: var(--muted);
  font-size: 0.95rem;
}

.info-sections p.formula-line > code {
  display: block;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0.15rem 0 0.35rem;
  padding: 0.7rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  color: var(--ink);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.92em;
  line-height: 1.65;
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.info-sections ul,
.info-sections ol {
  margin: 0 0 12px;
  padding-left: 1.2rem;
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 20px 0;
}

.lede {
  color: var(--muted);
  max-width: 42rem;
  margin: 8px 0 0;
}

.library-intro {
  max-width: 46rem;
  margin: 14px 0 22px;
  line-height: 1.65;
  color: color-mix(in srgb, var(--ink) 78%, var(--muted));
}

h1 {
  font-size: clamp(1.6rem, 2.4vw, 2rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  margin: 0;
}

.field label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.field input,
.field select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0 10px;
}

.seg {
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  height: 44px;
}

.seg button {
  border: 0;
  background: var(--surface);
  padding: 0 12px;
  color: var(--muted);
  cursor: pointer;
}

.seg button.is-on {
  background: var(--accent-soft);
  color: var(--ink);
  font-weight: 500;
}

@media (max-width: 720px) {
  .header-search {
    width: auto;
    min-width: 0;
    margin-left: auto;
  }
}

.quick {
  margin: 28px 0 36px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.quick-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}

.quick-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
}

.quick-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.field label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.field input,
.field select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0 10px;
}

.seg {
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  height: 44px;
}

.seg button {
  border: 0;
  background: var(--surface);
  padding: 0 12px;
  color: var(--muted);
  cursor: pointer;
}

.seg button.is-on {
  background: var(--accent-soft);
  color: var(--ink);
  font-weight: 500;
}

.quick-out {
  margin-top: 16px;
  min-height: 3.2rem;
}

.quick-out .readout {
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--readout);
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.quick-out .unit {
  font-size: 1rem;
  color: var(--muted);
  font-weight: 400;
  margin-left: 6px;
}

.quick-out .hint {
  color: var(--muted);
  margin: 0;
}

.quick-out .next {
  margin-top: 8px;
}

.catalog-filter {
  display: block;
  width: 100%;
  max-width: none;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0 12px;
  margin-bottom: 20px;
  box-sizing: border-box;
}

.groups {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.group h2 {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  margin: 0 0 10px;
}
.group h2 a { color: inherit; text-decoration: none; }
.group h2 a:hover { color: var(--ink); }

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: inherit;
  text-decoration: none;
}

.card:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.card strong {
  display: block;
  font-weight: 500;
}

.card span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 2px;
}

.card.is-soon {
  opacity: 0.55;
  pointer-events: none;
}

.card .tag {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 6px;
}

@media (max-width: 960px) {
  .cards {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .quick-grid {
    grid-template-columns: 1fr 1fr;
  }

  .cards {
    grid-template-columns: 1fr;
  }
}

.tool-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.rail {
  background: var(--rail);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  position: sticky;
  top: calc(var(--header-h) + 16px);
}

.rail a {
  display: block;
  padding: 8px 10px;
  color: var(--ink);
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 0.92rem;
}

.rail a.is-current {
  background: var(--surface);
  font-weight: 500;
  box-shadow: inset 3px 0 0 var(--accent);
}

.rail a.is-soon {
  color: var(--muted);
  pointer-events: none;
}

.rail .rail-label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 10px 4px;
}

.stage {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

.stage h1 {
  margin-bottom: 16px;
}

.phase-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
}

.chip.is-on {
  border-color: var(--accent);
  color: var(--ink);
  background: var(--accent-soft);
}

.inputs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  max-width: 640px;
}

.field[hidden] {
  display: none !important;
}

.field-row {
  display: flex;
  gap: 6px;
}

.field-row input {
  flex: 1;
}

.field-row select {
  width: 72px;
  flex: none;
}

.round-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 14px 0 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

.round-seg {
  height: 32px;
}

.round-seg button {
  min-width: 32px;
  padding: 0 10px;
  font-variant-numeric: tabular-nums;
}

.actions {
  display: flex;
  gap: 8px;
  margin: 12px 0 8px;
}

.btn {
  height: 40px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  color: var(--ink);
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.btn.is-ok {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.btn.is-fail {
  border-color: var(--warn);
  color: var(--warn);
}

.note {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 8px;
}

.error {
  color: var(--warn);
  font-size: 0.9rem;
  margin: 4px 0 0;
  min-height: 1.2em;
}

.result {
  margin-top: 16px;
  margin-bottom: 8px;
  padding: 16px 0 4px;
  border-top: 1px solid var(--line);
  min-height: 4.5rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 8px;
}

.metric {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 8px 10px;
}

.metric-k {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.metric-n {
  display: block;
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  margin-top: 2px;
}

.mini-h {
  margin: 16px 0 8px;
  font-size: 0.85rem;
  font-weight: 600;
}

.same-v {
  width: 100%;
  max-width: 360px;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

.same-v th,
.same-v td {
  text-align: left;
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
}

.same-v tr.is-on td {
  background: var(--accent-soft);
  font-weight: 600;
}

.kw-quick-block {
  margin: 16px 0 20px;
}

.kw-quick-block h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 8px;
}

.kw-quick-block .table-wrap {
  margin-bottom: 8px;
}

#powerQuick {
  font-variant-numeric: tabular-nums;
}

#powerQuick th[scope="row"] {
  font-weight: 500;
  background: var(--rail);
}

#powerQuick th.is-col,
#powerQuick td.is-col {
  background: var(--accent-soft);
}

#powerQuick tr.is-row th,
#powerQuick tr.is-row td {
  background: var(--accent-soft);
}

#powerQuick td.is-cell {
  font-weight: 600;
}

.xfmr-out {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 28px;
}

.xfmr-out .readout {
  font-size: clamp(2rem, 4vw, 2.8rem);
}

.xfmr-quick th[scope="row"] {
  font-weight: 500;
  background: var(--rail);
}

.xfmr-quick th.is-col,
.xfmr-quick td.is-col {
  background: var(--accent-soft);
}

.xfmr-quick tr.is-row th,
.xfmr-quick tr.is-row td {
  background: var(--accent-soft);
}

.xfmr-quick td.is-cell {
  font-weight: 600;
}

@media (max-width: 720px) {
  .xfmr-out {
    grid-template-columns: 1fr;
  }
}

.circuit-block {
  max-width: 640px;
  margin-bottom: 16px;
}

.circuit-block .field {
  margin-bottom: 10px;
}

.lab-with-tip {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tip {
  position: relative;
  display: inline-flex;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1;
  align-items: center;
  justify-content: center;
  cursor: help;
  flex: none;
}

.tip::after {
  content: attr(data-tip);
  position: absolute;
  z-index: 12;
  left: 0;
  top: calc(100% + 8px);
  width: min(280px, 72vw);
  padding: 8px 10px;
  background: var(--ink);
  color: var(--on-accent);
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.4;
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(28, 25, 23, 0.18);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  text-align: left;
  white-space: normal;
}

.tip.tip-up::after {
  top: auto;
  bottom: calc(100% + 8px);
}

.tip:hover::after,
.tip:focus::after,
.tip.is-on::after {
  opacity: 1;
  visibility: visible;
}

.warn-line {
  color: var(--warn);
}

@media (max-width: 720px) {
  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.readout {
  font-size: clamp(2.5rem, 5vw, 3.4rem);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1.05;
  color: var(--readout);
}

.readout .unit {
  font-size: 1.1rem;
  color: var(--muted);
  margin-left: 8px;
  font-weight: 400;
  letter-spacing: 0;
}

.readout-alt {
  margin: 6px 0 0;
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.readout-alt .unit {
  font-size: 0.85rem;
  color: var(--muted);
  margin-left: 6px;
}

.field-hint {
  margin: 6px 0 0;
  line-height: 1.35;
}

.sub {
  color: var(--muted);
  margin: 6px 0 0;
}

.next-bar {
  display: none;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: var(--surface);
}

.next-bar.is-on {
  display: block;
}

.next-bar p {
  margin: 0 0 6px;
  font-size: 0.9rem;
}

.extras {
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--muted);
}

.formula-block {
  margin: 20px 0 8px;
}

.formula-h {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 10px;
}

.formula-card {
  background: var(--formula-bg);
  color: var(--formula-ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 20px 18px;
}

.formula-card-label {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--formula-muted);
  margin-bottom: 14px;
}

.formula-eqs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  font-size: 1.22rem;
  font-weight: 500;
  line-height: 1.2;
}

.formula-card var,
.formula-sym var {
  font-family: "Cambria Math", "Latin Modern Math", "Times New Roman", serif;
  font-style: italic;
  font-weight: 500;
}

.eq {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.eq-op {
  font-weight: 400;
  opacity: 0.9;
}

.eq-and {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--formula-muted);
  font-style: italic;
}

.eq-cap {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--formula-muted);
  font-style: italic;
}

.eq-sep {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--formula-muted);
  flex: 0 0 auto;
}

.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  font-size: 0.92em;
}

.frac .num {
  padding: 0 10px 4px;
  border-bottom: 1.5px solid currentColor;
  line-height: 1.15;
}

.frac .den {
  padding: 4px 10px 0;
  line-height: 1.15;
}

.radic {
  display: inline-flex;
  align-items: flex-start;
  line-height: 1;
}

.radic-sym {
  font-size: 1.15em;
  line-height: 0.95;
  margin-right: 1px;
}

.radic-over {
  border-top: 1.5px solid currentColor;
  padding: 0 4px 1px 2px;
  margin-top: 0.12em;
  white-space: nowrap;
}

.formula-card.is-stack .formula-eqs {
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
}

.formula-card.is-stack .eq-sep {
  display: none;
}

.formula-where-label {
  margin: 14px 0 6px;
  font-size: 0.92rem;
  font-weight: 600;
}

.formula-where {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.formula-where li {
  margin: 0 0 4px;
}

.formula-where .formula-sym {
  color: var(--ink);
}

.formula-k {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.formula-k li {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.9rem;
  background: var(--surface);
}

.formula-k li.is-on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

@media (max-width: 640px) {
  .formula-eqs {
    font-size: 1.05rem;
  }
}

details.steps {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

details.steps summary {
  cursor: pointer;
  font-weight: 500;
}

details.steps pre {
  font-family: var(--mono);
  font-size: 0.85rem;
  background: var(--bg);
  padding: 12px;
  overflow: auto;
  white-space: pre-wrap;
}

.related {
  margin-top: 24px;
  color: var(--muted);
  font-size: 0.9rem;
}

.disclaimer {
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--muted);
}

@media (max-width: 959px) {
  .tool-layout {
    grid-template-columns: 1fr;
  }

  .rail {
    display: none;
  }

  .inputs {
    grid-template-columns: 1fr;
  }
}


.header-container { max-width: 1120px; margin: 0 auto; min-height: var(--header-h); padding: 8px 20px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.nav-main { flex-wrap: wrap; align-items: center; }
.search-input { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 0 10px; color: var(--ink); }
.search-results.active { display: block; }
.footer-container { max-width: 1120px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.logo-link { font-weight: 500; color: var(--ink); letter-spacing: -0.02em; white-space: nowrap; text-decoration: none; }
.logo-link:hover { text-decoration: none; color: var(--accent); }
.logo-link span { color: var(--accent); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ec-error-code { font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.ec-error-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }

.info-section { margin: 0 0 28px; }
.info-section h2 { font-size: 1.15rem; margin: 0 0 8px; }
.info-section .section-description { color: var(--ink); }
.faq h3 { font-size: 0.95rem; margin: 14px 0 4px; }
.band-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.band-lab { width: 1.2rem; color: var(--muted); font-size: 0.85rem; }
.band-name { min-width: 4.5rem; font-size: 0.85rem; text-transform: capitalize; }
.band-swatches { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.swatch { width: 22px; height: 22px; border: 1px solid var(--line); border-radius: 2px; padding: 0; cursor: pointer; }
.swatch.is-on { outline: 2px solid var(--accent); outline-offset: 1px; }
.rail .is-soon { display: block; padding: 8px 10px; color: var(--muted); font-size: 0.92rem; }

.theme-toggle {
  flex: none;
  width: 36px;
  height: 36px;
  margin-left: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.site-header {
  z-index: 30;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(16px);
}
.header-container {
  max-width: none;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 1rem;
  min-height: var(--header-h);
  flex-wrap: nowrap;
}
.top-left,
.top-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.logo-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9375rem;
}
.logo-link svg { width: 1.25rem; height: 1.25rem; flex: none; }
.logo-link span { color: var(--accent); }
.logo-link:hover { opacity: 0.8; color: var(--accent); }
.nav-main > a,
.nav-drop > summary {
  font-size: 0.8125rem;
  padding: 0.3rem 0.6rem;
}
.header-search {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: auto;
  min-width: 12rem;
}
.header-search .kbd {
  display: none;
  padding: 0 0.3rem;
  border: 1px solid var(--line);
  border-radius: 0.25rem;
  background: var(--rail);
  color: var(--muted);
  font: 0.625rem/1rem var(--mono);
}
.iconbtn-menu {
  display: none;
  width: 2rem;
  height: 2rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}
.iconbtn-menu svg { width: 1.1rem; height: 1.1rem; }

.portal {
  max-width: 72rem;
  margin: 0 auto;
  padding: 2.75rem 1.25rem 4rem;
}
.portal h1 {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--ink);
}
.hero-search {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  max-width: 30rem;
  width: 100%;
  margin: 1.4rem 0 0;
}
.hero-search input,
.hero-search .catalog-filter {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  height: 44px;
  margin: 0;
  padding: 0 0.8rem;
  border-radius: 0.5rem;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  white-space: nowrap;
  border: 0;
  background: var(--accent);
  color: #fff;
  border-radius: 0.5rem;
  padding: 0 1rem;
  height: 44px;
  cursor: pointer;
  font-size: 0.875rem;
}
.portal .groups { margin-top: 0.5rem; }
.portal .group h2,
.portal .groups .group > h2 {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  margin-top: 2.4rem;
}
.portal .cards {
  grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr));
  gap: 1rem;
}
.portal .card {
  border-radius: 0.75rem;
  padding: 1rem 1.1rem;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.portal .card:hover {
  border-color: oklch(87% 0 0);
  box-shadow: 0 8px 24px var(--shadow);
  transform: translateY(-1px);
}

.docs-layout {
  display: flex;
  align-items: stretch;
  width: 100%;
  --muted: oklch(44% 0 0);
  --line: oklch(89% 0 0);
}
html[data-theme="dark"] .docs-layout {
  --muted: #b4b4bc;
  --line: #3f3f46;
}
.docs-sidebar {
  display: none;
  flex: 0 0 var(--side);
  width: var(--side);
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--bg);
}
.docs-sidebar-inner { padding: 1rem 0.9rem 3rem; }
.docs-filter {
  margin: 0 0 0.25rem;
}
.docs-filter input {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 32px;
  margin: 0;
  padding: 0 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.8125rem;
  line-height: 30px;
  appearance: none;
  -webkit-appearance: none;
}
.docs-filter input::placeholder {
  color: var(--muted);
}
.docs-filter input::-webkit-search-decoration,
.docs-filter input::-webkit-search-cancel-button,
.docs-filter input::-webkit-search-results-button,
.docs-filter input::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
}
.docs-filter input:focus {
  outline: none;
  border-color: var(--accent);
}
.docs-filter input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.docs-tree a,
.docs-tree .is-soon {
  display: block;
  padding: 0.28rem 0.5rem;
  border-radius: var(--radius);
  color: oklch(38% 0 0);
  font-size: 0.875rem;
  text-decoration: none;
}
html[data-theme="dark"] .docs-tree a,
html[data-theme="dark"] .docs-tree .is-soon { color: #c4c4cc; }
.docs-tree a:hover { background: var(--rail); color: var(--ink); text-decoration: none; }
.docs-tree a.is-current,
.docs-tree a[aria-current="page"] {
  background: oklch(92% 0 0);
  color: var(--ink);
  font-weight: 500;
}
html[data-theme="dark"] .docs-tree a.is-current,
html[data-theme="dark"] .docs-tree a[aria-current="page"] {
  background: #27272a;
}
.docs-group {
  margin: 0;
}
.docs-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.55rem 0.5rem 0.25rem;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.docs-group-title::-webkit-details-marker {
  display: none;
}
.docs-group-title::after {
  content: "▸";
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0;
  color: inherit;
  opacity: 0.85;
}
.docs-group[open] > .docs-group-title::after {
  content: "▾";
}
.docs-group[open] > .docs-group-title {
  color: var(--accent);
}
.docs-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.docs-content {
  max-width: var(--content);
  margin: 0 auto;
  padding: 1.5rem 1.75rem 3.5rem;
  width: 100%;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}
.docs-content > h1 {
  color: var(--accent);
  font-size: 2.15rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  margin: 0;
  line-height: 1.2;
}
.docs-lede {
  margin: 0.45rem 0 0;
  color: oklch(36% 0 0);
  font-size: 1rem;
  line-height: 1.7;
}
html[data-theme="dark"] .docs-lede { color: #d4d4d8; }
.docs-meta { margin: 0.75rem 0 0; color: var(--muted); font-size: 0.75rem; }
.docs-hr { height: 1px; margin: 1.1rem 0 1.5rem; border: 0; background: var(--line); }
.docs-toc {
  display: none;
  flex: 0 0 var(--toc);
  width: var(--toc);
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow: auto;
  padding: 1.5rem 1.25rem 2rem 0.5rem;
}
.docs-toc h2 { margin: 0 0 0.5rem; font-size: 0.875rem; }
.docs-toc a {
  display: block;
  padding: 0.35rem 0.5rem 0.35rem 0.85rem;
  border-left: 2px solid var(--line);
  color: var(--muted);
  font-size: 0.8125rem;
  text-decoration: none;
}
.docs-toc a:hover { color: var(--ink); text-decoration: none; }
.docs-toc a.active { color: var(--ink); border-color: var(--accent); font-weight: 500; }
.docs-layout .stage {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 1.15rem 1.2rem 1.25rem;
  box-shadow: 0 8px 24px var(--shadow);
}
.docs-layout .info-sections {
  max-width: none;
  margin: 2rem 0 0;
  padding: 0;
}
.btn-go {
  border-color: transparent;
  background: #0891b2;
  color: #fff;
}
.btn-go:hover { background: #0e7490; color: #fff; }
.docs-layout .result {
  margin: 1rem 0 0.4rem;
  padding: 0;
  border: 0;
  min-height: 0;
}
.docs-layout .result:not(:empty) {
  padding: 0.85rem 1rem;
  border-radius: 0.5rem;
  background: var(--accent-soft);
}
.docs-layout .result .readout {
  font-size: 1.85rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  color: var(--accent);
  line-height: 1.15;
}
.docs-layout .result .readout .unit {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--accent);
  margin-left: 0.25rem;
}
.docs-layout .result .eq-line,
.docs-layout .result .sub {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}
.docs-layout .result .readout-alt {
  color: var(--muted);
  font-size: 0.95rem;
}
.docs-layout .info-sections h2,
.docs-layout .info-section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2rem 0 0.6rem;
  color: var(--ink);
}
.docs-layout .field label { color: oklch(38% 0 0); }
.docs-layout .info-sections p,
.docs-layout .info-sections li,
.docs-layout .info-section .section-description {
  color: oklch(34% 0 0);
}
html[data-theme="dark"] .docs-layout .field label { color: #c4c4cc; }
html[data-theme="dark"] .docs-layout .info-sections p,
html[data-theme="dark"] .docs-layout .info-sections li,
html[data-theme="dark"] .docs-layout .info-section .section-description {
  color: #d4d4d8;
}
.docs-crumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.5rem;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
}
.docs-crumb li { display: flex; align-items: center; gap: 0.35rem; }
.docs-crumb li + li::before { content: "/"; opacity: 0.55; }
.docs-crumb a { color: inherit; }
.docs-crumb a:hover { color: var(--ink); text-decoration: none; }
.docs-layout .site-footer { margin-top: auto; padding: 1.5rem 0 0; border: 0; }
.docs-layout .footer-container { max-width: none; font-size: 0.75rem; }

.quick-out .readout,
.result .readout { color: var(--readout); }

.docs-drawer-mask {
  display: none;
}

@media (min-width: 768px) {
  .docs-sidebar { display: block; }
  .header-search .kbd { display: inline-flex; }
}
@media (min-width: 1200px) {
  .docs-toc { display: block; }
}
@media (max-width: 767px) {
  .iconbtn-menu { display: inline-flex; align-items: center; justify-content: center; }
  .docs-sidebar {
    display: none;
    position: fixed;
    z-index: 40;
    left: 0;
    top: 0;
    height: 100vh;
    background: var(--surface);
    box-shadow: 8px 0 24px var(--shadow);
  }
  body.docs-nav-open .docs-sidebar { display: block; }
  body.docs-nav-open .docs-drawer-mask {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgb(0 0 0 / 40%);
    border: 0;
  }
  .site-header { position: sticky; }
  .header-container {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 0.5rem;
    row-gap: 0.4rem;
    padding: 0.45rem 0.75rem 0.55rem;
    min-height: 0;
  }
  .top-left,
  .top-right {
    display: contents;
  }
  .iconbtn-menu { grid-column: 1; grid-row: 1; }
  .logo-link { grid-column: 2; grid-row: 1; }
  .theme-toggle { grid-column: 3; grid-row: 1; }
  .nav-main {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0;
    padding: 0.4rem 0.75rem 0.75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 8px 24px var(--shadow);
    z-index: 31;
  }
  body.header-nav-open .nav-main { display: flex; }
  body.header-nav-open .nav-drop-panel {
    position: static;
    box-shadow: none;
    min-width: 0;
    max-width: none;
    max-height: none;
    border: 0;
    border-top: 1px solid var(--line);
  }
  .header-search {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-width: 0;
    max-width: none;
  }
  .header-search input {
    height: 36px;
    appearance: none;
    -webkit-appearance: none;
  }
  .search-results {
    width: min(280px, calc(100vw - 1.5rem));
  }
  .logo-link {
    min-width: 0;
    font-size: 0.875rem;
  }
}

.header-container {
  display: flex;
  align-items: center;
  max-width: none;
  width: 100%;
  margin-left: 0;
  margin-right: 0;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
  justify-content: space-between;
  flex-wrap: nowrap;
}
.top-left {
  flex: 1 1 auto;
  min-width: 0;
}
.top-right {
  flex: 0 0 auto;
  margin-left: auto;
}
@media (min-width: 768px) {
  .nav-main {
    flex: 1 1 auto;
    flex-wrap: nowrap;
  }
}
.footer-container {
  max-width: 72rem;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}
.info-sections {
  max-width: 72rem;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}
.header-search {
  position: relative;
}
.nav-drop-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px var(--shadow);
}

.field select,
.chips select,
.unit-row select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background-color: var(--surface);
  color: var(--ink);
  padding: 0 2rem 0 10px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%236b7280' d='M1 1l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.unit-row {
  margin-bottom: 12px;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.kv span { color: var(--muted); }
.kv strong { color: var(--ink); font-weight: 600; }
.quick .result:not(:empty) {
  margin-top: 12px;
  padding-top: 12px;
  min-height: 0;
}
.quick .metric-grid {
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
}
.portal .quick {
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}
