:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --border-focus: #2563eb;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: #eff6ff;
    --success: #059669;
    --success-bg: #ecfdf5;
    --error: #dc2626;
    --error-bg: #fef2f2;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.header {
    padding: 28px 28px 20px;
    border-bottom: 1px solid var(--border);
}

.header h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.header p {
    font-size: 14px;
    color: var(--text-secondary);
}

.body {
    padding: 24px 28px 28px;
}

.field-group {
    margin-bottom: 20px;
}

.field-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.mode-selector {
    display: flex;
    gap: 8px;
}

.mode-option {
    flex: 1;
    position: relative;
}

.mode-option input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.mode-option label {
    display: block;
    text-align: center;
    padding: 10px 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.mode-option input:checked + label {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

.mode-option label:hover {
    border-color: var(--text-muted);
}

.input-wrap {
    position: relative;
}

.code-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 500;
    letter-spacing: 0.05em;
    color: var(--text-primary);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: var(--transition);
}

.code-input::placeholder {
    color: var(--text-muted);
    font-family: inherit;
    letter-spacing: 0;
}

.code-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.code-input.error {
    border-color: var(--error);
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}

.hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    min-height: 18px;
}

.hint.error-text {
    color: var(--error);
}

.btn-primary {
    width: 100%;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.result-panel {
    margin-top: 20px;
    padding: 16px 20px;
    border-radius: var(--radius);
    border: 1.5px solid transparent;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 200ms ease, transform 200ms ease;
    display: none;
}

.result-panel.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.result-panel.success {
    background: var(--success-bg);
    border-color: #a7f3d0;
}

.result-panel.error {
    background: var(--error-bg);
    border-color: #fecaca;
}

.result-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.result-panel.success .result-label {
    color: var(--success);
}

.result-panel.error .result-label {
    color: var(--error);
}

.result-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.result-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.04em;
    word-break: break-all;
}

.result-panel.success .result-value {
    color: #065f46;
}

.result-panel.error .result-value {
    color: #991b1b;
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
}

.copy-btn {
    flex-shrink: 0;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--success);
    background: #fff;
    border: 1.5px solid #a7f3d0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.copy-btn:hover {
    background: #d1fae5;
}

.copy-btn.copied {
    color: var(--text-secondary);
    border-color: var(--border);
    background: var(--bg);
}

@media (max-width: 480px) {
    body {
        padding: 16px;
        align-items: flex-start;
        padding-top: 40px;
    }
    .header, .body {
        padding-left: 20px;
        padding-right: 20px;
    }
}

/* ========== 赞助弹窗 ========== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 250ms ease;
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
}

.modal-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.15), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    width: 90%;
    max-width: 360px;
    position: relative;
    padding: 24px;
    transform: scale(0.92) translateY(8px);
    transition: transform 250ms cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.show .modal-card {
    transform: scale(1) translateY(0);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 20px;
    line-height: 1;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--error-bg);
    color: var(--error);
}

.modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.modal-text {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    text-align: center;
    line-height: 1.6;
    margin: 4px 24px 0 0;
}

.modal-img {
    width: 220px;
    height: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.modal-tip {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: -4px;
}
