.screen--purchase,
.checkout-sheet {
  --checkout-radius: clamp(24px, 7.2vw, 40px);
  --checkout-inset: clamp(18px, 5.35vw, 30px);
  --checkout-size: clamp(16px, 4.3vw, 24px);
  --checkout-space: clamp(14px, 3.58vw, 20px);
  --checkout-gap: clamp(7px, 1.8vw, 10px);
}

.app-shell:has(.screen--purchase) {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  height: var(--checkout-height, 100svh);
  min-height: 0;
}

.screen--purchase {
  padding: clamp(14px, 3.58vw, 20px) var(--gutter) max(24px, var(--safe-bottom));
}

.screen--purchase .back-spacer { height: var(--safe-top); }
.screen--purchase .page-heading { margin-bottom: var(--checkout-space); }
.screen--purchase .page-title { font-size: clamp(35px, 8.6vw, 48px); }
.checkout-config { display: grid; gap: var(--checkout-space); }
.screen--purchase .notice { margin: 0; }
.screen--purchase .duration-card:active,
.screen--purchase .device-slider:active,
.checkout-sheet .checkout-method:active { transform: none; }

.purchase-section { display: grid; gap: var(--checkout-space); }
.purchase-section > h2,
.checkout-promo > label,
.checkout-sheet h2,
.checkout-sheet .billing-email-field label {
  color: var(--text);
  font-size: var(--checkout-size);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -.018em;
}

.screen--purchase .duration-options {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--checkout-gap);
}

.screen--purchase .duration-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 0;
  padding: clamp(16px, 4.65vw, 26px) var(--checkout-inset);
  border: 0;
  border-radius: var(--checkout-radius);
  background: #151515;
  text-align: left;
}

