:root {
  --bg: #f6f7f9; --surface: #fff; --surface-2: #f0f2f5; --border: #e3e6eb;
  --text: #16191d; --muted: #646b75; --accent: #2f5bea; --accent-ink: #fff;
  --good: #137a3f; --good-bg: #e3f5ea; --warn: #a14a00; --warn-bg: #fff1e0;
  --bad: #b42318; --bad-bg: #fde8e7; --radius: 12px; --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 2px 8px rgb(0 0 0 / .04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317; --surface: #1a1d22; --surface-2: #23272e; --border: #2e333b;
    --text: #e8eaed; --muted: #9aa1ab; --accent: #6d8cff; --accent-ink: #0b1020;
    --good: #5fd68f; --good-bg: #173324; --warn: #ffb066; --warn-bg: #3a2814;
    --bad: #ff8a80; --bad-bg: #3d1c1a; --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.btn { border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; border-radius: 8px; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger { color: var(--bad); }
input, select, textarea { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

header.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; padding: 12px 24px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
header.top h1 { font-size: 18px; margin: 0; }
header.top .spacer { flex: 1; }
.me { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 600; font-size: 12px; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.bell { position: relative; }
.bell .dot { position: absolute; top: 2px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }

main { max-width: 1200px; margin: 0 auto; padding: 20px 24px 60px; }
.rules { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; color: var(--muted); font-size: 14px; display: flex; gap: 20px; flex-wrap: wrap; }
.rules b { color: var(--text); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input[type=search] { flex: 1; min-width: 200px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: 13px; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; cursor: pointer; display: flex; flex-direction: column; transition: transform .1s; }
.card:hover { transform: translateY(-2px); }
.card.closed { opacity: .65; }
.photo { aspect-ratio: 16 / 10; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); position: relative; }
.photo img { width: 100%; height: 100%; object-fit: cover; }
/* Card photos fill a fixed 16:10 frame, whatever the photo's own shape. */
.card .photo { overflow: hidden; }
.card .photo img { position: absolute; inset: 0; }
.photo .lotno { position: absolute; top: 8px; left: 8px; background: var(--surface); border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600; color: var(--text); }
.photo .star { position: absolute; top: 6px; right: 8px; font-size: 20px; color: #f5b400; text-shadow: 0 1px 2px rgb(0 0 0 / .3); }
.card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card h3 { margin: 0; font-size: 15px; }
.card .specs { color: var(--muted); font-size: 13px; }
.card .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: end; padding-top: 8px; }
.price { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.price-label { font-size: 12px; color: var(--muted); }
.timer { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); text-align: right; }
.timer.soon { color: var(--bad); font-weight: 600; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.pill.win { background: var(--good-bg); color: var(--good); }
.pill.out { background: var(--bad-bg); color: var(--bad); }
.pill.neutral { background: var(--surface-2); color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

dialog { border: none; border-radius: 16px; padding: 0; width: min(760px, 94vw); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / .3); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
.detail { display: grid; grid-template-columns: 1fr 1fr; }
.detail .gallery { display: flex; flex-direction: column; background: var(--surface-2); }
.detail .photo { aspect-ratio: auto; min-height: 260px; flex: 1; }
.detail .photo img { object-fit: contain; max-height: 420px; }
.photo.zoomable { cursor: zoom-in; }
.zoomhint { position: absolute; bottom: 8px; right: 8px; background: rgb(0 0 0 / .55); color: #fff; font-size: 12px; padding: 3px 8px; border-radius: 6px; pointer-events: none; }
#viewer { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; border-radius: 0; background: rgb(0 0 0 / .92); padding: 0; }
#viewer::backdrop { background: rgb(0 0 0 / .8); }
#viewer[open] { display: flex; align-items: center; justify-content: center; }
#viewer img { max-width: 100%; max-height: calc(100vh - 56px); object-fit: contain; }
#viewer .vprev, #viewer .vnext { position: absolute; top: 50%; transform: translateY(-50%); background: rgb(255 255 255 / .15); color: #fff; border: none; font-size: 40px; width: 52px; height: 72px; border-radius: 10px; cursor: pointer; }
#viewer .vprev { left: 12px; } #viewer .vnext { right: 12px; }
#viewer .vprev:hover, #viewer .vnext:hover { background: rgb(255 255 255 / .3); }
#viewer .vbar { position: absolute; bottom: 0; left: 0; right: 0; display: flex; gap: 16px; align-items: center; justify-content: center; padding: 10px; color: #fff; font-size: 14px; }
#viewer .vbar a { color: #fff; }
.thumbs { display: flex; gap: 6px; padding: 8px; overflow-x: auto; }
.thumbs img { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; cursor: pointer; opacity: .6; border: 2px solid transparent; }
.thumbs img.on { opacity: 1; border-color: var(--accent); }
.detail .info { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.detail h2 { margin: 0; font-size: 20px; }
.detail .close { position: absolute; top: 10px; right: 10px; z-index: 2; }
.bidbox { background: var(--surface-2); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.bidrow { display: flex; gap: 8px; }
.bidrow .dollar { position: relative; flex: 1; }
.bidrow .dollar input { width: 100%; padding-left: 22px; }
.bidrow .dollar::before { content: "$"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); }
.msg { font-size: 13px; padding: 8px 10px; border-radius: 8px; }
.msg.ok { background: var(--good-bg); color: var(--good); }
.msg.err { background: var(--bad-bg); color: var(--bad); }
.history { padding: 0 20px 20px; }
.history h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.history ol { list-style: none; margin: 0; padding: 0; max-height: 200px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.history li { display: flex; justify-content: space-between; padding: 6px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
.history li:last-child { border-bottom: none; }
.history li.mine { background: var(--surface-2); }
.history .auto { color: var(--muted); font-size: 11px; margin-left: 6px; }
@media (max-width: 640px) {
  .detail { grid-template-columns: 1fr; }
  .detail .photo { min-height: 180px; }
  header.top, main { padding-left: 16px; padding-right: 16px; }
}

.toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: 360px; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: 0 6px 20px rgb(0 0 0 / .25); font-size: 14px; cursor: pointer; animation: in .2s ease-out; }
.toast small { display: block; opacity: .7; font-size: 11px; margin-bottom: 2px; }
@keyframes in { from { transform: translateY(10px); opacity: 0; } }
.panel { position: absolute; right: 16px; top: 54px; width: 340px; max-height: 60vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgb(0 0 0 / .15); z-index: 20; }
.panel div { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; cursor: pointer; }
.panel div:hover { background: var(--surface-2); }
.panel time { display: block; color: var(--muted); font-size: 11px; }

/* admin */
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: top; }
th { background: var(--surface-2); font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 20px; }
.section h2 { margin: 0 0 12px; font-size: 16px; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.form label.wide { grid-column: 1 / -1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
