:root {
  color-scheme: light;
  --canvas: #ffffff;
  --canvas-soft: #e8ebe6;
  --canvas-sunk: #f3f5f1;
  --ink: #0e0f0c;
  --ink-deep: #163300;
  --body: #454745;
  --mute: #62645f;
  --line: #d3d8cf;
  --field-line: #0e0f0c;
  --primary: #9fe870;
  --primary-hover: #b5f08e;
  --on-primary: #0e0f0c;
  --primary-pale: #e2f6d5;
  --secondary: #e8ebe6;
  --secondary-hover: #dde2da;
  --negative: #a72027;
  --footer-bg: #0e0f0c;
  --footer-text: #e8ebe6;
  --radius-card: 24px;
  --radius-field: 12px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --font: 'Manrope', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --canvas: #1a1c18;
    --canvas-soft: #0e0f0c;
    --canvas-sunk: #23261f;
    --ink: #eef1ec;
    --ink-deep: #c5edab;
    --body: #c3c7bf;
    --mute: #a3a79f;
    --line: #353a31;
    --field-line: #8c9287;
    --primary-pale: #22301a;
    --secondary: #2a2e26;
    --secondary-hover: #343930;
    --negative: #ff9a9e;
    --footer-bg: #1a1c18;
    --footer-text: #c3c7bf;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--canvas-soft);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  scrollbar-color: var(--mute) var(--canvas-soft);
}
::selection { background: var(--primary); color: var(--on-primary); }
button, input, textarea { font: inherit; color: inherit; }
button, .button { touch-action: manipulation; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1em; height: 1em; flex: none; fill: currentColor; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
p { margin: 0; }

.skip-link {
  position: fixed;
  z-index: 30;
  left: 16px;
  top: -80px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--canvas-soft);
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* Header */
.masthead {
  width: min(1200px, 100% - 48px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 18px;
}
.header-note { color: var(--body); font-size: 14px; font-weight: 600; }

/* Layout */
main {
  width: min(1200px, 100% - 48px);
  margin: 0 auto;
  padding: 16px 0 16px;
  flex: 1;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  align-items: end;
  gap: 24px 48px;
  margin-bottom: 14px;
}
h1 {
  font-size: clamp(32px, 4vw, 52px);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.03em;
  max-width: 18ch;
}
.intro-copy > p { margin-top: 10px; font-size: 16px; line-height: 1.5; color: var(--body); max-width: 40ch; }

.formula {
  background: var(--canvas);
  border-radius: var(--radius-card);
  padding: 16px;
}
.formula-line { display: flex; align-items: center; gap: 16px; }
.term { display: grid; gap: 2px; }
.term strong {
  font-size: 26px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.term span { font-size: 14px; font-weight: 600; color: var(--body); }
.op {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 14px;
  flex: none;
}
.formula-note { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 14px; color: var(--body); }

/* Calculator card */
.calculator {
  background: var(--canvas);
  border-radius: var(--radius-card);
  padding: 16px 20px;
}
.calc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
h2 { font-size: 24px; line-height: 1.25; font-weight: 700; letter-spacing: -0.02em; scroll-margin-top: 24px; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--canvas-soft);
}
.tabs button {
  min-height: 44px;
  padding: 8px 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--body);
  font-size: 15px;
  font-weight: 700;
  text-wrap: balance;
  line-height: 1.2;
  transition: background-color 200ms ease, color 200ms ease, transform 160ms var(--ease-out);
}
.tabs button.active { background: var(--ink); color: var(--canvas); }
.tabs button:active { transform: scale(0.97); }

.known {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: 32px;
  align-items: start;
}
.hint { font-size: 15px; color: var(--body); max-width: 60ch; }
.models > .hint { margin-bottom: 8px; }

/* Model list: hugs its content up to 2 models tall, then scrolls internally instead of growing further.
   Padded on both sides (with matching negative margin) so overflow-y:auto — which per spec
   forces overflow-x to clip too — doesn't cut off the focus ring on the leftmost inputs. */
#items {
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  padding: 0 8px;
  margin: 0 -8px;
  transition: mask-image 150ms ease;
}

