/* Сторінка оформлення замовлення (checkout.html), як у Shopify: форма ліворуч, замовлення праворуч;
   на телефоні замовлення згорнуте над формою. Файл рушія: не правити. Кольори, шрифт і форми сайт
   задає у css/checkout-theme.css (--co-*; без них беруться --rt-accent і нейтральні). */
.co {
  --co-bg-v: var(--co-bg, #f4f4f2);
  --co-card-v: var(--co-card, #fff);
  --co-field-v: var(--co-field, var(--co-bg-v));
  --co-text-v: var(--co-text, #1b1b1a);
  --co-muted-v: var(--co-muted, #6a6964);
  --co-line-v: var(--co-line, rgb(0 0 0 / .1));
  --co-strong-v: var(--co-strong, var(--co-text-v));
  --co-on-strong-v: var(--co-on-strong, var(--co-card-v));
  --co-accent-v: var(--co-accent, var(--rt-accent, var(--co-strong-v)));
  --co-on-accent-v: var(--co-on-accent, var(--rt-on-accent, var(--co-on-strong-v)));
  --co-error-v: var(--co-error-color, #b3261e);
  --co-radius-v: var(--co-radius, 14px);
  --co-card-radius-v: var(--co-card-radius, calc(var(--co-radius-v) * 1.5));
  --co-pill-v: var(--co-button-radius, 999px);
  --co-font-v: var(--co-font, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  --co-title-font-v: var(--co-title-font, var(--co-font-v));
  display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; margin: 0;
  background: var(--co-bg-v); color: var(--co-text-v);
  font: 400 15px / 1.45 var(--co-font-v);
  -webkit-font-smoothing: antialiased;
}
/* скидання з нульовою вагою (:where): будь-яке правило нижче його перекриває */
.co *, .co *::before, .co *::after { box-sizing: border-box; }
.co [hidden] { display: none !important; }
:where(.co) :where(h1, h2, p, dl, dd, ul) { margin: 0; padding: 0; }
:where(.co) :where(ul) { list-style: none; }
:where(.co) :where(a) { color: inherit; text-decoration: none; }
:where(.co) :where(img) { display: block; max-width: 100%; }
:where(.co) :where(button) { padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
:where(.co) :where(svg) { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.co :focus-visible { outline: 2px solid var(--co-strong-v); outline-offset: 2px; }

/* ───────────── шапка й низ ───────────── */
.co-header, .co-main, .co-footer { width: 100%; max-width: var(--co-width, 1200px); margin-inline: auto; padding-inline: max(20px, env(safe-area-inset-left)) max(20px, env(safe-area-inset-right)); }
.co-header { position: static; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 20px; }
.co-logo { display: flex; align-items: center; gap: 10px; font: 700 22px / 1 var(--co-title-font-v); letter-spacing: -.02em; }
.co-logo img { width: auto; height: var(--co-logo-height, 30px); }
.co-header__side { display: flex; align-items: center; gap: 12px; }
.co-back { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 44px; min-height: 44px; padding: 0 18px 0 14px; border-radius: var(--co-pill-v); background: var(--co-card-v); font-size: 14px; font-weight: 600; }
.co-back svg { width: 18px; height: 18px; flex: none; }
.co-lang { display: flex; gap: 2px; height: 44px; padding: 4px; border-radius: var(--co-pill-v); background: var(--co-card-v); }
.co-lang a { display: grid; place-items: center; width: 40px; border-radius: var(--co-pill-v); font-size: 13px; color: var(--co-muted-v); }
.co-lang a[aria-current] { background: var(--co-strong-v); color: var(--co-on-strong-v); }
.co-footer { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: auto; padding-block: 40px max(28px, env(safe-area-inset-bottom)); color: var(--co-muted-v); font-size: 14px; }
.co-footer .co-phone { color: var(--co-text-v); font-weight: 700; }

/* ───────────── розкладка ───────────── */
.co-main { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); grid-template-areas: "form summary"; gap: 16px 24px; align-content: start; }
.co-title { margin: 8px 0 2px; font: 600 clamp(28px, 4vw, 42px) / 1.1 var(--co-title-font-v); letter-spacing: -.02em; }
.co-form { grid-area: form; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.co-summary { grid-area: summary; position: sticky; top: 16px; align-self: start; min-width: 0; padding-top: 8px; }
.co-summary .co-card { max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); overflow-y: auto; overscroll-behavior: contain; }
.co-toggle { display: none; }
.co-card { padding: 28px; border-radius: var(--co-card-radius-v); background: var(--co-card-v); }
.co .co-card h2 { margin-bottom: 18px; font: 600 21px / 1.25 var(--co-title-font-v); letter-spacing: -.01em; }
.co-main:not([data-step="form"]) > :is(.co-summary, .co-form) { display: none; }
.co-main:not([data-step="done"]) > .co-done, .co-main:not([data-step="empty"]) > .co-empty { display: none; }
.co-done, .co-empty { grid-column: 1 / -1; justify-self: center; width: 100%; max-width: 640px; margin-top: 24px; text-align: center; }
.co .co-done p, .co .co-empty p { margin-bottom: 10px; line-height: 1.55; color: var(--co-muted-v); }
.co-done b { color: var(--co-text-v); white-space: nowrap; }
.co .co-done h2, .co .co-empty h2 { font-size: clamp(26px, 4vw, 34px); }
.co-done h2:focus { outline: 0; }
.co-done .co-btn, .co-empty .co-btn { margin-top: 14px; }
.co-done__mark { display: grid; place-items: center; width: 68px; height: 68px; margin: 4px auto 18px; border-radius: 50%; background: var(--co-accent-v); color: var(--co-on-accent-v); }
.co-done__mark svg { width: 34px; height: 34px; stroke-width: 2.2; }
.co .co-done__info { margin: 22px 0 6px; border-top: 1px solid var(--co-line-v); text-align: left; }
.co-done__info div { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--co-line-v); font-size: 14px; line-height: 1.5; }
.co-done__info dt { color: var(--co-muted-v); }
.co-done__info dd { white-space: pre-line; overflow-wrap: anywhere; }

/* ───────────── поля ───────────── */
.co-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.co-group > * + *, .co-group > [data-for] { margin-top: 10px; }
.co-group > h2 + * { margin-top: 0; }
.co-field { position: relative; display: block; min-width: 0; }
.co .co-field :is(input, select, textarea) { width: 100%; height: 58px; margin: 0; padding: 22px 18px 8px; border: 1.5px solid transparent; border-radius: var(--co-radius-v); background: var(--co-field-v); color: inherit; font: 500 16px / 1.3 var(--co-font-v); box-shadow: none; -webkit-appearance: none; appearance: none; }
.co .co-field textarea { height: auto; min-height: 104px; padding-top: 28px; resize: vertical; }
.co-field > span { position: absolute; top: 20px; right: 16px; left: 19.5px; overflow: hidden; color: var(--co-muted-v); font-size: 15px; line-height: 18px; white-space: nowrap; text-overflow: ellipsis; pointer-events: none; transform-origin: 0 50%; transition: translate .18s ease, scale .18s ease; }
.co-field :is(input, textarea):not(:placeholder-shown) ~ span, .co-field :is(input, textarea):focus ~ span, .co-field--select > span { translate: 0 -11px; scale: .75; }
.co .co-field :is(input, select, textarea):focus { border-color: var(--co-strong-v); background: var(--co-card-v); outline: 0; }
.co-field--select::after { content: ""; position: absolute; top: 24px; right: 22px; width: 8px; height: 8px; border-right: 1.8px solid; border-bottom: 1.8px solid; rotate: 45deg; pointer-events: none; }
.co .co-field [aria-invalid="true"] { border-color: var(--co-error-v); }
.co-field__error { display: block; padding: 6px 4px 2px 19.5px; color: var(--co-error-v); font-size: 13px; line-height: 1.4; }
.co-check { display: flex; align-items: center; gap: 12px; min-height: 32px; padding-left: 4px; font-size: 14px; line-height: 1.4; cursor: pointer; }
.co .co-check input, .co .co-option input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--co-strong-v); }

/* ───────────── вибір доставки й оплати ───────────── */
.co-options { display: flex; flex-direction: column; gap: 8px; }
.co-option { display: flex; align-items: flex-start; gap: 14px; margin: 0; padding: 16px 18px; border: 1.5px solid transparent; border-radius: var(--co-radius-v); background: var(--co-field-v); cursor: pointer; transition: border-color .2s ease, background-color .2s ease; }
.co-option:has(input:checked) { border-color: var(--co-strong-v); background: var(--co-card-v); }
.co-option:has(input:focus-visible) { outline: 2px solid var(--co-strong-v); outline-offset: 2px; }
.co-option__text { flex: 1; min-width: 0; }
.co-option__text b { display: block; font-size: 15px; line-height: 1.35; }
.co-option__text small { display: block; margin-top: 3px; color: var(--co-muted-v); font-size: 13px; line-height: 1.45; white-space: pre-line; }
.co-option em { flex: none; max-width: 40%; font-style: normal; font-weight: 700; font-size: 14px; line-height: 1.35; text-align: right; }
.co-option em.is-soft { color: var(--co-muted-v); font-weight: 500; font-size: 13px; }

/* ───────────── склад замовлення ───────────── */
.co-line { display: flex; gap: 14px; padding: 14px 0; border-top: 1px solid var(--co-line-v); }
.co-line__photo { display: grid; flex: none; place-items: center; width: 76px; height: 76px; overflow: hidden; border: 1px solid var(--co-line-v); border-radius: var(--co-radius-v); background: #fff; }
.co-line__photo img { max-width: 68px; max-height: 68px; object-fit: contain; }
.co-line__info { flex: 1; min-width: 0; }
.co-line__name { font-size: 14px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.co .co-line__sub { margin-top: 2px; color: var(--co-muted-v); font-size: 12px; }
.co-line__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.co-qty { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: var(--co-pill-v); background: var(--co-field-v); }
.co .co-qty button { width: 32px; height: 32px; border-radius: var(--co-pill-v); font-size: 18px; line-height: 1; }
.co-qty b { min-width: 22px; font-size: 13px; text-align: center; }
.co-line__price { font-size: 15px; font-weight: 700; white-space: nowrap; }
.co .co-line__remove { margin-top: 6px; color: var(--co-muted-v); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.co .co-line__why { margin-top: 6px; color: var(--co-error-v); font-size: 12px; font-weight: 600; }
.co-line.is-off .co-line__photo, .co-line.is-off .co-line__price { opacity: .4; }
.co-code { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin: 0; padding: 16px 0; border-top: 1px solid var(--co-line-v); }
.co .co-code .co-btn { width: auto; min-height: 58px; padding: 0 22px; }
.co-code__state { grid-column: 1 / -1; padding-left: 4px; font-size: 13px; line-height: 1.4; }
.co-code__state:empty { display: none; }
.co-code__state.is-bad { color: var(--co-error-v); }
.co .co-code__state button { margin-left: 8px; text-decoration: underline; text-underline-offset: 3px; }
.co .co-totals { padding-top: 8px; border-top: 1px solid var(--co-line-v); }
.co-totals > div { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 6px 0; font-size: 14px; }
.co-totals dt { color: var(--co-muted-v); }
.co-totals dt small { font-weight: 700; color: var(--co-text-v); }
.co-totals dd { text-align: right; font-weight: 600; }
.co-totals .co-totals__sum { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--co-line-v); }
.co-totals__sum dt { color: var(--co-text-v); font-size: 16px; font-weight: 700; }
.co-totals__sum dd { font-size: 24px; font-weight: 700; }
.co .co-vat { margin-top: 6px; color: var(--co-muted-v); font-size: 12px; }

/* ───────────── відправлення ───────────── */
.co .co-btn { display: inline-flex; align-items: center; justify-content: center; width: 100%; min-height: 56px; padding: 0 28px; border-radius: var(--co-pill-v); background: var(--co-strong-v); color: var(--co-on-strong-v); font-weight: 600; font-size: 15px; line-height: 1.2; text-align: center; cursor: pointer; transition: filter .2s ease, transform .15s ease; }
.co .co-btn--accent { background: var(--co-accent-v); color: var(--co-on-accent-v); }
.co .co-btn:active { transform: scale(.98); }
@media (hover: hover) { .co .co-btn:hover { filter: brightness(.92); } }
.co .co-btn:disabled { cursor: not-allowed; opacity: .6; }
.co .co-btn.is-busy { cursor: progress; }
.co-submit { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.co .co-submit .co-btn { min-height: 62px; font-size: 16px; }
.co-submit__wait, .co-submit .is-busy .co-submit__go { display: none; }
.co-submit .is-busy .co-submit__wait { display: inline; }
.co .co-submit__total { display: none; }
.co .co-error { color: var(--co-error-v); font-size: 14px; line-height: 1.45; text-align: center; }
.co .co-error:empty { display: none; }
.co .co-note { color: var(--co-muted-v); font-size: 13px; line-height: 1.5; text-align: center; }

/* ───────────── один стовпчик: замовлення згортається над формою ───────────── */
@media (max-width: 899px) {
  .co-main { grid-template-columns: minmax(0, 1fr); grid-template-areas: "summary" "form"; gap: 12px; max-width: 640px; }
  .co-header, .co-footer { max-width: 640px; }
  .co .co-toggle { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 58px; padding: 0 20px; border-radius: var(--co-pill-v); background: var(--co-card-v); font-size: 14px; font-weight: 600; }
  .co-toggle svg { width: 18px; height: 18px; transition: rotate .25s ease; }
  .co-toggle strong { margin-left: auto; font-size: 17px; white-space: nowrap; }
  .co-toggle__hide, .co-toggle[aria-expanded="true"] .co-toggle__show { display: none; }
  .co-toggle[aria-expanded="true"] .co-toggle__hide { display: inline; }
  .co-toggle[aria-expanded="true"] svg { rotate: 180deg; }
  .co-summary { position: static; padding-top: 0; }
  .co .co-summary .co-card { display: none; max-height: none; margin-top: 10px; overflow: visible; }
  .co .co-summary.is-open .co-card { display: block; }
  .co .co-summary h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .co-line:first-child { border-top: 0; padding-top: 0; }
  .co .co-submit__total { display: flex; align-items: baseline; justify-content: space-between; padding: 4px 8px; font-size: 15px; font-weight: 600; }
  .co-submit__total strong { font-size: 24px; }
}
@media (max-width: 559px) {
  .co-header, .co-main, .co-footer { padding-inline: 14px; }
  .co .co-card { padding: 20px 16px; }
  .co .co-card h2 { padding-left: 4px; }
  .co-row { grid-template-columns: minmax(0, 1fr); }
  /* ціна під назвою: поруч вона стискала назву в стовпчик */
  .co-option { flex-wrap: wrap; column-gap: 14px; row-gap: 6px; padding: 14px 16px; }
  .co-option__text { flex-basis: calc(100% - 34px); }
  .co-option em { max-width: 100%; margin-left: 34px; text-align: left; }
  .co-back { padding: 0; }
  .co-back > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}
@media (prefers-reduced-motion: reduce) { .co * { transition: none !important; } }
