:root {
    color-scheme: light dark;
    --bg: #fff; --fg: #1f2328; --muted: #6b7280;
    --line: #e5e7eb; --panel: #f6f8fa;
    --ok: #1a7f37; --error: #cf222e;
    /* PayWeb's expiry pill (paymentSummary.module.scss .expiry). */
    --expiry-bg: #f4f2fb; --expiry-low-bg: #fdecec;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1117; --fg: #e6edf3; --muted: #9198a1;
        --line: #30363d; --panel: #161b22;
        --ok: #3fb950; --error: #f85149;
        --expiry-bg: #1f1d2b; --expiry-low-bg: #3a1d1f;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0; padding: 16px;
    background: var(--bg); color: var(--fg);
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Hidden until the embed-origin check passes, so an unauthorised page never
   gets even a flash of a real payment UI to screenshot. main.js reveals it. */
.widget { max-width: 420px; margin: 0 auto; visibility: hidden; }
.widget.ready, .widget.blocked { visibility: visible; }

/* Loading state, over the still-hidden widget. */
.loading {
    position: absolute; top: 16px; left: 0; right: 0; margin: 0;
    text-align: center; font-size: 13px; color: var(--muted);
}
.loading__dot {
    display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -2px;
    border: 2px solid var(--line); border-top-color: var(--muted); border-radius: 50%;
    animation: capay-spin .8s linear infinite;
}
@keyframes capay-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading__dot { animation: none; } }
.widget.ready ~ .loading, .widget.blocked ~ .loading { display: none; }

h1 { margin: 0; font-size: 15px; font-weight: 600; }

/* data-countdown="1": time left, top right. The same soft pill as PayWeb's
   ExpiryCountdown, so a shopper who has seen one recognises the other; red
   only in the last five minutes. Tabular figures so it does not twitch every
   second. The title keeps clear of it. */
