:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #555b66;
  --accent: #1f5fbf;
  --card: #f4f6fa;
  --err: #b00020;
  --border: #d5dbe5;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121418;
    --fg: #eceff4;
    --muted: #a5adba;
    --accent: #7aa7ff;
    --card: #1c2028;
    --err: #ff8a95;
    --border: #2c323d;
  }
}
:root[data-theme="dark"] {
  --bg: #121418;
  --fg: #eceff4;
  --muted: #a5adba;
  --accent: #7aa7ff;
  --card: #1c2028;
  --err: #ff8a95;
  --border: #2c323d;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  padding: 0 16px;
  max-width: 760px;
  margin: 0 auto;
  overflow-wrap: anywhere;
}
header.top { padding: 12px 0; border-bottom: 1px solid var(--border); }
header.top a { color: var(--accent); text-decoration: none; font-weight: 600; }
main { padding: 16px 0; }
h1 { font-size: 1.7rem; line-height: 1.25; margin: 0.6em 0 0.4em; }
h2 { font-size: 1.25rem; margin: 1.6em 0 0.5em; }
h3 { font-size: 1.05rem; margin: 1em 0 0.3em; }
.intro { color: var(--muted); }
form.calc {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: grid;
  gap: 12px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
label { font-weight: 600; font-size: 0.95rem; }
input, select {
  font: inherit;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  width: 100%;
  min-height: 44px;
}
button {
  font: inherit;
  font-weight: 600;
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
}
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.result { margin-top: 16px; min-height: 2em; }
dl.res { margin: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
dl.res dt, dl.res dd { margin: 0; padding: 10px 14px; }
dl.res dt { background: var(--card); color: var(--muted); font-size: 0.92rem; border-top: 1px solid var(--border); }
dl.res dt:first-child { border-top: 0; }
dl.res dd { font-weight: 700; font-size: 1.1rem; padding-bottom: 12px; }
.err { color: var(--err); font-weight: 600; }
.disc, .refs { color: var(--muted); font-size: 0.9rem; }
ul.list { padding-left: 1.2em; }
ul.list li { margin: 6px 0; }
a { color: var(--accent); }
footer { border-top: 1px solid var(--border); padding: 12px 0 24px; color: var(--muted); }
@media (min-width: 600px) {
  form.calc { grid-template-columns: 1fr 1fr; }
  form.calc button { grid-column: 1 / -1; justify-self: start; }
}
