:root {
  --bg: #ffffff;
  --text: #1b1b1b;
  --muted: #555555;
  --border: #c4c4c4;
  --box: #f7f7f7;
  --zebra: #f3f3f3;
  --accent: #8e1e70;
  --accent-hover: #6e1757;
  --on-accent: #ffffff;
  --field: #ffffff;
  --ok: #1d6b32;
  --warn: #8a4b00;
  /* diagram colours */
  --d-line: #333333;
  --d-fill: #e4e4e4;
  --d-cone: rgba(142, 30, 112, 0.14);
  --d-mark: #666666;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1e1e1e;
    --text: #e6e6e6;
    --muted: #a8a8a8;
    --border: #4c4c4c;
    --box: #262626;
    --zebra: #262626;
    --accent: #e38bcb;
    --accent-hover: #f0b0de;
    --on-accent: #1e1e1e;
    --field: #2a2a2a;
    --ok: #7fd08f;
    --warn: #f0b46a;
    --d-line: #d0d0d0;
    --d-fill: #3a3a3a;
    --d-cone: rgba(227, 139, 203, 0.18);
    --d-mark: #9a9a9a;
  }
}
:root[data-theme="dark"] {
  --bg: #1e1e1e;
  --text: #e6e6e6;
  --muted: #a8a8a8;
  --border: #4c4c4c;
  --box: #262626;
  --zebra: #262626;
  --accent: #e38bcb;
  --accent-hover: #f0b0de;
  --on-accent: #1e1e1e;
  --field: #2a2a2a;
  --ok: #7fd08f;
  --warn: #f0b46a;
  --d-line: #d0d0d0;
  --d-fill: #3a3a3a;
  --d-cone: rgba(227, 139, 203, 0.18);
  --d-mark: #9a9a9a;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.55;
}
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
h1 { font-size: 30px; line-height: 1.25; margin: 24px 0 8px; }
h2 { font-size: 23px; line-height: 1.3; margin: 36px 0 10px; }
h3 { font-size: 19px; margin: 24px 0 6px; }
p, ul, ol { margin: 0 0 14px; }
img { max-width: 100%; height: auto; }
small, .note { color: var(--muted); font-size: 15px; }

/* header and nav */
.site-header { border-bottom: 1px solid var(--border); padding: 12px 0 0; }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.site-name { font-weight: bold; font-size: 19px; color: var(--text); }
.nav { list-style: none; padding: 0; margin: 8px 0 10px; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.nav a[aria-current="page"] { color: var(--text); font-weight: bold; }
.theme-toggle {
  white-space: nowrap; flex-shrink: 0;
  font: inherit; font-size: 15px; padding: 4px 10px; cursor: pointer;
  background: var(--field); color: var(--text); border: 1px solid var(--border); border-radius: 4px;
}

/* forms */
.calc { margin: 16px 0 8px; }
.calc fieldset { border: 1px solid var(--border); border-radius: 4px; padding: 12px 14px 14px; margin: 0; }
.calc legend { padding: 0 6px; font-weight: bold; }
.fields { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: flex-start; }
.actions { margin-top: 14px; display: flex; gap: 8px; }
.field label, .field .label { display: block; font-size: 15px; margin-bottom: 4px; }
.field .hint { display: block; font-size: 14px; color: var(--muted); margin-top: 3px; max-width: 240px; }
input[type="number"], select {
  font: inherit; font-size: 17px; padding: 6px 8px;
  background: var(--field); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
}
input[type="number"] { width: 6.5em; }
input.short { width: 4.5em; }
.pair { display: flex; gap: 6px; align-items: center; }
.units { display: flex; gap: 14px; flex-wrap: wrap; }
.units label { font-size: 16px; }
button.btn {
  font: inherit; font-size: 16px; padding: 7px 14px; cursor: pointer;
  background: var(--accent); color: var(--on-accent); border: 1px solid var(--accent); border-radius: 4px;
}
button.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.btn-plain {
  font: inherit; font-size: 16px; padding: 6px 12px; cursor: pointer;
  background: var(--field); color: var(--text); border: 1px solid var(--border); border-radius: 4px;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* results */
.results { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; margin: 16px 0 8px; align-items: start; }
.result-box { border: 1px solid var(--border); border-radius: 4px; background: var(--box); padding: 14px 16px; }
.result-box h2 { font-size: 19px; margin: 0 0 8px; }
.result-box h3 { font-size: 17px; margin: 16px 0 6px; }
.headline { font-size: 22px; font-weight: bold; margin: 0 0 6px; }
.verdict { margin: 0 0 10px; }
.verdict.ok { color: var(--ok); }
.verdict.warn { color: var(--warn); }
figure { margin: 0; }
figcaption { font-size: 15px; color: var(--muted); margin-top: 6px; }
.diagram { border: 1px solid var(--border); border-radius: 4px; background: var(--bg); padding: 8px; }
.diagram svg { display: block; width: 100%; height: auto; }

/* tables */
table { border-collapse: collapse; width: 100%; margin: 0 0 14px; font-size: 16px; }
th, td { border: 1px solid var(--border); padding: 6px 9px; text-align: left; vertical-align: top; }
th { background: var(--box); }
tbody tr:nth-child(even) td { background: var(--zebra); }
.result-box table { background: var(--bg); }
td.num, th.num { text-align: right; white-space: nowrap; }
.table-scroll { overflow-x: auto; }

/* content */
.content { max-width: 760px; }
.content img, .content figure { margin: 8px 0 16px; }
.sources li { margin-bottom: 8px; }
dl.faq dt { font-weight: bold; margin-top: 18px; }
dl.faq dd { margin: 4px 0 0; }

.site-footer { border-top: 1px solid var(--border); margin-top: 48px; padding: 14px 0 24px; font-size: 15px; color: var(--muted); }
.site-footer p { margin: 0 0 6px; }

@media (max-width: 760px) {
  body { font-size: 16px; }
  h1 { font-size: 26px; }
  h2 { font-size: 21px; }
  .site-name { font-size: 17px; }
  .headline { font-size: 20px; }
  .results { grid-template-columns: minmax(0, 1fr); }
  .fields { gap: 12px 16px; }
}

/* diagram parts (inline SVG) */
.d-line { stroke: var(--d-line); fill: none; stroke-width: 1.5; }
.d-solid { fill: var(--d-line); }
.d-fill { fill: var(--d-fill); stroke: var(--d-line); stroke-width: 1.2; }
.d-cone { fill: var(--d-cone); stroke: var(--accent); stroke-width: 1.5; }
.d-mark { stroke: var(--d-mark); stroke-width: 1; stroke-dasharray: 5 4; }
.d-text { fill: var(--text); font-size: 13px; }
.d-muted { fill: var(--muted); font-size: 12px; }
.d-acc { fill: var(--accent); font-size: 13px; font-weight: bold; }
.d-acc-line { stroke: var(--accent); fill: none; stroke-width: 1.5; }
