:root {
  --bg: #fffaf3;
  --card: #ffffff;
  --ink: #2b2730;
  --muted: #6b6475;
  --line: #ece4d8;
  --red: #e53238;
  --blue: #0064d2;
  --yellow: #f5af02;
  --green: #86b817;
  --accent: #0064d2;
  --accent-ink: #ffffff;
  --win: #2e7d32;
  --win-bg: #e8f5e9;
  --lose: #c62828;
  --lose-bg: #fdecea;
  --soft: #fff1d6;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 20px rgba(60, 40, 20, .06);
}

* { box-sizing: border-box; }
html { font-size: 18px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Nunito, system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
}
h1, h2, h3, .logo, .price, .btn { font-family: Fredoka, Nunito, system-ui, sans-serif; }
h1 { font-size: 2rem; line-height: 1.15; margin: .2em 0 .4em; }
h2 { font-size: 1.4rem; margin: 1.6em 0 .6em; }
h3 { font-size: 1.1rem; margin: 0 0 .3em; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.loading { padding: 3rem 0; text-align: center; color: var(--muted); }

/* ---------- top bar ---------- */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; flex-wrap: wrap; }
.logo { font-size: 2rem; font-weight: 700; text-decoration: none; letter-spacing: -.02em; }
.logo .l1 { color: var(--red); }
.logo .l2 { color: var(--blue); }
.logo .l3 { color: var(--yellow); }
.logo .l4 { color: var(--green); }
.logo .l5 { color: var(--ink); font-weight: 600; font-size: .7em; margin-left: 2px; }
.nav { display: flex; align-items: center; gap: 14px; font-size: .9rem; flex-wrap: wrap; }
.nav .hi { font-weight: 700; }
.linkish { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  border: 0; border-radius: 999px; padding: .7em 1.4em; font-size: 1.05rem; font-weight: 600;
  background: var(--accent); color: var(--accent-ink); cursor: pointer; text-decoration: none;
  min-height: 48px;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--card); color: var(--accent); border: 2px solid var(--accent); }