header { position: relative; }
.countdown {
    position: absolute; top: -2px; right: 0;
    display: inline-flex; align-items: center; gap: 5px;
    margin: 0; padding: 3px 10px; border-radius: 999px;
    background: var(--expiry-bg); color: var(--fg);
    font-size: 12px; line-height: 18px; white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.countdown[hidden] { display: none; }
.countdown strong { font-weight: 700; }
.countdown--low { background: var(--expiry-low-bg); color: var(--error); }
.countdown:not([hidden]) ~ h1 { padding-right: 150px; }

/* A narrow frame: clock and time only. The words leave the screen, not the
   accessibility tree, so the timer still says what it counts. */
@media (max-width: 320px) {
    .countdown { gap: 4px; }
    .countdown__label {
        position: absolute; width: 1px; height: 1px;
        overflow: hidden; clip-path: inset(50%); white-space: nowrap;
    }
    .countdown:not([hidden]) ~ h1 { padding-right: 84px; }
}
.amount { margin: 2px 0 16px; font-size: 24px; font-weight: 600; }

.buttons { display: flex; flex-direction: column; gap: 10px; }
.button-row { min-height: 48px; }

/* Holds Google Pay's place while its SDK loads (main.js startGooglePay).
   Neutral on purpose: plain "Loading Google Pay…" text, no logo, nothing
   resembling the button - only Google's SDK may draw that. Height and radius
   come from the button options, so the real button lands without moving
   anything. */
.cap-placeholder {
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; color: var(--muted);
    background: linear-gradient(90deg, var(--line) 25%, #f6f7f9 50%, var(--line) 75%);
    background-size: 300% 100%;
    animation: capay-shimmer 1.4s ease-in-out infinite;
}
@keyframes capay-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .cap-placeholder { animation: none; } }

/* Subscription terms.
   Deliberately plain and unmissable rather than decorative: this is the text
   the shopper is agreeing to, and Google requires the merchant to disclose it
   because Google's own sheet cannot. Not interactive — nothing here is a
   choice the shopper makes at checkout. */
.recurring {
    border: 1px solid var(--line); border-left: 3px solid var(--fg);
    border-radius: 6px; padding: 10px 12px; margin: 0 0 16px;
    background: var(--panel);
}
.recurring__label {
    margin: 0 0 2px; font-size: 11px; text-transform: uppercase;
    letter-spacing: .05em; color: var(--muted);
}
.recurring__summary { margin: 0; font-size: 13px; font-weight: 600; }
.recurring__manage { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.recurring__manage a { color: inherit; }
.recurring__warning {
    margin: 8px 0 0; font-size: 12px; font-weight: 600; color: var(--error);
}

/* Apple's required button styling — the -apple-pay-button appearance is only
   honoured by Safari on Apple devices. Everywhere else the button is Apple's
   <apple-pay-button> element from its SDK (applepay.js), sized through its
   --apple-pay-button-* custom properties. */
apple-pay-button { display: block; width: 100%; }

.apple-pay-button {
    display: block; width: 100%; height: 48px;
    -webkit-appearance: -apple-pay-button;
    -apple-pay-button-type: plain;
    -apple-pay-button-style: black;
    border: 0; border-radius: 6px; cursor: pointer;
    background: #000;
}

/* Type and style for Safari's native button, from data-type / data-style set
   in applepay.js. Inline style.setProperty() of these was ignored by Safari,
   which left every Mac shopper on 'plain'. */
.apple-pay-button[data-type='pay'] { -apple-pay-button-type: pay; }
.apple-pay-button[data-type='buy'] { -apple-pay-button-type: buy; }
.apple-pay-button[data-type='check-out'] { -apple-pay-button-type: check-out; }
.apple-pay-button[data-type='book'] { -apple-pay-button-type: book; }
.apple-pay-button[data-type='order'] { -apple-pay-button-type: order; }
.apple-pay-button[data-type='donate'] { -apple-pay-button-type: donate; }
.apple-pay-button[data-type='subscribe'] { -apple-pay-button-type: subscribe; }
.apple-pay-button[data-type='plain'] { -apple-pay-button-type: plain; }
.apple-pay-button[data-style='white'] { -apple-pay-button-style: white; }
.apple-pay-button[data-style='white-outline'] { -apple-pay-button-style: white-outline; }

.status { margin: 16px 0; font-size: 13px; color: var(--muted); }
.status--ok { color: var(--ok); }
.status--error { color: var(--error); font-weight: 600; }

/* dev:start  review outlines + diagnostics panels; not in the production build */
/* ── Review mode: ?outline=1 ──────────────────────────────────────────────
   Marks who drew what. OFF by default and never shown to a shopper - it is
   for reviewing the checkout, for screenshots, and for settling the question
   "is that text ours or Google's" without reading the source.

   Red, solid   this document. Our markup, our words, our responsibility.
   Grey, dashed the vendor's. Apple Pay's button is a native WebKit control
                and Google Pay's comes from their SDK; we may only set the
                options they publish, and their sheets are not in this
                document at all, so nothing inside these boxes can be
                restyled without failing the vendor's own review.

   outline rather than border, so nothing moves when it is switched on and
   the annotated layout is the real one. */
:root[data-cap-outline='1'] .cap-own,
:root[data-cap-outline='1'] .cap-vendor {
    position: relative;
}

:root[data-cap-outline='1'] .cap-own {
    outline: 2px solid #d1242f;
    outline-offset: 3px;
}

:root[data-cap-outline='1'] .cap-vendor {
    outline: 2px dashed #8b949e;
    outline-offset: 3px;
}

:root[data-cap-outline='1'] .cap-own::after,
:root[data-cap-outline='1'] .cap-vendor::after {
    content: attr(data-cap-label);
    position: absolute;
    top: -9px;
    left: 4px;
    padding: 0 5px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .02em;
    line-height: 14px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 2;
}

:root[data-cap-outline='1'] .cap-own::after {
    background: #d1242f;
    color: #fff;
}

:root[data-cap-outline='1'] .cap-vendor::after {
    background: #8b949e;
    color: #fff;
}

/* Hidden means hidden, always. [hidden] loses to any class that sets
   display (.card-divider is flex), so without this the "or pay by card" line
   showed on a card-only checkout, and an un-offered wallet appeared as an
   empty labelled box in review mode. */
[hidden] {
    display: none !important;
}

.panel {
    border: 1px solid var(--line); border-radius: 8px;
    padding: 12px; margin-bottom: 12px;
}
.panel--muted { background: var(--panel); }
.panel h2 {
    margin: 0 0 8px; font-size: 11px; text-transform: uppercase;
    letter-spacing: .05em; color: var(--muted);
}

pre {
    margin: 0; overflow-x: auto; font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.timeline { width: 100%; border-collapse: collapse; font-size: 12px; }
.timeline td { padding: 2px 0; vertical-align: top; }
.timeline td:first-child {
    width: 68px; color: var(--muted); text-align: right; padding-right: 12px;
    font-family: ui-monospace, Consolas, monospace;
}

.diag {
    display: grid; grid-template-columns: auto 1fr; gap: 4px 12px;
    margin: 0; font-size: 12px;
}
.diag dt { color: var(--muted); white-space: nowrap; }
.diag dd {
    margin: 0; word-break: break-all;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
/* dev:end */

/* Preferred wallet.
   Emphasis is applied to the space AROUND the button — a hint line above it and
   a little more breathing room. The button itself is untouched: both Apple and
   Google forbid restyling or animating their marks, and a decorated button
   fails their review. No entrance animation either; a payment control that
   moves invites a mis-tap. */
.wallet-hint {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--ok);
}

.button-row.preferred {
    margin-bottom: 4px;
}

.button-row.preferred + .button-row {
    opacity: 0.92;
}

/* ── Card form ────────────────────────────────────────────────────────────
   Uses the same tokens as everything else, so it follows the shopper's dark
   mode without a second palette. Deliberately plain: a card form that looks
   unusual reads as untrustworthy, and this one is asking for a card number. */
.card-section {
    margin-top: 16px;
}

.card-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0 12px;
    font-size: 12px;
    color: var(--muted);
}

.card-divider::before,
.card-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--line);
}

