body {
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}
.pay-page {
    max-width: 920px;
    margin: 0 auto;
    padding: 16px max(16px, env(safe-area-inset-left)) 48px max(16px, env(safe-area-inset-right));
}
.pay-head { text-align: center; padding: 8px 0 24px; position: relative; }
.pay-head h1 { font-size: clamp(24px, 5.5vw, 40px); font-weight: 800; margin: 0; letter-spacing: -0.03em; padding: 0 48px; }
.pay-head p { color: var(--muted); margin: 12px 0 0; font-size: clamp(14px, 3.5vw, 15px); }
.pay-head .back-btn { position: absolute; left: 0; top: 0; }

.plans-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 14px;
}
.plan-card {
    position: relative;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 20px;
    padding: clamp(18px, 4vw, 22px) clamp(14px, 3vw, 18px);
}
.plan-card.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(0,229,193,0.15), 0 14px 40px rgba(0,229,193,0.12);
}
.plan-card .mark {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border);
}
.plan-card.active .mark {
    border-color: var(--accent);
    background: var(--accent);
    box-shadow: inset 0 0 0 3px #0e1110;
}
.plan-card .pn { font-size: 14px; color: var(--muted); font-weight: 500; padding-right: 24px; }
.plan-card .pc { font-size: clamp(28px, 7vw, 36px); font-weight: 800; margin: 6px 0 2px; }
.plan-card .pd { font-size: 12px; color: var(--dim); }
.plan-card .pdev {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--muted);
}

.devices-note {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    margin: 14px 0 18px;
    font-size: 13px;
    color: var(--muted);
    line-height: 1.5;
}
.devices-note b { color: var(--text); }

.pay-bar {
    border-radius: 20px;
    padding: 16px;
    background: linear-gradient(180deg, rgba(0,229,193,0.12), rgba(255,255,255,0.03));
    border: 1px solid rgba(0,229,193,0.22);
}
.pay-bar button {
    width: 100%;
    border: none;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
    font-family: inherit;
    font-size: 17px;
    font-weight: 800;
    padding: 16px 20px;
    cursor: pointer;
    min-height: 52px;
    touch-action: manipulation;
    box-shadow: 0 10px 32px rgba(0,229,193,0.25);
}
.pay-note { text-align: center; font-size: 12px; color: var(--dim); margin-top: 14px; line-height: 1.5; }

.overlay {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s, visibility .2s;
    overscroll-behavior: contain;
}
.overlay.open { opacity: 1; visibility: visible; }
.sheet {
    width: 100%;
    max-width: 458px;
    max-height: 92dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #0e1110;
    border: 1px solid var(--border);
    border-radius: 24px 24px 0 0;
    padding: 22px 18px calc(24px + env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform .25s;
}
.overlay.open .sheet { transform: translateY(0); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.sheet-head b { font-size: 18px; }
.sheet-close {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.06);
    color: var(--text);
    cursor: pointer;
}
.method {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border-radius: 16px;
    border: 1.5px solid var(--border);
    background: rgba(255,255,255,0.03);
    margin-bottom: 10px;
    cursor: pointer;
    min-height: 44px;
    touch-action: manipulation;
}
.method.sel { border-color: var(--accent); }
.method .ico {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.agree-list { margin: 18px 0; }
.agree-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--border);
    font-size: 13px;
    line-height: 1.45;
}
.agree-item:first-child { border-top: none; }
.agree-item input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--accent); flex-shrink: 0; }
.agree-item a { color: var(--accent); }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; text-align: center; }
.success-box { display: none; text-align: center; padding: 20px 10px; background: var(--accent-soft); border-radius: 16px; margin-top: 14px; }
.success-box.show { display: block; }

.auth-gate {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0,0,0,0.88);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overscroll-behavior: contain;
}
.auth-gate.open { display: flex; }
.auth-gate-card {
    width: 100%;
    max-width: 420px;
    max-height: 92dvh;
    overflow-y: auto;
    background: #0e1110;
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 22px 18px;
}
.auth-gate-card h2 { margin: 0 0 8px; font-size: 20px; text-align: center; }
.auth-gate-card .sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; text-align: center; line-height: 1.5; }
.auth-gate-card input,
.email-card input {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 10px;
    padding: 13px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(0,0,0,0.25);
    color: var(--text);
    font-family: inherit;
    font-size: 16px;
}
.auth-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.auth-tabs button {
    flex: 1;
    border: none;
    border-radius: 999px;
    padding: 12px 10px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
    background: rgba(255,255,255,0.06);
    color: var(--muted);
}
.auth-tabs button.active { background: var(--accent); color: var(--accent-ink); }
.auth-divider { text-align: center; color: var(--dim); font-size: 12px; margin: 14px 0; }
.email-modal {
    position: fixed;
    inset: 0;
    z-index: 95;
    background: rgba(0,0,0,0.72);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.email-modal.open { display: flex; }
.email-card {
    width: 100%;
    max-width: 400px;
    background: #0e1110;
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 22px 18px;
}
.email-card h2 { margin: 0 0 8px; font-size: 20px; }
.email-card p { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.5; }

@media (min-width: 520px) {
    .overlay { align-items: center; }
    .sheet { border-radius: 24px; margin: 20px; }
}
@media (max-width: 720px) {
    .plans-grid { grid-template-columns: 1fr; }
    .pay-bar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 30;
        margin: 0;
        border-radius: 0;
        padding: 12px max(16px, env(safe-area-inset-left)) calc(12px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-right));
        background: rgba(7,8,9,0.96);
        border-top: 1px solid var(--border);
        border-bottom: none;
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }
    .pay-page { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
    .pay-note { margin-bottom: 8px; }
}
