:root {
    --brand-1: #7c19dd;
    --brand-2: #2f72ff;
    --brand-3: #7056f7;
    --bg-card: #ffffff;
    --bg-soft: #f7f9fd;
    --text-main: #10203f;
    --text-soft: #5f6f93;
    --text-faint: #8b97b3;
    --line: rgba(130, 149, 191, 0.22);
    --success: #22c55e;
    --danger: #ef4444;
    --shadow-lg: 0 26px 70px rgba(49, 76, 166, 0.18);
    --shadow-md: 0 14px 40px rgba(66, 92, 176, 0.12);
    --radius-xl: 26px;
    --radius-lg: 20px;
    --radius-md: 14px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(124, 25, 221, 0.28), transparent 34%),
        radial-gradient(circle at top right, rgba(47, 114, 255, 0.26), transparent 36%),
        linear-gradient(135deg, #6b79e2 0%, #7170e8 34%, #7256d8 100%);
    color: var(--text-main);
    padding: 36px 20px;
}

.redeem-shell {
    width: 100%;
    display: flex;
    justify-content: center;
}

.redeem-frame {
    width: min(1120px, 100%);
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.34);
    border-radius: 30px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(14px);
}

.hero-bar {
    position: relative;
    padding: 28px 32px 30px;
    background: linear-gradient(90deg, var(--brand-1) 0%, var(--brand-2) 100%);
    color: #fff;
}

.hero-copy {
    text-align: center;
}

