:root {
  --bg: #fbf7f2;
  --surface: #ffffff;
  --ink: #2b211c;
  --muted: #6b5d54;
  --line: #e8dfd5;
  --accent: #b4532a;
  --accent-ink: #ffffff;
  --accent-soft: #f6e6dc;
  --ok: #2f6b4f;
  --danger: #a63a2b;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(43 33 28 / 0.06), 0 8px 24px rgb(43 33 28 / 0.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1714;
    --surface: #25201c;
    --ink: #f3ece5;
    --muted: #b5a89d;
    --line: #3a322c;
    --accent: #e07a4f;
    --accent-ink: #1b1714;
    --accent-soft: #3a2a21;
    --ok: #7cc4a0;
    --danger: #f08a7a;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1, h2, h3, .brand { font-family: "Fraunces", Georgia, serif; font-weight: 600; line-height: 1.2; margin: 0; }
img { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

/* Header */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 1.4rem; color: var(--ink); text-decoration: none; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.intro { padding: 40px 0 24px; max-width: 60ch; }
.intro h1 { font-size: clamp(1.9rem, 5vw, 2.8rem); }
.intro p { color: var(--muted); margin: 10px 0 0; }
.foot { text-align: center; color: var(--muted); font-size: 0.875rem; padding: 48px 16px 32px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background-color 0.2s, opacity 0.2s;
}
.btn:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { background: transparent; color: var(--danger); border-color: currentColor; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 44px; height: 44px; border: 0; border-radius: 999px;
  background: transparent; color: var(--ink); cursor: pointer;
  transition: background-color 0.2s;
}
.icon-btn:hover { background: var(--accent-soft); }
.icon-btn svg { width: 24px; height: 24px; }
.badge {
  position: absolute; top: 2px; right: 0;
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 0.75rem; font-weight: 700; line-height: 20px; text-align: center;
}

/* Product grid */
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
}
@media (max-width: 480px) { .grid { grid-template-columns: 1fr 1fr; gap: 12px; } }
.card {
  display: flex; flex-direction: column; width: 100%; height: 100%;
  padding: 0; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); text-align: left; cursor: pointer; overflow: hidden;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.card:hover { box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.photo { aspect-ratio: 1; width: 100%; height: auto; object-fit: cover; background: var(--accent-soft); }
.card .meta { padding: 12px 14px 14px; display: grid; gap: 2px; }
.card .title { font-weight: 600; }
.price { color: var(--muted); font-variant-numeric: tabular-nums; }
.tag {
  justify-self: start; margin-top: 4px; padding: 2px 10px; border-radius: 999px;
  background: var(--line); color: var(--muted); font-size: 0.8rem; font-weight: 600;
}
.card.sold .photo { filter: grayscale(0.7); opacity: 0.7; }
.empty, .status { color: var(--muted); padding: 24px 0; }
.status:empty { display: none; }
.status.ok {
  color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 20px; font-weight: 500;
}
.skeleton { aspect-ratio: 0.8; border-radius: var(--radius); background: var(--line); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

/* Dialogs */
dialog {
  border: 0; padding: 0; color: var(--ink); background: var(--surface);
  box-shadow: var(--shadow); max-height: 100dvh;
}
dialog::backdrop { background: rgb(20 14 10 / 0.5); }
.sheet { width: min(92vw, 760px); border-radius: var(--radius); }
.sheet .body { display: grid; gap: 20px; padding: 20px; }
@media (min-width: 720px) { .sheet .body { grid-template-columns: 1fr 1fr; align-items: start; } }
.sheet .photo { border-radius: 10px; }
.sheet .desc { white-space: pre-line; color: var(--muted); margin: 12px 0 20px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 12px 0 20px; }
.drawer {
  margin: 0 0 0 auto; width: min(100vw, 420px); height: 100dvh; max-width: 100vw;
  border-radius: 0; display: none; flex-direction: column;
}
.drawer[open] { display: flex; }
.drawer .lines { list-style: none; margin: 0; padding: 8px 20px; overflow-y: auto; flex: 1; }
.line { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.line img, .line .ph { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--accent-soft); }
.line .title { font-weight: 600; line-height: 1.3; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; }
.stepper button { width: 40px; height: 40px; border: 0; background: none; cursor: pointer; border-radius: 999px; font-size: 1.1rem; }
.stepper button:hover:not(:disabled) { background: var(--accent-soft); }
.stepper button:disabled { opacity: 0.35; cursor: not-allowed; }
.stepper output { min-width: 28px; text-align: center; font-variant-numeric: tabular-nums; }
.totals { padding: 16px 20px; border-top: 1px solid var(--line); display: grid; gap: 4px; }
.totals div { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.totals .grand { font-weight: 700; font-size: 1.1rem; margin-top: 4px; }
.checkout { padding: 0 20px 20px; }
.msg { color: var(--danger); margin: 0 0 12px; min-height: 0; }
.msg:empty { display: none; }
.note { color: var(--muted); font-size: 0.875rem; }

/* Admin */
.tabs { display: flex; gap: 8px; padding: 16px 0; }
.tabs .btn[aria-selected="false"] { background: transparent; color: var(--ink); border-color: var(--line); }
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.row {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center;
  padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.row img, .row .ph { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--accent-soft); }
.row .title { font-weight: 600; line-height: 1.3; }
.row .edit { all: unset; cursor: pointer; display: grid; gap: 2px; }
.row .edit:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.form { display: grid; gap: 14px; padding: 20px; }
.form label { display: grid; gap: 6px; font-weight: 500; }
.form input:not([type="checkbox"]), .form textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.form textarea { min-height: 110px; resize: vertical; }
.form .check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.form .check input { width: 20px; height: 20px; accent-color: var(--accent); }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form .actions { display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.preview { width: 120px; aspect-ratio: 1; border-radius: 10px; object-fit: cover; background: var(--accent-soft); }
.order { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: grid; gap: 8px; }
.order.shipped { opacity: 0.65; }
.order pre { margin: 0; font: inherit; white-space: pre-line; color: var(--muted); }
.order ul { margin: 0; padding-left: 18px; }
.order a { color: var(--accent); }

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