.cc {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cc__field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* The label text only. .cc__number is also a direct span child — without
   :not() it would inherit the label styling and any future change to that rule
   would silently restyle the card-number wrapper. */
.cc__field > span:not(.cc__number) {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}

.cc input,
.cc select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    color: var(--fg);
    font: inherit;
    /* 16px, not 15. Below 16 iOS Safari ZOOMS THE PAGE when a field takes
       focus, and inside an iframe that zoom is what makes the form look like
       it has collapsed on itself: the document scales up, the iframe box does
       not, and the fields overlap. The old comment said 16 and the value said
       15, so the bug was sitting next to its own explanation. */
    font-size: 16px;
}

.cc input:focus,
.cc select:focus {
    outline: 2px solid var(--ok);
    outline-offset: -1px;
    border-color: transparent;
}

.cc input:disabled,
.cc select:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.cc__row {
    display: grid;
    grid-template-columns: 1fr 96px;
    gap: 12px;
    align-items: start;
}

/* A grid item defaults to min-width: auto, which means it REFUSES to shrink
   below its content and spills out of its column instead. At phone width the
   two expiry selects did exactly that and ran over the CVV field. This is the
   fix for that overlap; the font-size above is the fix for the zoom. */
.cc__row > * {
    min-width: 0;
}

.cc__expiry {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.cc__expiry > select {
    min-width: 0;
}

/* Narrow phones. Three fields across is not worth the crush, so expiry and
   CVV get a row each. */
@media (max-width: 380px) {
    .cc__row {
        grid-template-columns: 1fr;
    }
}

.cc__error {
    font-size: 12px;
    font-style: normal;
    color: var(--error);
}

.cc__submit {
    margin-top: 4px;
    padding: 14px 16px;
    border: 0;
    border-radius: 8px;
    background: var(--fg);
    color: var(--bg);
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.cc__submit:disabled {
    opacity: 0.55;
    cursor: default;
}

/* Brand mark inside the card-number field. Absolutely positioned so it never
   reflows the input, with right padding reserved so a long number cannot run
   underneath it. */
.cc__number {
    position: relative;
    display: block;
}

.cc__number input {
    padding-right: 60px;
}

.cc__brand {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    height: 22px;
    width: auto;
    max-width: 40px;
    pointer-events: none;
}

/* The marks are drawn for a white background. In light mode the field already is
   one, so a plate would only make the logo look like a sticker stuck on. In dark
   mode there is nothing behind them, so there they get one — the networks
   specify these colours, so the artwork is never recoloured to suit the theme. */
@media (prefers-color-scheme: dark) {
    .cc__brand {
        background: #fff;
        border-radius: 3px;
        padding: 2px 3px;
    }
}