.hero-copy h1 {
    margin: 0;
    font-size: clamp(1.85rem, 3vw, 2.6rem);
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.hero-actions {
    position: absolute;
    top: 28px;
    right: 32px;
}

.lang-switch {
    display: inline-block;
}

.lang-switch select {
    border: 1px solid rgba(255, 255, 255, 0.76);
    outline: none;
    background: #fff;
    border-radius: 999px;
    padding: 10px 16px;
    color: var(--text-main);
    font-size: 0.92rem;
    font-weight: 700;
    box-shadow: 0 12px 28px rgba(19, 35, 88, 0.16);
}

.frame-body {
    padding: 24px 32px 30px;
    background: linear-gradient(180deg, rgba(247, 250, 255, 0.82), rgba(250, 252, 255, 0.96));
}

.tab-switch {
    width: min(420px, 100%);
    margin: 0 auto 18px;
    padding: 6px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    background: #edf1f7;
    border-radius: 999px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.tab-btn {
    border: none;
    background: transparent;
    color: var(--text-soft);
    font-size: 1rem;
    font-weight: 700;
    padding: 14px 18px;
    border-radius: 999px;
    cursor: pointer;
    transition: 0.2s ease;
}

.tab-btn.active {
    background: #fff;
    color: var(--brand-2);
    box-shadow: var(--shadow-md);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.stepper-wrap {
    margin-bottom: 22px;
}

.stepper {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 58px minmax(0, 1fr) 58px minmax(0, 1fr) 58px minmax(0, 1fr);
    align-items: start;
}

.step-line {
    align-self: center;
    height: 2px;
    margin-top: 20px;
    background: #dbe4f3;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
}

.step-dot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #dde4f0;
    color: var(--text-soft);
    font-size: 1rem;
    font-weight: 800;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.step-item.active .step-dot {
    background: linear-gradient(135deg, var(--brand-3), var(--brand-2));
    color: #fff;
}

.step-item.done .step-dot {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
}

.step-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.step-meta strong {
    font-size: 0.9rem;
    color: var(--text-main);
}

.step-meta span {
    font-size: 0.78rem;
    color: var(--text-faint);
}

.service-layout,
.query-layout {
    display: grid;
    gap: 22px;
}

.service-layout {
    grid-template-columns: minmax(0, 1fr);
}

.query-layout.centered {
    grid-template-columns: minmax(0, 520px);
    justify-content: center;
}

.content-card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    box-shadow: 0 18px 50px rgba(79, 104, 182, 0.08);
}

.primary-card {
    padding: 26px;
}

.panel-header {
    margin-bottom: 24px;
}

.panel-header.compact {
    margin-bottom: 18px;
}

.panel-header.centered {
    text-align: center;
}

.panel-header h2,
.panel-header h3 {
    margin: 0 0 8px;
    color: var(--text-main);
    line-height: 1.2;
}

.panel-header h2 {
    font-size: 1.55rem;
    font-weight: 800;
}

.panel-header h3 {
    font-size: 1.12rem;
    font-weight: 800;
}

.panel-header p {
    margin: 0;
    color: var(--text-soft);
    font-size: 0.95rem;
}

.panel-header p:empty {
    display: none;
}

.service-stage {
    display: none;
}

.service-stage.active {
    display: block;
}

.stack-form {
    display: grid;
    gap: 18px;
}

.field-group {
    display: grid;
    gap: 10px;
}

.field-input,
.field-textarea {
    width: 100%;
    border: 1px solid #d8e1f0;
    outline: none;
    background: #f7f9fd;
    color: var(--text-main);
    border-radius: var(--radius-md);
    transition: 0.2s ease;
}

.field-input {
    padding: 18px;
    font-size: 1.08rem;
    text-align: center;
}

.field-input::placeholder {
    text-align: center;
}

.field-textarea {
    min-height: 170px;
    resize: vertical;
    padding: 16px 18px;
    font-size: 0.95rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    line-height: 1.55;
}

.field-input:focus,
.field-textarea:focus {
    border-color: rgba(55, 107, 255, 0.48);
    box-shadow: 0 0 0 5px rgba(85, 115, 255, 0.12);
    background: #fff;
}

.turnstile-wrap {
    display: flex;
    justify-content: center;
    padding-top: 2px;
}

.turnstile-wrap > div {
    min-height: 65px;
}

.guide-box {
    background: linear-gradient(180deg, #f1f6ff, #eef4ff);
    border: 1px solid rgba(80, 131, 255, 0.16);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    color: var(--text-soft);
    font-size: 0.92rem;
}

.guide-box strong {
    display: block;
    margin-bottom: 8px;
    color: var(--brand-2);
}

.guide-box ol {
    margin: 0;
    padding-left: 18px;
}

.guide-box li + li {
    margin-top: 4px;
}

.guide-box li {
    color: var(--text-main);
}

.guide-box a {
    color: var(--brand-2);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
    word-break: break-all;
}

.guide-box a:hover {
    color: var(--brand-1);
}

.button-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.action-btn {
    border: none;
    border-radius: var(--radius-md);
    min-height: 58px;
    padding: 0 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    transition: 0.22s ease;
}

.action-btn:disabled {
    opacity: 0.75;
    cursor: not-allowed;
}

.action-primary {
    background: linear-gradient(90deg, var(--brand-1), var(--brand-2));
    color: #fff;
    box-shadow: 0 14px 32px rgba(79, 73, 226, 0.28);
}

.action-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 18px 36px rgba(79, 73, 226, 0.34);
}

.action-muted {
    background: #fff;
    color: var(--text-main);
    border: 1px solid #d6deec;
}

.action-muted:hover:not(:disabled) {
    background: #f7f9fd;
}

.status-panel {
    display: grid;
    gap: 18px;
}

.status-hero {
    display: grid;
    justify-items: center;
    gap: 12px;
    padding: 6px 0 4px;
    text-align: center;
}

.status-icon-wrap {
    width: 82px;
    height: 82px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(124, 25, 221, 0.08), rgba(47, 114, 255, 0.12));
}

.status-spinner-ring {
    width: 66px;
    height: 66px;
    border-radius: 50%;
    border: 6px solid rgba(47, 114, 255, 0.14);
    border-top-color: var(--brand-2);
    animation: spin 1s linear infinite;
}

.status-icon-success,
.status-icon-failed {
    width: 66px;
    height: 66px;
    border-radius: 50%;
    display: grid;
    place-items: center;
}

.status-icon-success {
    background: rgba(34, 197, 94, 0.12);
    color: var(--success);
}

.status-icon-failed {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.status-title {
    font-size: 2rem;
    font-weight: 800;
}

.status-description {
    color: var(--text-soft);
    font-size: 1.02rem;
}

.detail-grid {
    display: grid;
    gap: 0;
    border: 1px solid #e1e8f4;
    border-radius: var(--radius-lg);
    background: var(--bg-soft);
    overflow: hidden;
}

.detail-row {
    display: grid;
    grid-template-columns: 128px minmax(0, 1fr);
    gap: 18px;
    padding: 18px 20px;
    align-items: center;
}

.detail-row + .detail-row {
    border-top: 1px solid #e1e8f4;
}

.detail-label {
    color: var(--text-soft);
    font-weight: 700;
}

.detail-value {
    color: var(--text-main);
    font-weight: 700;
    word-break: break-word;
}

.detail-status-wrap {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.detail-value.error-text {
    color: var(--danger);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 68px;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 0.92rem;
    font-weight: 800;
}

.status-badge.queued {
    background: rgba(47, 114, 255, 0.1);
    color: var(--brand-2);
}

.status-badge.success {
    background: rgba(34, 197, 94, 0.12);
    color: var(--success);
}

.status-badge.failed {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.status-refresh-btn {
    border: 1px solid #d6deec;
    background: #fff;
    color: var(--text-main);
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
}

.status-refresh-btn:hover {
    background: #f7f9fd;
}

.search-result-empty {
    min-height: 220px;
    display: grid;
    place-items: center;
    border: 1px dashed #d6deed;
    border-radius: var(--radius-lg);
    background: var(--bg-soft);
    color: var(--text-soft);
    font-size: 0.98rem;
    text-align: center;
}

.frame-footer {
    padding: 18px 32px 24px;
    text-align: center;
    color: var(--text-faint);
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.7);
}

.toast {
    position: fixed;
    top: 26px;
    right: 26px;
    z-index: 60;
    min-width: 240px;
    max-width: 360px;
    display: none;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.92);
    color: #fff;
    box-shadow: var(--shadow-md);
}

.toast.show {
    display: inline-flex;
}

.toast.success {
    background: rgba(15, 159, 83, 0.94);
}

.toast.error {
    background: rgba(220, 38, 38, 0.94);
}

.result-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1200;
}

.result-modal.open {
    display: flex;
}

.result-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(6px);
}

