:root {
  --bg: #fbf9f3; --surface: #ffffff; --ink: #14213d; --muted: #5a6478; --line: #e4dfd1;
  --accent: #f2b705; --accent-ink: #14213d; --brand: #0d3b66; --brand-soft: #e8eef6;
  --ok: #1b7f4b; --err: #b3261e; --shadow: 0 1px 2px rgba(20,33,61,.06), 0 8px 24px rgba(20,33,61,.08);
  --radius: 14px; --max: 1080px; --read: 720px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1523; --surface: #172036; --ink: #eef1f7; --muted: #a6b0c3; --line: #2a3550; --brand: #8fb8e8; --brand-soft: #1b2a47; --accent-ink: #14213d; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35); }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 1rem/1.65 var(--font); }
img, svg { max-width: 100%; }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-ink); padding: .6rem 1rem; z-index: 99; }
.skip:focus { left: 8px; top: 8px; }
.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 16px; }

/* header with ruler ticks */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: relative; }
.site-header::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 6px; background:
  repeating-linear-gradient(90deg, var(--ink) 0 1px, transparent 1px 10px),
  repeating-linear-gradient(90deg, var(--ink) 0 1px, transparent 1px 50px);
  background-size: 100% 4px, 100% 6px; background-repeat: no-repeat; background-position: left bottom; opacity: .35; pointer-events: none; }
.bar { display: flex; align-items: center; gap: 14px; min-height: 64px; flex-wrap: wrap; padding: 8px 0 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 700 1.35rem/1 var(--serif); color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.nav { display: flex; gap: 4px 18px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.nav a { color: var(--ink); text-decoration: none; font-weight: 600; font-size: .95rem; padding: 6px 2px; border-bottom: 2px solid transparent; }
.nav a:hover, .nav a[aria-current="page"] { border-bottom-color: var(--accent); }
.lang { position: relative; }
.lang summary { list-style: none; cursor: pointer; font-weight: 600; font-size: .92rem; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); user-select: none; }
.lang summary::-webkit-details-marker { display: none; }
.lang summary::after { content: " ▾"; font-size: .8em; }
.lang ul { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); min-width: 190px; max-height: 70vh; overflow: auto; }
.lang a { display: block; padding: 7px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); font-size: .95rem; }
.lang a:hover, .lang a[aria-current="true"] { background: var(--brand-soft); }

main { padding: 28px 0 56px; }
.crumbs { font-size: .85rem; color: var(--muted); margin: 0 0 10px; }
.crumbs a { color: var(--muted); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; letter-spacing: -.01em; margin: 0; }
h1 { font-size: clamp(1.75rem, 4.6vw, 2.6rem); margin-bottom: 12px; }
h2 { font-size: clamp(1.3rem, 3vw, 1.7rem); margin: 40px 0 12px; }
h3 { font-size: 1.1rem; margin: 20px 0 6px; }
.lead { font-size: 1.08rem; color: var(--muted); max-width: var(--read); margin: 0 0 22px; }
.prose { max-width: var(--read); }
.prose p { margin: 0 0 1em; }
.prose ol, .prose ul { padding-left: 1.3em; }
.prose li { margin: .4em 0; }

