/* =========================================================
   書店購物網站共用樣式（文青書店 + 綠化視覺）
   放在 src/main/resources/static/css/shop.css
   ========================================================= */

@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;700&family=Noto+Serif+TC:wght@600;700&display=swap");

/* ---------- 基本設定 ---------- */
:root {
    --brand: #3f6b52;
    --brand-dark: #2d5240;
    --brand-soft: #eaf3eb;
    --brand-line: #c9dbc9;
    --leaf: #5d8a68;
    --moss: #7a9e7e;
    --gold: #c4a574;
    --paper: #f6f1e6;
    --bg: #eef3ea;
    --card: #fffcf6;
    --text: #2c3228;
    --muted: #6b7266;
    --line: #e4ddd0;
    --line-strong: #d4ccbe;
    --ok-bg: #e4f2e6;
    --ok-text: #2d6a45;
    --err-bg: #fff0f0;
    --err-text: #c0182a;
    --shadow: 0 8px 24px rgba(45, 82, 64, 0.08);
    --nav-h: 56px;
    --serif: "Noto Serif TC", "Iwanami Mincho", "PMingLiU", serif;
    --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
    --leaf-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%235d8a68' stroke-width='1.2' opacity='0.18'%3E%3Cpath d='M22 58c14-28 30-28 44 0-14 28-30 28-44 0z'/%3E%3Cpath d='M44 58v22'/%3E%3Cpath d='M78 28c8-16 18-16 26 0-8 16-18 16-26 0z'/%3E%3Cpath d='M91 28v14'/%3E%3C/g%3E%3C/svg%3E");
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background-color: var(--bg);
    background-image:
        radial-gradient(ellipse 80% 50% at 0% -10%, rgba(93, 138, 104, 0.22), transparent 55%),
        radial-gradient(ellipse 70% 40% at 100% 0%, rgba(196, 165, 116, 0.16), transparent 50%),
        var(--leaf-pattern);
    background-attachment: fixed;
    color: var(--text);
    font: 15px/1.65 var(--sans);
}

img {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

[hidden] {
    display: none !important;
}

:focus-visible {
    outline: 3px solid var(--moss);
    outline-offset: 2px;
}

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

/* ---------- 版面容器 ---------- */
.container {
    width: min(1200px, calc(100% - 24px));
    margin: 16px auto;
}

/* ---------- 頁首（橘色漸層） ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    padding-top: env(safe-area-inset-top);
    background:
        linear-gradient(180deg, rgba(47, 74, 58, 0.18), transparent 40%),
        linear-gradient(135deg, #2f4a3a, #3f6b52 55%, #4a7a5c);
    color: #f6f1e6;
    border-bottom: 3px solid var(--gold);
}

.header-inner {
    width: min(1200px, calc(100% - 24px));
    margin: 0 auto;
}

.header-top {
    display: flex;
    justify-content: flex-end;
    gap: 18px;
    padding: 6px 0;
    font-size: 13px;
}

.header-top a,
.header-top button {
    padding: 0;
    border: 0;
    background: none;
    color: #ffffff;
    font-size: 13px;
    cursor: pointer;
}

.header-top a:hover,
.header-top button:hover {
    opacity: 0.85;
}

.header-main {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 10px 0 14px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--serif);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.brand svg {
    width: 34px;
    height: 34px;
    flex: none;
}

.search {
    display: flex;
    flex: 1;
    min-width: 0;
    padding: 3px;
    border-radius: 2px;
    background: #ffffff;
}

.search input {
    flex: 1;
    min-width: 0;
    height: 38px;
    padding: 0 12px;
    border: 0;
    border-radius: 2px;
    color: var(--text);
    outline: 0;
}

.search button {
    display: grid;
    place-items: center;
    width: 60px;
    border: 0;
    border-radius: 2px;
    background: var(--brand);
    color: #ffffff;
    cursor: pointer;
}

.search button:hover {
    background: var(--brand-dark);
}

.search button svg {
    width: 20px;
    height: 20px;
}

.cart-link {
    position: relative;
    display: grid;
    place-items: center;
    flex: none;
    width: 44px;
    height: 44px;
    color: #ffffff;
}

.cart-link svg {
    width: 28px;
    height: 28px;
}

.badge-count {
    position: absolute;
    top: 2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border: 1px solid var(--brand);
    border-radius: 9px;
    background: #ffffff;
    color: var(--brand);
    font-size: 12px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

.badge-count[data-zero="true"] {
    display: none;
}

/* ---------- 手機底部導覽列 ---------- */
.bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    .header-top {
        display: none;
    }

    .header-main {
        gap: 10px;
        padding: 8px 0;
    }

    .brand span {
        display: none;
    }

    .search button {
        width: 48px;
    }

    body.has-bottom-nav {
        padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
    }

    .bottom-nav {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 40;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        padding-bottom: env(safe-area-inset-bottom);
        border-top: 1px solid var(--line);
        background: #ffffff;
    }

    .bottom-nav a {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        height: var(--nav-h);
        color: var(--muted);
        font-size: 11px;
    }

    .bottom-nav a.active {
        color: var(--brand);
    }

    .bottom-nav svg {
        width: 24px;
        height: 24px;
        margin-bottom: 2px;
    }

    .bottom-nav .badge-count {
        top: 4px;
        right: calc(50% - 24px);
    }

    .container {
        width: calc(100% - 16px);
        margin: 8px auto;
    }
}