/* Model rows */
.model {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.model:last-child { border-bottom: 0; }
@starting-style {
  .model { opacity: 0; transform: translateY(20px) scale(0.98); }
}
.model { transition: opacity 260ms var(--ease-out), transform 260ms var(--ease-out); }
.model-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; min-height: 36px; }
.model-header strong { font-size: 16px; font-weight: 800; }
.remove {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--body);
  font-size: 14px;
  font-weight: 700;
  transition: background-color 200ms ease, color 200ms ease, transform 160ms var(--ease-out);
}
.remove:active { transform: scale(0.97); }
.fields { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 12px 16px; }
label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 700; }
label .optional { font-weight: 500; color: var(--mute); }
.input-wrap { position: relative; }
input {
  width: 100%;
  min-width: 0;
  min-height: 52px;
  padding: 12px 16px;
  border: 1px solid var(--field-line);
  border-radius: var(--radius-field);
  background: var(--canvas);
  color: var(--ink);
  font-size: 16px;
  caret-color: var(--ink);
  transition: box-shadow 160ms ease, border-color 160ms ease;
}
input::placeholder { color: var(--mute); opacity: 1; }
input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink), 0 0 0 5px var(--primary); }
input[aria-invalid="true"] { border-color: var(--negative); box-shadow: 0 0 0 1px var(--negative); }
.volume-input { min-height: 56px; padding-right: 56px; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.volume-input::placeholder { font-weight: 600; }
.unit {
  position: absolute;
  right: 8px;
  top: 50%;
  translate: 0 -50%;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--canvas-soft);
  font-size: 13px;
  font-weight: 700;
  pointer-events: none;
}
.error { margin-top: 8px; color: var(--negative); font-size: 14px; font-weight: 600; }

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 24px;
  border: 0;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
  text-decoration: none;
  text-align: center;
  transition: background-color 200ms ease, transform 160ms var(--ease-out), opacity 200ms ease;
}
.button:active:not(:disabled) { transform: scale(0.97); }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button .icon { font-size: 18px; }
.primary { width: 100%; background: var(--primary); color: var(--on-primary); }
.secondary { background: var(--secondary); color: var(--ink); }
.add-button { width: 100%; margin-top: 8px; }
.button .label { transition: opacity 180ms ease, filter 180ms ease; }
.button.is-swapping .label { opacity: 0; filter: blur(2px); }

.small-note { margin-top: 10px; font-size: 14px; color: var(--body); }
.text-button {
  min-height: 24px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--primary);
  text-underline-offset: 4px;
}

/* Price slip */
.slip {
  position: sticky;
  top: 24px;
  padding-left: 32px;
  border-left: 1px solid var(--line);
}
.slip h2 { font-size: 20px; margin-bottom: 6px; }
.slip-lines:empty::before {
  content: "Your models will be listed here, line by line.";
  display: block;
  padding: 12px 0;
  color: var(--mute);
  font-size: 14px;
}
.slip-line {
  display: grid;
  grid-template-columns: minmax(0, auto) 1fr auto;
  align-items: baseline;
  column-gap: 8px;
  padding: 10px 0;
  transition: opacity 220ms var(--ease-out), transform 260ms var(--ease-out);
}
@starting-style {
  .slip-line { opacity: 0; transform: translateY(10px); }
}
.slip-name { font-weight: 700; overflow-wrap: anywhere; min-width: 0; }
.slip-leader { border-bottom: 2px dotted var(--mute); opacity: 0.5; transform: translateY(-4px); min-width: 16px; }
.slip-price { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.slip-math { grid-column: 1 / -1; font-size: 13px; color: var(--body); font-variant-numeric: tabular-nums; }
.slip-line.is-adjust .slip-name { font-weight: 600; }
.total-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 2px dashed var(--line);
}
.total-row > span { font-weight: 700; }
#total {
  font-size: 48px;
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}
#total.is-empty { color: var(--mute); }
.summary-hint { margin: 4px 0 10px; font-size: 14px; color: var(--body); }
.contact { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-top: 8px; }
.contact .button { padding-inline: 16px; font-size: 15px; }
.disclaimer { margin-top: 8px; font-size: 13px; line-height: 1.55; color: var(--body); }