.duration-label,
.duration-cost { display: grid; justify-items: start; gap: clamp(6px, 1.8vw, 10px); }
.duration-cost { justify-items: end; text-align: right; }
.duration-card strong { font-size: var(--checkout-size); line-height: 1.2; font-weight: 600; letter-spacing: -.02em; }
.duration-cost strong { white-space: nowrap; font-variant-numeric: tabular-nums; }
.duration-charge { color: #a4a4a8; font-size: clamp(9px, 2.2vw, 12px); white-space: nowrap; }
.screen--purchase .duration-discount {
  padding: 2px 8px;
  border: 1px solid #487a57;
  background: #1d3428;
  color: #9ae6ae;
  font-size: clamp(9px, 2.2vw, 12px);
  line-height: 1.3;
}
.screen--purchase [data-duration="3"] .duration-discount { border-color: #507a48; background: #21341d; }
.duration-card[aria-pressed="true"] .duration-charge { color: #f4f9ff; }

.screen--purchase .device-selector {
  padding: var(--checkout-inset);
  border-radius: var(--checkout-radius);
  background: #151515;
}
.device-selector label, .device-count { font-size: var(--checkout-size); font-weight: 600; }
.screen--purchase .device-count { display: flex; align-items: center; gap: 4px; color: var(--accent); }
.screen--purchase .device-range {
  --thumb-width: clamp(35px, 9vw, 50px);
  --thumb-height: clamp(24px, 6.1vw, 34px);
  --track-height: clamp(6px, 1.8vw, 10px);
  margin: 4px 0 -9px;
}
.screen--purchase .device-range-track {
  inset-inline: calc(var(--thumb-width) / 2);
  height: var(--track-height);
  margin-top: calc(var(--track-height) / -2);
  background: #282828;
}
.screen--purchase .device-range-fill { background: var(--accent); }
.screen--purchase .device-range-fill[data-device-index="1"] { width: 33.333%; }
.screen--purchase .device-range-fill[data-device-index="2"] { width: 66.667%; }
.screen--purchase .device-slider::-webkit-slider-runnable-track { height: var(--track-height); }
.screen--purchase .device-slider::-moz-range-track { height: var(--track-height); }
.screen--purchase .device-slider::-webkit-slider-thumb {
  width: var(--thumb-width);
  height: var(--thumb-height);
  margin-top: calc((var(--track-height) - var(--thumb-height)) / 2);
  border: 0;
  background: #d9d9d9;
  box-shadow: none;
}
.screen--purchase .device-slider::-moz-range-thumb {
  width: var(--thumb-width);
  height: var(--thumb-height);
  border: 0;
  background: #d9d9d9;
}

.checkout-promo > input,
.checkout-sheet .billing-email-field input {
  width: 100%;
  min-height: clamp(54px, 14vw, 78px);
  padding: 12px var(--checkout-inset);
  border: 1px solid transparent;
  border-radius: var(--checkout-radius);
  background: #151515;
  color: var(--text);
  font-size: var(--checkout-size);
}
.checkout-promo > input::placeholder,
.checkout-sheet .billing-email-field input::placeholder { color: #85858a; opacity: 1; }
.checkout-promo > input[aria-invalid="true"],
.checkout-sheet .billing-email-field input[aria-invalid="true"] { border-color: var(--danger); }
.checkout-promo .referral-error, .checkout-promo .promo-applied { margin: 0 4px; }
.checkout-promo .text-action { margin: 0 0 0 auto; }

.checkout-primary {
  width: 100%;
  min-height: clamp(54px, 14vw, 80px);
  border: 0;
  border-radius: var(--checkout-radius);
  padding: 12px var(--checkout-inset);
  color: #fff;
  font-size: var(--checkout-size);
  font-weight: 600;
}
.checkout-primary,
.screen--purchase .duration-card[aria-pressed="true"],
.checkout-method[aria-pressed="true"] { background: var(--accent-gradient); }
#checkout-renew:checked + .checkout-switch { background: var(--accent); }
.checkout-primary:disabled { opacity: .6; }

.checkout-sheet {
  position: fixed;
  inset: auto 0 var(--checkout-keyboard-inset, 0px);
  width: min(100%, 519px);
  max-width: 100%;
  max-height: calc(var(--checkout-visible-height, 100dvh) - max(8px, var(--safe-top)));
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: var(--checkout-radius) var(--checkout-radius) 0 0;
  overflow: hidden;
  background: #050505;
  color: var(--text);
  translate: 0 var(--checkout-drag, 0px);
}
.checkout-sheet[open] { display: grid; grid-template-rows: minmax(0, 1fr); }
.checkout-sheet[data-closing] .checkout-sheet-frame { pointer-events: none; }
.checkout-sheet::backdrop { background: #0009; }
.checkout-sheet.is-opening::backdrop { animation: checkout-backdrop 220ms ease-out both; }
@keyframes checkout-backdrop { from { opacity: 0; } to { opacity: 1; } }
.checkout-sheet-frame { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; max-height: inherit; }
.checkout-sheet-handle {
  display: grid;
  justify-items: center;
  align-items: center;
  width: 100%;
  min-height: 36px;
  touch-action: none;
  user-select: none;
  cursor: grab;
}
.checkout-sheet-handle > span { width: clamp(52px, 16.95vw, 88px); height: 4px; border-radius: 2px; background: #85858a; }
.checkout-sheet-handle:active { cursor: grabbing; }
#checkout-sheet-title:focus { outline: none; }
.checkout-sheet-scroll {
  padding: 0 var(--checkout-inset);
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-block: 4px;
  scrollbar-width: none;
}
.checkout-methods { display: grid; gap: var(--checkout-gap); margin-top: var(--checkout-space); }
.checkout-method,
.checkout-renew-choice {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: clamp(62px, 19.5vw, 101px);
  padding: 10px var(--checkout-inset);
  border: 0;
  border-radius: var(--checkout-radius);
  background: #151515;
  text-align: left;
}
.checkout-method strong, .checkout-renew-choice strong {
  min-width: 0;
  font-size: clamp(14px, 3.85vw, 20px);
  font-weight: 800;
  line-height: 1.2;
}
.checkout-logo { flex: 0 0 auto; transform-origin: right center; }
.checkout-logo--heleket { position: relative; width: 73.03px; height: 15.58px; }
.checkout-logo--heleket img, .checkout-heleket-mark { position: absolute; }
.checkout-heleket-mark {
  top: 0;
  left: .975px;
  width: 13.38px;
  height: 15.33px;
  mask: url('/static/assets/checkout/checkout-heleket-mask.svg') -.975px 0 no-repeat;
}
.checkout-logo--heleket > img:nth-child(2) { top: 20.29%; left: 48.1%; }
.checkout-logo--heleket > img:nth-child(3) { top: 20.29%; left: 65.61%; }
.checkout-logo--heleket > img:nth-child(4) { top: 20.29%; left: 88.21%; }
.checkout-logo--heleket > img:nth-child(5) { top: 35.28%; left: 35.84%; }
.checkout-logo--heleket > img:nth-child(6) { top: 24.05%; left: 24.32%; }
.checkout-logo--heleket > img:nth-child(7) { top: 24.05%; left: 22.65%; }
.checkout-logo--heleket > img:nth-child(8) { top: 35.28%; left: 52.96%; }
.checkout-logo--heleket > img:nth-child(9) { top: 35.28%; left: 75.95%; }

.checkout-renew-choice { position: relative; margin-top: var(--checkout-inset); cursor: pointer; }
.checkout-renew-choice:has(input:disabled) { cursor: default; }
#checkout-renew { position: absolute; width: 1px; height: 1px; opacity: 0; }
#checkout-renew:focus-visible + .checkout-switch { filter: brightness(1.35); }
.checkout-switch {
  --switch-width: clamp(56px, 13.87vw, 72px);
  --switch-knob: clamp(37px, 9.63vw, 50px);
  position: relative;
  flex: 0 0 var(--switch-width);
  height: clamp(29px, 7.32vw, 38px);
  border-radius: 24px;
  background: #282828;
}
.checkout-switch::before {
  content: '';
  position: absolute;
  inset: 2px auto 2px 2px;
  width: var(--switch-knob);
  border-radius: inherit;
  background: #d9d9d9;
  transition: translate 200ms cubic-bezier(.2,.75,.2,1);
}
#checkout-renew:checked + .checkout-switch::before { translate: calc(var(--switch-width) - var(--switch-knob) - 4px) 0; }
.checkout-email-reveal {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 220ms cubic-bezier(.2,.75,.2,1), opacity 160ms ease;
}
.checkout-email-reveal.is-visible { grid-template-rows: 1fr; opacity: 1; }
.checkout-email-clip { min-height: 0; overflow: clip; overflow-clip-margin: 4px; }
.checkout-sheet .billing-email-field { margin: var(--checkout-inset) 0 4px; }
.checkout-sheet .billing-email-field label { margin-bottom: var(--checkout-space); }

.checkout-sheet .purchase-dock {
  display: grid;
  gap: var(--checkout-space);
  border: 0;
  padding: var(--checkout-inset) var(--checkout-inset) max(var(--checkout-space), var(--safe-bottom));
  background: #050505;
}
.checkout-total { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.checkout-total strong { font-size: var(--checkout-size); font-weight: 800; line-height: 1.2; }
.checkout-terms { color: var(--muted); text-align: center; font-size: clamp(10px, 2.7vw, 14px); }
.checkout-terms a { color: var(--accent); text-decoration: none; }
.checkout-sheet .toast { position: absolute; bottom: 12px; }
.checkout-sheet.has-keyboard .purchase-dock { gap: 6px; padding-block: 8px; }
.checkout-sheet.has-keyboard .checkout-sheet-handle { min-height: 24px; }
.checkout-sheet.has-keyboard .checkout-primary { min-height: 44px; }

@media (max-width: 470px) {
  .checkout-logo { transform: scale(.78); margin-inline-start: -14px; }
}
@media (max-width: 350px) {
  .duration-card strong { font-size: 15px; }
}
@media (max-height: 480px) {
  .checkout-sheet .purchase-dock { gap: 6px; padding-block: 8px; }
  .checkout-sheet-handle { min-height: 24px; }
  .checkout-sheet .checkout-primary { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .checkout-email-reveal, .checkout-switch::before { transition: none; }
}
