:root {
  color-scheme: light;
  font: 16px/1.5 system-ui, sans-serif;
  color: #1e3040;
  background: #f4f3ed;
  --muted: #53636c;
  --line: #d6dbd8;
  --paper: #fffefa;
  --blue: #21475b;
  --accent: #a1371b;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, textarea { font: inherit; }
button, input, textarea { border-radius: 5px; }
:focus-visible { outline: 3px solid #2e6b8e; outline-offset: 3px; }

.shell { max-width: 1180px; padding: 0 clamp(16px, 4vw, 54px); margin: auto; }
.intro { padding: clamp(27px, 6vw, 68px) 0 28px; }
.brand { margin: 0 0 14px; color: var(--accent); font-size: .83rem; font-weight: 750; letter-spacing: .045em; }
h1, h2, p, dl, dd { margin: 0; }
h1 { max-width: 780px; font-size: clamp(1.9rem, 4.8vw, 3.6rem); line-height: 1.04; letter-spacing: -.048em; }
.intro > p:last-child { max-width: 600px; margin-top: 14px; color: var(--muted); }
h2 { font-size: 1.17rem; letter-spacing: -.022em; }
.layout { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); align-items: start; gap: 18px; }
.panel { min-width: 0; padding: clamp(16px, 2.6vw, 27px); border: 1px solid var(--line); border-radius: 9px; background: var(--paper); }
.settings { box-shadow: 0 2px 2px #162c3810; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 12px; margin-top: 20px; }
label { display: block; color: #253c49; font-size: .83rem; font-weight: 740; }
label span { margin-left: .15em; color: var(--muted); font-weight: 500; }
input, textarea { display: block; width: 100%; margin-top: 5px; border: 1px solid #aab6b7; padding: 8px 10px; color: #1e3040; background: #fff; }
input { min-height: 42px; }
textarea { min-height: 96px; max-height: 380px; resize: vertical; font: .92rem/1.5 ui-monospace, monospace; }
.hint { color: var(--muted); font-size: .84rem; }
.settings .hint { margin: 8px 0 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
button, #download { min-height: 42px; padding: 8px 12px; cursor: pointer; font-size: .84rem; font-weight: 730; border: 1px solid transparent; }
#download { display: inline-flex; align-items: center; border-radius: 5px; border-color: var(--line); text-decoration: none; }
.primary { color: white; background: var(--accent); }
.primary:hover { background: #842710; }
.quiet, .secondary { color: var(--blue); background: transparent; }
.secondary { border-color: var(--line); }
.quiet:hover, .secondary:hover { background: #edf2ef; }
.error { margin-top: 13px; padding: 9px 11px; background: #fff0e8; color: #842710; border: 1px solid #e1b4a6; border-radius: 5px; font-size: .86rem; }

.result-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 17px 0; background: #eaf0ee; border-radius: 7px; }
.summary > div { min-width: 0; padding: 11px clamp(7px, 2vw, 15px); }
.summary > div + div { border-left: 1px solid #d0dad8; }
.summary dt { color: var(--muted); font-size: .78rem; font-weight: 700; }
.summary dd { margin-top: 2px; font-size: clamp(1rem, 3vw, 1.55rem); font-weight: 750; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.bars { display: grid; margin: 0; padding: 0; gap: 10px; list-style: none; }
.bar { min-width: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 7px; }
.bar-heading { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; font-size: .86rem; }
.bar-heading span, .parts { color: var(--muted); }
.track { display: flex; overflow: hidden; background: #e7ebe6; height: 13px; margin: 8px 0 6px; border-radius: 2px; }
.segment { flex-basis: 0; min-width: 0; }
.piece { background: #346580; border-right: 1px solid #fffefa; }
.piece:nth-of-type(even) { background: #547e8e; }
.allowance { background: #a1371b; }
.parts { font-size: .81rem; }
#losses { margin-top: 12px; }
.workshop { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 16px 0; margin-top: 22px; border-top: 1px solid var(--line); }
.workshop h2 { font-size: 1rem; }
.workshop p { color: var(--muted); font-size: .84rem; }
.workshop a, .site-footer a, .legal a { color: var(--blue); text-underline-offset: .19em; }
.workshop-link { font-size: .86rem; font-weight: 730; }
.site-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: .8rem; padding: 12px 0 28px; }
.site-footer nav { display: flex; gap: 18px; }
.legal { max-width: 720px; margin-bottom: 14px; }
.legal h2 { margin-top: 18px; }
.legal p + p, .legal h2 + p { margin-top: 7px; }
.legal address { font-style: normal; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
}

@media print {
  :root { color: #111; background: white; }
  .shell { max-width: none; padding: 0; }
  .intro { padding: 0 0 12px; }
  .intro h1 { font-size: 24pt; }
  .layout { display: block; }
  .intro > p:last-child, .settings, .actions, .workshop, footer { display: none !important; }
  .result { border: 0; padding: 0; }
  .summary, .bar { break-inside: avoid; }
  .track { print-color-adjust: exact; }
}
