:root {
  --background: #f3efe7;
  --surface: #faf8f2;
  --surface-strong: #fffdf8;
  --text-primary: #20231f;
  --text-secondary: #6a6f68;
  --primary-green: #173b2b;
  --primary-green-soft: #dfe7df;
  --accent-red: #a84f43;
  --divider: #d8d4cb;
  --danger: #a63d3d;
  --focus: rgba(168, 79, 67, 0.28);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.25rem;
  --text-xl: clamp(1.65rem, 4vw, 2.5rem);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --transition: 160ms ease;
  --content-width: 1320px;
  --safe-bottom: max(14px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--background);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
body.drawer-open,
body.detail-open { overflow: hidden; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
button:disabled { cursor: not-allowed; opacity: 0.48; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--divider);
  background: rgba(243, 239, 231, 0.96);
}
.header-inner {
  width: min(100%, var(--content-width));
  min-height: 64px;
  margin: 0 auto;
  padding: 0 var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}
.brand-mark { display: inline-flex; align-items: baseline; gap: var(--space-2); color: inherit; text-decoration: none; }
.brand-mark strong { font-size: 1.05rem; letter-spacing: 0.01em; }
.brand-mark small { color: var(--text-secondary); font-size: var(--text-xs); }
.header-actions { display: flex; align-items: center; gap: var(--space-2); }
.header-search-button,
.header-cart-button,
.detail-inquiry-button,
.detail-back-button {
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--primary-green);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 700;
}
.header-search-button { padding: 8px 10px; }
.header-cart-button,
.detail-inquiry-button { padding: 8px 12px; border: 1px solid var(--primary-green); border-radius: var(--radius-sm); }
.cart-badge,
.detail-inquiry-button span {
  min-width: 21px;
  height: 21px;
  padding: 0 5px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-red);
  color: #fff;
  font-size: 0.7rem;
}

.catalog-section { width: min(100%, var(--content-width)); margin: 0 auto; padding: var(--space-7) var(--space-5) 120px; }
.catalog-heading { display: flex; align-items: end; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); }
.eyebrow { margin: 0 0 var(--space-2); color: var(--accent-red); font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.12em; }
.catalog-heading h1 { margin: 0; font-size: var(--text-xl); line-height: 1.15; letter-spacing: -0.025em; }
.result-count { margin: 0; color: var(--text-secondary); font-size: var(--text-sm); white-space: nowrap; }

