:root {
    --canvas: #f3f5f7;
    --canvas-grid: rgba(29, 41, 57, 0.035);
    --surface: rgba(255, 255, 255, 0.88);
    --surface-solid: #ffffff;
    --surface-muted: #f7f9fb;
    --ink: #161a1d;
    --ink-soft: #374151;
    --muted: #66717a;
    --line: #dfe5ea;
    --line-strong: #cbd4dc;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --accent-soft: rgba(37, 99, 235, 0.09);
    --success: #0f8a68;
    --success-soft: rgba(15, 138, 104, 0.1);
    --warning: #a76518;
    --warning-soft: rgba(183, 121, 31, 0.11);
    --danger: #b83b36;
    --danger-soft: #fff1f0;
    --alipay: #1677ff;
    --wechat: #07a957;
    --shadow-panel: 0 22px 64px rgba(28, 39, 50, 0.1), 0 2px 8px rgba(28, 39, 50, 0.04);
    --shadow-button: 0 12px 24px rgba(22, 26, 29, 0.14);
    --focus-outline: #174ebf;
    --focus-ring: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

* { box-sizing: border-box; }

html {
    min-width: 320px;
    min-height: 100%;
    background: var(--canvas);
}

body {
    position: relative;
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font-family: "HarmonyOS Sans SC", "MiSans", "Source Han Sans CN", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    letter-spacing: 0;
}

body::before {
    position: fixed;
    z-index: -1;
    inset: 0;
    content: "";
    pointer-events: none;
    background:
        linear-gradient(var(--canvas-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--canvas-grid) 1px, transparent 1px);
    background-size: 72px 72px;
    mask-image: linear-gradient(to bottom, #000, transparent 76%);
}

button,
input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1,
p { margin-top: 0; }

.public-shell {
    min-height: 100svh;
    padding: 32px;
    display: grid;
    place-items: center;
}

.public-workspace {
    width: min(1080px, 100%);
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    align-items: stretch;
}

.public-workspace.is-single {
    grid-template-columns: minmax(0, 520px);
    justify-content: center;
}

.workspace-panel {
    min-width: 0;
    min-height: 470px;
    padding: 28px;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.92);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-panel), inset 0 1px 0 rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(24px) saturate(135%);
    backdrop-filter: blur(24px) saturate(135%);
}

.panel-heading {
    min-height: 36px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
}

.panel-heading-inline { justify-content: space-between; gap: 18px; }
.panel-heading h1 { margin: 0; font-size: 23px; font-weight: 760; line-height: 1.2; }

.panel-price {
    display: inline-flex;
    align-items: baseline;
    color: var(--ink-soft);
    white-space: nowrap;
}

.panel-price span { margin-right: 3px; color: var(--accent); font-size: 15px; font-weight: 760; }
.panel-price strong {
    font-family: "Bahnschrift", "DIN Alternate", "Microsoft YaHei", sans-serif;
    font-size: 25px;
    font-weight: 650;
    line-height: 1;
}

.panel-form {
    min-height: 0;
    display: flex;
    flex: 1;
    flex-direction: column;
}

.field-group { margin-bottom: 16px; }
.field-group label,
.payment-fieldset legend {
    display: block;
    margin-bottom: 6px;
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 700;
}

