*, *::before, *::after { box-sizing: border-box; }
html { font-size: var(--fs-base); scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font-family); color: var(--color-text);
  background: var(--color-bg); line-height: 1.5;
  padding-bottom: calc(var(--contact-footer-h) + var(--bottom-nav-h) + var(--safe-area-bottom));
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--color-accent); }
.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 8px; top: 8px; z-index: 999; background: #fff; padding: 8px; }

.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: var(--color-bg-card); border-bottom: 1px solid var(--color-border);
  padding-top: env(safe-area-inset-top, 0);
}
.navbar-inner {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; max-width: 1100px; margin: 0 auto;
}
.navbar-title { font-weight: 700; flex: 1; font-size: 15px; }
.navbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 14px; border-radius: 8px; border: 1px solid transparent;
  font-size: 14px; cursor: pointer; text-decoration: none; font-family: inherit;
  background: var(--color-bg-card); color: var(--color-text);
}
.btn-primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-secondary { border-color: var(--color-border); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.section-title { font-size: var(--fs-h2); margin: 0 0 8px; }
.section-desc { color: var(--color-text-secondary); font-size: 14px; margin: 0 0 16px; }
.field-hint { font-size: 12px; color: var(--color-text-secondary); }

.bookshelf-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px;
}
@media (min-width: 768px) { .bookshelf-grid { grid-template-columns: repeat(3, 1fr); } }

.bookshelf-card {
  text-decoration: none; color: inherit; display: block;
  perspective: 800px;
}
.bookshelf-cover {
  border-radius: 8px; overflow: hidden; box-shadow: var(--theme-shadow);
  transform: rotateY(-4deg); transition: transform .25s, box-shadow .25s;
  aspect-ratio: 4/5; background: var(--color-border);
}
.bookshelf-card:hover .bookshelf-cover { transform: rotateY(0deg) translateY(-4px); box-shadow: 0 12px 32px rgba(0,0,0,.12); }
.bookshelf-cover img { width: 100%; height: 100%; object-fit: cover; }
.bookshelf-meta { margin-top: 10px; }
.bookshelf-meta strong { display: block; font-size: 14px; }
.bookshelf-meta span { font-size: 12px; color: var(--color-text-secondary); }

.product-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
@media (min-width: 768px) { .product-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .product-grid { grid-template-columns: repeat(4, 1fr); } }