.btn.bin { background: var(--yellow); color: #2b2100; }
.btn.danger { background: var(--lose); }
.btn.small { font-size: .85rem; padding: .35em .9em; min-height: 36px; }
.btn.block { width: 100%; }
label { display: block; font-weight: 700; margin: 0 0 .3em; }
input, textarea, select {
  width: 100%; font: inherit; padding: .65em .8em; border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
.field { margin-bottom: 1rem; }
.hint { font-size: .85rem; color: var(--muted); margin-top: .25em; }
.error { color: var(--lose); font-weight: 700; min-height: 1.5em; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; }

/* ---------- gate ---------- */
.gate { display: grid; grid-template-columns: 1.1fr 1fr; gap: 32px; align-items: center; padding: 40px 0; }
.gate .hero-emoji { font-size: 4rem; line-height: 1; }
.gate h1 { font-size: 2.4rem; }
.gate .lede { font-size: 1.15rem; color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
@media (max-width: 760px) { .gate { grid-template-columns: 1fr; padding: 20px 0; } .gate h1 { font-size: 1.9rem; } }

/* ---------- how it works ---------- */
.how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0 8px; }
.how div { background: var(--soft); border-radius: var(--radius); padding: 14px 16px; font-size: .92rem; }
.how b { display: block; font-family: Fredoka, sans-serif; font-size: 1.05rem; }
@media (max-width: 700px) { .how { grid-template-columns: 1fr; } }

/* ---------- lot grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.lot-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); text-decoration: none; color: inherit; display: flex; flex-direction: column; transition: transform .12s; }
.lot-card:hover { transform: translateY(-2px); }
.lot-card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.thumb { aspect-ratio: 4 / 3; background: linear-gradient(135deg, #ffe7ba, #ffd1dc); display: grid; place-items: center; font-size: 4.5rem; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.lot-card.ended .thumb { filter: grayscale(.6); }
.price { font-size: 1.6rem; font-weight: 700; }
.meta { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: .88rem; color: var(--muted); flex-wrap: wrap; }
.urgent { color: var(--lose); font-weight: 800; }
.badge { display: inline-block; font-size: .78rem; font-weight: 800; padding: .15em .7em; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.badge.winning, .badge.won { background: var(--win-bg); color: var(--win); }
.badge.outbid, .badge.lost { background: var(--lose-bg); color: var(--lose); }
.badge.ended { background: #eee; color: #555; }
.badge.binbadge { background: #fff4cc; color: #7a5600; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

/* ---------- lot detail ---------- */
.crumbs { margin: 18px 0 6px; font-size: .9rem; }
.detail { display: grid; grid-template-columns: 1.1fr 1fr; gap: 28px; align-items: start; }
.detail .thumb { border-radius: var(--radius); font-size: 8rem; }
@media (max-width: 820px) { .detail { grid-template-columns: 1fr; } }
.bidbox .price { font-size: 2.2rem; }
.bidbox .status { padding: 12px 14px; border-radius: 12px; font-weight: 700; margin: 12px 0; }
.status.winning, .status.won { background: var(--win-bg); color: var(--win); }
.status.outbid, .status.lost { background: var(--lose-bg); color: var(--lose); }
.status.neutral { background: var(--soft); }
.timeleft { font-size: 1.05rem; }
.bidform { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.money { position: relative; flex: 1 1 140px; }
.money span { position: absolute; left: .85em; top: 50%; transform: translateY(-50%); font-weight: 800; color: var(--muted); }
.money input { padding-left: 1.8em; font-size: 1.2rem; font-weight: 700; }
.bidform .btn { flex: 1 1 140px; }
.or { text-align: center; color: var(--muted); margin: 12px 0 8px; font-size: .9rem; }
.specs { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: .95rem; }
.specs th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 12px 6px 0; width: 40%; vertical-align: top; }
.specs td { padding: 6px 0; }
.specs tr + tr { border-top: 1px solid var(--line); }
.seller { display: flex; gap: 12px; align-items: center; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); font-size: .9rem; }
.seller .avatar { font-size: 2rem; }
.stars { color: var(--yellow); }
.desc { white-space: pre-wrap; }
.history { list-style: none; padding: 0; margin: 0; }
.history li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.history li.me { font-weight: 800; }
.history .when { color: var(--muted); font-size: .82rem; }
.winner-banner { background: linear-gradient(135deg, #fff4cc, #ffe0ea); border-radius: var(--radius); padding: 16px 18px; margin: 12px 0; font-weight: 700; font-size: 1.05rem; }

/* ---------- admin ---------- */
.admin-lot { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.admin-lot header { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.admin-lot .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-bids { font-size: .88rem; margin: 8px 0 0; padding: 0; list-style: none; }
.admin-bids li { display: flex; gap: 10px; justify-content: space-between; align-items: center; padding: 4px 0; border-top: 1px dashed var(--line); }
.photo-preview { width: 120px; height: 90px; border-radius: 10px; object-fit: cover; background: var(--soft); }
table.bidders { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.bidders td, table.bidders th { text-align: left; padding: 8px 6px; border-top: 1px solid var(--line); }

/* ---------- misc ---------- */
.footer { margin-top: 56px; padding-top: 20px; padding-bottom: 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; text-align: center; }
.footer .fine { font-size: .8rem; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(150%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 700; transition: transform .25s; z-index: 50; max-width: calc(100% - 32px); text-align: center; }
.toast.show { transform: translateX(-50%) translateY(0); }
dialog { border: 0; border-radius: var(--radius); padding: 24px; max-width: 420px; width: calc(100% - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(30, 20, 10, .45); }
dialog .row { margin-top: 18px; }

/* ---------- utility classes (CSP forbids inline style attributes) ---------- */
[hidden] { display: none !important; }
.flush { margin-top: 0; }
.page-title { margin-top: 28px; }
.outbid-alert { margin-top: 16px; }
.timeleft { margin-top: 8px; }
.bid-label { margin-top: 14px; }
.gate.narrow { grid-template-columns: 1fr; max-width: 460px; margin: 0 auto; }
.row.center { align-items: center; }
#nophoto { flex: 0 0 auto; }
