:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1d1b18;
  --muted: #6d675e;
  --line: #e3ded4;
  --accent: #b4462b;
  --accent-ink: #ffffff;
  --ok: #2f7a4a;
  --warn: #a86b00;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; letter-spacing: -.01em; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.35rem; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
header.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
header.top .wrap { display: flex; align-items: center; gap: 20px; height: 60px; }
.brand { font-weight: 800; font-size: 1.15rem; color: var(--ink); letter-spacing: -.02em; }
.brand span { color: var(--accent); }
nav.main { display: flex; gap: 16px; margin-left: auto; align-items: center; flex-wrap: wrap; }
nav.main a { color: var(--ink); font-weight: 500; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: .75rem; text-align: center; line-height: 20px; }
main { padding: 28px 0 60px; min-height: 70vh; }
footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; padding: 20px 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--ink); background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { opacity: .9; text-decoration: none; }
.btn.accent { background: var(--accent); border-color: var(--accent); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn.danger { background: #fff; color: #a3261b; border-color: #e7b7b1; }
.btn:disabled { opacity: .5; cursor: default; }

input, select, textarea { font: inherit; width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: auto; }
label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.stack > * + * { margin-top: 16px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip { border: 1px solid var(--line); background: var(--card); padding: 5px 12px; border-radius: 99px; color: var(--ink); font-size: .9rem; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.pcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.pcard .img { aspect-ratio: 1; background: #ece8df; display: grid; place-items: center; color: #b7afa1; font-size: 2.5rem; position: relative; }
.noimg { font-size: .85rem; color: #a59d8f; letter-spacing: .05em; text-transform: uppercase; }
.pcard .img img { width: 100%; height: 100%; object-fit: cover; }
.pcard .body { padding: 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.pcard .name { font-weight: 600; color: var(--ink); }
.pcard .foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.price { font-weight: 700; }
.price .old { color: var(--muted); text-decoration: line-through; font-weight: 400; font-size: .85em; margin-right: 6px; }
.price.sale { color: var(--accent); }
.price .from { font-weight: 400; font-size: .8em; margin-left: 3px; }
.salebadge { position: absolute; top: 10px; left: 10px; background: var(--accent); color: #fff; font-size: .75rem; font-weight: 700; padding: 3px 8px; border-radius: 6px; }

.detail { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.detail .gallery .main { aspect-ratio: 1; background: #ece8df; border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; font-size: 4rem; color: #b7afa1; }
.detail .gallery .main img { width: 100%; height: 100%; object-fit: cover; }
.thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; cursor: pointer; border: 2px solid transparent; }
.thumbs img.on { border-color: var(--accent); }
.prose { max-width: 70ch; }
.prose img { border-radius: 8px; margin: 1em 0; }

table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.t th { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
table.t td.num, table.t th.num { text-align: right; white-space: nowrap; }
.qty { width: 70px; }

.cart { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: start; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .grand { font-size: 1.2rem; font-weight: 800; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; cursor: pointer; font-weight: 500; color: var(--ink); font-size: .95rem; }
.opt:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, white); }
.opt .r { margin-left: auto; white-space: nowrap; }

.posts { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.post-card .cover { aspect-ratio: 16/9; background: #ece8df; border-radius: 8px; overflow: hidden; margin-bottom: 12px; }
.post-card .cover img { width: 100%; height: 100%; object-fit: cover; }

.status { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .8rem; font-weight: 600; background: #eee; }
.status.new { background: #fde9c8; color: #7a4a00; }
.status.paid, .status.processing { background: #dde9fb; color: #1f4a8a; }
.status.shipped { background: #e4dcf7; color: #4a2f8a; }
.status.delivered { background: #d8efdf; color: #1f6a3a; }
.status.cancelled { background: #eee; color: #777; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 360px; }
.toast.err { background: #a3261b; }
.toast.ok { background: var(--ok); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.auth-box { max-width: 420px; margin: 0 auto; }

@media (max-width: 760px) {
  .detail, .cart { grid-template-columns: 1fr; }
  h1 { font-size: 1.5rem; }
  header.top .wrap { height: auto; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
  nav.main { margin-left: 0; gap: 12px; }
}