/* ---------- 按鈕 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 20px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.btn-primary {
    background: var(--brand);
    color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--brand-dark);
}

.btn-outline {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--brand);
}

.btn-outline:hover:not(:disabled) {
    background: #dff0e3;
}

.btn-plain {
    border-color: var(--line-strong);
    background: #ffffff;
    color: var(--text);
}

.btn-plain:hover:not(:disabled) {
    background: #fafafa;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    min-height: 34px;
    padding: 0 12px;
    font-size: 13px;
}

.btn:disabled {
    border-color: #e5e5e5;
    background: #e5e5e5;
    color: #9b9b9b;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .btn {
        min-height: 44px;
    }

    .btn-sm {
        min-height: 38px;
    }
}

/* ---------- 白色區塊、標題 ---------- */
.panel {
    border-radius: 14px;
    background: var(--card);
    box-shadow: var(--shadow);
    border: 1px solid var(--line);
}

.section-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 10px;
    padding: 14px 16px;
    border-radius: 3px;
    background: var(--card);
    box-shadow: var(--shadow);
}

.section-title h1 {
    margin: 0;
    color: var(--brand);
    font-size: 16px;
    font-weight: 500;
    text-transform: uppercase;
}

.section-title .sub {
    color: var(--muted);
    font-size: 13px;
}

.empty {
    padding: 48px 16px;
    color: var(--muted);
    text-align: center;
}

.empty p {
    margin: 0 0 16px;
}

/* ---------- 提示訊息 ---------- */
.alert {
    margin: 0 0 12px;
    padding: 10px 14px;
    border-radius: 2px;
    background: var(--ok-bg);
    color: var(--ok-text);
    line-height: 1.6;
}

.alert-error {
    background: var(--err-bg);
    color: var(--err-text);
}

.toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    z-index: 100;
    max-width: min(420px, calc(100% - 32px));
    padding: 10px 18px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.82);
    color: #ffffff;
    text-align: center;
    transform: translateX(-50%);
}

.toast.error {
    background: rgba(192, 24, 42, 0.94);
}

@media (max-width: 768px) {
    .toast {
        bottom: calc(80px + env(safe-area-inset-bottom));
    }
}

/* ---------- 表單 ---------- */
.field {
    margin: 0 0 16px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
}

.input {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: #ffffff;
    color: var(--text);
}

.input:focus {
    border-color: var(--brand);
    outline: 0;
    box-shadow: 0 0 0 2px rgba(63, 107, 82, 0.18);
}

.input[readonly] {
    background: #f7f7f7;
    color: var(--muted);
}

.hint {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 12px;
}

/* 數量加減器（− 數字 +） */
.stepper {
    display: inline-flex;
    height: 34px;
    border: 1px solid var(--line-strong);
    border-radius: 2px;
    background: #ffffff;
}