.product-card {
  background: var(--color-bg-card); border-radius: 12px; border: 1px solid var(--color-border);
  overflow: hidden; display: flex; flex-direction: column;
}
.product-card__img { aspect-ratio: 4/3; object-fit: cover; width: 100%; background: var(--color-border); }
.product-card__body { padding: 10px; flex: 1; }
.product-card__name { font-size: 13px; font-weight: 600; margin: 0 0 4px; line-height: 1.3; }
.product-card__model { font-size: 11px; color: var(--color-text-secondary); }
.product-card__price { font-size: 14px; color: var(--color-primary); font-weight: 700; margin: 6px 0; }
.product-badges { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.product-badge {
  font-size: 10px; padding: 2px 6px; border-radius: 4px;
  background: rgba(59,130,246,0.12); color: var(--color-accent);
}
.product-badge--hot { background: rgba(220,38,38,0.12); color: #DC2626; }
.product-card__actions { display: flex; gap: 6px; padding: 0 10px 10px; }
.product-card__actions .btn { flex: 1; font-size: 11px; padding: 6px 4px; }
.product-card__actions .btn.active { background: var(--color-primary); color: #fff; }

.filter-drawer {
  position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.4);
  display: flex; align-items: flex-end;
}
.filter-drawer.hidden { display: none; }
.filter-panel__inner {
  background: var(--color-bg-card); border-radius: 16px 16px 0 0;
  padding: 16px; width: 100%; max-height: 85vh; overflow-y: auto;
}
@media (min-width: 768px) {
  .filter-drawer { align-items: center; justify-content: center; }
  .filter-panel__inner { max-width: 420px; border-radius: 16px; }
}
.filter-panel__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

.compare-bar {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--contact-footer-h) + var(--bottom-nav-h) + var(--safe-area-bottom));
  z-index: 90; background: var(--color-primary); color: #fff;
  padding: 10px 16px; display: flex; align-items: center; gap: 10px;
  transform: translateY(100%); transition: transform .25s;
}
.compare-bar.show { transform: translateY(0); }
.compare-bar a { color: #fff; font-weight: 600; }

.bottom-nav {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--contact-footer-h) + var(--safe-area-bottom));
  z-index: 80; display: flex; background: var(--color-bg-card);
  border-top: 1px solid var(--color-border); height: var(--bottom-nav-h);
}
.bottom-nav a {
  flex: 1; text-align: center; padding: 6px 4px; font-size: 11px;
  text-decoration: none; color: var(--color-text-secondary);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.bottom-nav a.active { color: var(--color-primary); font-weight: 600; }
.bottom-nav .nav-badge {
  background: #DC2626; color: #fff; font-size: 10px; min-width: 16px;
  height: 16px; border-radius: 8px; padding: 0 4px; line-height: 16px;
}

.contact-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 85;
  background: var(--color-bg-card); border-top: 1px solid var(--color-border);
  padding: 8px 12px calc(8px + var(--safe-area-bottom));
}
.contact-footer__btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.contact-footer__cta, .contact-footer__btn {
  padding: 8px 14px; border-radius: 8px; font-size: 13px; text-decoration: none; border: 1px solid var(--color-border);
  background: var(--color-bg-card); color: var(--color-text); cursor: pointer;
}
.contact-footer__cta { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.contact-footer__brand { text-align: center; font-size: 11px; color: var(--color-text-secondary); margin: 6px 0 0; }

/* Flipbook */
.flip-viewport {
  position: relative; max-width: 900px; margin: 0 auto;
  background: var(--color-bg-card); border-radius: 12px; overflow: hidden;
  box-shadow: var(--theme-shadow);
}
.flip-slide {
  display: none; padding: 16px; min-height: 420px;
}
.flip-slide.active { display: block; animation: fadeIn .35s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.flip-page-grid { display: grid; gap: 12px; }
.flip-page-grid.grid2 { grid-template-columns: 1fr 1fr; }
.flip-page-title { font-size: 16px; margin-bottom: 12px; text-align: center; }
.flip-thumb { border-radius: 8px; overflow: hidden; border: 1px solid var(--color-border); }
.flip-thumb img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.flip-thumb strong { display: block; padding: 6px; font-size: 12px; }
.flip-controls {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 12px; border-top: 1px solid var(--color-border);
}
.flip-progress { font-size: 13px; color: var(--color-text-secondary); }

/* Compare */
.compare-table-wrap { overflow-x: auto; }
.compare-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  background: var(--color-bg-card); border-radius: 12px;
}
.compare-table th, .compare-table td {
  border: 1px solid var(--color-border); padding: 10px 8px; text-align: center; min-width: 100px;
}
.compare-table th:first-child, .compare-table td:first-child {
  text-align: left; font-weight: 600; background: var(--color-bg); position: sticky; left: 0;
}
.compare-table .diff-better { background: rgba(5,150,105,0.12); color: #059669; }
.compare-table .diff-worse { background: rgba(220,38,38,0.08); color: #DC2626; }

/* Product detail */
.product-hero img { width: 100%; border-radius: 12px; aspect-ratio: 4/3; object-fit: cover; }
.spec-group { margin-bottom: 16px; }
.spec-group h3 { font-size: 14px; margin: 0 0 8px; color: var(--color-primary); }
.spec-table { width: 100%; font-size: 13px; }
.spec-table td { padding: 6px 8px; border-bottom: 1px solid var(--color-border); }
.spec-table td:first-child { color: var(--color-text-secondary); width: 40%; }

/* Inquiry */
.inquiry-item {
  display: flex; gap: 12px; padding: 12px; border-bottom: 1px solid var(--color-border);
  align-items: center; background: var(--color-bg-card); border-radius: 8px; margin-bottom: 8px;
}
.inquiry-item img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.inquiry-item__info { flex: 1; min-width: 0; }
.inquiry-item__info strong { font-size: 13px; display: block; }
.qty-input { width: 48px; padding: 4px; border-radius: 6px; border: 1px solid var(--color-border); }

.form-field { margin-bottom: 14px; }
.form-field label { display: block; font-size: 13px; margin-bottom: 4px; color: var(--color-text-secondary); }
.form-field input, .form-field textarea, .form-field select {
  width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--color-border);
  background: var(--color-bg-card); color: var(--color-text); font-family: inherit;
}

.editor-page { padding: 16px; max-width: 720px; margin: 0 auto; }
.editor-hint { font-size: 13px; color: var(--color-text-secondary); margin-bottom: 12px; }
.editor-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.product-editor-row {
  margin-bottom: 16px; padding: 12px; border-radius: 12px;
  border: 1px solid var(--color-border); background: var(--color-bg-card);
}
.import-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.hidden-input { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; }
.avatar-field { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.avatar-preview { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--color-border); }

.editor-modal {
  position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.editor-modal.hidden { display: none; }
.editor-modal__panel {
  background: var(--color-bg-card); border-radius: 16px; padding: 16px;
  max-width: 480px; width: 100%; max-height: 90vh; overflow-y: auto;
}
.editor-modal__actions { display: flex; gap: 8px; margin-top: 12px; }

.animate-in { animation: fadeUp .5s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.r160-toast {
  position: fixed; left: 50%; bottom: calc(var(--contact-footer-h) + 100px);
  transform: translateX(-50%); background: rgba(0,0,0,.85); color: #fff;
  padding: 10px 18px; border-radius: 8px; z-index: 9999; opacity: 0; transition: opacity .2s;
}
.r160-toast.show { opacity: 1; }

.success-hero { text-align: center; padding: 32px 16px; }
.success-hero h1 { color: var(--color-primary); }
