:root {
    color-scheme: light;
    --ink: #173042;
    --muted: #68788a;
    --line: #d8e1e8;
    --surface: #fff;
    --soft: #f4f8fa;
    --primary: #1e6171;
    --primary-dark: #173d4d;
    --accent: #17786c;
    --danger: #ad2940;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: #eaf1f5;
    font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
    letter-spacing: 0;
}
button, input, select { font: inherit; letter-spacing: 0; }
.site-shell { width: min(900px, calc(100% - 30px)); margin: 0 auto; padding: 40px 0 24px; }
.redeem-card { padding: 36px; border: 1px solid #e2e9ee; border-radius: 12px; background: var(--surface); box-shadow: 0 20px 55px rgba(23, 48, 66, .11); }
.site-header { display: flex; align-items: center; justify-content: center; gap: 15px; margin-bottom: 32px; }
.brand-mark { display: grid; width: 54px; height: 54px; flex: 0 0 54px; place-items: center; border-radius: 7px; color: #fff; background: var(--primary-dark); font-size: 18px; font-weight: 800; }
.site-header h1 { margin: 0 0 5px; font-size: 31px; line-height: 1.2; }
.site-header p { margin: 0; color: var(--muted); font-size: 14px; }
.announcement, .alert { margin-bottom: 20px; padding: 14px 16px; border-radius: 7px; line-height: 1.65; }
.announcement { border: 1px solid #ead39a; color: #725316; background: #fff9eb; }
.alert-error { border: 1px solid #efbbc4; color: #8c2036; background: #fff3f5; }
.alert-success { border: 1px solid #a8d7ce; color: #0d6157; background: #eef9f7; }
.result-meta { margin-top: 5px; color: #55726f; font-size: 13px; }
.redeem-form { display: grid; gap: 20px; }
.field label { display: block; margin-bottom: 8px; color: #2d4556; font-size: 14px; font-weight: 700; }
.field input, .field select { width: 100%; min-height: 55px; padding: 0 16px; border: 1px solid var(--line); border-radius: 7px; outline: 0; color: #1d3445; background: #fff; font-size: 16px; }
.field input:focus, .field select:focus { border-color: #5e8c9c; box-shadow: 0 0 0 3px rgba(30, 97, 113, .12); }
.field-hint { display: block; margin-top: 6px; color: #8995a2; font-size: 12px; }
.primary-button, .history-button { display: flex; min-height: 56px; align-items: center; justify-content: center; gap: 10px; border-radius: 7px; cursor: pointer; text-decoration: none; font-weight: 700; }
.primary-button { border: 0; color: #fff; background: linear-gradient(90deg, var(--primary), var(--primary-dark)); box-shadow: 0 8px 20px rgba(23, 61, 77, .16); font-size: 17px; }
.primary-button:hover { opacity: .94; transform: translateY(-1px); }
.primary-button:disabled { opacity: .48; cursor: not-allowed; transform: none; }
.history-button { min-height: 50px; border: 1px solid #b9c9d1; color: #27495b; background: #f8fbfc; font-size: 15px; }
.history-button:hover { border-color: #7194a2; background: #f0f6f7; }
.code-result { display: flex; align-items: stretch; gap: 10px; margin-top: 13px; }
.code-result code { display: flex; min-width: 0; flex: 1; align-items: center; overflow-wrap: anywhere; padding: 12px 14px; border: 1px dashed #69a99e; border-radius: 6px; color: #9f1731; background: #fff; font-family: Consolas, monospace; font-size: 21px; font-weight: 700; }
.copy-button { min-width: 78px; border: 0; border-radius: 6px; color: #fff; background: var(--accent); cursor: pointer; }
.rules { margin-top: 28px; padding: 19px; border-left: 4px solid var(--accent); border-radius: 5px; color: #536474; background: var(--soft); }
.rules-heading { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; color: #243d4c; }
.rules-icon { display: grid; width: 22px; height: 22px; place-items: center; border-radius: 50%; color: #fff; background: var(--accent); font-family: Georgia, serif; font-weight: 700; }
.rules-content { line-height: 1.9; font-size: 15px; }
.site-footer { display: flex; justify-content: space-between; padding: 17px 8px 0; color: #7b8995; font-size: 12px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 10; padding: 11px 16px; border-radius: 6px; color: #fff; background: #173d4d; opacity: 0; pointer-events: none; transform: translateY(10px); transition: opacity 160ms ease, transform 160ms ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
body.popup-open { overflow: hidden; }
.auto-popup { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; opacity: 0; pointer-events: none; transition: opacity 180ms ease; }
.auto-popup.is-visible { opacity: 1; pointer-events: auto; }
.auto-popup-backdrop { position: absolute; inset: 0; background: rgba(15, 31, 45, .58); }
.auto-popup-dialog { position: relative; z-index: 1; display: grid; grid-template-rows: auto minmax(260px, var(--popup-height, 620px)); width: min(960px, 100%); max-height: calc(100vh - 40px); overflow: hidden; border-radius: 8px; background: #fff; box-shadow: 0 24px 70px rgba(15, 31, 45, .28); transform: translateY(8px); transition: transform 180ms ease; }
.auto-popup.is-visible .auto-popup-dialog { transform: translateY(0); }
.auto-popup-header { display: flex; min-height: 54px; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px 0 20px; border-bottom: 1px solid var(--line); }
.auto-popup-header h2 { min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
.auto-popup-close { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border: 0; border-radius: 6px; color: #34485a; background: #eef3f7; cursor: pointer; font-size: 24px; line-height: 1; }
.auto-popup iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 27px; }
.page-heading .site-header { justify-content: flex-start; margin: 0; }
.back-button { flex: 0 0 auto; color: #526676; text-decoration: none; font-size: 14px; }
.history-search { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; margin-bottom: 28px; }
.history-search .primary-button { align-self: end; min-width: 128px; box-shadow: none; }
.history-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.history-summary h2 { margin: 0; font-size: 18px; }
.status-pill { display: inline-flex; min-height: 26px; align-items: center; padding: 0 9px; border-radius: 4px; font-size: 12px; font-weight: 700; }
.status-pill.used { color: #0e655b; background: #e8f6f3; }
.status-pill.available { color: #7a5917; background: #fff3d5; }
.result-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 20px 0 4px; }
.result-detail span, .result-detail strong { display: block; }
.result-detail span { margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.history-empty { padding: 32px 12px 8px; color: var(--muted); text-align: center; line-height: 1.8; }

@media (max-width: 640px) {
    .site-shell { width: min(100% - 20px, 900px); padding-top: 15px; }
    .redeem-card { padding: 23px 18px; border-radius: 9px; }
    .site-header { align-items: flex-start; justify-content: flex-start; gap: 11px; margin-bottom: 25px; }
    .brand-mark { width: 44px; height: 44px; flex-basis: 44px; font-size: 15px; }
    .site-header h1 { font-size: 22px; }
    .site-header p { font-size: 12px; }
    .code-result { flex-direction: column; }
    .code-result code { font-size: 17px; }
    .copy-button { min-height: 44px; }
    .page-heading { align-items: flex-start; }
    .page-heading .site-header { flex: 1; }
    .back-button { padding-top: 11px; }
    .history-search, .result-detail { grid-template-columns: 1fr; }
    .history-search .primary-button { width: 100%; }
    .site-footer { gap: 10px; }
    .auto-popup { padding: 10px; }
    .auto-popup-dialog { grid-template-rows: auto minmax(260px, min(var(--popup-height, 620px), calc(100vh - 74px))); max-height: calc(100vh - 20px); }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .01ms !important; } }