.stepper button {
    width: 34px;
    border: 0;
    background: #ffffff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.stepper button:hover:not(:disabled) {
    background: #fafafa;
}

.stepper button:disabled {
    color: #c4c4c4;
    cursor: not-allowed;
}

.stepper input {
    width: 54px;
    border: 0;
    border-right: 1px solid var(--line-strong);
    border-left: 1px solid var(--line-strong);
    border-radius: 0;
    text-align: center;
    -moz-appearance: textfield;
    appearance: textfield;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button {
    margin: 0;
    -webkit-appearance: none;
}

.stepper input:disabled {
    background: #f7f7f7;
    color: #b0b0b0;
}

/* ---------- 價格、分頁 ---------- */
.price {
    color: var(--brand);
    font-weight: 500;
}

.price small {
    margin-right: 2px;
    font-size: 0.75em;
}

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 18px 0;
    color: var(--muted);
}

/* ---------- 書籍商品格狀列表 ---------- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 10px;
}

.product-card {
    display: flex;
    flex-direction: column;
    border: 1px solid transparent;
    border-radius: 2px;
    background: var(--card);
    box-shadow: var(--shadow);
    transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}

.product-card:hover {
    border-color: var(--brand);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.product-link {
    display: block;
    flex: 1;
}

.product-cover {
    position: relative;
    aspect-ratio: 3 / 4;
    background: #f0f0f0;
}

.product-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-cover.no-image::after {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #b5b5b5;
    content: "No Image";
}

.sold-out-mask {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.4);
    color: #ffffff;
    font-size: 16px;
    font-weight: 500;
}

.product-name {
    display: -webkit-box;
    min-height: 2.9em;
    margin: 8px 8px 4px;
    overflow: hidden;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.45;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.product-price {
    margin: 0 8px;
    font-size: 18px;
}

.product-stock {
    margin: 2px 8px 8px;
    color: var(--muted);
    font-size: 12px;
}

.product-stock.low {
    color: var(--brand);
}

.product-foot {
    padding: 0 8px 8px;
}

@media (max-width: 768px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .product-price {
        font-size: 16px;
    }
}

/* ---------- 登入、註冊等頁面 ---------- */
.auth-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--paper);
}

.auth-top {
    background: var(--paper);
    border-bottom: 3px solid var(--gold);
}

.auth-top .inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: min(1040px, calc(100% - 24px));
    height: 64px;
    margin: 0 auto;
    color: var(--brand);
}

.auth-top .brand {
    font-size: 22px;
}

.auth-top .help {
    color: var(--brand);
    font-size: 14px;
}

.auth-hero {
    display: grid;
    flex: 1;
    place-items: center;
    padding: 40px 16px;
    background-color: #3f6b52;
    background-image:
        radial-gradient(circle at 12% 20%, rgba(232, 244, 228, 0.16), transparent 28%),
        radial-gradient(circle at 88% 80%, rgba(196, 165, 116, 0.22), transparent 32%),
        var(--leaf-pattern);
}

.auth-card {
    width: min(420px, 100%);
    padding: 28px 30px 30px;
    border-radius: 18px;
    background: var(--card);
    border: 1px solid var(--line);
    box-shadow: 0 18px 40px rgba(47, 74, 58, 0.18);
}

.auth-card.wide {
    width: min(560px, 100%);
}