/* Manual quote */
.unknown {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}
h3 { font-size: 32px; line-height: 1.1; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 12px; }
.unknown > div > p { font-size: 17px; color: var(--body); max-width: 46ch; }
.request { padding-left: 32px; border-left: 1px solid var(--line); }
.request-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; }
.request-list li, .included li { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.request-list .icon, .included .icon {
  width: 24px;
  height: 24px;
  padding: 5px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
}
.request .hint { margin-bottom: 16px; font-size: 14px; }

#copy-fallback { margin-top: 24px; }
textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--field-line);
  border-radius: var(--radius-field);
  background: var(--canvas);
  font-size: 15px;
  line-height: 1.5;
}

/* Included */
.included {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 32px;
  margin-top: 14px;
}
.included h2 { font-size: 20px; }
.included ul { display: flex; flex-wrap: wrap; gap: 12px 24px; margin: 0; padding: 0; list-style: none; }
.included > p { color: var(--body); font-size: 15px; }

/* Footer */
.site-footer { background: var(--footer-bg); color: var(--footer-text); }
.site-footer > div {
  width: min(1200px, 100% - 48px);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0 max(16px, env(safe-area-inset-bottom));
  font-size: 14px;
  font-weight: 600;
}

/* Toast */
.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 32px);
  padding: 10px 10px 10px 20px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--canvas);
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(14, 15, 12, 0.18);
  transform: translate(-50%, 0);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}
.toast:empty { opacity: 0; transform: translate(-50%, 12px); pointer-events: none; padding: 0; }
.toast .undo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 700;
}

@media (hover: hover) and (pointer: fine) {
  .tabs button:not(.active):hover { color: var(--ink); background: var(--secondary-hover); }
  .remove:hover { background: var(--canvas-soft); color: var(--negative); }
  .primary:hover:not(:disabled) { background: var(--primary-hover); }
  .secondary:hover { background: var(--secondary-hover); }
  .text-button:hover { text-decoration-color: var(--ink); }
  .brand:hover .brand-mark { background: var(--primary-hover); }
}

@media (max-width: 960px) {
  .intro { grid-template-columns: 1fr; align-items: start; }
  .known, .unknown { grid-template-columns: 1fr; }
  .slip, .request { position: static; padding: 24px 0 0; border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 600px) {
  .masthead, main, .site-footer > div { width: calc(100% - 32px); }
  .masthead { padding: 14px 0; }
  .header-note { display: none; }
  main { padding: 16px 0 40px; }
  .intro { gap: 20px; margin-bottom: 24px; }
  h1 { font-size: 40px; max-width: none; }
  .intro-copy > p { font-size: 17px; margin-top: 14px; }
  .formula { padding: 20px; }
  .term strong { font-size: 28px; }
  .calculator { padding: 20px; border-radius: 20px; }
  .calc-head { margin-bottom: 16px; }
  .tabs { width: 100%; border-radius: 20px; }
  .tabs button { flex: 1; padding: 8px 10px; font-size: 14px; border-radius: 16px; }
  .fields { grid-template-columns: 1fr; }
  #total { font-size: 40px; }
  h3 { font-size: 26px; }
  .included { margin-top: 28px; }
  .site-footer > div { flex-direction: column; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .model, .slip-line { transition: opacity 200ms ease; }
  @starting-style {
    .model, .slip-line { opacity: 0; transform: none; }
  }
  .button:active:not(:disabled), .tabs button:active, .remove:active { transform: none; }
  .toast, .toast:empty { transform: translate(-50%, 0); }
}
