:root {
    --bg: #f8f3ea;
    --surface: #fffdf8;
    --surface-strong: #fff7eb;
    --text: #1f1a14;
    --muted: #6a5c4d;
    --line: #e3d5c4;
    --primary: #b2502f;
    --primary-dark: #8f3c20;
    --accent: #2f6b5f;
    --danger: #9f3030;
    --shadow: 0 20px 60px rgba(65, 38, 20, 0.08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Noto Sans TC", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top right, rgba(178, 80, 47, 0.12), transparent 30%),
        linear-gradient(180deg, #fffaf3 0%, var(--bg) 100%);
}
body.nav-open { overflow: hidden; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }

.container { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
    background: rgba(255, 250, 243, 0.92);
    border-bottom: 1px solid rgba(227, 213, 196, 0.8);
}
.nav-bar, .nav-links, .hero-actions, .card-actions, .inline-form, .section-head, .cart-summary, .footer-grid, .nav-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}
.nav-bar { justify-content: space-between; padding: 16px 0; }
.nav-actions { justify-content: flex-end; }
.nav-drawer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1090;
}
.nav-links {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 72px 20px 20px;
    border-left: 1px solid rgba(227, 213, 196, 0.9);
    border-radius: 0;
    background:
        radial-gradient(circle at top right, rgba(178, 80, 47, 0.16), transparent 32%),
        linear-gradient(180deg, rgba(255, 253, 248, 0.99), rgba(248, 243, 234, 0.98));
    box-shadow: -20px 0 48px rgba(65, 38, 20, 0.18);
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(360px, calc(100vw - 28px));
    min-height: 100dvh;
    z-index: 1100;
    overflow-y: auto;
    transform: translateX(104%);
    transition: transform 0.28s ease;
}
.nav-panel-head {
    margin-bottom: 10px;
    padding: 10px 4px 14px;
    border-bottom: 1px solid rgba(227, 213, 196, 0.8);
}
.nav-panel-kicker {
    display: inline-block;
    margin-bottom: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(178, 80, 47, 0.12);
    color: var(--primary-dark);
    font-size: 11px;
    letter-spacing: 0.12em;
}
.nav-panel-head strong {
    display: block;
    font-family: "Noto Serif TC", serif;
    font-size: 24px;
    line-height: 1.1;
}
.nav-panel-head p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.6;
}
.nav-close-button {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(227, 213, 196, 0.9);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--text);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(65, 38, 20, 0.08);
}
.nav-close-button:hover {
    background: #fff;
    color: var(--primary-dark);
}
.nav-links a {
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 52px;
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(227, 213, 196, 0.88);
    color: var(--text);
    box-shadow: 0 6px 16px rgba(65, 38, 20, 0.04);
}
.nav-links a:hover {
    color: var(--primary-dark);
    background: #fff;
    transform: translateY(-1px);
}
.nav-links a::after {
    content: "›";
    color: var(--primary);
    font-size: 20px;
    line-height: 1;
}
.cart-link {
    padding: 10px 16px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--primary), #d68d4a);
    color: #fff;
    box-shadow: 0 12px 24px rgba(178, 80, 47, 0.18);
}
.cart-link:hover {
    color: #fff;
    transform: translateY(-1px);
}
.nav-overlay { display: none; }
.nav-toggle-button {
    display: inline-flex;
    min-width: 112px;
    height: 52px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(245, 235, 221, 0.98));
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    gap: 10px;
    box-shadow: 0 14px 28px rgba(65, 38, 20, 0.1);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.nav-toggle-icon {
    display: inline-flex;
    width: 22px;
    flex-direction: column;
    gap: 5px;
}
.nav-toggle-icon span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text);
    border-radius: 999px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav-toggle-text {
    font-size: 12px;
    letter-spacing: 0.12em;
    color: var(--primary-dark);
    font-weight: 700;
}
.nav-toggle-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 32px rgba(65, 38, 20, 0.14);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand strong, h1, h2, h3, h4 { font-family: "Noto Serif TC", serif; }
.brand small { display: block; color: var(--muted); }
.brand-badge {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), #d68d4a);
    color: #fff;
    font-weight: 700;
}
.site-header.nav-open .nav-links {
    transform: translateX(0);
}
.site-header.nav-open .nav-drawer {
    pointer-events: auto;
}
.page-shell { padding: 28px 0 64px; min-height: calc(100vh - 160px); }
.flash {
    margin-bottom: 20px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
}
.flash-success { background: #edf8f3; color: #1c5d46; }
.flash-error { background: #fff0ee; color: var(--danger); }

.hero, .checkout-grid, .product-detail, .category-grid, .product-grid {
    display: grid;
    gap: 24px;
}
.hero {
    grid-template-columns: 1.5fr 1fr;
    padding: 40px;
    border-radius: 28px;
    background: linear-gradient(135deg, rgba(178, 80, 47, 0.95), rgba(47, 107, 95, 0.92));
    color: #fffefb;
    box-shadow: var(--shadow);
}
.eyebrow { font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.84; }
.hero h1 { margin: 10px 0 16px; font-size: clamp(36px, 5vw, 58px); line-height: 1.08; }
.hero p { color: rgba(255, 255, 255, 0.9); }
.promo-card, .summary-card, .form-card, .table-card, .empty-card, .success-card {
    padding: 24px;
    border-radius: 24px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.invoice-mode-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.invoice-mode-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.76);
    cursor: pointer;
    transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.invoice-mode-card input {
    width: auto;
    margin: 0;
}
.invoice-mode-card strong {
    font-size: 16px;
}
.invoice-mode-card span {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}
.invoice-mode-card:has(input:checked) {
    border-color: rgba(178, 80, 47, 0.5);
    background: linear-gradient(180deg, rgba(255, 247, 235, 0.96), rgba(255, 255, 255, 0.98));
    box-shadow: 0 12px 24px rgba(178, 80, 47, 0.08);
    transform: translateY(-1px);
}
.invoice-fields {
    display: grid;
    gap: 16px;
    margin-bottom: 8px;
}
.invoice-fields[hidden] {
    display: none !important;
}
.promo-card { background: rgba(255, 250, 243, 0.16); border: 1px solid rgba(255,255,255,0.16); }
.section { margin-top: 32px; }
.section-head { justify-content: space-between; margin-bottom: 18px; }
.category-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.category-card, .product-card {
    border-radius: 22px;
    overflow: hidden;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.category-card {
    padding: 24px;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: linear-gradient(180deg, #fff8ef, #fffefb);
    border: 1px solid var(--line);
}
.product-grid { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.product-card-body { padding: 18px; }
.product-card img { aspect-ratio: 4 / 3; object-fit: cover; }
.price-row { display: flex; align-items: baseline; gap: 10px; margin: 14px 0; }
.old-price { color: var(--muted); text-decoration: line-through; }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 999px;
    border: 0;
    cursor: pointer;
    transition: transform 0.16s ease, background 0.16s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: #f1e6d8; color: var(--text); }
.btn-danger { background: #f9dada; color: var(--danger); }

.filter-bar, .inline-form { display: flex; gap: 12px; flex-wrap: wrap; }
.filter-bar input, .filter-bar select,
.form-card input, .form-card select, .form-card textarea,
table input, table select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
}
.form-card label { display: block; margin-bottom: 14px; }
.form-card textarea { min-height: 110px; resize: vertical; }
.checkbox { display: flex !important; gap: 10px; align-items: center; }
.checkbox input { width: auto; }

.product-detail { grid-template-columns: 1.1fr 1fr; align-items: start; }
.product-image-wrap img { border-radius: 28px; box-shadow: var(--shadow); aspect-ratio: 1 / 1; object-fit: cover; }
.subtitle { font-size: 20px; color: var(--primary-dark); }
.description { color: var(--muted); line-height: 1.8; }
.price-box {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 22px 0;
}
.price-box > div {
    padding: 16px;
    border-radius: 20px;
    background: var(--surface-strong);
}
.spec-list { padding-left: 18px; color: var(--muted); line-height: 1.8; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.cart-summary { justify-content: space-between; align-items: flex-start; margin-top: 22px; }
.summary-card p, .promo-card li { display: flex; justify-content: space-between; gap: 20px; }
.summary-total { font-size: 22px; font-weight: 700; }
.checkout-grid { grid-template-columns: 1.1fr 0.9fr; align-items: start; }
.sticky-card { position: sticky; top: 100px; }
.narrow { max-width: 720px; margin-left: auto; margin-right: auto; }
.success-card { text-align: center; }
.markdown-doc {
    line-height: 1.7;
}
.markdown-doc h1,
.markdown-doc h2,
.markdown-doc h3 {
    margin-top: 0;
}
.markdown-doc h2,
.markdown-doc h3 {
    margin-top: 24px;
}
.markdown-doc ul,
.markdown-doc ol {
    padding-left: 22px;
}
.markdown-doc code {
    padding: 2px 6px;
    border-radius: 8px;
    background: #f4ece1;
    font-size: 0.95em;
}

.site-footer {
    padding: 40px 0 60px;
    background: #1f1a14;
    color: rgba(255,255,255,0.84);
}
.footer-grid {
    align-items: start;
    justify-content: space-between;
}
.footer-grid > div { flex: 1; }

.nav-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(31, 26, 20, 0.38);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1080;
}
.site-header.nav-open .nav-overlay {
    opacity: 1;
    pointer-events: auto;
}
.site-header.nav-open .nav-toggle-icon span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}
.site-header.nav-open .nav-toggle-icon span:nth-child(2) {
    opacity: 0;
}
.site-header.nav-open .nav-toggle-icon span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

@media (max-width: 900px) {
    .hero, .checkout-grid, .product-detail { grid-template-columns: 1fr; }
    .footer-grid, .cart-summary { align-items: stretch; flex-direction: column; }
    .invoice-mode-grid { grid-template-columns: 1fr; }
    .nav-bar {
        gap: 12px;
        padding: 14px 0;
    }
    .brand {
        flex: 1;
        min-width: 0;
    }
    .brand span:last-child {
        min-width: 0;
    }
    .brand strong {
        display: block;
        font-size: 18px;
        line-height: 1.1;
    }
    .brand small {
        font-size: 12px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .nav-actions {
        gap: 10px;
    }
    .cart-link {
        padding: 10px 12px;
        font-size: 14px;
        white-space: nowrap;
    }
    .nav-toggle-button {
        min-width: 56px;
        padding: 0 12px;
    }
    .nav-toggle-text {
        display: none;
    }
    .nav-links {
        width: min(320px, calc(100vw - 24px));
        padding: 68px 16px 18px;
    }
    .nav-panel-head strong {
        font-size: 21px;
    }
    .nav-close-button {
        top: 14px;
        right: 14px;
    }
    .price-box { grid-template-columns: 1fr; }
    .sticky-card { position: static; }
}