.auth-card h1 {
    margin: 0 0 22px;
    font-family: var(--serif);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.auth-card .lead {
    margin: -10px 0 20px;
    color: var(--muted);
    line-height: 1.6;
}

.auth-card .message,
.auth-card .error {
    display: none;
    margin: 0 0 14px;
    padding: 10px 14px;
    border-radius: 2px;
    line-height: 1.6;
}

.auth-card .message {
    background: var(--ok-bg);
    color: var(--ok-text);
}

.auth-card .error {
    background: var(--err-bg);
    color: var(--err-text);
}

.auth-card .btn {
    width: 100%;
    margin-top: 6px;
    min-height: 42px;
}

.auth-links {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    font-size: 13px;
}

.auth-links a {
    color: var(--brand);
}

.auth-links a:hover {
    text-decoration: underline;
}

.two-col {
    display: grid;
    gap: 0 16px;
}

@media (min-width: 640px) {
    .two-col {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 640px) {
    .auth-hero {
        align-items: start;
        padding: 20px 16px;
        background: #ffffff;
    }

    .auth-card {
        padding: 8px 0;
        box-shadow: none;
    }

    .auth-top .help {
        display: none;
    }
}

/* ---------- 書籍介紹頁 ---------- */
.breadcrumb {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 13px;
}

.breadcrumb a {
    color: var(--brand);
}

.detail {
    display: grid;
    grid-template-columns: minmax(240px, 420px) 1fr;
    gap: 30px;
    padding: 15px;
}

.detail-cover {
    width: 100%;
    aspect-ratio: 3 / 4;
    border: 1px solid var(--line);
    background: #f0f0f0;
    object-fit: cover;
}

.detail-title {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 500;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.detail-tagline {
    margin: 0 0 14px;
    color: var(--muted);
}

.price-band {
    margin: 0 0 20px;
    padding: 14px 20px;
    background: #fafafa;
    color: var(--brand);
    font-size: 30px;
    font-weight: 500;
}

.price-band small {
    margin-right: 4px;
    font-size: 18px;
}

.buy-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
    margin-bottom: 14px;
}

.buy-line .label {
    min-width: 56px;
    color: var(--muted);
}

.stock-text {
    color: var(--muted);
    font-size: 13px;
}

.stock-text.out {
    color: var(--err-text);
    font-weight: 500;
}

.subtotal-text {
    color: var(--muted);
}

.subtotal-text b {
    color: var(--brand);
    font-size: 16px;
    font-weight: 500;
}

.detail-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.detail-actions .btn {
    min-width: 170px;
    min-height: 46px;
}

.info-section {
    margin-top: 10px;
    padding: 20px;
}

.info-section h2 {
    margin: 0 0 14px;
    padding: 12px 14px;
    background: #fafafa;
    font-size: 18px;
    font-weight: 500;
    text-transform: uppercase;
}

.info-section h3 {
    margin: 18px 0 6px;
    font-size: 15px;
}

.info-section p,
.info-section li {
    max-width: 70ch;
    line-height: 1.8;
}

.info-section p {
    margin: 0;
}

.info-section ul {
    margin: 0;
    padding-left: 20px;
}

.specs {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 8px 16px;
    margin: 0;
}

.specs dt {
    color: var(--muted);
}

.specs dd {
    margin: 0;
    overflow-wrap: anywhere;
}

@media (max-width: 768px) {
    .detail {
        grid-template-columns: 1fr;
        gap: 14px;
        padding: 0 0 14px;
    }

    .detail-cover {
        max-height: 70vh;
        border: 0;
    }

    .detail-body {
        padding: 0 14px;
    }

    .price-band {
        margin-right: -14px;
        margin-left: -14px;
        padding: 12px 14px;
        font-size: 26px;
    }

    body.has-action-bar {
        padding-bottom: calc(64px + env(safe-area-inset-bottom));
    }

    .detail-actions {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 40;
        margin: 0;
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
        border-top: 1px solid var(--line);
        background: #ffffff;
    }

    .detail-actions .btn {
        flex: 1;
        min-width: 0;
    }

    .info-section {
        padding: 14px;
    }
}

/* ---------- 購物車 ---------- */
.cart-head,
.cart-row {
    display: grid;
    grid-template-columns: 80px minmax(0, 1fr) 110px 140px 110px 70px;
    grid-template-areas: "thumb info price qty sub act";
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
}

.cart-head {
    margin-bottom: 10px;
    border-radius: 3px;
    background: #ffffff;
    box-shadow: var(--shadow);
    color: var(--muted);
    font-size: 13px;
}

.cart-head .book-col {
    grid-column: 1 / 3;
}

.cart-list {
    overflow: hidden;
}

.cart-row {
    border-bottom: 1px solid var(--line);
}

.cart-row:last-child {
    border-bottom: 0;
}

.cart-row.unavailable {
    background: #f6f3ea;
}

.cart-thumb {
    grid-area: thumb;
}

.cart-thumb img {
    width: 80px;
    aspect-ratio: 3 / 4;
    border: 1px solid var(--line);
    background: #f0f0f0;
    object-fit: cover;
}

.cart-info {
    grid-area: info;
    min-width: 0;
}

.cart-info a {
    display: -webkit-box;
    overflow: hidden;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.cart-info a:hover {
    color: var(--brand);
}

.cart-note {
    display: block;
    margin-top: 4px;
    color: var(--err-text);
    font-size: 12px;
    font-weight: 500;
}

.cart-price {
    grid-area: price;
}

.cart-qty {
    grid-area: qty;
}

.cart-sub {
    grid-area: sub;
    color: var(--brand);
    font-weight: 500;
}

.cart-act {
    grid-area: act;
}

.link-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--text);
    cursor: pointer;
}

.link-button:hover {
    color: var(--brand);
}

.checkout-bar {
    position: sticky;
    bottom: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 20px;
    margin-top: 10px;
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: #ffffff;
    box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.06);
}

