:root {
    --bg: #0f1115;
    --surface: #181b22;
    --surface-sunken: #12141a;
    --border: #2f3542;
    --text: #f3f4f6;
    --text-soft: #d1d5db;
    --muted: #9ca3af;
    --accent: #a5b4fc;
    --danger: #fca5a5;
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: clip;
    background:
            radial-gradient(900px 500px at 85% -10%, rgba(165, 180, 252, 0.12), transparent 65%),
            radial-gradient(700px 400px at -10% 100%, rgba(165, 180, 252, 0.06), transparent 65%),
            var(--bg);
    background-attachment: fixed;
    color: var(--text);
    font-family: 'Manrope', sans-serif;
}

/*
 * Для чекбокса используется "~", а не "+":
 * th:field вставляет <input type="hidden" name="_consent"> сразу после чекбокса,
 * поэтому .consent__box уже не является ближайшим соседом.
 */
a:focus-visible,
button:focus-visible,
input:focus-visible ~ .provider__radio,
input:focus-visible ~ .consent__box {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

/* ===== Шапка ===== */

.checkout-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: 1080px;
    margin: 0 auto;
    padding: 24px;
}

.checkout-top__logo {
    color: var(--text);
    font-size: 18px;
    font-weight: 700;
    text-decoration: none;
}

.checkout-top__back {
    color: var(--muted);
    font-size: 14px;
    text-decoration: none;
    transition: color 0.2s ease;
}

.checkout-top__back:hover {
    color: var(--accent);
}

/* ===== Основна частина ===== */

.checkout {
    max-width: 1080px;
    margin: 0 auto;
    padding: 24px 24px 80px;
}

.checkout__heading {
    margin-bottom: 36px;
}

.checkout__step {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.checkout__title {
    margin: 0;
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(40px, 5.5vw, 60px);
    font-weight: 600;
    line-height: 1.05;
}

.checkout__title em {
    color: var(--accent);
    font-style: italic;
    font-weight: 500;
}

.checkout__layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    grid-template-areas: "form summary";
    gap: 32px;
    align-items: start;
}

/* ===== Підсумок ===== */

.summary {
    grid-area: summary;
    position: sticky;
    top: 24px;
    padding: 28px;
    background:
            linear-gradient(165deg, rgba(165, 180, 252, 0.10) 0%, rgba(165, 180, 252, 0) 50%),
            var(--surface);
    border: 1px solid rgba(165, 180, 252, 0.35);
    border-radius: 20px;
}

.summary__label {
    margin: 0 0 14px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.summary__course {
    margin: 0 0 6px;
    font-family: 'Cormorant Garamond', serif;
    font-size: 28px;
    font-weight: 600;
    line-height: 1.15;
}

.summary__tariff {
    display: inline-block;
    margin: 0 0 24px;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(165, 180, 252, 0.14);
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
}

.summary__row,
.summary__total {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.summary__row {
    padding: 14px 0;
    border-top: 1px solid var(--border);
    color: var(--text-soft);
    font-size: 15px;
}

.summary__total {
    padding: 16px 0 4px;
    border-top: 1px solid var(--border);
    font-size: 15px;
    color: var(--text-soft);
}

.summary__total strong {
    color: var(--text);
    font-size: 26px;
    font-weight: 700;
    white-space: nowrap;
}

.summary__note {
    margin: 16px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
}

/* ===== Форма ===== */

.checkout-form {
    grid-area: form;
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
}

.checkout-form__title {
    margin: 0 0 20px;
    font-size: 18px;
    font-weight: 700;
}

.checkout-form__title:not(:first-of-type) {
    margin-top: 36px;
}

.checkout-form__unavailable {
    margin: 0;
    padding: 24px;
    border: 1px dashed var(--border);
    border-radius: 14px;
    color: var(--text-soft);
    text-align: center;
}

.field {
    margin-bottom: 18px;
}

.field label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-soft);
    font-size: 14px;
    font-weight: 500;
}

.field input {
    width: 100%;
    padding: 14px 16px;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-family: inherit;
    font-size: 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input::placeholder {
    color: #6b7280;
}

.field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(165, 180, 252, 0.15);
}

.field input.is-invalid {
    border-color: var(--danger);
}

.field__error {
    margin: 8px 0 0;
    color: var(--danger);
    font-size: 13px;
}

/* ===== Способи оплати ===== */

.providers {
    display: grid;
    gap: 12px;
}

.provider {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    column-gap: 14px;
    align-items: center;
    padding: 16px 18px;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: 14px;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.provider:hover {
    border-color: #444c5c;
}

.provider input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.provider__radio {
    grid-row: 1 / 3;
    width: 20px;
    height: 20px;
    border: 2px solid #4b5262;
    border-radius: 50%;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.provider__name {
    color: var(--text);
    font-size: 16px;
    font-weight: 600;
}

.provider__hint {
    color: var(--muted);
    font-size: 13px;
}

.provider:has(input:checked) {
    border-color: var(--accent);
    background: rgba(165, 180, 252, 0.07);
}

.provider input:checked ~ .provider__radio {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 4px var(--surface-sunken), inset 0 0 0 10px var(--accent);
}

/* ===== Згода ===== */

.consent {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-top: 28px;
    cursor: pointer;
}

.consent input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.consent__box {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 1px;
    border: 2px solid #4b5262;
    border-radius: 6px;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.consent input:checked ~ .consent__box {
    border-color: var(--accent);
    background:
            url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23111827' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E") center / 14px no-repeat,
            var(--accent);
}

.consent__text {
    color: var(--text-soft);
    font-size: 14px;
    line-height: 1.55;
}

.consent__text a {
    color: var(--accent);
    text-underline-offset: 3px;
}

/* ===== Кнопка ===== */

.checkout-submit {
    width: 100%;
    margin-top: 28px;
    padding: 17px 24px;
    border: none;
    border-radius: 999px;
    background: var(--accent);
    color: #111827;
    font-family: inherit;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(165, 180, 252, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.checkout-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 38px rgba(165, 180, 252, 0.45);
}

.checkout-secure {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 16px 0 0;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.checkout-secure svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.summary__items {
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
}

.summary__item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.summary__item:first-child { padding-top: 0; }

.summary__item .summary__course { margin: 0; }
.summary__item .summary__tariff { margin: 4px 0 0; }

.summary__item-price {
    font-weight: 600;
    white-space: nowrap;
}

/* ===== Планшет і мобільний ===== */

@media (max-width: 900px) {
    .checkout__layout {
        grid-template-columns: 1fr;
        grid-template-areas:
            "summary"
            "form";
        gap: 20px;
    }

    .summary {
        position: static;
    }
}

@media (max-width: 600px) {
    .checkout-top {
        padding: 18px 16px;
    }

    .checkout {
        padding: 12px 16px 56px;
    }

    .checkout__heading {
        margin-bottom: 24px;
    }

    .summary,
    .checkout-form {
        padding: 22px 18px;
        border-radius: 18px;
    }

    .summary__total strong {
        font-size: 22px;
    }
}