:root {
    color-scheme: light;
    --ink: #10213b;
    --muted: #52627b;
    --line: #dce5f2;
    --accent: #204cbb;
    --surface: #f2f5fa;
    --card: #fff;
    --radius: 18px;
    --shadow: 0 6px 18px #10213b0a;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    background: var(--surface);
    color: var(--ink);
    font-family: system-ui, "Microsoft YaHei", sans-serif;
    line-height: 1.55;
}
main { flex: 1; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #638bff; outline-offset: 3px; }
.wrap { width: min(1104px, calc(100% - 40px)); margin-inline: auto; }
.site-header { background: #11223d; color: #fff; }
.header-row, .account { display: flex; align-items: center; }
.header-row { min-height: 66px; justify-content: space-between; gap: 14px; }
.brand { font-size: 20px; font-weight: 780; white-space: nowrap; }
.account { gap: 16px; font-size: 14px; }
.account a { display: inline-flex; align-items: center; min-height: 42px; }
.account .account-link { padding-inline: 13px; background: #ffffff16; border-radius: 10px; font-weight: 650; }

.catalog { padding-top: 36px; }
.catalog-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.catalog-heading h1, .page-heading { margin: 0; font-size: clamp(27px, 5vw, 40px); letter-spacing: -.035em; line-height: 1.2; }
.catalog-heading > span, .category, .site-footer { color: var(--muted); font-size: 13px; }
.catalog-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin: 20px 0 12px; }
.catalog-tools :is(select, input) {
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card);
    color: var(--ink);
}
.catalog-search { position: relative; }
.catalog-search input { width: 100%; padding: 8px 12px 8px 40px; }
.catalog-tools select { max-width: 100%; padding-inline: 10px; }
.search-icon { position: absolute; inset: 15px auto auto 14px; width: 13px; height: 13px; border: 2px solid var(--muted); border-radius: 50%; pointer-events: none; }
.search-icon::after { content: ""; position: absolute; width: 6px; height: 2px; background: var(--muted); transform: rotate(45deg); top: 10px; left: 8px; }
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 4px 4px 12px; margin: 0 -4px 8px; scrollbar-width: thin; }
.filter {
    flex: 0 0 auto;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 14px;
    background: var(--card);
    color: var(--ink);
    font-size: 14px;
    white-space: nowrap;
}
.filter[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 24px; }
.pagination button:disabled { opacity: .45; cursor: default; }

.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.product-card, .product-overview, .product-content {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow);
}
.product-card:hover { border-color: #829dd7; }
.card-link { display: flex; flex-direction: column; height: 100%; border-radius: inherit; overflow: hidden; }
.cover { display: block; width: 100%; aspect-ratio: 5 / 3; object-fit: contain; background: #142138; }
.card-copy { padding: 12px 14px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.category { margin: 0; overflow-wrap: anywhere; }
.card-copy h3 { margin: 0; font-size: 16px; line-height: 1.4; overflow-wrap: anywhere; }
.card-bottom { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 4px; padding-top: 6px; }
.card-bottom strong, .detail-price, .checkout-price { color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.detail-link { display: grid; place-items: center; width: 25px; height: 25px; flex: 0 0 auto; border-radius: 50%; background: #eaf1ff; color: var(--accent); font-size: 20px; line-height: 1; }
.summary { margin: 0; color: var(--muted); grid-column: 1 / -1; }
.site-footer { margin-top: 34px; padding: 20px 0 max(24px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.site-footer p { margin: 5px 0; }
.site-footer a, .back-link { color: var(--accent); font-weight: 650; }

.product-page, .checkout-page { padding-top: 22px; }
.back-link { display: inline-flex; align-items: center; min-height: 44px; margin-bottom: 8px; font-size: 14px; }
.product-overview { display: grid; grid-template-columns: 1fr 1fr; align-items: stretch; overflow: hidden; }
.detail-cover-frame { display: grid; align-items: center; min-width: 0; background: #142138; }
.detail-cover-frame .cover { max-height: 440px; }
.product-intro { min-width: 0; padding: clamp(20px, 4vw, 42px); }
.eyebrow { margin: 0 0 8px; font-size: 13px; font-weight: 720; color: var(--accent); }
.product-intro h1 { margin: 0 0 8px; font-size: clamp(26px, 4vw, 42px); line-height: 1.2; overflow-wrap: anywhere; }
.product-summary { margin: 17px 0 0; color: var(--muted); }
.purchase-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 22px; }
.detail-price { font-size: clamp(24px, 5vw, 32px); }
.primary-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 10px 22px;
    border: 0;
    border-radius: 12px;
    background: var(--accent);
    color: #fff;
    font-weight: 720;
    white-space: nowrap;
}
.primary-action:active { filter: brightness(.9); }
.product-content { margin-top: 16px; padding: clamp(18px, 4vw, 30px); }
.product-content h2 { margin: 0 0 10px; font-size: 19px; }
.product-content p { margin: 0; }
#product-detail .product-content p { white-space: pre-line; }

.checkout-page { max-width: 780px; }
.checkout-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; gap: 14px; }
.checkout-order { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.checkout-order strong { overflow-wrap: anywhere; }
.checkout-cover { overflow: hidden; border-radius: 9px; }
.checkout-cover .cover { aspect-ratio: 1; }
.checkout-total { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0; color: var(--muted); }
.checkout-total strong { font-size: 25px; }
.wechat-pay { width: 100%; background: #097345; }
.checkout-message:not(:empty) { margin-top: 12px; padding: 10px 13px; border-radius: 9px; background: #fff3d8; color: #744506; }

@media (max-width: 900px) {
    .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
    .wrap { width: calc(100% - 28px); }
    .header-row { min-height: 58px; }
    .catalog { padding-top: 24px; }
    .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .card-copy { padding: 10px; }
    .card-copy h3 { font-size: 14px; }
    .product-overview, .checkout-layout { grid-template-columns: 1fr; }
    .checkout-layout { gap: 0; }
    .product-page:has(.purchase-bar) ~ .site-footer { margin-bottom: calc(72px + env(safe-area-inset-bottom)); }
    .purchase-bar {
        position: fixed;
        z-index: 2;
        inset: auto 0 0;
        margin: 0;
        padding: 10px max(16px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
        background: var(--card);
        border-top: 1px solid var(--line);
        box-shadow: 0 -5px 18px #10213b12;
    }
    .purchase-bar a { min-width: 46%; }
}
