/* BidRumble — OLED dark live-commerce UI. Tokens from design-system/lotstream/MASTER.md */
:root {
  --bg: #020617; --surface: #0b1020; --card: #0e1223; --muted: #1a1e2f; --raised: #1e293b;
  --border: #334155; --border-soft: #1f2a3d;
  --fg: #f8fafc; --fg-muted: #a3b1c6; --fg-dim: #7c8aa0;
  --accent: #22c55e; --accent-strong: #16a34a; --on-accent: #04130a;
  --danger: #ef4444; --on-danger: #fff; --warn: #f59e0b; --info: #38bdf8; --live: #f43f5e;
  --ring: #e2e8f0;
  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-pill: 999px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --shadow: 0 8px 30px rgba(0,0,0,.45);
  --font: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(.2,.8,.2,1);
  --z-nav: 40; --z-overlay: 100; --z-toast: 1000;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--fg); color: var(--bg); padding: 8px 12px; border-radius: 8px; z-index: 2000; }
.skip:focus { left: 8px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--fg-muted); } .dim { color: var(--fg-dim); } .small { font-size: 14px; } .tiny { font-size: 12px; }
.row { display: flex; align-items: center; gap: var(--s3); } .row.wrap { flex-wrap: wrap; } .between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: var(--s3); } .grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; } h2 { font-size: 20px; font-weight: 700; } h3 { font-size: 16px; font-weight: 700; }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; } .icon.lg { width: 24px; height: 24px; }

/* ---------- App shell ---------- */
.topbar { position: sticky; top: 0; z-index: var(--z-nav); display: flex; align-items: center; gap: var(--s4); padding: 10px var(--s4); background: rgba(2,6,23,.88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border-soft); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 19px; letter-spacing: -.02em; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), #0ea5e9); display: grid; place-items: center; color: var(--on-accent); }
.topnav { display: flex; gap: 4px; margin-left: var(--s4); }
.topnav a { text-decoration: none; padding: 8px 12px; border-radius: var(--r-sm); color: var(--fg-muted); font-weight: 600; font-size: 15px; display: flex; gap: 6px; align-items: center; min-height: 40px; }
.topnav a:hover { color: var(--fg); background: var(--muted); }
.topnav a[aria-current="page"] { color: var(--fg); background: var(--raised); }
.top-actions { margin-left: auto; display: flex; gap: var(--s2); align-items: center; }
main { min-height: calc(100dvh - 60px); }
.page { max-width: 1240px; margin: 0 auto; padding: var(--s5) var(--s4) 96px; }
.bottomnav { display: none; }
@media (max-width: 760px) {
  .topnav { display: none; }
  .bottomnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: var(--z-nav); background: rgba(11,16,32,.96); border-top: 1px solid var(--border-soft); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); backdrop-filter: blur(10px); }
  .bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; font-size: 11px; font-weight: 600; color: var(--fg-dim); min-height: 48px; justify-content: center; border-radius: 10px; }
  .bottomnav a[aria-current="page"] { color: var(--accent); }
  .page { padding: var(--s4) var(--s4) 96px; }
  h1 { font-size: 24px; }
}

