:root {
  --bg: #f6f4ef; --surface: #ffffff; --surface-2: #efece5; --text: #1d1c1a; --muted: #6b675f;
  --line: #e2ddd3; --accent: #0f7b5f; --accent-ink: #ffffff; --warn: #a6501a; --warn-bg: #fbeee3;
  --ok-bg: #e3f3ec; --sale: #c2332b; --radius: 14px; --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 6px 20px rgb(0 0 0 / .05);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151514; --surface: #1f1f1d; --surface-2: #2a2a27; --text: #ecebe7; --muted: #a29e95;
    --line: #34332f; --accent: #3fbf96; --accent-ink: #0d1f19; --warn: #f0a46c; --warn-bg: #3a2618; --ok-bg: #173229; --sale: #f0675e; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

header.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
header.top .wrap { display: flex; align-items: center; gap: 16px; height: 60px; }
.brand { font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; display: flex; gap: 8px; align-items: center; }
.brand .dot { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: inline-block; }
header.top nav { margin-left: auto; display: flex; gap: 16px; }
header.top nav a { color: var(--muted); text-decoration: none; }
header.top nav a:hover { color: var(--text); }

h1 { font-size: 28px; line-height: 1.2; margin: 28px 0 6px; }
h2 { font-size: 19px; margin: 0 0 12px; }
.lead { color: var(--muted); margin: 0 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.tabs { display: flex; gap: 6px; margin: 8px 0 16px; flex-wrap: wrap; }
.tab { border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 8px 14px;
  border-radius: 999px; cursor: pointer; font: inherit; }
.tab[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

.searchbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.searchbar input[type=search] { flex: 1 1 260px; }
label.check { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 14px; }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; width: 100%; }
input[type=checkbox] { width: auto; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
button, .btn { font: inherit; border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none; display: inline-block; }
button.secondary, .btn.secondary { background: var(--surface-2); color: var(--text); }
button:disabled { opacity: .5; cursor: not-allowed; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.card { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  text-decoration: none; color: inherit; display: flex; flex-direction: column; transition: transform .15s; }
.card:hover { transform: translateY(-2px); }
.card .img { aspect-ratio: 1; background: var(--surface-2); overflow: hidden; }
.card .img img { width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card .title { font-weight: 600; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { display: flex; justify-content: space-between; align-items: center; margin-top: auto; font-size: 13px; color: var(--muted); gap: 8px; }
.card .price { color: var(--text); font-weight: 700; }
.card.locked .img img { filter: grayscale(.6); opacity: .75; }

.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--accent); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }

.notice { background: var(--warn-bg); color: var(--warn); padding: 12px 14px; border-radius: 10px; margin: 12px 0; }
.notice.ok { background: var(--ok-bg); color: var(--accent); }
.empty { padding: 40px; text-align: center; color: var(--muted); background: var(--surface); border-radius: var(--radius); }
.center { display: flex; justify-content: center; margin: 20px 0; }

/* model page */
.model { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 28px; margin: 24px 0 48px; }
@media (max-width: 860px) { .model { grid-template-columns: minmax(0, 1fr); } }
.gallery .main { aspect-ratio: 1; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.gallery .main img { width: 100%; height: 100%; object-fit: contain; }
.thumbs { display: flex; gap: 8px; overflow-x: auto; margin-top: 10px; padding-bottom: 4px; }
.thumbs button { padding: 0; width: 64px; height: 64px; flex: 0 0 64px; border-radius: 8px; overflow: hidden; background: var(--surface-2);
  border: 2px solid transparent; }
.thumbs button[aria-current="true"] { border-color: var(--accent); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.panel { background: var(--surface); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.profiles { display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow-y: auto; }
.profile { display: flex; gap: 10px; align-items: center; text-align: left; background: var(--surface-2); color: var(--text);
  border: 2px solid transparent; font-weight: 400; padding: 8px; }
.profile[aria-pressed="true"] { border-color: var(--accent); }
.profile img { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; flex: 0 0 48px; }
.profile .pt { font-size: 14px; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.profile .pm { font-size: 12px; color: var(--muted); }
.profile .pp { margin-left: auto; font-weight: 700; white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 10px; }
.stat b { display: block; font-size: 18px; }
.stat span { font-size: 12px; color: var(--muted); }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.swatch { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; background: var(--surface-2); padding: 3px 8px 3px 4px; border-radius: 999px; }
.swatch i { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--line); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form .full { grid-column: 1 / -1; }
.form label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
@media (max-width: 520px) { .form { grid-template-columns: 1fr; } }
table.breakdown { width: 100%; border-collapse: collapse; font-size: 14px; }
table.breakdown td { padding: 4px 0; }
table.breakdown td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
table.breakdown tr.total td { border-top: 1px solid var(--line); padding-top: 8px; font-weight: 700; font-size: 18px; }
.summary { white-space: pre-line; color: var(--muted); font-size: 14px; max-height: 220px; overflow: auto; }

footer { color: var(--muted); font-size: 13px; padding: 32px 0; border-top: 1px solid var(--line); margin-top: 40px; }

/* admin */
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table img { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; }
.scroll-x { overflow-x: auto; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.kv label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }

.steps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin: 12px 0; }
.steps div { background: var(--surface-2); border-radius: 8px; padding: 8px 6px; font-size: 12px; color: var(--muted); text-align: center; }
.steps div.done { background: var(--ok-bg); color: var(--accent); }
@media (max-width: 520px) { header.top nav { gap: 10px; font-size: 14px; } .brand { font-size: 16px; } }

.price { display: inline-flex; gap: 4px; align-items: baseline; flex-wrap: wrap; }
.price .was { color: var(--muted); font-weight: 400; font-size: .9em; }
.price .now { color: var(--sale); }
.pill.sale { background: var(--sale); color: #fff; font-weight: 700; }
.card .img { position: relative; }
.card .img .pill.sale { position: absolute; top: 8px; left: 8px; font-size: 13px; }
.card .pricing { display: flex; justify-content: space-between; align-items: center; gap: 6px; min-height: 22px; font-size: 14px; }
.skeleton { display: inline-block; width: 70px; height: 14px; border-radius: 4px; background: var(--surface-2); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.notice.sale-banner { background: color-mix(in srgb, var(--sale) 12%, var(--surface)); color: var(--sale); display: flex; gap: 8px; align-items: center; }
tr.sale-row td { color: var(--sale); font-weight: 600; }

/* category bar, Bambu Handy style */
.catbar { position: relative; display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 10px; margin: 0 -2px 4px;
  scroll-snap-type: x proximity; scrollbar-width: thin; }
.cat { flex: 0 0 auto; width: 84px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; color: var(--text); font-weight: 500; padding: 6px 2px; border-radius: 12px; scroll-snap-align: start; }
.cat:hover { background: var(--surface-2); }
.cat .ic { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: #f1eee7; color: #352f2d; border: 2px solid transparent; transition: border-color .15s, transform .15s; }
.cat .ic img { width: 26px; height: 26px; }
.cat .nm { font-size: 12px; line-height: 1.2; text-align: center; }
.cat[aria-pressed="true"] .ic { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, #f1eee7); transform: scale(1.05); }
.cat[aria-pressed="true"] .nm { color: var(--accent); font-weight: 700; }
.subcats { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: thin; }
.chip { flex: 0 0 auto; background: var(--surface); color: var(--text); border: 1px solid var(--line); font-weight: 500;
  padding: 6px 12px; border-radius: 999px; font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
@media (max-width: 520px) { .cat { width: 72px; } .cat .ic { width: 46px; height: 46px; } }

@media (max-width: 520px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card .body { padding: 8px 10px 10px; }
  .card .title { font-size: 13px; }
  .card .pricing { font-size: 13px; }
  .card .img .pill.sale { font-size: 11px; top: 6px; left: 6px; }
}