.filters { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-3); margin-bottom: var(--space-6); padding-bottom: var(--space-5); border-bottom: 1px solid var(--divider); }
.search-field { position: relative; min-width: 0; }
.search-field svg { position: absolute; left: var(--space-4); top: 50%; transform: translateY(-50%); color: var(--text-secondary); pointer-events: none; }
.search-field input { width: 100%; min-height: 52px; border: 1px solid var(--divider); border-radius: var(--radius-md); padding: 12px 16px 12px 48px; background: var(--surface-strong); color: var(--text-primary); }
.search-field input:focus { border-color: var(--primary-green); }
.reset-button { min-height: 52px; padding: 8px var(--space-3); color: var(--accent-red); font-size: var(--text-sm); }
.mobile-filter-controls {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}
.filter-select-field { min-width: 0; }
.filter-select-field span { display: block; margin-bottom: var(--space-1); color: var(--text-secondary); font-size: var(--text-xs); font-weight: 700; }
.filter-select-field select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  padding: 9px 34px 9px 12px;
  background: var(--surface);
  color: var(--text-primary);
}
.filter-select-field select:focus { border-color: var(--primary-green); }
.filter-navigation { display: none; }
.filter-mode-tabs { display: flex; gap: var(--space-5); margin-bottom: var(--space-3); border-bottom: 1px solid var(--divider); }
.filter-mode-button { position: relative; min-height: 40px; padding: 0 0 10px; border: 0; background: transparent; color: var(--text-secondary); font-weight: 700; }
.filter-mode-button::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: transparent; }
.filter-mode-button.is-active { color: var(--primary-green); }
.filter-mode-button.is-active::after { background: var(--primary-green); }
.filter-panel { min-width: 0; }
.filter-chip-row { display: flex; gap: var(--space-2); min-width: 0; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: none; padding: 1px 1px var(--space-2); }
.filter-chip-row::-webkit-scrollbar { display: none; }
.subcategory-row { margin-top: var(--space-1); }
.filter-chip { flex: 0 0 auto; min-height: 36px; border: 1px solid var(--divider); border-radius: var(--radius-sm); padding: 7px 12px; background: transparent; color: var(--text-secondary); font-size: var(--text-sm); transition: color var(--transition), background var(--transition), border-color var(--transition); }
.filter-chip.is-active { border-color: var(--primary-green); background: var(--primary-green); color: #fff; }

.button { min-height: 44px; border: 0; border-radius: var(--radius-md); padding: 11px 16px; font-weight: 750; transition: background var(--transition), color var(--transition), border-color var(--transition); }
.button-primary { background: var(--primary-green); color: #fff; }
.button-primary:hover:not(:disabled) { background: #24513c; }
.button-secondary { border: 1px solid var(--divider); background: var(--surface-strong); color: var(--primary-green); }
.button-ghost { border: 1px solid var(--divider); background: transparent; color: var(--primary-green); }
.full-button { width: 100%; }
.text-button { border: 0; background: transparent; font-weight: 700; }
.danger-text { color: var(--danger); }

.status-panel,
.empty-state { min-height: 220px; display: grid; place-items: center; align-content: center; gap: var(--space-2); padding: var(--space-5); border-top: 1px solid var(--divider); border-bottom: 1px solid var(--divider); color: var(--text-secondary); text-align: center; }
.spinner { width: 24px; height: 24px; border: 2px solid var(--divider); border-top-color: var(--primary-green); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state span { font-size: 1.5rem; }
.empty-state h3,
.empty-state p { margin: 0; }

.product-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); column-gap: var(--space-5); row-gap: var(--space-7); }
.product-card { min-width: 0; cursor: pointer; border-bottom: 1px solid var(--divider); padding-bottom: var(--space-4); }
.product-image-wrap { position: relative; width: 100%; aspect-ratio: 1 / 1; display: grid; place-items: center; overflow: hidden; padding: clamp(8px, 2vw, 18px); background: var(--surface-strong); }
.product-image { width: 100%; height: 100%; object-fit: contain; object-position: center; transition: transform var(--transition); }
.product-card:hover .product-image { transform: scale(1.018); }
.image-placeholder,
.detail-image-placeholder { height: 100%; display: grid; place-items: center; align-content: center; color: var(--text-secondary); font-size: var(--text-sm); }
.image-placeholder::before,
.detail-image-placeholder::before { content: ""; width: 46px; height: 36px; margin-bottom: var(--space-2); border: 1px solid currentColor; }
.image-placeholder small,
.detail-image-placeholder small { color: var(--text-secondary); font-size: var(--text-xs); }
.product-content { padding-top: var(--space-3); }
.product-name { margin: 0; min-height: 3em; font-size: var(--text-md); line-height: 1.5; font-weight: 650; overflow-wrap: anywhere; }
.product-spec { margin: var(--space-1) 0 0; color: var(--text-secondary); font-size: var(--text-sm); line-height: 1.45; }

.product-detail-view { position: fixed; inset: 0; z-index: 50; overflow-y: auto; background: var(--background); }
.detail-header { position: sticky; top: 0; z-index: 2; border-bottom: 1px solid var(--divider); background: rgba(243, 239, 231, 0.97); }
.detail-header-inner { width: min(100%, 1120px); min-height: 64px; margin: 0 auto; padding: 0 var(--space-5); display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.detail-back-button { padding: 8px 0; }
.detail-layout { width: min(100%, 1120px); margin: 0 auto; padding: var(--space-7) var(--space-5) var(--space-8); display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr); gap: clamp(36px, 7vw, 88px); align-items: start; }
.detail-image-column { min-width: 0; }
.detail-image-wrap { width: 100%; height: clamp(360px, 42vw, 560px); display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); place-items: center; overflow: hidden; padding: clamp(22px, 5vw, 54px); background: var(--surface-strong); }
.detail-product-image { width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; object-position: center; }
.detail-copy { min-width: 0; padding-top: var(--space-3); }
.detail-context { margin: 0 0 var(--space-3); color: var(--accent-red); font-size: var(--text-sm); font-weight: 700; }
.detail-copy h1 { margin: 0 0 var(--space-6); font-size: clamp(1.65rem, 3.2vw, 2.6rem); line-height: 1.3; letter-spacing: -0.025em; overflow-wrap: anywhere; }
.detail-primary-meta,
.detail-more dl { margin: 0; }
.detail-primary-meta > div,
.detail-more dl > div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: var(--space-4); padding: var(--space-3) 0; border-top: 1px solid var(--divider); }
.detail-primary-meta > div:last-child,
.detail-more dl > div:last-child { border-bottom: 1px solid var(--divider); }
.detail-primary-meta dt,
.detail-more dt { color: var(--text-secondary); font-size: var(--text-sm); }
.detail-primary-meta dd,
.detail-more dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.detail-features { margin-top: var(--space-7); }
.detail-features h2 { margin: 0 0 var(--space-3); padding-bottom: var(--space-3); border-bottom: 1px solid var(--divider); font-size: var(--text-md); }
.detail-features p,
.detail-features li { color: var(--text-secondary); }
.detail-features p { margin: 0; white-space: pre-line; }
.detail-features ul { margin: 0; padding-left: 1.25em; }
.detail-more { margin-top: var(--space-6); border-top: 1px solid var(--divider); }
.detail-more summary { padding: var(--space-4) 0; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); color: var(--primary-green); font-weight: 700; list-style: none; cursor: pointer; }
.detail-more summary::-webkit-details-marker { display: none; }
.detail-more summary span::before { content: "〉"; }
.detail-more[open] summary span::before { content: "﹀"; }
.detail-more dl { padding-bottom: var(--space-2); }
.detail-add-button { width: 100%; margin-top: var(--space-6); }
.detail-add-button.added { background: var(--primary-green-soft); color: var(--primary-green); }