/* ---------- Controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--raised); color: var(--fg); font-weight: 650; font-size: 15px; cursor: pointer; text-decoration: none; transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease); touch-action: manipulation; white-space: nowrap; }
.btn:hover { background: #26344b; border-color: #475569; }
.btn:active { transform: scale(.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: #4ade80; }
.btn.danger { background: transparent; border-color: rgba(239,68,68,.6); color: #fca5a5; }
.btn.danger:hover { background: rgba(239,68,68,.12); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--fg-muted); }
.btn.ghost:hover { background: var(--muted); color: var(--fg); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.lg { min-height: 56px; font-size: 18px; padding: 0 22px; border-radius: 16px; }
.btn.block { width: 100%; }
.iconbtn { width: 44px; height: 44px; padding: 0; }
.iconbtn.sm { width: 36px; height: 36px; min-height: 36px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 13px; font-weight: 650; color: var(--fg-muted); }
.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--fg); font-size: 16px; }
textarea.input { min-height: 90px; resize: vertical; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34,197,94,.25); }
.help { font-size: 13px; color: var(--fg-dim); }
.err { font-size: 13px; color: #fca5a5; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); }
@media (max-width: 600px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; cursor: pointer; font-weight: 600; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.card { background: var(--card); border: 1px solid var(--border-soft); border-radius: var(--r-lg); padding: var(--s4); }
.card.pad-lg { padding: var(--s5); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--r-pill); font-size: 12px; font-weight: 700; background: var(--muted); color: var(--fg-muted); white-space: nowrap; }
.badge.live { background: var(--live); color: #fff; } .badge.ok { background: rgba(34,197,94,.15); color: #86efac; }
.badge.warn { background: rgba(245,158,11,.15); color: #fcd34d; } .badge.bad { background: rgba(239,68,68,.15); color: #fca5a5; }
.badge.info { background: rgba(56,189,248,.15); color: #7dd3fc; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-soft); margin-bottom: var(--s4); overflow-x: auto; }
.tabs button, .tabs a { background: none; border: 0; padding: 10px 14px; color: var(--fg-muted); font-weight: 650; cursor: pointer; border-bottom: 2px solid transparent; min-height: 44px; text-decoration: none; white-space: nowrap; }
.tabs [aria-selected="true"], .tabs [aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: var(--r-md); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--fg-dim); padding: 10px 12px; background: var(--surface); position: sticky; top: 0; }
table.data td { padding: 10px 12px; border-top: 1px solid var(--border-soft); vertical-align: middle; }
table.data tr:hover td { background: rgba(30,41,59,.35); }
.empty { text-align: center; padding: var(--s7) var(--s4); color: var(--fg-muted); }
.empty .icon { width: 40px; height: 40px; margin: 0 auto var(--s3); color: var(--fg-dim); }
.stat { padding: var(--s4); }
.stat .v { font-size: 26px; font-weight: 800; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.stat .k { font-size: 13px; color: var(--fg-muted); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s3); }
.thumb { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; background: var(--muted); flex: none; display: grid; place-items: center; font-weight: 800; font-size: 14px; color: var(--fg-muted); overflow: hidden; }
.thumb.lg { width: 72px; height: 72px; }
.section { margin-top: var(--s6); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }

/* ---------- Show cards ---------- */
.show-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s4); }
.show-card { text-decoration: none; display: block; border-radius: var(--r-lg); overflow: hidden; background: var(--card); border: 1px solid var(--border-soft); transition: transform .2s var(--ease), border-color .2s; }
.show-card:hover { transform: translateY(-2px); border-color: var(--border); }
.show-card .cover { aspect-ratio: 3/4; position: relative; background: var(--muted); }
.show-card .cover img, .cover .ph { width: 100%; height: 100%; object-fit: cover; }
.show-card .cover .badges { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; }
.show-card .meta { padding: 10px 12px 14px; }
.ph { display: grid; place-items: center; font-weight: 800; color: rgba(255,255,255,.85); text-align: center; padding: 16px; font-size: 18px; letter-spacing: -.01em; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.chip { padding: 8px 14px; border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; min-height: 40px; }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.hero { border-radius: var(--r-lg); padding: var(--s6) var(--s5); background: radial-gradient(1200px 400px at 10% -20%, rgba(34,197,94,.22), transparent), radial-gradient(800px 300px at 100% 0%, rgba(14,165,233,.18), transparent), var(--card); border: 1px solid var(--border-soft); }
.hero p { max-width: 620px; color: var(--fg-muted); font-size: 17px; }

/* ---------- Live show (viewer) ---------- */
.stage-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--s4); max-width: 1320px; margin: 0 auto; padding: var(--s4); height: calc(100dvh - 60px); }
.stage { position: relative; border-radius: var(--r-lg); overflow: hidden; background: #000; min-height: 0; }
.stage video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.stage .poster { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--fg-muted); background: radial-gradient(600px 400px at 50% 30%, #13203a, #000); }
.stage-top { position: absolute; top: 0; left: 0; right: 0; padding: 12px; display: flex; gap: 8px; align-items: center; background: linear-gradient(rgba(0,0,0,.6), transparent); }
.host-chip { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.45); padding: 4px 6px 4px 4px; border-radius: var(--r-pill); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #6366f1, #22c55e); display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; flex: none; }
.stage-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px; background: linear-gradient(transparent, rgba(0,0,0,.85) 40%); display: flex; flex-direction: column; gap: 10px; }
.chat-overlay { max-height: 34vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; mask-image: linear-gradient(transparent, #000 25%); padding-right: 30%; scrollbar-width: none; }
.chat-line { font-size: 14px; line-height: 1.35; text-shadow: 0 1px 2px #000; }
.chat-line b { color: #c4b5fd; margin-right: 4px; } .chat-line.host b { color: var(--accent); }
.chat-line.system { color: #fde68a; font-weight: 600; }
.lot-panel { background: rgba(14,18,35,.92); border: 1px solid var(--border-soft); border-radius: var(--r-lg); padding: 12px; display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; backdrop-filter: blur(8px); }
.lot-panel .thumb { width: 64px; height: 64px; }
.price { font-size: 26px; font-weight: 800; font-family: var(--mono); font-variant-numeric: tabular-nums; line-height: 1; }
.timer { position: relative; width: 58px; height: 58px; display: grid; place-items: center; font-family: var(--mono); font-weight: 800; font-size: 18px; }
.timer svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 5; }
.timer .track { stroke: rgba(255,255,255,.12); } .timer .prog { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .25s linear, stroke .2s; }
.timer.urgent .prog { stroke: var(--live); } .timer.urgent { color: #fda4af; }
.bid-row { display: grid; grid-template-columns: auto 1fr; gap: 10px; }
.bid-btn { min-height: 56px; font-size: 18px; border-radius: 16px; }
.leader { font-size: 13px; color: var(--fg-muted); }
.leader.you { color: var(--accent); font-weight: 700; }
.flash { animation: flash .6s var(--ease); }
@keyframes flash { 0% { transform: scale(1.12); color: var(--accent); } 100% { transform: scale(1); } }
.sold-banner { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); background: var(--accent); color: var(--on-accent); padding: 14px 22px; border-radius: 16px; font-weight: 800; font-size: 20px; text-align: center; box-shadow: var(--shadow); animation: pop .35s var(--ease); max-width: 90%; }
@keyframes pop { from { transform: translate(-50%, -40%) scale(.9); opacity: 0; } }
.side { display: flex; flex-direction: column; min-height: 0; background: var(--card); border: 1px solid var(--border-soft); border-radius: var(--r-lg); overflow: hidden; }
.side .tabs { margin: 0; padding: 0 8px; }
.side-body { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.lot-row { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border-soft); }
.lot-row .t { font-weight: 650; font-size: 14px; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border-soft); }
.side-chat { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 960px) {
  .stage-wrap { grid-template-columns: 1fr; height: auto; padding: 0; gap: 0; }
  .stage { border-radius: 0; height: calc(100dvh - 60px - 64px); }
  .stage .poster { align-items: start; padding-top: 64px; }
  #mode-banner { display: none; }
  .side { border-radius: 0; border-left: 0; border-right: 0; max-height: 70vh; }
}
@media (min-width: 961px) { .mobile-only { display: none !important; } }
@media (max-width: 960px) { .side .chat-tab { display: none; } }

/* ---------- Host console ---------- */
.console { display: grid; grid-template-columns: 340px minmax(0,1fr) 320px; gap: var(--s3); padding: var(--s3); height: calc(100dvh - 60px); max-width: 1600px; margin: 0 auto; }
.panel { background: var(--card); border: 1px solid var(--border-soft); border-radius: var(--r-lg); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.panel-head { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-body { padding: 12px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.runsheet-item { display: grid; grid-template-columns: 22px 44px 1fr auto; gap: 8px; align-items: center; padding: 8px; background: var(--surface); border: 1px solid var(--border-soft); border-radius: 12px; }
.runsheet-item.next { border-color: rgba(34,197,94,.55); box-shadow: inset 3px 0 0 var(--accent); }
.runsheet-item .pos { font-family: var(--mono); color: var(--fg-dim); font-size: 12px; text-align: center; }
.runsheet-item .thumb { width: 44px; height: 44px; }
.reorder { display: flex; flex-direction: column; gap: 2px; }
.host-stage { position: relative; background: #000; border-radius: var(--r-lg); overflow: hidden; aspect-ratio: 16/10; max-height: 46vh; }
.host-stage video { width: 100%; height: 100%; object-fit: cover; }
.ctrl-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 1200px) { .console { grid-template-columns: 300px minmax(0,1fr); height: auto; } .console > .panel:first-child { max-height: 80vh; } .console .chat-panel { grid-column: 1 / -1; height: 360px; } }
@media (max-width: 800px) { .console { grid-template-columns: 1fr; height: auto; } .console .panel { max-height: none; } .ctrl-grid { grid-template-columns: 1fr 1fr; } }

/* ---------- Modal / toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(2,6,23,.72); backdrop-filter: blur(4px); z-index: var(--z-overlay); display: grid; place-items: center; padding: var(--s4); animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg); width: min(560px, 100%); max-height: 90dvh; overflow-y: auto; box-shadow: var(--shadow); animation: rise .2s var(--ease); }
.modal.wide { width: min(860px, 100%); }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border-soft); position: sticky; top: 0; background: var(--card); z-index: 1; }
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 16px; border-top: 1px solid var(--border-soft); position: sticky; bottom: 0; background: var(--card); }
.toasts { position: fixed; top: 70px; right: 16px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--raised); border: 1px solid var(--border); border-left: 4px solid var(--info); padding: 12px 14px; border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; font-weight: 600; animation: rise .2s var(--ease); }
.toast.ok { border-left-color: var(--accent); } .toast.bad { border-left-color: var(--danger); } .toast.warn { border-left-color: var(--warn); }
.photo-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-grid .ph-item { position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; background: var(--muted); }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; }
.photo-grid .rm { position: absolute; top: 2px; right: 2px; }
.dropzone { width: 84px; height: 84px; border: 2px dashed var(--border); border-radius: 10px; display: grid; place-items: center; cursor: pointer; color: var(--fg-dim); }
.ship-card { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: start; }
.addr { font-size: 14px; line-height: 1.4; }
.notice { padding: 12px 14px; border-radius: 12px; background: rgba(56,189,248,.08); border: 1px solid rgba(56,189,248,.3); font-size: 14px; }
.notice.warn { background: rgba(245,158,11,.08); border-color: rgba(245,158,11,.35); }
.auth-wrap { max-width: 420px; margin: var(--s6) auto; }
/* Native app (Capacitor): respect notch / status bar / home indicator */
.native .topbar { padding-top: calc(10px + env(safe-area-inset-top)); }
.native main { min-height: calc(100dvh - 60px - env(safe-area-inset-top)); }
.native .toasts { top: calc(70px + env(safe-area-inset-top)); }
@media (display-mode: standalone) { .topbar { padding-top: calc(10px + env(safe-area-inset-top)); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
