:root {
  --bg: #fbfaf7;
  --fg: #1d1d1b;
  --muted: #6b6a66;
  --line: #e2dfd8;
  --accent: #1f5f4a;
  --warn: #9a3412;
  --warn-bg: #fff4ec;
  --card: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161614;
    --fg: #ece9e2;
    --muted: #9b9890;
    --line: #34332f;
    --accent: #6fc3a2;
    --warn: #f5a77a;
    --warn-bg: #2b1d14;
    --card: #1f1f1c;
  }
}
:root[data-theme="dark"] {
  --bg: #161614;
  --fg: #ece9e2;
  --muted: #9b9890;
  --line: #34332f;
  --accent: #6fc3a2;
  --warn: #f5a77a;
  --warn-bg: #2b1d14;
  --card: #1f1f1c;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
header nav {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
header nav a { color: var(--accent); text-decoration: none; }
header nav .who { color: var(--muted); margin-left: 8px; }
main { max-width: 1040px; margin: 0 auto; padding: 16px; }
h1 { font-size: 26px; margin: 8px 0 12px; }
h2 { font-size: 19px; margin: 24px 0 8px; }
a { color: var(--accent); }
.muted, .fine, .small, .ship, .cond { color: var(--muted); }
.small { font-size: 13px; }
.fine { font-size: 14px; }
.mono { font-family: ui-monospace, Menlo, monospace; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  color: var(--fg);
  text-decoration: none;
  display: block;
}
.card img, .noimg {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  background: var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.card h2 { font-size: 16px; margin: 10px 0 4px; }
.price { font-size: 18px; font-weight: 600; margin: 4px 0; }
.price .ship { font-size: 14px; font-weight: 400; }

.item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
}
.item .photos img {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--card);
}
.desc { margin-top: 16px; white-space: normal; }
@media (max-width: 720px) {
  .item { grid-template-columns: 1fr; }
  main { padding: 16px; }
}

button {
  font: inherit;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 10px 18px;
  cursor: pointer;
}
button.link {
  background: none;
  color: var(--accent);
  padding: 0;
  font-size: 13px;
}
button.danger { color: var(--warn); }
.inline { display: inline-block; margin: 0 6px 6px 0; }
.actions { margin: 12px 0; }

form.stack { display: flex; flex-direction: column; gap: 12px; max-width: 760px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--fg); }
input, select, textarea {
  font: inherit;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  min-width: 0;
}
textarea { resize: vertical; }
.row { display: flex; flex-wrap: wrap; gap: 12px; }
.row > label { flex: 1 1 160px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
legend { color: var(--muted); padding: 0 6px; font-size: 14px; }
.admin-photos figure { margin: 0; width: 140px; }
.admin-photos img { width: 140px; height: 105px; object-fit: cover; border-radius: 6px; }

table { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 15px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
table.small { font-size: 13px; }

.badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--line);
  color: var(--fg);
}
.badge.s-live, .badge.s-paid { background: #d9f0e6; color: #14452f; }
.badge.s-reserved { background: #fde9b8; color: #5b4300; }
.badge.s-sold, .badge.s-shipped { background: #e4e4f2; color: #2c2c55; }
.badge.s-conflict, .badge.s-refunded { background: #fbd9cc; color: #7a2a0a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge.s-live, :root:not([data-theme="light"]) .badge.s-paid { background: #1d3b2e; color: #bfe9d6; }
  :root:not([data-theme="light"]) .badge.s-reserved { background: #3d3212; color: #fbe3a0; }
  :root:not([data-theme="light"]) .badge.s-sold, :root:not([data-theme="light"]) .badge.s-shipped { background: #2a2a40; color: #d6d6f2; }
  :root:not([data-theme="light"]) .badge.s-conflict, :root:not([data-theme="light"]) .badge.s-refunded { background: #41241a; color: #f5c3ad; }
}

.alert, .flash, .errors {
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 10px 0;
}
.flash { background: var(--card); color: var(--accent); border: 1px solid var(--line); }
.errors ul { margin: 0; padding-left: 18px; }
