:root {
  color-scheme: light;
  --page: #eff3f0;
  --paper: #fff;
  --ink: #172722;
  --muted: #52635b;
  --pine: #184636;
  --deep: #173a30;
  --line: #d6e0d9;
  --light: #e8f2eb;
  --gold: #f0c568;
  --radius: 18px;
  font: 16px/1.45 "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--page); }
button, select, input, textarea { font: inherit; }
button, label { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid #337958; outline-offset: 3px;
}
.shell { max-width: 1000px; margin-inline: auto; padding-inline: 20px; }
.masthead { background: var(--deep); color: #fff; padding-top: env(safe-area-inset-top); }
.masthead-inner { padding-block: 20px 29px; }
.brand { display: flex; align-items: center; gap: 9px; margin: 0 0 14px; font-size: .9rem; font-weight: 650; }
.brand-mark { display: grid; place-items: center; border: 1px solid #d6b568; color: var(--gold); border-radius: 8px; width: 31px; height: 28px; font-size: .72rem; }
h1 { margin: 0; font: 500 clamp(1.9rem, 5vw, 2.85rem)/1.07 Georgia, serif; letter-spacing: -.025em; }
.intro { margin: 9px 0 0; color: #d6e4da; font-size: .95rem; }
.layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 18px; padding-block: 18px 26px; }
.controls { display: grid; gap: 14px; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.section-head { margin: 0 0 13px; }
h2 { font-size: 1.06rem; margin: 0; letter-spacing: -.01em; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend, .field { font-size: .84rem; font-weight: 650; color: var(--muted); }
legend { padding: 0; margin-bottom: 6px; }
.field { display: grid; gap: 6px; }
.separated { margin-top: 13px; }
.pills { display: flex; gap: 5px; background: var(--page); border-radius: 12px; padding: 4px; }
.pills label { position: relative; flex: 1 1 0; cursor: pointer; min-width: 0; }
.pills input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.pills span { display: grid; place-items: center; border-radius: 9px; min-height: 36px; text-align: center; padding: 3px 4px; font-size: .86rem; font-weight: 650; line-height: 1.2; }
.pills input:checked + span { background: var(--pine); color: #fff; }
.pills input:focus-visible + span { outline: 2px solid #337958; outline-offset: 2px; }
.mode-pills span { font-size: .81rem; }
.select { position: relative; }
.select::after { content: ""; position: absolute; top: 17px; right: 13px; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); pointer-events: none; }
select, input[type="text"], input[type="number"], textarea {
  appearance: none; width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink); font-size: 1rem; text-overflow: ellipsis;
}
select { padding-right: 29px; }
input::placeholder { color: #64736a; opacity: 1; }
.dimensions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 12px; }
input[type="range"] { width: 100%; accent-color: var(--pine); margin: 2px 0 0; min-height: 26px; }
.geometry { display: flex; flex-wrap: wrap; gap: 7px; }
.geometry span { border-radius: 8px; background: var(--light); color: #294536; padding: 5px 8px; font-size: .8rem; }
.field-note { color: var(--muted); font-size: .83rem; margin: 8px 0 0; }
.check { cursor: pointer; display: flex; gap: 15px; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); padding-top: 10px; }
.check strong, .check small { display: block; }
.check strong { font-size: .91rem; }
.check small { font-size: .77rem; color: var(--muted); margin-top: 2px; }
.check input { appearance: none; position: relative; width: 41px; height: 24px; flex: 0 0 41px; background: #d9e3dc; border: 1px solid #b0c1b6; border-radius: 16px; cursor: pointer; }
.check input::after { content: ""; width: 16px; height: 16px; position: absolute; border-radius: 50%; left: 3px; top: 3px; background: #fff; box-shadow: 0 1px 3px #18352e4a; }
.check input:checked { background: var(--pine); border-color: var(--pine); }
.check input:checked::after { left: 20px; }
.result { position: sticky; top: 14px; border-top: 4px solid #b78b35; padding: 18px 18px 15px; }
.status { display: inline-block; margin: 0 0 11px; border-radius: 6px; background: var(--light); color: #234f3d; padding: 4px 7px; font-weight: 650; font-size: .77rem; }
.status[data-state="manual"] { background: #f8edda; color: #624619; }
.amount { font-size: clamp(1.36rem, 3.65vw, 2.22rem); font-weight: 720; font-variant-numeric: tabular-nums; letter-spacing: -.045em; overflow-wrap: anywhere; margin: 2px 0 8px; color: var(--pine); }
.result-description { margin: 0; color: var(--muted); font-size: .88rem; }
#breakdown { margin: 16px 0 0; padding: 0; }
#breakdown:empty { display: none; }
.line { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; padding-block: 7px; border-top: 1px solid var(--line); font-size: .875rem; }
dd, dt { margin: 0; }
dd { text-align: right; font-weight: 650; }
dd[data-pending] { font-weight: 500; color: var(--muted); }
.primary { display: inline-flex; min-height: 46px; padding: 9px 13px; align-items: center; justify-content: center; border: 0; border-radius: 10px; background: var(--pine); color: #fff; text-align: center; text-decoration: none; font-weight: 700; cursor: pointer; }
.primary:hover { background: #215843; }
.primary:disabled { background: #dce5df; color: #5b6b62; cursor: default; }
.full { width: 100%; margin-top: 15px; }
#feedback { display: block; min-height: 15px; margin-top: 4px; color: var(--pine); font-size: .8rem; }
.copy-fallback { min-height: 120px; }
.quick-result { display: none; }
.gate { margin-block: 20px; }
.gate p { color: var(--muted); }
.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; }
@media (max-width: 690px) {
  .shell { padding-inline: 12px; }
  .masthead-inner { padding-block: 16px 20px; }
  .layout { grid-template-columns: 1fr; gap: 12px; padding-top: 12px; padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
  .controls { gap: 10px; }
  .panel { padding: 14px; border-radius: 15px; }
  .result { position: static; }
  .amount { font-size: clamp(1.48rem, 6vw, 2rem); }
  .quick-result { position: fixed; z-index: 1; bottom: max(8px, env(safe-area-inset-bottom)); left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 49px; padding: 8px 11px; border: 1px solid #2d694f; border-radius: 12px; background: var(--pine); box-shadow: 0 3px 14px #18352e4a; color: #fff; cursor: pointer; font-size: .82rem; }
  .quick-result strong { text-align: right; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