.result-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(760px, 100%);
    max-height: min(88vh, 900px);
    overflow: auto;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(219, 228, 243, 0.9);
    border-radius: 28px;
    box-shadow: 0 30px 80px rgba(15, 23, 42, 0.2);
    padding: 24px;
}

.modal-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 42px;
    height: 42px;
    border: 1px solid #d7e0ef;
    border-radius: 50%;
    background: #fff;
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.modal-close-btn:hover {
    background: #f7f9fd;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 1100px) {
    .service-layout,
    .query-layout,
    .query-layout.centered {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 860px) {
    body {
        padding: 18px 12px;
    }

    .hero-bar {
        padding: 24px 20px;
    }

    .hero-copy {
        text-align: center;
    }

    .hero-actions {
        position: static;
        display: flex;
        justify-content: center;
        margin-top: 16px;
    }

    .frame-body {
        padding: 20px 16px 22px;
    }

    .stepper {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .step-line {
        display: none;
    }

    .step-item {
        padding: 12px 14px;
        border: 1px solid #e0e7f4;
        border-radius: 16px;
        background: #fff;
        flex-direction: row;
        text-align: left;
        justify-content: flex-start;
    }

    .detail-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .result-modal {
        padding: 16px;
    }

    .result-modal-dialog {
        padding: 20px 18px;
    }
}

@media (max-width: 540px) {
    .primary-card {
        padding: 18px;
    }

    .tab-switch {
        width: 100%;
    }

    .tab-btn {
        padding: 12px 10px;
        font-size: 0.94rem;
    }

    .hero-copy h1 {
        font-size: 1.55rem;
    }

    .status-title {
        font-size: 1.45rem;
    }

    .button-row {
        grid-template-columns: 1fr;
    }

    .field-input,
    .field-textarea {
        font-size: 0.95rem;
    }

    .turnstile-wrap {
        justify-content: stretch;
    }

    .toast {
        left: 12px;
        right: 12px;
        min-width: 0;
        max-width: none;
        top: 14px;
    }
}
