:root {
    --g-paper: #fbf7ef;
    --g-card: #fffdf8;
    --g-ink: #2b2013;
    --g-muted: #6f6353;
    --g-line: #e8d8ba;
    --g-line-strong: #d9c39a;
    --g-accent: #ef6515;
    --g-accent-deep: #c94f0a;
    --g-gold: #f2c46d;
    --g-success: #2f7d4f;
    --g-error: #b3261e;
}

/* ---------- standalone pages ---------- */
.gate-page {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--g-ink);
    background: var(--g-paper);
}

.gate-page *,
.gate-overlay * {
    box-sizing: border-box;
}

.gate-shell {
    width: 90%;
    max-width: 720px;
    margin: 0 auto;
    padding: 28px 0 56px;
}

.gate-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.gate-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.gate-brand img {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--g-line);
}

.gate-brand strong {
    display: block;
    font-size: 0.98rem;
    letter-spacing: 0.5px;
}

.gate-brand span {
    display: block;
    font-size: 0.74rem;
    color: var(--g-muted);
}

.gate-back {
    flex: none;
    color: var(--g-accent);
    font-size: 0.84rem;
    text-decoration: none;
}

.gate-back:hover {
    text-decoration: underline;
}

.gate-hero h1 {
    margin: 0 0 8px;
    font-size: clamp(1.5rem, 4vw, 2rem);
    letter-spacing: 0.5px;
}

.gate-hero p {
    max-width: 36em;
    margin: 0 0 20px;
    font-size: 0.9rem;
    color: var(--g-muted);
}

.gate-card {
    margin-bottom: 16px;
    padding: 20px;
    background: var(--g-card);
    border: 1px solid var(--g-line);
    border-radius: 18px;
}

/* ---------- steps ---------- */
.gate-steps {
    display: flex;
    flex-direction: column;
}

.gate-step {
    position: relative;
    display: grid;
    grid-template-columns: 36px 1fr;
    gap: 14px;
    padding-bottom: 24px;
}

.gate-step:last-child {
    padding-bottom: 0;
}

.gate-step::before {
    content: "";
    position: absolute;
    top: 36px;
    bottom: 0;
    left: 17px;
    border-left: 1px dashed var(--g-line-strong);
}

.gate-step:last-child::before {
    display: none;
}

.gate-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1.5px solid var(--g-line-strong);
    border-radius: 50%;
    background: #fff;
    color: var(--g-accent);
    font-weight: 700;
    font-size: 0.92rem;
}

.gate-step h2 {
    margin: 5px 0 6px;
    font-size: 1rem;
}

.gate-step p {
    margin: 0 0 10px;
    font-size: 0.85rem;
    color: var(--g-muted);
}

.gate-copy {
    position: relative;
    padding: 14px;
    background: #fff;
    border: 1px dashed var(--g-line-strong);
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.gate-copy::before,
.gate-copy::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    margin-top: -7px;
    background: var(--g-card);
    border: 1px solid var(--g-line);
    border-radius: 50%;
}

.gate-copy::before {
    left: -8px;
}

.gate-copy::after {
    right: -8px;
}