/* calculator */
.calc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; max-width: 760px; }
.calc-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.field label { display: block; font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.field input, .field select { width: 100%; font: inherit; font-size: 1.15rem; color: var(--ink); background: var(--bg); border: 2px solid var(--line); border-radius: 10px; padding: 11px 12px; min-height: 48px; }
.field input:focus, .field select:focus { border-color: var(--brand); outline: none; }
.field-ftin { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-ftin[hidden], .field-value[hidden] { display: none; }
.units { display: grid; grid-template-columns: 1fr 48px 1fr; gap: 10px; align-items: end; }
.swap { height: 48px; width: 48px; border-radius: 50%; border: 2px solid var(--line); background: var(--accent); color: var(--accent-ink); font-size: 1.25rem; cursor: pointer; display: grid; place-items: center; transition: transform .2s; }
.swap:hover { transform: rotate(180deg); }
.swap:active { transform: scale(.94); }
.result { margin-top: 18px; padding: 16px 18px; border-radius: 12px; background: var(--brand-soft); border: 1px solid var(--line); min-height: 118px; }
.result.is-empty .res-main { color: var(--muted); }
.res-label { font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.res-main { font: 700 clamp(1.8rem, 6vw, 2.8rem)/1.15 var(--serif); font-variant-numeric: tabular-nums; word-break: break-word; margin-top: 2px; }
.res-main .u { font-size: .55em; color: var(--muted); margin-left: .2em; font-family: var(--font); font-weight: 600; }
.res-lines { list-style: none; margin: 8px 0 0; padding: 0; color: var(--muted); font-size: .95rem; display: grid; gap: 2px; }
.err { color: var(--err); font-weight: 600; margin: 8px 0 0; }
.copy { margin-top: 12px; font: inherit; font-weight: 700; font-size: .92rem; padding: 8px 16px; min-height: 40px; border-radius: 999px; border: 2px solid var(--brand); background: transparent; color: var(--brand); cursor: pointer; }
.copy:hover:not(:disabled) { background: var(--brand); color: var(--surface); }
.copy:disabled { opacity: .5; cursor: default; }
.opts { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.opts label { font-size: .85rem; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.opts select { font: inherit; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; min-height: 36px; }

/* tables */
.table-wrap { max-width: 560px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
table.ctable { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ctable caption { text-align: left; font-weight: 700; padding: 10px 14px; background: var(--brand-soft); }
.ctable th, .ctable td { padding: 8px 14px; text-align: left; border-top: 1px solid var(--line); }
.ctable thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--bg); }
.ctable tbody tr:nth-child(even) { background: color-mix(in srgb, var(--brand-soft) 45%, transparent); }
.ctable td:first-child { font-weight: 600; }
.tables-2 { display: grid; grid-template-columns: 1fr; gap: 20px; }
.tables-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; align-items: start; }
.tables-4 .table-wrap { max-width: none; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.card { display: block; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; transition: transform .15s, box-shadow .15s, border-color .15s; height: 100%; }
.card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); }
.card strong { display: block; font-family: var(--serif); font-size: 1.05rem; }
.card span { color: var(--muted); font-size: .88rem; font-variant-numeric: tabular-nums; }
.why { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.why div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.why h3 { margin: 0 0 6px; }
.why p { margin: 0; color: var(--muted); }

.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin: 8px 0; padding: 0 16px; max-width: var(--read); }
.faq summary { cursor: pointer; font-weight: 700; padding: 14px 0; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.3rem; line-height: 1; color: var(--brand); }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin: 0 0 14px; color: var(--muted); }
.unit-info { display: grid; gap: 10px; max-width: var(--read); }
.unit-info p { margin: 0; padding: 12px 14px; background: var(--surface); border-left: 4px solid var(--accent); border-radius: 0 10px 10px 0; }

.ad-slot { margin: 24px 0; min-height: 100px; text-align: center; }
.ad-slot::before { content: "Advertisement"; display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 4px; }

.legal h2 { font-size: 1.25rem; margin-top: 28px; }
.updated { color: var(--muted); font-size: .9rem; }

.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 36px 0 28px; font-size: .93rem; }
.foot-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 24px; }
.foot-grid h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 8px; font-family: var(--font); }
.foot-grid ul { list-style: none; margin: 0; padding: 0; }
.foot-grid li { margin: 4px 0; }
.foot-grid a { color: var(--ink); text-decoration: none; }
.foot-grid a:hover { text-decoration: underline; }
.foot-note { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); }
.foot-note p { margin: 4px 0; }

@media (min-width: 720px) {
  .calc-grid { grid-template-columns: 1.1fr 2fr; align-items: end; }
  .tables-2 { grid-template-columns: 1fr 1fr; }
  .tables-2 .table-wrap { max-width: none; }
  main { padding-top: 40px; }
}
@media (max-width: 520px) {
  .units { grid-template-columns: 1fr; }
  .swap { justify-self: center; transform: rotate(90deg); }
  .swap:hover { transform: rotate(270deg); }
  .nav { margin-left: 0; width: 100%; }
}
@media print {
  .site-header, .site-footer, .calc, .ad-slot, .lang, .nav { display: none !important; }
  body { background: #fff; color: #000; }
  .table-wrap { border: 1px solid #999; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } .swap:hover { transform: none; } }

.ctable tr.cur td { background: var(--brand-soft); font-weight: 700; }
.tvlinks { margin-top: 12px; line-height: 2; }