.field-group input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    color: var(--ink);
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.72);
    outline: none;
    transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.field-group input::placeholder { color: #7b858e; }
.field-group input:hover { border-color: #abb7c1; background: #fff; }
.field-group input:focus { border-color: var(--accent); background: #fff; box-shadow: var(--focus-ring); }
.field-group input:focus-visible { outline: 2px solid var(--focus-outline); outline-offset: 2px; }

.payment-fieldset { min-width: 0; margin: 0 0 18px; padding: 0; border: 0; }
.payment-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.payment-option { min-width: 0; cursor: pointer; }
.payment-option:only-child { grid-column: 1 / -1; }
.payment-option input { position: absolute; opacity: 0; pointer-events: none; }

.payment-choice {
    min-height: 56px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: rgba(247, 249, 251, 0.72);
    transition: border-color 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.payment-choice:hover { border-color: #aeb9c3; background: #fff; }
.payment-logo {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    flex: 0 0 30px;
    color: #fff;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 800;
}

.payment-alipay .payment-logo { background: var(--alipay); }
.payment-wechat .payment-logo { background: var(--wechat); }
.payment-choice strong { min-width: 0; font-size: 13px; overflow-wrap: anywhere; }
.radio-dot {
    width: 16px;
    height: 16px;
    margin-left: auto;
    flex: 0 0 16px;
    border: 1px solid #a9b4be;
    border-radius: 50%;
    box-shadow: inset 0 0 0 4px #fff;
}

.payment-option input:checked + .payment-choice {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 1px var(--accent);
}

.payment-option input:checked + .payment-choice .radio-dot { border-color: var(--accent); background: var(--accent); }
.payment-option input:focus-visible + .payment-choice { outline: 2px solid var(--focus-outline); outline-offset: 3px; }

.primary-button,
.secondary-button,
.download-button {
    min-height: 50px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border: 1px solid transparent;
    border-radius: 7px;
    cursor: pointer;
    font-weight: 740;
    transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.primary-button {
    width: 100%;
    margin-top: auto;
    color: #fff;
    background: #20252b;
    box-shadow: var(--shadow-button), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.primary-button:hover:not(:disabled) { background: var(--accent-dark); box-shadow: 0 14px 28px rgba(37, 99, 235, 0.2); }
.primary-button:active:not(:disabled),
.download-button:active:not(:disabled) { transform: translateY(1px); }
.primary-button:focus-visible,
.secondary-button:focus-visible,
.download-button:focus-visible,
.text-link:focus-visible,
.purchase-again-link:focus-visible,
.mobile-tab:focus-visible { outline: 3px solid var(--focus-outline); outline-offset: 3px; }
.primary-button:disabled { color: #87919a; background: #dfe4e8; box-shadow: none; cursor: not-allowed; }
.button-end-icon { width: 18px; height: 18px; margin-left: auto; stroke: currentColor; }

.secondary-button { color: var(--ink); border-color: var(--line-strong); background: rgba(255, 255, 255, 0.72); }
.secondary-button:hover { color: var(--accent-dark); border-color: var(--accent); background: #fff; }
.is-submitting { pointer-events: none; opacity: 0.75; }
.is-submitting .button-end-icon { animation: softPulse 900ms ease-in-out infinite; }

.notice { margin: -4px 0 14px; padding: 10px 12px; border: 1px solid; border-radius: 7px; font-size: 12px; }
.notice-error { color: #8c2e2a; border-color: rgba(184, 59, 54, 0.22); background: var(--danger-soft); }

.result-panel { justify-content: flex-start; }
.status-pill {
    padding: 5px 9px;
    color: var(--ink-soft);
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-muted);
    font-size: 11px;
    font-weight: 720;
    white-space: nowrap;
}

.status-issued { color: #087357; border-color: rgba(15, 138, 104, 0.18); background: var(--success-soft); }
.status-pending { color: #8c5514; border-color: rgba(167, 101, 24, 0.18); background: var(--warning-soft); }
.status-issuance_failed { color: var(--danger); border-color: rgba(184, 59, 54, 0.18); background: var(--danger-soft); }

.summary-list { margin: 0; border-top: 1px solid var(--line); }
.summary-list div {
    min-width: 0;
    padding: 13px 0;
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
    border-bottom: 1px solid var(--line);
}

.summary-list dt { color: var(--muted); font-size: 12px; }
.summary-list dd { min-width: 0; margin: 0; color: var(--ink-soft); font-weight: 680; text-align: right; }
.summary-value { overflow-wrap: anywhere; }
.mono { font-family: Consolas, "SFMono-Regular", monospace; letter-spacing: 0; }
.state-copy { margin: 18px 0 0; color: var(--muted); font-size: 13px; }

.download-form { margin-top: 22px; }
.download-button {
    width: 100%;
    min-height: 54px;
    justify-content: flex-start;
    color: #fff;
    background: #151b22;
    box-shadow: 0 14px 30px rgba(21, 27, 34, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.download-button:hover:not(:disabled) { background: var(--accent-dark); box-shadow: 0 16px 32px rgba(37, 99, 235, 0.22); }
.download-feedback {
    margin: 10px 2px 0;
    color: var(--danger);
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
}
.download-icon {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    flex: 0 0 34px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.12);
}

.download-icon-svg { width: 18px; height: 18px; stroke: currentColor; }
.download-button.is-submitting .download-icon-svg { animation: softPulse 850ms ease-in-out infinite; }
.text-link { margin-top: auto; padding-top: 18px; color: var(--accent-dark); font-size: 12px; font-weight: 700; align-self: flex-start; }
.text-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.status-panel { position: relative; align-items: center; justify-content: center; text-align: center; }
.purchase-again-link {
    position: absolute;
    top: 24px;
    left: 24px;
    min-height: 34px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    transition: color 180ms ease, background-color 180ms ease, transform 180ms ease;
}
.purchase-again-link:hover { color: var(--ink); background: rgba(22, 26, 29, 0.055); }
.purchase-again-link:active { transform: translateX(-1px); }
.purchase-again-icon { width: 16px; height: 16px; flex: 0 0 16px; stroke: currentColor; }
.status-panel h1 { margin: 0 0 8px; font-size: 25px; line-height: 1.2; }
.status-panel form,
.status-panel .download-form { width: min(100%, 360px); }
.status-panel .primary-button,
.status-panel .secondary-button { width: min(100%, 360px); margin-top: 20px; }
.status-panel .download-form .download-button { margin-top: 0; }
.status-order { max-width: 100%; margin: 0 0 4px; color: var(--muted); overflow-wrap: anywhere; }
.status-icon {
    width: 52px;
    height: 52px;
    margin-bottom: 18px;
    display: grid;
    place-items: center;
    color: var(--accent);
    border: 1px solid rgba(37, 99, 235, 0.18);
    border-radius: 50%;
    background: var(--accent-soft);
}

.status-icon-svg { width: 27px; height: 27px; stroke: currentColor; }
.status-icon.is-success { color: var(--success); border-color: rgba(15, 138, 104, 0.18); background: var(--success-soft); }
.status-icon.is-pending { color: var(--warning); border-color: rgba(167, 101, 24, 0.18); background: var(--warning-soft); }
.status-icon.is-error { color: var(--danger); border-color: rgba(184, 59, 54, 0.18); background: var(--danger-soft); }
.status-icon.is-loading {
    border: 3px solid rgba(37, 99, 235, 0.15);
    border-top-color: var(--accent);
    background: transparent;
    animation: spin 850ms linear infinite;
}

.compact-summary { width: min(100%, 390px); margin-top: 12px; }
.error-panel { min-height: 360px; }
.mobile-tabbar { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes softPulse { 50% { opacity: 0.45; } }

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .workspace-panel,
    .mobile-tabbar { background: rgba(255, 255, 255, 0.98); }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 1ms !important;
    }
}

@media (max-width: 900px) {
    .public-shell { padding: 22px; }
    .public-workspace { gap: 13px; }
    .workspace-panel { padding: 22px; }
}

@media (max-width: 760px) {
    body { min-height: 100dvh; overflow: hidden; }
    body::before { background-size: 56px 56px; }

    .public-shell {
        width: 100%;
        height: 100dvh;
        min-height: 520px;
        padding: clamp(18px, 6vh, 44px) 10px calc(72px + env(safe-area-inset-bottom, 0px));
        display: flex;
        align-items: flex-start;
        overflow: hidden;
    }

    .public-workspace,
    .public-workspace.is-single { width: 100%; max-height: 100%; display: block; }
    .public-workspace[data-mobile-view="purchase"] > .query-panel,
    .public-workspace[data-mobile-view="query"] > .purchase-panel { display: none; }

    .workspace-panel {
        width: 100%;
        min-height: 0;
        max-height: calc(100dvh - 94px - env(safe-area-inset-bottom, 0px));
        padding: 18px;
        overflow-y: auto;
        overscroll-behavior: contain;
        box-shadow: 0 14px 40px rgba(28, 39, 50, 0.09), inset 0 1px 0 #fff;
    }

    .panel-heading { min-height: 30px; margin-bottom: 13px; }
    .panel-heading h1 { font-size: 21px; }
    .panel-price strong { font-size: 22px; }
    .field-group { margin-bottom: 10px; }
    .field-group label,
    .payment-fieldset legend { margin-bottom: 4px; }
    .field-group input { height: 44px; }
    .payment-fieldset { margin-bottom: 12px; }
    .payment-options { gap: 7px; }
    .payment-choice { min-height: 46px; padding: 6px 8px; gap: 7px; }
    .payment-logo { width: 27px; height: 27px; flex-basis: 27px; }
    .payment-choice strong { font-size: 12px; }
    .primary-button,
    .secondary-button { min-height: 46px; }
    .download-form { margin-top: 16px; }
    .download-button { min-height: 50px; }
    .summary-list div { padding: 10px 0; grid-template-columns: 76px minmax(0, 1fr); gap: 10px; }
    .status-panel h1 { font-size: 23px; }
    .purchase-again-link { top: 14px; left: 14px; }
    .status-icon { width: 48px; height: 48px; margin-bottom: 14px; }
    .state-copy { margin-top: 13px; }
    .text-link { padding-top: 14px; }

    .mobile-tabbar {
        position: fixed;
        z-index: 30;
        right: 10px;
        bottom: calc(8px + env(safe-area-inset-bottom, 0px));
        left: 10px;
        height: 56px;
        padding: 4px;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        border: 1px solid rgba(255, 255, 255, 0.94);
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.9);
        box-shadow: 0 16px 40px rgba(28, 39, 50, 0.16), inset 0 1px 0 #fff;
        -webkit-backdrop-filter: blur(22px) saturate(145%);
        backdrop-filter: blur(22px) saturate(145%);
    }

    .mobile-tab {
        min-width: 0;
        min-height: 46px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        color: var(--muted);
        border-radius: 6px;
        font-size: 13px;
        font-weight: 700;
        transition: color 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
    }

    .mobile-tab.is-active { color: #fff; background: #20252b; box-shadow: 0 7px 16px rgba(22, 26, 29, 0.16); }
    .tab-icon { width: 17px; height: 17px; stroke: currentColor; }
}

@media (max-width: 360px) {
    .public-shell { padding-right: 8px; padding-left: 8px; }
    .workspace-panel { padding: 15px; }
    .purchase-again-link { top: 10px; left: 10px; }
    .field-group input { padding: 0 11px; }
    .payment-choice { padding-right: 7px; padding-left: 7px; }
    .payment-logo { width: 25px; height: 25px; flex-basis: 25px; }
    .mobile-tabbar { right: 8px; left: 8px; }
}

@media (max-width: 760px) and (max-height: 650px) {
    .public-shell { padding-top: 14px; }
    .workspace-panel { padding: 14px; }
    .panel-heading { margin-bottom: 10px; }
    .field-group { margin-bottom: 8px; }
    .payment-fieldset { margin-bottom: 9px; }
    .status-icon { margin-bottom: 10px; }
    .status-panel .primary-button,
    .status-panel .secondary-button { margin-top: 14px; }
}
