:root {
    --background: #f5f5f5;
    --surface: #ffffff;
    --text: #222222;
    --muted: #8a8a8a;
    --line: #eeeeee;
    --price: #e64340;
    --wechat: #07c160;
    --nav-height: 58px;
}

* { box-sizing: border-box; }

html {
    min-width: 320px;
    background: var(--background);
    -webkit-text-size-adjust: 100%;
}

body {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    color: var(--text);
    background: var(--background);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

button {
    font: inherit;
    -webkit-tap-highlight-color: transparent;
}

.tab-page { padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom)); }

.page-shell,
.detail-shell {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
}

.page-shell { padding: 10px; }

.product-grid {
    display: flex;
    flex-wrap: wrap;
    overflow: hidden;
    border-top: 1px solid var(--line);
    background: var(--surface);
}

.product-card {
    display: block;
    flex: 0 0 50%;
    width: 50%;
    max-width: 50%;
    min-width: 0;
    overflow: hidden;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.product-card:nth-child(odd) { border-right: 1px solid var(--line); }

.product-card:active,
.order-card:active { opacity: .82; }

.product-card__image-wrap {
    width: 100%;
    padding-top: 12px;
    background: var(--surface);
}

.product-card__image {
    display: block;
    width: 85%;
    height: auto;
    margin: 0 auto;
}

.product-card__body {
    width: 85%;
    min-width: 0;
    margin: 8px auto 10px;
    padding: 0;
}

.product-card h3 {
    margin: 0;
    overflow: hidden;
    font-size: 16px;
    font-weight: 400;
    line-height: 24px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.price,
.detail-price {
    margin: 7px 0 0;
    color: var(--price);
    font-family: Arial, sans-serif;
    font-weight: 600;
}

.price { margin-top: 2px; font-size: 16px; line-height: 24px; }
.price small { margin-right: 1px; font-size: 12px; }

.bottom-nav {
    position: fixed;
    z-index: 20;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    padding: 0 max(0px, calc((100vw - 480px) / 2)) env(safe-area-inset-bottom);
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, .97);
}

.bottom-nav a {
    display: grid;
    place-items: center;
    color: #777777;
    font-size: 13px;
}

.bottom-nav a.is-active { color: var(--wechat); font-weight: 600; }

.empty-card {
    display: grid;
    min-height: 62vh;
    place-items: center;
    color: var(--muted);
    font-size: 14px;
}

.detail-page {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
    background: var(--surface);
}

.detail-nav {
    position: absolute;
    z-index: 5;
    top: max(10px, env(safe-area-inset-top));
    left: max(10px, calc((100vw - 480px) / 2 + 10px));
}

.back-link {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border-radius: 50%;
    color: #ffffff;
    background: rgba(0, 0, 0, .42);
    font-size: 20px;
}

.detail-image-wrap {
    width: 100%;
    overflow: hidden;
    background: var(--surface);
}

.detail-image {
    display: block;
    width: 100%;
    height: auto;
}

.detail-card {
    padding: 17px 16px 24px;
    border-bottom: 8px solid var(--background);
    background: var(--surface);
}

.detail-card h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
    line-height: 26px;
    word-break: break-all;
}

.detail-price { font-size: 25px; line-height: 30px; }
.detail-price span { margin-left: 2px; }

.detail-description {
    margin: 15px 0 0;
    padding-top: 15px;
    border-top: 1px solid var(--line);
    color: #555555;
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.detail-description img {
    max-width: 100% !important;
    height: auto !important;
}

.detail-description table,
.detail-description iframe,
.detail-description video {
    max-width: 100% !important;
}

.detail-description > :first-child { margin-top: 0; }
.detail-description > :last-child { margin-bottom: 0; }

.checkout-bar {
    position: fixed;
    z-index: 20;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: calc(62px + env(safe-area-inset-bottom));
    padding: 9px max(12px, calc((100vw - 456px) / 2)) calc(9px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--surface);
}

.checkout-total strong { color: var(--price); font: 600 24px/1 Arial, sans-serif; }
.checkout-total strong span { margin-right: 2px; font-size: 13px; }

.pay-button {
    width: 150px;
    height: 44px;
    border: 0;
    border-radius: 22px;
    color: #ffffff;
    background: var(--wechat);
    font-size: 15px;
    font-weight: 600;
}

.pay-button:disabled { opacity: .6; }

.toast {
    position: fixed;
    z-index: 40;
    bottom: calc(82px + env(safe-area-inset-bottom));
    left: 50%;
    max-width: calc(100vw - 32px);
    padding: 10px 14px;
    border-radius: 5px;
    color: #ffffff;
    background: rgba(0, 0, 0, .78);
    font-size: 13px;
    opacity: 0;
    transform: translate(-50%, 8px);
    transition: .18s ease;
    pointer-events: none;
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.order-list { display: grid; gap: 10px; }

.order-card {
    display: flex;
    min-width: 0;
    gap: 11px;
    padding: 12px;
    border-radius: 8px;
    background: var(--surface);
}

.order-card__image {
    flex: 0 0 76px;
    width: 76px;
    height: 76px;
    border-radius: 5px;
    object-fit: cover;
    background: #ededed;
}

.order-card__content {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    justify-content: space-between;
}

.order-card__top,
.order-card__bottom {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.order-card h2 {
    display: -webkit-box;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.order-status {
    flex: 0 0 auto;
    color: #8a8a8a;
    font-size: 12px;
    line-height: 20px;
}

.order-status.status-paid { color: var(--wechat); }
.order-status.status-failed,
.order-status.status-closed { color: #999999; }

.order-card__bottom { align-items: flex-end; }
.order-card time { color: var(--muted); font-size: 10px; }
.order-card strong { color: var(--price); font: 600 16px/1 Arial, sans-serif; }

.result-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 20px 14px;
}

.result-shell { width: 100%; max-width: 420px; }

.result-card {
    padding: 30px 18px 18px;
    border-radius: 10px;
    text-align: center;
    background: var(--surface);
}

.result-icon,
.wechat-logo {
    display: grid;
    width: 58px;
    height: 58px;
    margin: 0 auto 18px;
    place-items: center;
    border-radius: 50%;
    color: #ffffff;
    background: #f2a33a;
    font-size: 24px;
    font-weight: 700;
}

.status-paid .result-icon,
.wechat-logo { background: var(--wechat); }
.status-failed .result-icon,
.status-closed .result-icon { background: var(--price); }
.result-card h1 { margin: 0; font-size: 21px; }

.result-hint {
    margin: 9px 0 20px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

.order-summary {
    margin: 0 0 18px;
    padding: 5px 13px;
    border-radius: 6px;
    background: var(--background);
    text-align: left;
}

.order-summary > div {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 0;
}

.order-summary > div + div { border-top: 1px solid #e7e7e7; }
.order-summary dt { flex: 0 0 auto; color: var(--muted); font-size: 12px; }

.order-summary dd {
    margin: 0;
    font-size: 12px;
    text-align: right;
    word-break: break-all;
}

.order-summary .summary-price { color: var(--price); font-size: 15px; font-weight: 600; }
.order-summary .order-number { max-width: 74%; font: 10px/1.5 ui-monospace, Consolas, monospace; }

.primary-link {
    display: block;
    height: 44px;
    border-radius: 22px;
    color: #ffffff;
    background: var(--wechat);
    font-size: 14px;
    font-weight: 600;
    line-height: 44px;
}

@media (max-width: 350px) {
    .page-shell { padding: 8px; }
    .pay-button { width: 138px; }
}

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