/* Sumloft — one stylesheet for every page. Colour tokens first; seo-check.js reads them for WCAG contrast. */
:root {
  --bg: #f6f4ef; --card: #ffffff; --ink: #1d1b26; --mute: #5a5668; --line: #e4e0d6; --field: #fdfcfa; --field-line: #858196;
  --accent: #4b3fc4; --accent-ink: #ffffff; --link: #4337b5; --tint: #eeecfb; --tint-line: #cfcaf3;
  --res-bg: #1f1b4d; --res-ink: #ffffff; --res-mute: #c9c4f5; --warn: #fff6df; --warn-line: #e2c07a; --err: #a3271b;
  --r: 14px; --shadow: 0 1px 2px rgba(30,25,60,.06), 0 6px 20px rgba(30,25,60,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14131a; --card: #1d1c25; --ink: #eceaf3; --mute: #aeaabd; --line: #2f2d3b; --field: #17161e; --field-line: #75718a;
    --accent: #a9a1ff; --accent-ink: #17142b; --link: #b9b2ff; --tint: #262343; --tint-line: #3d3970;
    --res-bg: #2a2560; --res-ink: #ffffff; --res-mute: #d3cffa; --warn: #2b2416; --warn-line: #6b5527; --err: #ff9b8f;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14131a; --card: #1d1c25; --ink: #eceaf3; --mute: #aeaabd; --line: #2f2d3b; --field: #17161e; --field-line: #75718a;
  --accent: #a9a1ff; --accent-ink: #17142b; --link: #b9b2ff; --tint: #262343; --tint-line: #3d3970;
  --res-bg: #2a2560; --res-ink: #ffffff; --res-mute: #d3cffa; --warn: #2b2416; --warn-line: #6b5527; --err: #ff9b8f;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--link); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--card); color: var(--ink); padding: 8px 12px; border-radius: 8px; z-index: 9; }
.skip:focus { left: 8px; }
h1 { font-size: clamp(1.6rem, 5.5vw, 2.3rem); line-height: 1.15; letter-spacing: -.02em; margin: 0 0 8px; }
h2 { font-size: 1.25rem; line-height: 1.3; margin: 0 0 10px; letter-spacing: -.01em; }
h3 { font-size: 1.02rem; margin: 18px 0 6px; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .93em; }

/* Header / footer */
.top { border-bottom: 1px solid var(--line); background: var(--card); }
.top .in { max-width: 1080px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; }
.brand svg { width: 30px; height: 30px; flex: none; }
.top nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.top nav a { color: var(--mute); text-decoration: none; font-weight: 600; font-size: .92rem; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.top nav a:hover, .top nav a[aria-current] { background: var(--tint); color: var(--ink); }
#theme { flex: none; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--field); color: var(--ink); cursor: pointer; display: grid; place-items: center; }
#theme svg { width: 20px; height: 20px; }
@media (max-width: 640px) { .top .in { flex-wrap: wrap; } .top nav { order: 3; width: 100%; margin: 0; } }
.foot { border-top: 1px solid var(--line); color: var(--mute); font-size: .9rem; margin-top: 32px; }
.foot .in { max-width: 1080px; margin: 0 auto; padding: 20px 16px 28px; display: flex; flex-wrap: wrap; gap: 8px 20px; }
.foot a { color: var(--mute); }

/* Layout */
main { width: 100%; max-width: 1080px; margin: 0 auto; padding: 18px 16px 24px; flex: 1; }
.crumb ol { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 4px 6px; font-size: .88rem; color: var(--mute); }
.crumb li + li::before { content: "/"; margin-right: 6px; color: var(--mute); }
.crumb a { color: var(--mute); }
.lede { color: var(--mute); font-size: 1.05rem; margin: 0 0 18px; max-width: 62ch; }
.updated { display: inline-block; font-size: .82rem; font-weight: 700; color: var(--ink); background: var(--tint); border: 1px solid var(--tint-line); border-radius: 999px; padding: 2px 10px; margin: 0 0 14px; }
.calc { display: grid; gap: 16px; align-items: start; margin-bottom: 20px; }
@media (min-width: 860px) { .calc { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); } .calc .result { position: sticky; top: 16px; } }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); }
.prose { max-width: 70ch; }
.prose p, .prose li { margin: 0 0 10px; }
section { margin: 0 0 22px; }

