/* Palette follows rakuhobby.com: near-black chrome, white content, red accent (SHOP_ACCENT). */
:root {
  --ink: #121212;
  --ink-2: #1f1f1f;
  --bg: #ffffff;
  --bg-2: #f3f3f3;
  --line: #e2e2e2;
  --text: rgba(18, 18, 18, .85);
  --muted: rgba(18, 18, 18, .55);
  --accent: #d7262e;
  --green: #1f8a4c;
  --radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Helvetica, Arial, sans-serif;
}
a { color: var(--ink); }
h1, h2, h3 { color: var(--ink); margin: 0; letter-spacing: .01em; }
h1 { font-size: 26px; }
h2 { font-size: 19px; margin-bottom: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ── Top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 24px;
  background: var(--ink); color: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand img { display: block; height: 40px; width: auto; }
.brand b { font-size: 20px; letter-spacing: .04em; }
.brand span {
  padding-left: 12px; border-left: 1px solid rgba(255, 255, 255, .25);
  font-size: 14px; letter-spacing: .12em; text-transform: uppercase; color: rgba(255, 255, 255, .75);
}
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a {
  color: rgba(255, 255, 255, .75); padding: 7px 12px; border-radius: 6px;
  font-weight: 600; font-size: 14px; text-decoration: none;
}
.topbar nav a.on, .topbar nav a:hover { color: #fff; background: var(--ink-2); }
.topbar nav a.cta { background: var(--accent); color: #fff; }

.wrap { max-width: 1400px; margin: 0 auto; padding: 22px 24px 60px; }
.site-foot {
  max-width: 1400px; margin: 0 auto; padding: 18px 24px 28px;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; line-height: 1.6;
}
.site-foot p { margin: 0 0 4px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 4px 0 0; }

/* ── Controls ── */
input, select, textarea, button { font: inherit; }
input[type=text], input[type=search], input[type=number], input[type=url], select, textarea {
  border: 1px solid #cfcfcf; border-radius: 6px; padding: 8px 10px; background: #fff; color: var(--ink);
  min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: -1px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid var(--ink); background: var(--ink); color: #fff;
  border-radius: 6px; padding: 8px 14px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #333; }
.btn.ghost { background: #fff; color: var(--ink); }
.btn.ghost:hover { background: var(--bg-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger { background: #fff; color: #b3261e; border-color: #e6b3b0; }
.btn:disabled { opacity: .5; cursor: default; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input[type=search] { flex: 1 1 220px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px;
  cursor: pointer; font-weight: 600; color: var(--text);
}
.tabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ── Public buylist grid ── */
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 18px;
}
.tile { display: flex; flex-direction: column; gap: 6px; }
.tile .img {
  position: relative; display: block; border-radius: 8px; overflow: hidden; background: var(--bg-2);
  aspect-ratio: 200 / 279;
}
.tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tile .price {
  font-size: 19px; font-weight: 700; color: var(--accent); line-height: 1.2;
}
.tile .name { font-weight: 600; color: var(--ink); line-height: 1.3; }
.tile .meta { font-size: 12.5px; color: var(--muted); }
.tile .want {
  position: absolute; left: 8px; top: 8px; background: var(--ink); color: #fff;
  font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
}
.tile .note { font-size: 12.5px; color: var(--text); background: var(--bg-2); border-radius: 6px; padding: 4px 8px; }
.empty { padding: 40px 0; text-align: center; color: var(--muted); }

/* ── Admin ── */
.panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 20px; background: #fff; }
.panel h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.list th { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
table.list tr.off td { opacity: .5; }
table.list img.thumb { width: 44px; height: 61px; object-fit: cover; border-radius: 4px; background: var(--bg-2); display: block; }
table.list input[type=number] { width: 120px; }
table.list input.qty { width: 80px; }
table.list input.note { width: 100%; min-width: 140px; }
.saved { color: var(--green); font-size: 12px; }
.err { color: #b3261e; }
.tag { display: inline-block; font-size: 11.5px; padding: 1px 6px; border-radius: 4px; background: var(--bg-2); color: var(--muted); }
.tag.warn { background: #fdecea; color: #b3261e; }

/* Card picker */
.picker { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: var(--bg-2); margin-bottom: 20px; }
.pick-grid {
  list-style: none; margin: 0; padding: 0; max-height: 520px; overflow: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px;
}
.pick { background: #fff; border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); }
.pick img { width: 100%; aspect-ratio: 200 / 279; object-fit: cover; border-radius: 4px; background: var(--bg-2); }
.pick .name { font-size: 13px; font-weight: 600; line-height: 1.25; color: var(--ink); }
.pick .meta { font-size: 12px; color: var(--muted); }
.pick .row { display: flex; gap: 6px; }
.pick .row input { width: 100%; padding: 6px 8px; }
.pick.added { border-color: var(--green); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; align-items: end; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }

.settings { display: flex; flex-direction: column; gap: 14px; max-width: 560px; }
.settings label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px; }
.settings small { font-weight: 400; }
.settings input[type=color] { width: 64px; height: 36px; padding: 2px; border: 1px solid #cfcfcf; border-radius: 6px; }

/* ── Shared bits for sell / account / inbox ── */
.mt { margin-top: 18px; }
.narrow { max-width: 440px; margin: 20px auto; }
.narrow h1 { margin-bottom: 6px; }
.stack { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px; }
.stack input { padding: 10px 12px; font-size: 16px; }
.code-input { letter-spacing: .4em; font-size: 22px !important; text-align: center; }
.flash { background: #fff7e6; border: 1px solid #f3dca5; border-radius: 8px; padding: 10px 14px; margin: 0 0 16px; }
.topbar nav a .count {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 12px; text-align: center;
}
.st { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--bg-2); color: var(--text); vertical-align: middle; }
.st-submitted { background: #fff3cd; color: #7a5a00; }
.st-offered { background: #e3edff; color: #1d4ea8; }
.st-accepted { background: #ddf3e4; color: #1f6b3d; }
.st-completed { background: var(--ink); color: #fff; }
.st-rejected, .st-declined { background: #fdecea; color: #b3261e; }
.st-cancelled { background: var(--bg-2); color: var(--muted); }
.totals { display: flex; gap: 20px; flex-wrap: wrap; justify-content: flex-end; align-items: baseline; padding-top: 14px; color: var(--muted); }
.totals .big { font-size: 20px; font-weight: 700; color: var(--ink); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.actions form { margin: 0; }
.photos { display: flex; gap: 10px; flex-wrap: wrap; }
.photos img { width: 120px; height: 120px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 20px; }
.btn.wa { background: #25d366; border-color: #25d366; color: #0b2e17; }
.btn.wa:hover { background: #1ebe5b; }
a.tab { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; font-weight: 600; color: var(--text); text-decoration: none; font-size: 14px; }
a.tab.on { background: var(--ink); color: #fff; border-color: var(--ink); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--bg-2); }
.pick .buy { font-size: 13px; font-weight: 700; color: var(--accent); min-height: 1em; }
table.cart input.qty { width: 80px; }
table.cart input.ask { width: 130px; }

/* Offer editor */
.oitem { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.oitem .thumb { width: 64px; height: 89px; object-fit: cover; border-radius: 4px; background: var(--bg-2); flex: none; }
.oitem.bad { background: #fff8f7; }
.obody { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.olines { display: flex; flex-direction: column; gap: 6px; }
.oline { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.oline .q { width: 70px; }
.oline .p { width: 140px; }
.oline .r { flex: 1 1 200px; }
.ofoot { display: flex; gap: 12px; align-items: center; }

@media (max-width: 700px) {
  .topbar { padding: 8px 16px; flex-wrap: wrap; }
  .brand img { height: 32px; }
  .brand span { display: none; }
  .wrap { padding: 16px 16px 48px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  table.list thead { display: none; }
  table.list tr { display: grid; grid-template-columns: 52px 1fr; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.list td { border: 0; padding: 2px 0; }
  table.list td:first-child { grid-row: span 6; }
  table.list input[type=number], table.list input.qty { width: 100%; }
}