.mobile-cart-bar { display: none; position: fixed; z-index: 25; left: var(--space-4); right: var(--space-4); bottom: var(--safe-bottom); min-height: 52px; border: 1px solid var(--primary-green); border-radius: var(--radius-md); padding: 12px 16px; background: var(--primary-green); color: #fff; font-weight: 700; align-items: center; justify-content: space-between; }
.mobile-cart-meta { color: #fff; font-size: var(--text-sm); }
.detail-open .mobile-cart-bar { display: none !important; }

.drawer-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(23, 29, 25, 0.5); }
.cart-drawer { position: fixed; z-index: 70; top: 0; right: 0; width: min(560px, 100%); height: 100dvh; display: flex; flex-direction: column; background: var(--background); border-left: 1px solid var(--divider); transform: translateX(102%); transition: transform 220ms ease; visibility: hidden; }
.cart-drawer.open { transform: translateX(0); visibility: visible; }
.drawer-header { display: flex; justify-content: space-between; align-items: center; padding: var(--space-5); border-bottom: 1px solid var(--divider); background: var(--surface-strong); }
.drawer-header h2 { margin: 0; }
.drawer-header .eyebrow { color: var(--accent-red); }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--divider); border-radius: 50%; background: transparent; color: var(--text-secondary); font-size: 1.5rem; line-height: 1; }
.drawer-scroll-area { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 20px 120px; }
.drawer-footer { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--divider); background: rgba(255, 253, 248, 0.97); }
.drawer-footer p { margin: 6px 0 0; text-align: center; color: var(--text-secondary); font-size: var(--text-xs); }
.cart-section,
.customer-section,
.generated-section { padding: 18px; margin-bottom: 16px; background: var(--surface-strong); border: 1px solid var(--divider); border-radius: var(--radius-md); }
.cart-section h3,
.customer-section h3,
.generated-section h3 { margin: 0; font-size: var(--text-md); }
.section-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.cart-items { display: grid; gap: 12px; }
.cart-empty { min-height: 160px; display: grid; place-items: center; align-content: center; gap: 8px; color: var(--text-secondary); text-align: center; }
.cart-empty span { font-size: 1.7rem; }
.cart-empty p { margin: 0 0 4px; }
.cart-item { padding: 14px; border-top: 1px solid var(--divider); background: transparent; }
.cart-item:first-child { border-top: 0; }
.cart-item-main { display: flex; justify-content: space-between; gap: 10px; }
.cart-item-brand { color: var(--accent-red); font-size: var(--text-xs); font-weight: 700; }
.cart-item h4 { margin: 3px 0; line-height: 1.35; }
.cart-item-spec { margin: 0; color: var(--text-secondary); font-size: 0.82rem; }
.remove-button { flex: 0 0 auto; width: 34px; height: 34px; font-size: 1.2rem; }
.quantity-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--divider); color: var(--text-secondary); font-size: 0.82rem; }
.quantity-control { display: grid; grid-template-columns: 38px 58px 38px; align-items: center; }
.quantity-button,
.quantity-input { height: 38px; border: 1px solid var(--divider); background: var(--surface-strong); color: var(--text-primary); text-align: center; }
.quantity-button { font-size: 1.1rem; font-weight: 700; }
.quantity-button:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.quantity-button:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.quantity-input { width: 58px; border-left: 0; border-right: 0; border-radius: 0; appearance: textfield; }
.quantity-input::-webkit-inner-spin-button { appearance: none; }
.form-help { margin: 5px 0 15px; color: var(--text-secondary); font-size: var(--text-xs); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label { display: grid; gap: 6px; color: var(--primary-green); font-size: 0.8rem; font-weight: 700; }
.form-grid .full-width { grid-column: 1 / -1; }
.customer-section input,
.customer-section textarea,
.generated-text { width: 100%; min-height: 44px; border: 1px solid var(--divider); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface); color: var(--text-primary); }
.customer-section textarea { resize: vertical; min-height: 88px; }
.field-error { min-height: 1.1em; color: var(--danger); font-weight: 600; }
.has-error { border-color: var(--danger) !important; background: #fff7f7 !important; }
.success-label { color: var(--primary-green); font-size: var(--text-xs); font-weight: 700; }
.generated-text { margin-bottom: 10px; resize: vertical; }
.generated-actions { display: grid; gap: 8px; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); transform: translate(-50%, 16px); max-width: calc(100% - 32px); padding: 10px 14px; border-radius: var(--radius-md); background: var(--primary-green); color: #fff; opacity: 0; visibility: hidden; transition: opacity var(--transition), transform var(--transition), visibility var(--transition); text-align: center; font-weight: 700; }
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.noscript-message { margin: 16px; padding: 14px; border: 1px solid var(--divider); background: var(--surface-strong); }

@media (max-width: 1199px) { .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail-layout { grid-template-columns: 1fr 1fr; gap: var(--space-6); }
}
@media (max-width: 820px) {
  .mobile-filter-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .filter-select-brand { grid-column: 1 / -1; }
  .filter-navigation { display: none; }
}
@media (max-width: 700px) {
  .header-inner { min-height: 58px; padding: 0 var(--space-4); }
  .brand-mark small { display: none; }
  .header-search-button span { display: none; }
  .header-search-button { width: 40px; padding: 8px; }
  .header-cart-button { padding: 7px 9px; }
  .catalog-section { padding: var(--space-5) var(--space-4) 104px; }
  .catalog-heading { align-items: start; margin-bottom: var(--space-4); }
  .catalog-heading h1 { font-size: 1.75rem; }
  .catalog-heading .eyebrow { margin-bottom: var(--space-1); }
  .filters { margin-left: calc(var(--space-4) * -1); margin-right: calc(var(--space-4) * -1); padding: 0 var(--space-4) var(--space-4); }
  .search-field input { min-height: 48px; }
  .reset-button { min-height: 48px; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--space-3); row-gap: var(--space-6); }
  .product-name { min-height: 3.2em; font-size: 0.9rem; line-height: 1.55; }
  .product-spec { font-size: var(--text-xs); }
  .product-content { padding-top: 10px; }
  .product-card { padding-bottom: var(--space-3); }
  .mobile-cart-bar { display: flex; }
  .detail-header-inner { min-height: 58px; padding: 0 var(--space-4); }
  .detail-layout { grid-template-columns: 1fr; gap: var(--space-5); padding: var(--space-4) var(--space-4) var(--space-8); }
  .detail-image-wrap { height: clamp(300px, 82vw, 420px); padding: clamp(20px, 9vw, 38px); }
  .detail-copy { padding-top: 0; }
  .detail-copy h1 { margin-bottom: var(--space-5); font-size: 1.6rem; }
  .detail-features { margin-top: var(--space-6); }
  .detail-more { margin-top: var(--space-5); }
  .detail-add-button { margin-top: var(--space-5); }
  .drawer-scroll-area { padding: 14px 14px 122px; }
  .drawer-header,
  .drawer-footer { padding-left: 16px; padding-right: 16px; }
  .cart-section,
  .customer-section,
  .generated-section { padding: 15px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full-width { grid-column: auto; }
}
@media (max-width: 390px) {
  .catalog-section { padding-left: 12px; padding-right: 12px; }
  .filters { margin-left: -12px; margin-right: -12px; padding-left: 12px; padding-right: 12px; }
  .product-grid { column-gap: 10px; }
  .product-image-wrap { padding: 8px; }
  .product-name { font-size: 0.86rem; }
  .result-count { font-size: var(--text-xs); }
  .detail-layout { padding-left: 12px; padding-right: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