.checkout-bar .count {
    color: var(--muted);
}

.checkout-bar .total {
    color: var(--brand);
    font-size: 22px;
    font-weight: 500;
}

.checkout-bar .btn {
    min-width: 180px;
    min-height: 44px;
}

@media (max-width: 768px) {
    .cart-head {
        display: none;
    }

    .cart-row {
        grid-template-columns: 72px 1fr auto;
        grid-template-areas:
            "thumb info info"
            "thumb price act"
            "thumb qty sub";
        gap: 6px 12px;
        padding: 12px;
    }

    .cart-thumb img {
        width: 72px;
    }

    .cart-act {
        text-align: right;
    }

    .cart-sub {
        text-align: right;
    }

    .checkout-bar {
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
        gap: 12px;
    }

    .checkout-bar .count {
        display: none;
    }

    .checkout-bar .total {
        flex: 1;
        font-size: 18px;
    }

    .checkout-bar .btn {
        min-width: 120px;
    }
}

/* ---------- 我的訂單 ---------- */
.tabs {
    display: flex;
    margin-bottom: 10px;
    overflow-x: auto;
    border-radius: 3px;
    background: #ffffff;
    box-shadow: var(--shadow);
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tabs button {
    flex: 1 0 auto;
    min-width: 88px;
    padding: 14px 16px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--text);
    white-space: nowrap;
    cursor: pointer;
}

.tabs button:hover {
    color: var(--brand);
}

.tabs button.active {
    border-bottom-color: var(--brand);
    color: var(--brand);
    font-weight: 500;
}

.order-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 12px;
}

.order-filter .input {
    width: auto;
    flex: 1 1 200px;
    height: 38px;
}

.order-filter .date-input {
    flex: 0 1 160px;
}

.order-filter .range-sep {
    color: var(--muted);
}

.order-card {
    margin-bottom: 10px;
}

.order-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}

.order-no {
    color: var(--muted);
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
    overflow-wrap: anywhere;
}

.order-status {
    flex: none;
    color: var(--brand);
    font-weight: 500;
    text-transform: uppercase;
}

.order-status.PAID {
    color: var(--ok-text);
}

.order-status.CANCELLED {
    color: var(--muted);
}

.order-item {
    display: grid;
    grid-template-columns: 72px 1fr auto;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}

.order-item:last-of-type {
    border-bottom: 0;
}

.order-item img {
    width: 72px;
    aspect-ratio: 3 / 4;
    border: 1px solid var(--line);
    background: #f0f0f0;
    object-fit: cover;
}

