/* Шторка оформления покупки и страница «Спасибо». Подключается после style.css
   и читает те же токены (--surface, --brand, --text …), поэтому обе темы работают сами.
   Телефон — база: шторка снизу на всю ширину. С 720 px — диалог по центру. */

html.co-lock, html.co-lock body { overflow: hidden; }

/* ---------- шторка ---------- */
.co { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; background: transparent; color: var(--text); overflow: hidden; }
.co::backdrop { background: var(--backdrop); }
.co[open] { display: flex; align-items: flex-end; justify-content: center; }
.co-sheet { position: relative; width: 100%; max-width: 520px; max-height: 94vh; max-height: 94dvh;
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 10px 20px calc(22px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0; background: var(--sheet-bg); font-family: var(--display);
  animation: co-up .3s var(--ease); }
.co-grip { width: 40px; height: 5px; margin: 0 auto 14px; border-radius: 999px; background: var(--surface-3); }
.co-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.co-head h2 { margin: 0 0 6px; font-size: 24px; line-height: 1.2; outline: none; }
.co-lead { margin: 0; font-size: 14.5px; line-height: 1.45; color: var(--muted); }
.co-x { flex: none; display: grid; place-items: center; width: 44px; height: 44px; margin: -4px -8px 0 0;
  border: 0; border-radius: 50%; background: var(--surface); color: var(--text-2); cursor: pointer; }
.co-x:disabled { opacity: .5; }

.co-sum { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 16px 0 18px; padding: 14px 16px; border-radius: 18px; background: var(--surface); }
.co-sum span { font-size: 16px; font-weight: 600; line-height: 1.3; }
.co-sum small { display: block; margin-top: 2px; font-size: 13.5px; font-weight: 400; color: var(--muted); }
.co-sum b { font-size: 24px; font-weight: 700; letter-spacing: -.05em; white-space: nowrap; color: var(--brand); }

.co-field label, .co-seg legend { display: block; padding: 0; margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.co-field input { display: block; width: 100%; height: 56px; padding: 0 16px; border: 0; border-radius: 16px;
  background: var(--surface); color: var(--text); font: 500 17px var(--display);   /* ≥16 px: iOS не приближает */
  -webkit-appearance: none; appearance: none; }
.co-field input::placeholder { color: var(--muted); opacity: .8; }
.co-field input:focus { outline: none; box-shadow: 0 0 0 2px var(--brand); }
.co-field input[aria-invalid="true"] { box-shadow: 0 0 0 2px var(--loss); }
.co-hint { margin: 8px 2px 0; font-size: 13.5px; line-height: 1.4; color: var(--muted); }
.co-ferr { margin: 8px 2px 0; font-size: 14px; line-height: 1.4; color: var(--loss); }

.co-seg { min-width: 0; margin: 18px 0 0; padding: 0; border: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.co-seg legend { grid-column: 1 / -1; }
.co-opt { position: relative; display: block; min-width: 0; }
.co-opt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.co-opt .b { display: flex; flex-direction: column; justify-content: center; gap: 2px; min-height: 64px; padding: 10px 16px;
  border-radius: 16px; background: var(--surface); color: var(--text); pointer-events: none; }
.co-opt .b b { font-size: 17px; font-weight: 700; }
.co-opt .b small { font-size: 13px; color: var(--muted); }
.co-opt input:checked + .b { background: var(--text); color: var(--bg); }
.co-opt input:checked + .b small { color: inherit; opacity: .75; }
.co-opt input:focus-visible + .b { outline: 2px solid var(--brand); outline-offset: 2px; }

.co-consent { display: flex; gap: 12px; align-items: flex-start; min-height: 44px; margin-top: 18px;
  font-size: 14.5px; line-height: 1.5; color: var(--text-2); cursor: pointer; }
.co-consent input { flex: none; width: 24px; height: 24px; margin: 1px 0 0; accent-color: var(--brand); cursor: pointer; }
.co-consent a { color: var(--text); text-underline-offset: 3px; }

.co-err { margin-top: 14px; padding: 12px 14px; border-radius: 14px; font-size: 14.5px; line-height: 1.45;
  background: rgba(220, 58, 58, .10); color: var(--loss); }
.co-err a { color: inherit; font-weight: 600; text-underline-offset: 3px; }
.co-pay { margin-top: 18px; }
.co-pay:disabled { opacity: .75; cursor: progress; transform: none; }
.co-pay[aria-busy="true"]::before { content: ""; width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid currentColor; border-right-color: transparent; animation: co-spin .8s linear infinite; }
.co-fine { margin: 12px 0 0; font-size: 13px; line-height: 1.4; text-align: center; color: var(--muted); }

/* Низкие экраны (iPhone SE, альбомная): убираем второстепенный текст, чтобы кнопка была на виду */
@media (max-height: 780px) {
  .co-sheet { padding-top: 8px; }
  .co-grip { margin-bottom: 8px; }
  .co-lead, .co-fine { display: none; }
  .co-sum { margin: 10px 0 14px; padding: 12px 14px; }
  .co-seg, .co-consent { margin-top: 14px; }
  .co-opt .b { min-height: 58px; }
  .co-pay { margin-top: 14px; }
}

@keyframes co-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes co-pop { from { transform: translateY(12px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes co-spin { to { transform: rotate(360deg); } }

@media (min-width: 720px) {
  .co[open] { align-items: center; }
  .co-sheet { padding: 28px 28px 26px; max-height: 92vh; max-height: 92dvh; border-radius: 28px; animation-name: co-pop; }
  .co-grip { display: none; }
  .co-head h2 { font-size: 26px; }
}

/* ---------- страница «Спасибо» ---------- */
.th-head .wrap { display: flex; align-items: center; min-height: 68px; }
.thanks { padding: 12px 0 72px; }
.th-card { width: 100%; max-width: 540px; margin: 0 auto; padding: 32px 22px 26px; border-radius: 28px;
  background: var(--surface); text-align: center; }
.th-icon { display: grid; place-items: center; width: 76px; height: 76px; margin: 0 auto 20px; border-radius: 50%;
  background: var(--brand-a10); color: var(--brand); }
.th-icon svg { width: 34px; height: 34px; }
.th-icon.err { background: rgba(220, 58, 58, .12); color: var(--loss); }
.th-spin { width: 34px; height: 34px; border-radius: 50%; border: 3.5px solid var(--brand-a20);
  border-top-color: var(--brand); animation: co-spin 1s linear infinite; }
.th-card h1 { margin: 0 0 10px; font-size: clamp(26px, 7vw, 32px); letter-spacing: -.03em; outline: none; }
.th-card p { margin: 0 0 12px; font-size: 16px; line-height: 1.55; color: var(--text-2); }
.th-card .btn { margin-top: 10px; }
.th-meter { margin: 22px auto 6px; max-width: 320px; }
.th-meter .pbar { height: 6px; }
.th-meter .pbar i { transition: width .6s linear; }
.th-small { font-size: 14px !important; color: var(--muted) !important; }
.th-fallback { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); text-align: left; }
.th-fallback p { font-size: 14.5px; }
.th-code { display: block; margin: 8px 0 12px; padding: 14px; border-radius: 14px; background: var(--bg);
  color: var(--text); font: 500 14.5px/1.5 var(--mono); text-align: left; overflow-wrap: anywhere; word-break: break-all; user-select: all; }
.th-copy { width: 100%; background: var(--surface-3); }
.th-copied { min-height: 22px; margin: 8px 0 0 !important; font-size: 14px !important; text-align: center; color: var(--brand) !important; }
.th-links { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.th-links a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; color: var(--muted); font-size: 15px; }

@media (min-width: 560px) { .th-card { padding: 40px 36px 32px; } }
@media (prefers-reduced-motion: reduce) {
  .co-sheet { animation: none; }
  .th-spin { animation: none; border-color: var(--brand); }
  .co-pay[aria-busy="true"]::before { animation: none; }
}
