:root {
  --paper: #f3f4f5;
  --card: #ffffff;
  --ink: #1f1c17;
  --muted: #5e564a;
  --line: #d6d8dc;
  --accent: #8a1c2c;
  --first: #8a1c2c;
  --c21: #5b5040;
  --c22: #75684f;
  --third: #c8bfae;
  --fail: #e9e3d8;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.6 var(--sans); }
a { color: var(--accent); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
header.site { border-bottom: 1px solid var(--line); }
header.site .wrap { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font: 600 18px/1 var(--serif); color: var(--ink); text-decoration: none; }
.brand svg { width: 26px; height: 26px; }
nav.main a { color: var(--muted); text-decoration: none; margin-left: 16px; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; font-weight: 600; }
h1 { font-size: clamp(30px, 5vw, 42px); margin: 28px 0 8px; }
h2 { font-size: 26px; margin: 40px 0 10px; }
h3 { font-size: 19px; margin: 24px 0 6px; }
.lead { max-width: 60ch; color: var(--muted); margin: 0 0 20px; }
.content { max-width: 62ch; }
p, li { text-wrap: pretty; }
::placeholder { color: #5e564a; opacity: 1; }
.content p, .content li { color: #2e2a23; }

.tool { margin-bottom: 8px; }
.controls { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: end; padding: 14px 0; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line); }
.controls label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.controls label.check { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--ink); font-weight: 500; padding-bottom: 8px; }
select, input { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 4px; padding: 7px 9px; min-height: 40px; }
select:focus, input:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=checkbox] { min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; margin-top: 18px; align-items: start; }
fieldset.year { border: 0; border-top: 1px solid var(--line); margin: 0 0 18px; padding: 10px 0 0; min-width: 0; }
legend { font: 600 19px/1 var(--serif); padding: 0 8px 0 0; }
.ywt { font: 500 13px var(--sans); color: var(--muted); margin-left: 6px; }
.mhead, .mrow { display: grid; grid-template-columns: minmax(0, 1fr) 76px 86px 36px; gap: 8px; align-items: center; }
.mhead { font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.mrow { margin-bottom: 6px; }
.mrow input { width: 100%; }
.mc, .mm { text-align: right; font-variant-numeric: tabular-nums; }
.mm:placeholder-shown { background: transparent; border-style: dashed; }
button { font: inherit; cursor: pointer; border-radius: 4px; }
.del { border: 0; background: none; color: var(--muted); font-size: 22px; line-height: 1; height: 40px; }
.del:hover { color: var(--accent); }
.add { border: 1px dashed var(--line); background: none; color: var(--muted); padding: 6px 12px; margin-top: 2px; }
.ystat { font-size: 14px; color: var(--muted); margin: 8px 0 0; font-variant-numeric: tabular-nums; }

.result { position: sticky; top: 12px; background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--accent); padding: 16px 18px; }
.rlabel { margin: 0; font-size: 13px; color: var(--muted); }
.big { margin: 2px 0 0; font: 600 44px/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.cls { margin: 2px 0 12px; font: 600 22px var(--serif); }
.cls.c-first { color: var(--first); }
.bar { position: relative; display: grid; grid-template-columns: 1fr 1fr 1fr 1fr 2fr; height: 26px; font-size: 11px; font-weight: 700; margin-bottom: 8px; }
.bar .z { display: flex; align-items: center; justify-content: center; }
.z-fail { background: var(--fail); } .z-third { background: var(--third); } .z-22 { background: var(--c22); color: #fff; }
.z-21 { background: var(--c21); color: #fff; } .z-first { background: var(--first); color: #fff; }
#marker { position: absolute; top: -5px; bottom: -5px; width: 3px; margin-left: -1px; background: var(--ink); box-shadow: 0 0 0 2px var(--card); }
.basis { font-size: 13px; color: var(--muted); margin: 6px 0 10px; }
.border { font-size: 14px; background: #f8ecd9; border-left: 3px solid #b8741a; padding: 8px 10px; margin: 0 0 12px; }
#needs { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
#needs caption { text-align: left; font-size: 13px; color: var(--muted); padding-bottom: 6px; }
#needs th, #needs td { text-align: left; padding: 7px 0; border-top: 1px solid var(--line); vertical-align: top; }
#needs th { font-weight: 600; padding-right: 10px; white-space: nowrap; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.actions button { border: 1px solid var(--accent); background: var(--accent); color: #fff; padding: 8px 12px; }
.actions .ghost { background: none; color: var(--ink); border-color: var(--line); }
.note { font-size: 14px; color: var(--muted); max-width: 70ch; }

table.bounds { border-collapse: collapse; margin: 12px 0; min-width: 280px; }
table.bounds caption { text-align: left; font-weight: 600; padding-bottom: 6px; }
table.bounds th, table.bounds td { border-bottom: 1px solid var(--line); padding: 6px 24px 6px 0; text-align: left; }

footer.site { border-top: 1px solid var(--line); margin-top: 48px; padding: 20px 0 32px; font-size: 14px; color: var(--muted); }
footer.site .wrap { display: flex; gap: 18px; flex-wrap: wrap; }
footer.site a { color: var(--muted); }
.breadcrumb { font-size: 14px; color: var(--muted); margin-top: 20px; }

@media (max-width: 820px) {
  .grid { grid-template-columns: 1fr; }
  .result { position: static; order: -1; }
  #years { order: 1; }
  .mhead, .mrow { grid-template-columns: minmax(0, 1fr) 62px 72px 30px; gap: 6px; }
}