.order-item .name {
    display: -webkit-box;
    overflow: hidden;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.order-item .name:hover {
    color: var(--brand);
}

.order-item .qty {
    margin-top: 4px;
    color: var(--muted);
}

.order-item .unit {
    align-self: end;
    text-align: right;
}

.order-foot {
    padding: 14px 16px;
    border-top: 1px solid var(--line);
    background: #f4f8f3;
    text-align: right;
}

.order-foot .time {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
}

.order-foot .total-line b {
    margin-left: 6px;
    color: var(--brand);
    font-size: 20px;
    font-weight: 500;
}

/* ---------- 我的帳戶（會員資料） ---------- */
.account-layout {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.side-nav {
    padding: 8px 0;
}

.side-nav a,
.side-nav button {
    display: block;
    width: 100%;
    padding: 11px 16px;
    border: 0;
    background: none;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.side-nav a:hover,
.side-nav button:hover {
    color: var(--brand);
}

.side-nav a.active {
    color: var(--brand);
    font-weight: 500;
}

.account-card {
    padding: 20px 28px 28px;
}

.account-card h1 {
    margin: 0;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
    font-size: 18px;
    font-weight: 500;
}

.account-card .sub {
    margin: 4px 0 20px;
    color: var(--muted);
    font-size: 13px;
}

.form-row {
    display: grid;
    grid-template-columns: 120px minmax(0, 420px);
    align-items: start;
    gap: 8px 20px;
    margin-bottom: 20px;
}

.form-row > label {
    padding-top: 11px;
    color: var(--muted);
    text-align: right;
}

.form-actions {
    display: grid;
    grid-template-columns: 120px minmax(0, 420px);
    gap: 20px;
}

.form-actions .btn {
    grid-column: 2;
    justify-self: start;
    min-width: 120px;
}

@media (max-width: 768px) {
    .account-layout {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .side-nav {
        display: none;
    }

    .account-card {
        padding: 14px 14px 20px;
    }

    .form-row,
    .form-actions {
        grid-template-columns: 1fr;
    }

    .form-row > label {
        padding-top: 0;
        text-align: left;
    }

    .form-actions .btn {
        grid-column: 1;
        width: 100%;
    }
}

/* ---------- 現行頁面：列表／介紹／購物車／訂單／會員 ---------- */
body:not(.auth-page) > header {
    position: sticky;
    top: 0;
    z-index: 20;
    background:
        linear-gradient(180deg, rgba(246, 241, 230, 0.08), transparent 42%),
        linear-gradient(135deg, #2f4a3a, #3f6b52 58%, #4a7a5c);
    color: #f6f1e6;
    border-bottom: 3px solid var(--gold);
    box-shadow: 0 10px 28px rgba(47, 74, 58, 0.18);
}

body:not(.auth-page) > header .bar {
    width: min(1080px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 18px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 16px;
}

body:not(.auth-page) > header h1 {
    margin: 0;
    font-family: var(--serif);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

body:not(.auth-page) > header a,
body:not(.auth-page) > header .cart-link {
    color: #eef6ea;
    font-weight: 500;
}

body:not(.auth-page) > header a:hover,
body:not(.auth-page) > header .cart-link:hover {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 4px;
}

body:not(.auth-page) > header nav,
body:not(.auth-page) .bar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
}

body:not(.auth-page) > header button {
    padding: 8px 16px;
    border: 1px solid rgba(246, 241, 230, 0.45);
    border-radius: 999px;
    background: transparent;
    color: #f6f1e6;
    font-weight: 600;
    cursor: pointer;
}

body:not(.auth-page) > header button:hover {
    background: rgba(246, 241, 230, 0.12);
}

body:not(.auth-page) > main {
    width: min(1080px, calc(100vw - 32px));
    margin: 28px auto 48px;
}

body:not(.auth-page) > main:not(:has(.detail)):not(:has(.filters)):not(:has(#profileForm)) {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

body:not(.auth-page) a {
    color: var(--brand);
    font-weight: 600;
    text-decoration: none;
}

body:not(.auth-page) a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    background: #f4f8f3;
    font-size: 13px;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 700;
}

tr:last-child td {
    border-bottom: 0;
}

table .price,
.num {
    text-align: right;
    white-space: nowrap;
}

.action {
    width: 200px;
    text-align: center;
    white-space: nowrap;
}

.stock {
    width: 72px;
    text-align: right;
}

.qty-input {
    width: 64px;
    margin-right: 8px;
    padding: 9px 6px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    font-size: 15px;
    text-align: center;
    background: #fff;
    color: var(--text);
}

.qty-input:disabled {
    background: #f1f4ee;
    color: #94a3b8;
}

body:not(.auth-page) button {
    padding: 10px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: #fff;
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
}

.buy-button,
.checkout-button,
.button:not(.secondary) {
    min-width: 88px;
    border: 0;
    background: var(--brand);
    color: #fff;
}

.buy-button:hover:not(:disabled),
.checkout-button:hover:not(:disabled),
.button:not(.secondary):hover:not(:disabled) {
    background: var(--brand-dark);
}

.buy-button:disabled,
.checkout-button:disabled,
.button:disabled {
    cursor: not-allowed;
    border-color: #d7ddd3;
    background: #e6ebe3;
    color: #7a8476;
}

.message {
    padding: 32px;
    text-align: center;
    color: var(--muted);
}

.message.error,
.buy-error {
    color: var(--err-text);
}

.pager {
    padding: 14px 16px;
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    background: #fbfaf4;
}

.pager select {
    padding: 9px 10px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
}

.pager button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

#pageInfo {
    min-width: 120px;
    text-align: center;
    color: var(--muted);
    font-weight: 700;
}

.book-link {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.book-thumb {
    width: 36px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--line);
    background: #e7eee6;
    box-shadow: 2px 2px 0 rgba(63, 107, 82, 0.12);
}

.cart-count {
    min-width: 20px;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--gold);
    color: #2c3228;
    font-size: 12px;
    text-align: center;
}

.success {
    color: var(--ok-text);
}

p.message {
    margin: 0;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    color: var(--ok-text);
    background: var(--ok-bg);
}

p.message.error {
    color: var(--err-text);
    background: var(--err-bg);
}

p.message[role="alert"] {
    margin: 0 0 16px;
    border-bottom: 0;
    border-radius: 10px;
    color: var(--err-text);
    background: var(--err-bg);
}

.empty {
    padding: 48px 32px;
    text-align: center;
    color: var(--muted);
}

.empty p {
    margin: 0 0 16px;
}

.book-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.book-name {
    overflow-wrap: anywhere;
}

.stock-note {
    display: block;
    margin-top: 4px;
    color: var(--err-text);
    font-size: 13px;
    font-weight: 700;
}

tr.unavailable td {
    background: #f6f3ea;
}

.remove-button {
    padding: 8px 12px;
    border: 1px solid #e3c7c7;
    border-radius: 999px;
    background: #fff;
    color: var(--err-text);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.remove-button:hover {
    background: #fff1f1;
}

.summary {
    padding: 20px 16px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 20px;
    background: linear-gradient(180deg, #fbfaf4, #f0f6ef);
}

.summary-text {
    color: var(--muted);
    font-weight: 700;
}

.total {
    font-family: var(--serif);
    font-size: 24px;
    font-weight: 700;
    color: var(--brand);
}

.checkout-button {
    min-width: 160px;
    padding: 12px 24px;
    font-size: 16px;
}

@media (max-width: 720px) {
    #cartContent th:nth-child(2),
    #cartContent td:nth-child(2) {
        display: none;
    }
}

.back {
    display: inline-block;
    margin-bottom: 16px;
}

.detail {
    display: grid;
    grid-template-columns: minmax(220px, 320px) 1fr;
    gap: 32px;
    padding: 32px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.cover {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #e7eee6;
    box-shadow: 8px 10px 0 rgba(63, 107, 82, 0.08);
}

.info h2 {
    margin: 0 0 8px;
    font-family: var(--serif);
    font-size: 32px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.tagline {
    margin: 0 0 20px;
    color: var(--muted);
    line-height: 1.6;
}

.info .price {
    margin: 0 0 24px;
    font-family: var(--serif);
    font-size: 28px;
    font-weight: 700;
    color: var(--brand);
    text-align: left;
}

.status {
    display: inline-block;
    margin: -8px 0 8px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
    background: var(--ok-bg);
    color: var(--ok-text);
}

.status.unavailable {
    background: #e7eee6;
    color: var(--muted);
}

.buy-row {
    margin: 8px 0 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.qty-label {
    font-weight: 700;
}

.subtotal {
    color: var(--muted);
    font-weight: 700;
}

.buy-button {
    min-width: 160px;
    padding: 12px 24px;
    font-size: 16px;
}

.buy-error,
.cart-notice {
    margin: 12px 0 0;
    padding: 12px;
    border-radius: 10px;
    max-width: 60ch;
}

.buy-error {
    background: var(--err-bg);
}

.cart-notice {
    background: var(--ok-bg);
    color: var(--ok-text);
}

.info h3 {
    margin: 28px 0 8px;
    font-family: var(--serif);
    font-size: 18px;
}

.info p,
.info li {
    line-height: 1.8;
    max-width: 60ch;
}

.info p {
    margin: 0;
}

.info ul {
    margin: 0;
    padding-left: 20px;
}

.specs {
    margin: 0;
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 8px 16px;
    padding: 16px;
    background: #f4f8f3;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.specs dt {
    color: var(--muted);
    font-weight: 700;
}

.specs dd {
    margin: 0;
}

body:not(.auth-page) > main > .message {
    padding: 48px 32px;
    text-align: center;
    color: var(--err-text);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
}

@media (max-width: 720px) {
    .detail {
        grid-template-columns: 1fr;
        padding: 20px;
    }

    .cover {
        max-width: 320px;
    }
}

.cart-button {
    min-width: 140px;
    padding: 11px 20px;
    border: 2px solid var(--brand);
    border-radius: 999px;
    background: #fff;
    color: var(--brand);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.cart-button:hover:not(:disabled) {
    background: var(--brand-soft);
}

.cart-button:disabled {
    cursor: not-allowed;
    border-color: #e6ebe3;
    background: #e6ebe3;
    color: #7a8476;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.filters {
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px;
}

.filters label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 700;
    color: var(--muted);
}

.filters input,
.filters select {
    box-sizing: border-box;
    padding: 10px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    font-size: 15px;
    background: #fff;
}

.filters input[type="text"] {
    width: 200px;
}

.button {
    padding: 10px 18px;
    font-size: 15px;
}

.button.secondary {
    border: 1px solid var(--line-strong);
    background: #fff;
    color: var(--text);
}

.order-no {
    font-family: Consolas, "Courier New", monospace;
    font-size: 14px;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    background: #e7eee6;
    color: #475569;
}

.badge.PAID {
    background: var(--ok-bg);
    color: var(--ok-text);
}

.badge.PENDING_PAYMENT {
    background: #fff4d6;
    color: #8a5a00;
}

.badge.FAILED {
    background: var(--err-bg);
    color: var(--err-text);
}

.toggle-button {
    padding: 6px 12px;
    border: 1px solid var(--brand-line);
    border-radius: 999px;
    background: #fff;
    color: var(--brand);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

tr.detail-row td {
    background: #f4f8f3;
    white-space: normal;
}

.detail-table {
    width: 100%;
    background: #fff;
    border: 1px solid var(--line);
}

.detail-table th,
.detail-table td {
    padding: 10px 12px;
    white-space: normal;
}

.detail-meta {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
}

.table-wrap {
    overflow-x: auto;
}

body:not(.auth-page) > main:has(#profileForm) {
    width: min(520px, calc(100vw - 32px));
    padding: 28px;
    box-sizing: border-box;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

body:not(.auth-page) h2 {
    margin: 0 0 8px;
    font-family: var(--serif);
    font-size: 20px;
}

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

#profileForm label {
    display: block;
    margin: 16px 0 8px;
    font-weight: 700;
}

#profileForm input,
#profileForm select {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    font-size: 16px;
    background: #fff;
}

#profileForm input[readonly] {
    background: #f1f4ee;
    color: var(--muted);
}

.field-note {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
}

#saveButton {
    width: 100%;
    margin-top: 24px;
    padding: 12px 16px;
    border: 0;
    background: var(--brand);
    color: #fff;
    font-size: 16px;
}

#saveButton:disabled {
    background: #94a3b8;
}

#profileForm .message {
    margin: 0 0 16px;
    padding: 12px;
    border-radius: 10px;
    border-bottom: 0;
    text-align: left;
    background: var(--ok-bg);
    color: var(--ok-text);
}

#profileForm .message.error {
    background: var(--err-bg);
    color: var(--err-text);
}