/* Forms */
form.calc-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 14px; }
form.calc-form .wide { grid-column: 1 / -1; }
.f label, .f .lbl { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
.f small { display: block; color: var(--mute); font-size: .8rem; line-height: 1.35; }
input[type=number], input[type=search], select {
  width: 100%; min-height: 44px; padding: 8px 11px; font: inherit; color: var(--ink); background: var(--field);
  border: 1px solid var(--field-line); border-radius: 10px; }
input:focus, select:focus { outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent); outline-offset: 0; border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 600; font-size: .92rem; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
fieldset { border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px 12px; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px 12px; }
legend { font-weight: 700; font-size: .85rem; color: var(--mute); padding: 0 4px; }
.btns { display: flex; gap: 8px; }
.btn { min-height: 44px; padding: 8px 16px; border-radius: 10px; font: inherit; font-weight: 700; cursor: pointer; border: 1px solid var(--accent); }
.btn.go { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; color: var(--link); }

/* Result */
.result { background: var(--res-bg); color: var(--res-ink); border-radius: var(--r); padding: 18px 18px 12px; box-shadow: var(--shadow); }
.result .res-label { margin: 0; color: var(--res-mute); font-size: .9rem; font-weight: 600; }
.result .res-main { margin: 2px 0 12px; font-size: clamp(1.7rem, 6vw, 2.3rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.res-table { width: 100%; border-collapse: collapse; font-size: .94rem; font-variant-numeric: tabular-nums; }
.res-table th { text-align: left; font-weight: 500; color: var(--res-mute); padding: 6px 8px 6px 0; }
.res-table td { text-align: right; padding: 6px 0; white-space: nowrap; }
.res-table tr + tr { border-top: 1px solid rgba(255,255,255,.14); }
.res-table tr.strong th, .res-table tr.strong td { color: var(--res-ink); font-weight: 800; }
.res-err { margin: 0 0 8px; font-weight: 700; color: #ffd9d4; }
.res-note { margin: 8px 0 0; font-size: .85rem; color: var(--res-mute); }
.multi { display: grid; gap: 16px; }
@media (min-width: 860px) { .multi { grid-template-columns: 1fr 1fr; } }
.mini .result { margin-top: 12px; padding: 12px 14px 8px; }
.mini .result .res-main { font-size: 1.6rem; margin-bottom: 6px; }

/* Content blocks */
.formula { background: var(--tint); border: 1px solid var(--tint-line); border-radius: 10px; padding: 12px 14px; overflow-x: auto; }
.formula p { margin: 0 0 6px; }
.formula p:last-child { margin: 0; }
.example ol { padding-left: 20px; margin: 0; }
.example li { margin-bottom: 4px; }
.note { background: var(--warn); border: 1px solid var(--warn-line); border-radius: 10px; padding: 10px 14px; font-size: .92rem; }
.note p { margin: 0 0 6px; } .note p:last-child { margin: 0; }
.sources { font-size: .9rem; }
.sources li { margin-bottom: 4px; overflow-wrap: anywhere; }
table.data { width: 100%; border-collapse: collapse; font-size: .94rem; font-variant-numeric: tabular-nums; background: var(--card); border-radius: 10px; overflow: hidden; }
table.data th, table.data td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; }
table.data thead th { background: var(--tint); font-size: .85rem; }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.faq details { background: var(--card); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.faq summary { cursor: pointer; padding: 12px 14px; font-weight: 700; list-style-position: inside; }
.faq summary h3 { display: inline; font-size: 1rem; margin: 0; }
.faq details > div { padding: 0 14px 12px; }
.faq details > div p { margin: 0 0 8px; }
.related ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.related a { display: block; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; font-weight: 600; }
.related a:hover { border-color: var(--accent); }

/* Ad placeholder: reserves space so a future ad does not shift the layout */
.ad-slot { min-height: 100px; margin: 8px 0 24px; border: 1px dashed var(--line); border-radius: 10px; display: grid; place-items: center; color: var(--mute); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; }

/* Homepage */
.hero { padding: 10px 0 6px; }
.hero h1 { font-size: clamp(1.8rem, 6vw, 2.8rem); max-width: 22ch; }
.search { max-width: 520px; margin: 0 0 6px; }
#q-count { color: var(--mute); font-size: .9rem; min-height: 1.5em; margin: 0 0 10px; }
.cat-block { margin-bottom: 26px; }
.cat-block h2 { display: flex; align-items: baseline; gap: 10px; }
.cat-block h2 a { font-size: .85rem; font-weight: 600; }
.tiles { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.tiles a { display: block; height: 100%; padding: 14px; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; text-decoration: none; color: var(--ink); }
.tiles a:hover { box-shadow: var(--shadow); }
.tiles strong { display: block; color: var(--link); }
.tiles span { display: block; color: var(--mute); font-size: .88rem; line-height: 1.4; margin-top: 2px; }

/* Align inputs in a row even when one label wraps to two lines */
form.calc-form .f, fieldset .f { display: flex; flex-direction: column; }
form.calc-form .f > input, form.calc-form .f > select { margin-top: auto; }
.f small { margin: -2px 0 5px; }
@media (max-width: 640px) { #theme { margin-left: auto; } }