.gate-platforms {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.gate-platforms span {
    padding: 4px 12px;
    border: 1px solid var(--g-line);
    border-radius: 999px;
    background: #fff;
    font-size: 0.8rem;
    color: var(--g-muted);
}

.gate-hint {
    margin: 8px 0 0;
    font-size: 0.78rem;
    color: var(--g-muted);
}

.gate-hint.ok {
    color: var(--g-success);
}

.gate-hint.err {
    color: var(--g-error);
}

/* ---------- buttons ---------- */
.gate-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid var(--g-line-strong);
    border-radius: 999px;
    background: #fff;
    color: var(--g-ink);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.gate-btn:hover {
    background: #fdf4e5;
}

.gate-btn.primary {
    border-color: var(--g-accent);
    background: var(--g-accent);
    color: #fff;
    font-weight: 700;
}

.gate-btn.primary:hover {
    border-color: var(--g-accent-deep);
    background: var(--g-accent-deep);
}

.gate-btn.block {
    width: 100%;
}

.gate-card > .gate-btn.block {
    margin-top: 14px;
}

.gate-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.gate-btn:focus-visible,
.gate-back:focus-visible,
.gate-help:focus-visible,
.gate-drop:focus-visible {
    outline: 2px solid var(--g-accent);
    outline-offset: 2px;
}

/* ---------- upload / verify ---------- */
.gate-drop {
    padding: 26px 16px;
    text-align: center;
    background: #fffdf8;
    border: 2px dashed var(--g-line-strong);
    border-radius: 14px;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

.gate-drop:hover,
.gate-drop.dragover {
    background: #fff5e6;
    border-color: var(--g-accent);
}

.gate-drop strong {
    display: block;
    font-size: 0.95rem;
}

.gate-drop span {
    display: block;
    margin-top: 5px;
    font-size: 0.78rem;
    color: var(--g-muted);
}

.gate-preview {
    display: none;
    margin-top: 12px;
    text-align: center;
}

.gate-preview.show {
    display: block;
}

.gate-preview img {
    max-width: 100%;
    max-height: 220px;
    border: 1px solid var(--g-line);
    border-radius: 10px;
}

.gate-preview .gate-btn {
    margin-top: 8px;
}

.gate-target {
    margin: 0 0 14px;
    font-size: 0.82rem;
    color: var(--g-muted);
}

.gate-target code {
    padding: 1px 6px;
    border: 1px solid var(--g-line);
    border-radius: 5px;
    background: #fff;
    color: var(--g-ink);
}

.gate-status {
    min-height: 1.4em;
    margin: 10px 0 0;
    font-size: 0.82rem;
    color: var(--g-muted);
}

.gate-status.ok {
    color: var(--g-success);
}

.gate-status.err {
    color: var(--g-error);
}

.gate-error-card {
    padding: 16px;
    background: #fff7f6;
    border: 1px solid #f0cdc9;
    border-radius: 12px;
    color: var(--g-error);
    font-size: 0.86rem;
}

.gate-error-card[hidden] {
    display: none;
}

.gate-error-card ul {
    margin: 8px 0 0;
    padding-left: 18px;
    color: var(--g-muted);
}

/* ---------- password pass ---------- */
.gate-pass {
    display: none;
    padding: 20px;
    text-align: center;
    background: #fff;
    border: 2px solid var(--g-accent);
    border-radius: 16px;
}

.gate-pass.show {
    display: block;
}

.gate-kicker {
    margin: 0 0 4px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--g-accent);
}

.gate-pass h2 {
    margin: 0 0 10px;
    font-size: 1.1rem;
}

.gate-code {
    max-width: 280px;
    margin: 0 auto 14px;
    padding: 12px;
    background: var(--g-paper);
    border: 1px dashed var(--g-line-strong);
    border-radius: 10px;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    user-select: all;
}

.gate-pass .gate-btn {
    margin: 4px;
}

/* ---------- modal (iOS page) ---------- */
.gate-lock {
    overflow: hidden;
}

.gate-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(43, 32, 19, 0.64);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.gate-overlay[hidden] {
    display: none;
}

.gate-modal {
    position: relative;
    width: 100%;
    max-width: 380px;
    padding: 24px;
    background: var(--g-card);
    border: 1px solid var(--g-line);
    border-radius: 20px;
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.32);
    line-height: 1.55;
    animation: gate-in 0.22s ease-out;
}

.gate-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--g-muted);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
}

.gate-close:hover {
    background: #fdf4e5;
}

.gate-modal .gate-kicker {
    margin-bottom: 6px;
}

.gate-modal h2 {
    margin: 0 0 6px;
    font-size: 1.25rem;
}

.gate-modal .gate-desc {
    margin: 0 0 16px;
    font-size: 0.85rem;
    color: var(--g-muted);
}

.gate-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.8rem;
    color: var(--g-muted);
}

.gate-input-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.gate-input-row input {
    flex: 1;
    min-width: 0;
    width: 100%;
    padding: 11px 12px;
    background: #fff;
    border: 1px solid var(--g-line-strong);
    border-radius: 10px;
    font: inherit;
    font-size: 1rem;
    letter-spacing: 0.06em;
}

.gate-reveal {
    flex: none;
    padding: 6px 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--g-accent);
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
}

.gate-reveal:hover {
    background: #fdf4e5;
}

.gate-reveal:focus-visible {
    outline: 2px solid var(--g-accent);
    outline-offset: 1px;
}

.gate-input-row input:focus {
    outline: 2px solid var(--g-accent);
    outline-offset: 1px;
    border-color: var(--g-accent);
}

.gate-field-error {
    margin: 8px 0 0;
    font-size: 0.8rem;
    color: var(--g-error);
}

.gate-field-error[hidden] {
    display: none;
}

.gate-modal .gate-btn.primary {
    width: 100%;
    margin-top: 14px;
}

.gate-help {
    display: block;
    margin-top: 14px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--g-accent);
    text-decoration: none;
}

.gate-help:hover {
    text-decoration: underline;
}

.gate-note {
    margin: 14px 0 0;
    padding-top: 12px;
    border-top: 1px dashed var(--g-line);
    font-size: 0.72rem;
    color: var(--g-muted);
    text-align: center;
}

@keyframes gate-in {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@media (max-width: 520px) {
    .gate-shell {
        width: 92%;
        padding-top: 20px;
    }

    .gate-card {
        padding: 16px;
    }

    .gate-overlay {
        padding: 14px;
    }

    .gate-modal {
        padding: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gate-modal {
        animation: none;
    }

    .gate-btn,
    .gate-drop,
    .gate-close {
        transition: none;
    }
}

.gate-link-card[hidden] {
    display: none;
}

.gate-link-card h2 {
    margin: 0 0 6px;
    font-size: 1.05rem;
}

.gate-link-card .gate-field {
    margin-top: 12px;
}

.gate-link-card input {
    width: 100%;
    padding: 11px 12px;
    background: #fff;
    border: 1px solid var(--g-line-strong);
    border-radius: 10px;
    font: inherit;
    font-size: 1rem;
}

.gate-link-card input:focus {
    outline: 2px solid var(--g-accent);
    outline-offset: 1px;
    border-color: var(--g-accent);
}
