:root {
  color-scheme: light;
  --paper: #f4efe3;
  --paper-deep: #e8deca;
  --surface: #fffdf7;
  --ink: #27231d;
  --muted: #726b5e;
  --line: #cbc0ab;
  --accent: #c94d32;
  --accent-dark: #8f2f1f;
  --sage: #56715c;
  --sage-soft: #dce5d8;
  --warning: #9c5a18;
  --shadow: 0 18px 45px rgba(66, 48, 30, 0.12);
  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --content: 1180px;
  --display: Charter, "Bitstream Charter", "Sitka Text", Georgia, serif;
  --body: Aptos, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--body); line-height: 1.5; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
.skip-link { position: fixed; left: 1rem; top: 1rem; z-index: 100; width: 1px; height: 1px; overflow: hidden; white-space: nowrap; clip-path: inset(50%); background: var(--ink); color: white; padding: 0; border-radius: 8px; }
.skip-link:focus-visible { width: auto; height: auto; overflow: visible; clip-path: none; padding: .7rem 1rem; }

.site-header { max-width: var(--content); margin: 0 auto; min-height: 82px; padding: 16px 24px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand strong { display: block; font-family: var(--display); font-size: 1.15rem; letter-spacing: -.02em; }
.brand small { display: block; color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
.brand-mark { width: 42px; aspect-ratio: 1; border: 2px solid var(--ink); border-radius: 50%; display: grid; place-items: center; transform: rotate(-8deg); }
.brand-mark::before { content: ""; width: 20px; height: 14px; background: var(--accent); clip-path: polygon(0 100%, 48% 0, 100% 100%); }
.brand-mark span { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--paper); transform: translateY(4px); }

.quiet-button, .icon-button { border: 0; background: transparent; cursor: pointer; }
.quiet-button { border-bottom: 1px solid var(--ink); padding: 5px 0; font-weight: 650; }
.quiet-button:hover { color: var(--accent-dark); border-color: var(--accent-dark); }

.hero { max-width: var(--content); margin: 0 auto; min-height: 540px; padding: 80px 24px 72px; position: relative; overflow: hidden; }
.hero::before { content: ""; position: absolute; width: 460px; height: 460px; border: 1px solid var(--line); border-radius: 50%; right: -60px; top: 30px; box-shadow: inset 0 0 0 70px var(--paper), inset 0 0 0 71px var(--line), inset 0 0 0 145px var(--paper), inset 0 0 0 146px var(--line); opacity: .75; }
.hero::after { content: "3 ингредиента + упаковка + труд"; position: absolute; right: 30px; top: 245px; width: 220px; color: var(--accent-dark); font: italic 1.15rem/1.35 var(--display); transform: rotate(-7deg); text-align: center; }
.eyebrow { margin: 0; color: var(--accent-dark); font-size: .72rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.hero h1 { max-width: 760px; margin: 16px 0 22px; font: 700 clamp(3.5rem, 8vw, 7.6rem)/.9 var(--display); letter-spacing: -.065em; text-wrap: balance; }
.hero-copy { max-width: 560px; margin: 0 0 30px; color: var(--muted); font-size: 1.15rem; }
.primary-button, .secondary-button { min-height: 48px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 0 20px; font-weight: 750; text-decoration: none; cursor: pointer; transition: transform .16s ease, background .16s ease, box-shadow .16s ease; }
.primary-button { border: 1px solid var(--accent); background: var(--accent); color: #fffaf0; box-shadow: 0 7px 0 var(--accent-dark); }
.primary-button:hover { background: #b84029; transform: translateY(-1px); }
.primary-button:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--accent-dark); }
.secondary-button { border: 1px solid var(--ink); background: transparent; color: var(--ink); }
.secondary-button:hover { background: var(--ink); color: var(--surface); }
.hero-action { padding-inline: 25px; }
.hero-note { position: absolute; bottom: 48px; right: 24px; display: flex; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.hero-note span { padding: 10px 16px; color: var(--muted); font: italic .92rem var(--display); }
.hero-note span + span { border-left: 1px solid var(--line); }

.workspace { background: var(--surface); border-block: 1px solid var(--line); padding: 72px max(24px, calc((100vw - var(--content)) / 2)); display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(310px, .74fr); gap: 64px; align-items: start; }
.flow-column { min-width: 0; }
.section-heading { display: grid; grid-template-columns: 120px minmax(0, 1fr); column-gap: 24px; margin-bottom: 32px; }
.section-heading > div { grid-row: 1 / span 2; }
.section-heading h2 { margin: 0 0 6px; font: 700 clamp(2rem, 4vw, 3.25rem)/1 var(--display); letter-spacing: -.04em; }
.section-heading > p { margin: 0; max-width: 520px; color: var(--muted); }
.step-number { display: block; margin-bottom: 9px; color: var(--line); font: 700 2.7rem/1 var(--display); }
.section-heading.compact { margin-top: 0; }
.section-heading.compact h2 { font-size: clamp(1.8rem, 3vw, 2.55rem); }
.section-divider { border-top: 1px dashed var(--line); margin: 56px 0; }

.field-block { position: relative; }
.field-block label { display: block; margin-bottom: 6px; color: var(--muted); font-size: .73rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
input, select { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fffefa; color: var(--ink); padding: 10px 12px; outline: 0; }
input::placeholder { color: #aaa18f; }
input:hover, select:hover { border-color: #9f927c; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid rgba(201, 77, 50, .28); outline-offset: 2px; }
input:disabled { background: #ebe7dc; cursor: not-allowed; }
.order-name-field { max-width: 520px; margin-bottom: 28px; }
.ingredients-header { display: grid; grid-template-columns: 1.1fr 1.7fr .8fr .6fr 32px; gap: 12px; padding: 0 12px 8px; color: var(--muted); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
.ingredients-list { display: grid; gap: 10px; }
.ingredient-row { display: grid; grid-template-columns: 1.1fr 1.7fr .8fr .6fr 32px; gap: 12px; align-items: end; padding: 14px 12px; border: 1px solid #ded5c4; border-radius: var(--radius-md); background: #faf6ed; }
.ingredient-row label { display: none; }
.purchase-group { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.suffix-field input { padding-right: 42px; }
.suffix-field > span { position: absolute; right: 12px; bottom: 14px; color: var(--muted); font-size: .85rem; pointer-events: none; }
.amount-unit { display: grid; grid-template-columns: minmax(0, 1fr) 57px; }
.amount-unit label { grid-column: 1 / -1; }
.amount-unit input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.amount-unit select, .amount-unit > span { min-height: 48px; border: 1px solid var(--line); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--paper); display: grid; place-items: center; padding: 10px 7px; color: var(--muted); }
.ingredient-row output { min-height: 48px; display: flex; align-items: center; justify-content: flex-end; font: 700 1.05rem var(--display); white-space: nowrap; }
.icon-button { width: 32px; height: 32px; border-radius: 50%; font-size: 1.5rem; line-height: 1; }
.icon-button:hover { background: var(--paper-deep); }
.ingredient-row .icon-button { margin-bottom: 8px; color: var(--muted); }
.add-button { margin-top: 14px; }
.field-grid { display: grid; gap: 16px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.extra-costs { margin-top: 18px; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 0 18px; }
.extra-costs summary { padding: 18px 0; cursor: pointer; font-weight: 750; }
.extra-costs summary span { color: var(--muted); font-weight: 400; }
.extra-grid { padding: 2px 0 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; align-items: end; }
.toggle-row { min-height: 48px; display: flex; align-items: center; gap: 10px; }
.toggle-row input { width: 20px; min-height: 20px; accent-color: var(--accent); }
.muted-note { margin: 0 0 16px; color: var(--muted); font-size: .84rem; }

.result-card { position: sticky; top: 20px; border: 1px solid var(--ink); border-radius: var(--radius-lg); background: var(--paper); padding: 28px; box-shadow: var(--shadow); overflow: hidden; }
.result-card::after { content: ""; position: absolute; width: 92px; height: 24px; background: rgba(208, 183, 129, .35); left: 50%; top: -4px; transform: translateX(-50%) rotate(-2deg); }
.result-topline { display: flex; align-items: center; justify-content: space-between; }
.result-topline > span { color: var(--muted); font-size: .76rem; }
.result-card h2 { margin: 16px 0 0; font: italic 1.35rem var(--display); }
.total { margin: 0 0 24px; color: var(--accent-dark); font: 700 4.5rem/1 var(--display); letter-spacing: -.05em; }
.total small { margin-left: 5px; font-size: 1.3rem; letter-spacing: 0; }
.result-lines { padding-block: 17px; border-block: 1px dashed var(--line); display: grid; gap: 10px; }
.result-lines div, .per-kilo { display: flex; justify-content: space-between; gap: 14px; }
.result-lines span, .per-kilo span { color: var(--muted); }
.unknown { color: var(--warning); font-weight: 650; }
.remainder-block { padding: 21px 0; }
.remainder-block span { display: block; color: var(--muted); }
.remainder-block strong { display: block; font: 700 2rem var(--display); }
.remainder-block strong.negative { color: var(--accent-dark); }
.remainder-block small { display: block; margin-top: 5px; color: var(--muted); line-height: 1.35; }
.result-meta { margin-bottom: 24px; padding-top: 15px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.per-kilo { margin: 0; }
.full-width { width: 100%; }
.feedback { min-height: 22px; margin-top: 12px; color: var(--sage); font-size: .88rem; }
.feedback.error { color: var(--accent-dark); }
.feedback ul { margin: 5px 0 0; padding-left: 20px; }

.saved-section { max-width: var(--content); margin: 0 auto; padding: 80px 24px 100px; }
.tariff-section { padding: 80px max(24px, calc((100vw - var(--content)) / 2)); background: var(--sage); color: #f9f3e7; display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(300px, .7fr); gap: 64px; align-items: center; }
.tariff-section .eyebrow { color: #f2c7ad; }
.tariff-copy h2 { margin: 12px 0 18px; font: 700 clamp(2.4rem, 5vw, 4.7rem)/.98 var(--display); letter-spacing: -.05em; }
.tariff-copy > p { max-width: 650px; color: #e2e8df; font-size: 1.05rem; }
.legal-links { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 26px; }
.legal-links a, footer a { color: inherit; text-underline-offset: 4px; }
.tariff-card { border-radius: var(--radius-lg); background: var(--surface); color: var(--ink); padding: 28px; box-shadow: var(--shadow); }
.price-line { display: flex; align-items: baseline; gap: 8px; }
.price-line strong { font: 700 3.5rem/1 var(--display); color: var(--accent-dark); }
.price-line span, .access-status { color: var(--muted); }
.tariff-card ul { padding-left: 20px; margin: 22px 0 26px; }
.tariff-card li + li { margin-top: 7px; }
.primary-button:disabled { background: #a59e90; border-color: #a59e90; box-shadow: none; cursor: not-allowed; transform: none; }
.access-status { margin: 14px 0 0; font-size: .84rem; text-align: center; }
.access-status.error { color: var(--accent-dark); }
.empty-state { min-height: 180px; border: 1px dashed var(--line); border-radius: var(--radius-lg); display: grid; place-items: center; align-content: center; color: var(--muted); }
.empty-state span { font-size: 2rem; color: var(--accent); }
.empty-state p { margin: 5px 0 0; }
.saved-orders { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.saved-order { position: relative; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); padding: 20px; }
.saved-order time { color: var(--muted); font-size: .76rem; }
.saved-order h3 { margin: 7px 32px 14px 0; font: 700 1.45rem/1.1 var(--display); }
.saved-order .snapshot-total { margin: 0; font: 700 2rem var(--display); color: var(--accent-dark); }
.saved-order dl { margin: 15px 0 0; display: grid; grid-template-columns: 1fr auto; gap: 5px 10px; color: var(--muted); font-size: .85rem; }
.saved-order dt, .saved-order dd { margin: 0; }
.saved-order dd { color: var(--ink); font-weight: 650; }
.saved-order .delete-order { position: absolute; right: 12px; top: 12px; }
.saved-order details { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 10px; }
.saved-order .load-order { min-height: 38px; margin-top: 16px; padding-inline: 14px; }
.saved-order summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
.snapshot-ingredients { margin: 10px 0 0; padding: 0; list-style: none; font-size: .82rem; }
.snapshot-ingredients li { display: flex; justify-content: space-between; gap: 10px; }

footer { border-top: 1px solid var(--line); max-width: var(--content); margin: 0 auto; padding: 25px 24px 38px; display: flex; justify-content: space-between; gap: 24px; color: var(--muted); }
footer span { color: var(--ink); font: 700 1rem var(--display); }
footer p { margin: 0; }
footer nav { display: flex; gap: 14px; }

.legal-page { background: var(--surface); }
.legal-page main { max-width: 780px; margin: 40px auto 100px; padding: 0 24px; }
.legal-page h1 { margin: 12px 0 20px; font: 700 clamp(3rem, 8vw, 5.4rem)/.95 var(--display); letter-spacing: -.05em; }
.legal-page h2 { margin: 38px 0 10px; font: 700 1.6rem var(--display); }
.legal-page p { color: var(--muted); }
.legal-page a { color: var(--accent-dark); }

dialog { width: min(520px, calc(100vw - 32px)); border: 0; border-radius: var(--radius-lg); padding: 0; background: var(--surface); color: var(--ink); box-shadow: 0 30px 90px rgba(39, 35, 29, .32); }
dialog::backdrop { background: rgba(39, 35, 29, .52); backdrop-filter: blur(3px); }
.dialog-card { padding: 26px; }
.dialog-heading { display: flex; justify-content: space-between; gap: 20px; }
.dialog-heading h2 { margin: 5px 0 12px; font: 700 2.4rem var(--display); }
.dialog-actions { display: flex; gap: 10px; margin-top: 22px; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }

@media (max-width: 900px) {
  .hero { min-height: 500px; padding-top: 58px; }
  .hero::before { width: 320px; height: 320px; right: -130px; top: 120px; }
  .hero::after { display: none; }
  .hero-note { position: static; margin-top: 50px; width: max-content; }
  .workspace { grid-template-columns: 1fr; gap: 42px; }
  .result-card { position: static; }
  .saved-orders { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tariff-section { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .site-header { padding-inline: 16px; }
  .brand small { display: none; }
  .hero { padding: 56px 16px 48px; min-height: auto; }
  .hero h1 { font-size: clamp(3rem, 18vw, 4.8rem); }
  .hero-copy { font-size: 1rem; }
  .hero-note { max-width: 100%; overflow-x: auto; margin-top: 42px; }
  .hero-note span { white-space: nowrap; padding-inline: 11px; font-size: .82rem; }
  .workspace { padding: 52px 16px; }
  .section-heading { grid-template-columns: 72px minmax(0, 1fr); gap: 12px; }
  .section-heading > p { grid-column: 1 / -1; margin-top: 12px; }
  .step-number { font-size: 2rem; }
  .ingredients-header { display: none; }
  .ingredient-row { grid-template-columns: 1fr 32px; padding: 16px; }
  .ingredient-row label { display: block; }
  .ingredient-name { grid-column: 1; }
  .purchase-group { grid-column: 1 / -1; }
  .ingredient-row > .amount-unit { grid-column: 1; }
  .ingredient-row output { grid-column: 1; justify-content: flex-start; min-height: auto; color: var(--accent-dark); }
  .ingredient-row output::before { content: "В заказе: "; margin-right: 5px; color: var(--muted); font: 400 .8rem var(--body); }
  .ingredient-row .icon-button { grid-column: 2; grid-row: 1; margin: 6px 0 0; }
  .two-columns, .extra-grid { grid-template-columns: 1fr; }
  .result-card { padding: 25px 20px; }
  .total { font-size: 4rem; }
  .saved-section { padding: 60px 16px 80px; }
  .saved-orders { grid-template-columns: 1fr; }
  footer { margin-inline: 16px; padding-inline: 0; display: block; }
  footer p { margin-top: 5px; }
  footer nav { margin-top: 14px; flex-wrap: wrap; }
  .tariff-section { padding: 60px 16px; gap: 34px; }
  .dialog-actions { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
