:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #d97706;
  --accent-strong: #b45309;
  --accent-ink: #ffffff;
  --live: #047857;
  --urgent: #dc2626;
  --closed: #64748b;
  --save: #e11d48;
  --shadow: 0 1px 2px rgb(15 23 42 / .06), 0 4px 12px rgb(15 23 42 / .05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120;
    --surface: #111a2e;
    --surface-2: #1a2540;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: #23304d;
    --accent: #f59e0b;
    --accent-strong: #fbbf24;
    --accent-ink: #111827;
    --live: #34d399;
    --urgent: #f87171;
    --closed: #94a3b8;
    --save: #fb7185;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120; --surface: #111a2e; --surface-2: #1a2540; --text: #e2e8f0; --muted: #94a3b8;
  --border: #23304d; --accent: #f59e0b; --accent-strong: #fbbf24; --accent-ink: #111827;
  --live: #34d399; --urgent: #f87171; --closed: #94a3b8; --save: #fb7185; --shadow: none; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
a { color: inherit; }
img { max-width: 100%; display: block; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
.muted { color: var(--muted); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; text-decoration: none; letter-spacing: -.01em; }
.nav { display: flex; gap: 2px; }
.nav a {
  text-decoration: none; padding: 6px 10px; border-radius: 999px; font-size: 15px; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.nav a.active, .nav a:hover { color: var(--text); background: var(--surface-2); }
.badge {
  background: var(--save); color: #fff; font-size: 11px; font-weight: 700; line-height: 1;
  padding: 3px 6px; border-radius: 999px; min-width: 18px; text-align: center;
}
.offline-banner { background: var(--surface-2); color: var(--muted); text-align: center; font-size: 14px; padding: 6px 16px; }

main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 16px; outline: none; }
.footer { color: var(--muted); font-size: 13px; text-align: center; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.footer p { margin: 2px 0; }
.status-msg, .empty { color: var(--muted); text-align: center; padding: 48px 16px; grid-column: 1 / -1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 18px; border-radius: 10px; font-weight: 600; text-decoration: none;
  border: 1px solid transparent; cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }
.back { display: inline-block; color: var(--muted); text-decoration: none; margin-bottom: 12px; font-size: 15px; }
.back:hover { color: var(--text); }

/* ---------- hero ---------- */
.hero { max-width: 720px; margin: 0 auto; padding: 40px 0 24px; text-align: center; }
.hero h1 { font-size: clamp(30px, 7vw, 48px); letter-spacing: -.02em; }
.lede { color: var(--muted); font-size: 18px; margin: 14px auto 24px; max-width: 560px; }
.hero-search { display: flex; gap: 8px; max-width: 560px; margin: 0 auto; }
.hero-search input, .toolbar input, .toolbar select {
  min-width: 0; min-height: 48px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.hero-search input { flex: 1; font-size: 17px; }
.hero-search input:focus, .toolbar input:focus, .toolbar select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.hero-search button {
  min-height: 48px; padding: 0 20px; border: 0; border-radius: 12px; font-weight: 600;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 28px auto 12px; max-width: 560px; }
.stat {
  display: flex; flex-direction: column; align-items: center; padding: 14px 8px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.stat strong { font-size: 26px; font-variant-numeric: tabular-nums; }
.stat:first-child strong { color: var(--accent); }
.stat span { font-size: 13px; color: var(--muted); }
.fineprint { color: var(--muted); font-size: 13px; margin-top: 16px; }

/* ---------- browse ---------- */
.view-head { margin: 4px 0 14px; }
.view-head h1 { font-size: 26px; letter-spacing: -.01em; }
.view-head p { margin: 4px 0 0; }
.auction-head .btn { margin-top: 12px; }
.toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.toolbar input { grid-column: 1 / -1; }
.toolbar select { width: 100%; }
.result-count { color: var(--muted); font-size: 14px; margin: 4px 0 12px; }
@media (min-width: 960px) {
  .toolbar { grid-template-columns: 2fr repeat(3, minmax(160px, 1fr)); }
  .toolbar input { grid-column: auto; }
}

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 14px; }
.card {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-media { display: block; aspect-ratio: 4 / 3; background: var(--surface-2); }
.lot-img, .auction-img, .detail-img { width: 100%; height: 100%; object-fit: cover; background: var(--surface-2); }
.placeholder {
  display: block; width: 100%; height: 100%;
  background: var(--surface-2) center / 40px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='1.5'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Ccircle cx='9' cy='10' r='2'/%3E%3Cpath d='m21 16-5-5-9 8'/%3E%3C/svg%3E");
}
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.card-title { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-title a { text-decoration: none; }
.card-title a:hover { text-decoration: underline; }
.card-sub { margin: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; margin-top: auto; padding-top: 6px; }
.bidbox { display: flex; flex-direction: column; min-width: 0; }
.bid-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.bid { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bid.muted { font-size: 15px; font-weight: 500; color: var(--muted); }
.bids { font-size: 13px; color: var(--muted); white-space: nowrap; }
.listing-link { font-size: 14px; font-weight: 600; color: var(--accent); text-decoration: none; margin-top: 4px; }
.listing-link:hover { text-decoration: underline; }

.time { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.time.live { color: var(--live); }
.time.live.urgent { color: var(--urgent); }
.time.closed, .time.ended { color: var(--closed); }

.save {
  position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; border-radius: 999px;
  display: grid; place-items: center; cursor: pointer;
  background: rgb(15 23 42 / .55); border: 0; color: #fff;
}
.save svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.save.on svg { fill: var(--save); stroke: var(--save); }
.save.big {
  position: static; width: auto; height: auto; min-height: 44px; padding: 10px 16px; gap: 8px;
  display: inline-flex; border-radius: 10px; background: transparent; border: 1px solid var(--border); color: var(--text); font-weight: 600;
}
.save.big:hover { background: var(--surface-2); }

.sentinel { display: flex; justify-content: center; padding: 20px 0; min-height: 1px; }

/* ---------- auctions ---------- */
.auction-list { display: grid; gap: 12px; }
@media (min-width: 900px) { .auction-list { grid-template-columns: 1fr 1fr; } }
.auction {
  display: grid; grid-template-columns: 96px 1fr; gap: 12px; padding: 10px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.auction:hover { border-color: var(--accent); }
.auction .auction-img { width: 96px; height: 96px; border-radius: 10px; }
.auction-body { min-width: 0; }
.auction-body h3 { font-size: 16px; overflow-wrap: anywhere; }
.auction-body p { margin: 4px 0 0; font-size: 13px; }
.auction-stats { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); }

/* ---------- detail ---------- */
.detail-grid { display: grid; gap: 20px; }
@media (min-width: 860px) { .detail-grid { grid-template-columns: 1.1fr 1fr; align-items: start; } }
.detail-media { aspect-ratio: 1 / 1; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.detail-img { object-fit: contain; }
.detail-info h1 { font-size: clamp(22px, 5vw, 30px); overflow-wrap: anywhere; }
.detail-price {
  display: flex; justify-content: space-between; gap: 16px; margin: 16px 0; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.detail-price .bid { font-size: 28px; }
.detail-time { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.detail-time .time { font-size: 20px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.detail-actions .btn.primary { flex: 1 1 200px; font-size: 17px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 20px 0 0; font-size: 15px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
