/* ─── Yahoo Auctions JP Scraper — Design System v2 ─────────── */
/* Mobile-first, app-native feel, rich gallery with zoom         */

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
  --bg:          #06060b;
  --bg-subtle:   #0c0c14;
  --surface:     #111119;
  --surface-2:   #18182240;
  --surface-3:   #1e1e2a;
  --border:      #22223366;
  --border-focus:#7c5cff88;
  --text:        #e4e4ec;
  --text-dim:    #7a7a96;
  --text-muted:  #50506a;
  --accent:      #ff4757;
  --accent-glow: #ff475730;
  --purple:      #7c5cff;
  --purple-glow: #7c5cff25;
  --green:       #2ed573;
  --green-glow:  #2ed57320;
  --gold:        #ffa502;
  --gold-glow:   #ffa50220;
  --radius:      12px;
  --radius-sm:   8px;
  --radius-xs:   5px;
  --shadow:      0 1px 3px rgba(0,0,0,.4), 0 4px 20px rgba(0,0,0,.25);
  --shadow-lg:   0 4px 40px rgba(0,0,0,.5);
  --transition:  180ms cubic-bezier(.4,0,.2,1);
  --font:        'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono:        'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --safe-b:      env(safe-area-inset-bottom, 0px);
  --safe-t:      env(safe-area-inset-top, 0px);
  --safe-l:      env(safe-area-inset-left, 0px);
  --safe-r:      env(safe-area-inset-right, 0px);
  --bottom-nav-h: 60px;
}

/* ── Reset ──────────────────────────────────────────────────── */
*,*::before,*::after { margin:0; padding:0; box-sizing:border-box; }
html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
a { color: var(--purple); text-decoration: none; transition: color var(--transition); }
a:hover { color: #a58aff; }
::selection { background: var(--purple); color: #fff; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Layout ─────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  grid-row: 1 / -1;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  z-index: 10;
}

.sidebar-brand {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand h1 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-brand h1 .icon {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand h1 .icon svg { width: 16px; height: 16px; stroke: #fff; fill: none; }

.sidebar-brand p {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  line-height: 1.4;
}

.sidebar-section {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-section-title {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.sidebar-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
}

.sidebar-stat .label { font-size: 0.78rem; color: var(--text-dim); }
.sidebar-stat .value { font-size: 0.82rem; font-weight: 600; font-family: var(--mono); }

.sidebar-nav { padding: 0.5rem 0; flex: 1; }

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1.25rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition);
  border-left: 2px solid transparent;
}

.sidebar-nav-item:hover { background: var(--surface-2); color: var(--text); }

.sidebar-nav-item.active {
  color: var(--purple);
  background: var(--purple-glow);
  border-left-color: var(--purple);
}

.sidebar-nav-item svg { width: 16px; height: 16px; stroke: currentColor; fill: none; flex-shrink: 0; }

.sidebar-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); }
.sidebar-footer .version { font-size: 0.68rem; color: var(--text-muted); font-family: var(--mono); }

/* ── Status indicator ───────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
}
.status-dot.on  { background: var(--green); box-shadow: 0 0 6px var(--green-glow); }
.status-dot.off { background: var(--accent); }
.status-dot.warn { background: var(--gold); box-shadow: 0 0 6px var(--gold-glow); }

/* ── Main Content ───────────────────────────────────────────── */
.main {
  padding: 2rem 2.5rem;
  padding-bottom: calc(2rem + var(--safe-b));
  max-width: 1100px;
  width: 100%;
}

/* ── Page Header ────────────────────────────────────────────── */
.page-header { margin-bottom: 2rem; }
.page-header h2 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.03em; }
.page-header p { color: var(--text-dim); font-size: 0.85rem; margin-top: 0.25rem; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  transition: border-color var(--transition);
}
.card:hover { border-color: #2a2a40; }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}
.card-header h3 { font-size: 0.92rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.card-header h3 svg { width: 16px; height: 16px; stroke: var(--text-dim); fill: none; }

/* ── Search Form ────────────────────────────────────────────── */
.search-row { display: flex; gap: 0.75rem; align-items: stretch; }
.input-group { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.input-group label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.input-group input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  color: var(--text);
  font-size: 0.88rem;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.input-group input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-glow); }
.input-group input::placeholder { color: var(--text-muted); }
.input-group input[type="number"] { width: 80px; flex: 0 0 80px; }

/* ── Pages Control ──────────────────────────────────────────── */
.pages-control { display: flex; align-items: stretch; gap: 0; }
.pages-control .pages-input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: none; width: 60px; flex: 0 0 60px; }
.toggle-all-pages {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0 0.7rem;
  background: var(--bg); border: 1px solid var(--border); border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  font-size: 0.78rem; font-weight: 600; color: var(--text-dim);
  cursor: pointer; transition: all var(--transition); white-space: nowrap; user-select: none;
}
.toggle-all-pages:has(input:checked) { background: var(--purple-glow); border-color: var(--purple); color: var(--purple); }
.toggle-all-pages input { display: none; }
.pages-group { flex: 0 0 auto !important; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.65rem 1.4rem;
  font-size: 0.85rem; font-weight: 600; font-family: var(--font);
  border: none; border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--transition); white-space: nowrap; text-decoration: none; line-height: 1;
}
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #cc2233); color: #fff; box-shadow: 0 2px 8px var(--accent-glow); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px var(--accent-glow); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: #333; }
.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.76rem; border-radius: var(--radius-xs); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.btn-success { background: linear-gradient(135deg, var(--green), #1e8449); color: #fff; }

/* ── Progress ───────────────────────────────────────────────── */
.progress-wrap { margin-top: 0.5rem; }
.progress-track { background: var(--bg); border-radius: 20px; height: 6px; overflow: hidden; position: relative; }
.progress-fill {
  height: 100%; border-radius: 20px;
  background: linear-gradient(90deg, var(--accent), var(--purple), var(--green));
  background-size: 200% 100%;
  transition: width 0.4s cubic-bezier(.4,0,.2,1);
  position: relative;
}
.progress-fill.animate { animation: shimmer 2s linear infinite; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.progress-label { display: flex; justify-content: space-between; margin-top: 0.5rem; font-size: 0.76rem; color: var(--text-dim); }
.progress-label .phase { font-weight: 600; text-transform: uppercase; font-size: 0.68rem; letter-spacing: 0.04em; }
.progress-label .phase.search  { color: var(--purple); }
.progress-label .phase.extract { color: var(--gold); }
.progress-label .phase.done    { color: var(--green); }
.progress-label .phase.error   { color: var(--accent); }
.progress-msg { font-size: 0.78rem; color: var(--text-dim); margin-top: 0.25rem; min-height: 1.2em; }

/* ── Stats Grid ─────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin-bottom: 1.25rem; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; text-align: center; position: relative; overflow: hidden;
  transition: border-color var(--transition);
}
.stat-card:hover { border-color: #2a2a40; }
.stat-card .stat-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; margin: 0 auto 0.6rem;
}
.stat-card .stat-icon svg { width: 16px; height: 16px; fill: none; stroke: #fff; }
.stat-card .stat-icon.purple { background: var(--purple-glow); }
.stat-card .stat-icon.purple svg { stroke: var(--purple); }
.stat-card .stat-icon.green  { background: var(--green-glow); }
.stat-card .stat-icon.green svg  { stroke: var(--green); }
.stat-card .stat-icon.gold   { background: var(--gold-glow); }
.stat-card .stat-icon.gold svg   { stroke: var(--gold); }
.stat-card .stat-icon.red    { background: var(--accent-glow); }
.stat-card .stat-icon.red svg    { stroke: var(--accent); }
.stat-card .stat-val { font-size: 1.35rem; font-weight: 700; font-family: var(--mono); letter-spacing: -0.02em; color: var(--text); }
.stat-card .stat-lbl { font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 0.15rem; }

/* ── Connection Test ────────────────────────────────────────── */
.conn-test { display: flex; align-items: center; gap: 0.75rem; padding: 0.9rem 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1.25rem; font-size: 0.82rem; }
.conn-test .label { color: var(--text-dim); flex-shrink: 0; }
.conn-test .result { font-size: 0.78rem; }
.conn-test .result.ok { color: var(--green); }
.conn-test .result.err { color: var(--accent); }
.conn-test .result.loading { color: var(--text-muted); }

/* ── Table ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
thead th {
  text-align: left; padding: 0.6rem 0.75rem;
  font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 0; z-index: 1;
}
tbody td { padding: 0.65rem 0.75rem; border-bottom: 1px solid #1a1a2840; vertical-align: middle; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--surface-2); }
tbody tr.clickable { cursor: pointer; }

/* ── Tags ───────────────────────────────────────────────────── */
.tag { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.68rem; font-weight: 600; padding: 0.2rem 0.55rem; border-radius: 20px; letter-spacing: 0.02em; }
.tag-done    { background: var(--green-glow); color: var(--green); }
.tag-running { background: var(--purple-glow); color: var(--purple); }
.tag-error   { background: var(--accent-glow); color: var(--accent); }
.tag-pending { background: var(--gold-glow); color: var(--gold); }

/* ── Price ──────────────────────────────────────────────────── */
.price { color: var(--gold); font-weight: 700; font-family: var(--mono); white-space: nowrap; }

/* ── Offers Grid ────────────────────────────────────────────── */
.offers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }

.offer-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.offer-card:hover { border-color: var(--purple); transform: translateY(-2px); box-shadow: 0 4px 20px rgba(124, 92, 255, 0.12); }
.offer-card:active { transform: scale(0.98); }

.offer-img-wrap { width: 100%; aspect-ratio: 4/3; background: var(--surface); overflow: hidden; position: relative; }
.offer-img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s ease; }
.offer-card:hover .offer-img { transform: scale(1.04); }
.offer-img-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: var(--surface-3); }
.offer-img-placeholder svg { width: 32px; height: 32px; stroke: var(--text-muted); opacity: 0.4; }
.offer-img-wrap.no-img .offer-img { display: none; }

.offer-info { padding: 0.85rem 1rem; }
.offer-title { font-size: 0.82rem; font-weight: 600; line-height: 1.35; color: var(--text); margin-bottom: 0.4rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.offer-meta { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.35rem; }
.offer-price { color: var(--gold); font-weight: 700; font-family: var(--mono); font-size: 0.88rem; white-space: nowrap; }
.offer-bids { font-size: 0.7rem; color: var(--text-muted); background: var(--surface-3); padding: 0.15rem 0.45rem; border-radius: 10px; }
.offer-desc { font-size: 0.72rem; color: var(--text-muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.offer-gallery-badge {
  position: absolute; bottom: 0.4rem; right: 0.4rem;
  background: rgba(0,0,0,0.65); color: #fff;
  font-size: 0.62rem; font-weight: 600; padding: 0.15rem 0.4rem; border-radius: 8px;
  backdrop-filter: blur(4px); z-index: 1;
}

/* ── Filter Bar ─────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: stretch;
  flex-wrap: wrap;
}

.filter-search-wrap {
  position: relative;
  flex: 1;
  min-width: 180px;
}

.filter-search-wrap svg {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  stroke: var(--text-muted);
  fill: none;
  pointer-events: none;
}

.filter-search {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.9rem 0.6rem 2.2rem;
  color: var(--text);
  font-size: 0.82rem;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.filter-search:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-glow);
}

.filter-search::placeholder { color: var(--text-muted); }

.filter-search-clear {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 4px;
  display: none;
  line-height: 1;
}

.filter-search-clear.visible { display: block; }
.filter-search-clear:hover { color: var(--text); background: var(--surface-2); }
.filter-search-clear svg { width: 14px; height: 14px; stroke: currentColor; position: static; transform: none; }

.filter-sort {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.9rem;
  color: var(--text);
  font-size: 0.78rem;
  font-family: var(--font);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
  min-width: 120px;
}

.filter-sort:focus { border-color: var(--purple); }

.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.6rem 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 0.78rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.filter-toggle:hover { background: var(--surface-2); color: var(--text); border-color: #333; }
.filter-toggle.active { background: var(--purple-glow); border-color: var(--purple); color: var(--purple); }
.filter-toggle svg { width: 15px; height: 15px; stroke: currentColor; fill: none; }

.filter-results { font-size: 0.74rem; color: var(--text-muted); margin-bottom: 0.5rem; }

/* ── Filter Panel (expandable) ─────────────────────────────── */
.filter-panel {
  display: none;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.filter-panel.open { display: grid; }

.filter-group { display: flex; flex-direction: column; gap: 0.3rem; }

.filter-group label {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.filter-group .range-inputs {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}

.filter-group .range-inputs input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 0.4rem 0.5rem;
  color: var(--text);
  font-size: 0.78rem;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
}

.filter-group .range-inputs input:focus { border-color: var(--purple); }
.filter-group .range-inputs span { color: var(--text-muted); font-size: 0.7rem; }

/* ── Filter Chips ───────────────────────────────────────────── */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  min-height: 0;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  background: var(--purple-glow);
  border: 1px solid var(--purple);
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--purple);
  cursor: default;
  animation: chipIn 0.15s ease-out;
}

@keyframes chipIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

.filter-chip button {
  background: none;
  border: none;
  color: var(--purple);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  display: flex;
  align-items: center;
  opacity: 0.6;
  transition: opacity var(--transition);
}

.filter-chip button:hover { opacity: 1; }
.filter-chip button svg { width: 12px; height: 12px; stroke: currentColor; fill: none; }

.filter-chip-clear-all {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.68rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: all var(--transition);
}

.filter-chip-clear-all:hover { color: var(--accent); background: var(--accent-glow); }

/* ── Empty State ────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--text-muted); }
.empty-state .empty-icon { width: 48px; height: 48px; margin: 0 auto 1rem; background: var(--surface-2); border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.empty-state .empty-icon svg { width: 22px; height: 22px; stroke: var(--text-muted); fill: none; }
.empty-state .empty-title { font-size: 0.92rem; font-weight: 600; color: var(--text-dim); margin-bottom: 0.3rem; }
.empty-state .empty-desc { font-size: 0.78rem; max-width: 300px; margin: 0 auto; line-height: 1.5; }

/* ── Modal (Desktop: centered) ──────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s cubic-bezier(.16,1,.3,1);
  overscroll-behavior: contain;
}
.modal.modal-lg { max-width: 800px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
}
.modal-top h3 { font-size: 1rem; font-weight: 600; padding-right: 1rem; }
.modal-close {
  background: none; border: none; color: var(--text-muted); font-size: 1.3rem;
  cursor: pointer; padding: 0.2rem; border-radius: 4px; line-height: 1; transition: all var(--transition);
}
.modal-close:hover { color: var(--text); background: var(--surface-2); }
.modal-body { padding: 1.5rem; }

.modal-field { margin-bottom: 1rem; }
.modal-field .mf-label { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 0.2rem; }
.modal-field .mf-value { font-size: 0.88rem; color: var(--text); word-break: break-word; }

.modal-desc { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; max-height: 260px; overflow-y: auto; white-space: pre-wrap; font-size: 0.82rem; line-height: 1.6; color: var(--text-dim); }

/* ── Detail Modal Layout ────────────────────────────────────── */
.detail-hero { margin: -1.5rem -1.5rem 1.25rem; overflow: hidden; background: var(--bg); }
.detail-hero img { width: 100%; max-height: 360px; object-fit: contain; display: block; }

/* ── Gallery ────────────────────────────────────────────────── */
.detail-gallery {
  margin: -1.5rem -1.5rem 1.25rem;
  background: var(--bg);
  user-select: none;
  -webkit-user-select: none;
}

.gallery-main {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: pan-y;
  cursor: grab;
}

.gallery-main:active { cursor: grabbing; }

.gallery-main img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.2s cubic-bezier(.16,1,.3,1), opacity 0.2s ease;
  will-change: transform;
  touch-action: none;
  pointer-events: none;
}

.gallery-main img.zoomed {
  cursor: grab;
  touch-action: none;
  transition: none;
}

.gallery-main img.zoomed:active {
  cursor: grabbing;
}

/* Loading spinner */
.gallery-main .gallery-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-3);
  z-index: 1;
}
.gallery-main .gallery-loading::after {
  content: '';
  width: 28px; height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Nav arrows */
.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  backdrop-filter: blur(6px);
  z-index: 3;
  -webkit-tap-highlight-color: transparent;
}
.gallery-nav:hover { background: rgba(124, 92, 255, 0.7); border-color: var(--purple); }
.gallery-nav svg { width: 20px; height: 20px; stroke: #fff; fill: none; }
.gallery-prev { left: 0.75rem; }
.gallery-next { right: 0.75rem; }

.gallery-counter {
  position: absolute;
  bottom: 0.6rem;
  right: 0.75rem;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 0.7rem;
  font-family: var(--mono);
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 10px;
  backdrop-filter: blur(4px);
  z-index: 3;
}

/* Zoom button */
.gallery-zoom-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.75rem;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  backdrop-filter: blur(6px);
  z-index: 4;
  -webkit-tap-highlight-color: transparent;
}
.gallery-zoom-btn:hover { background: rgba(124, 92, 255, 0.7); border-color: var(--purple); }
.gallery-zoom-btn svg { width: 18px; height: 18px; stroke: #fff; fill: none; }

/* Fullscreen indicator */
.gallery-fullscreen-badge {
  position: absolute;
  top: 0.6rem;
  left: 0.75rem;
  background: rgba(0,0,0,0.6);
  color: var(--text-dim);
  font-size: 0.62rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 10px;
  backdrop-filter: blur(4px);
  z-index: 4;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: none;
}

/* Thumbnail strip */
.gallery-thumbs {
  display: flex;
  gap: 0.4rem;
  padding: 0.6rem 0.75rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.gallery-thumbs::-webkit-scrollbar { display: none; }

.gallery-thumb {
  flex: 0 0 56px;
  height: 42px;
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  background: var(--surface-3);
  transition: all var(--transition);
  opacity: 0.55;
  scroll-snap-align: center;
  -webkit-tap-highlight-color: transparent;
}
.gallery-thumb:hover { opacity: 0.85; }
.gallery-thumb.active {
  border-color: var(--purple);
  opacity: 1;
  box-shadow: 0 0 0 2px var(--purple-glow);
}
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ── Detail modal content ───────────────────────────────────── */
.detail-price-bar { display: flex; align-items: baseline; gap: 0.75rem; margin-bottom: 1.25rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.detail-price { font-size: 1.6rem; font-weight: 800; font-family: var(--mono); color: var(--gold); letter-spacing: -0.02em; }
.detail-bids { font-size: 0.78rem; color: var(--text-dim); background: var(--surface-3); padding: 0.2rem 0.6rem; border-radius: 12px; }

.detail-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1.25rem; }
.detail-info-item { display: flex; flex-direction: column; gap: 0.15rem; }
.detail-info-label { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.detail-info-val { font-size: 0.85rem; color: var(--text); font-family: var(--mono); }

.detail-link { margin-bottom: 1.25rem; }
.detail-link a {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.55rem 1.2rem;
  background: linear-gradient(135deg, var(--purple), #5a3fcf);
  color: #fff; border-radius: var(--radius-sm);
  font-size: 0.82rem; font-weight: 600; transition: all var(--transition); text-decoration: none;
}
.detail-link a:hover { transform: translateY(-1px); box-shadow: 0 4px 12px var(--purple-glow); color: #fff; }

.detail-section-title { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 0.5rem; }
.detail-desc { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; font-size: 0.82rem; line-height: 1.7; color: var(--text-dim); max-height: 300px; overflow-y: auto; }

/* ── Mobile Bottom Nav ──────────────────────────────────────── */
.bottom-nav {
  display: none;  /* hidden on desktop */
}

/* ── Mobile Sidebar Overlay ─────────────────────────────────── */
.sidebar-overlay {
  display: none;
}

/* ── RESPONSIVE: Mobile (app-native feel) ───────────────────── */
@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
    padding-bottom: calc(var(--bottom-nav-h) + var(--safe-b));
  }

  /* Hide desktop sidebar, replace with bottom nav */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 85vw;
    max-width: 300px;
    height: 100vh;
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(.16,1,.3,1);
    z-index: 200;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }

  /* Overlay when sidebar open */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
    backdrop-filter: blur(2px);
    -webkit-tap-highlight-color: transparent;
  }
  .sidebar-overlay.open { display: block; }

  /* Bottom navigation bar */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-h);
    padding-bottom: var(--safe-b);
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 150;
    align-items: center;
    justify-content: space-around;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.35rem 0.6rem;
    color: var(--text-muted);
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: color var(--transition);
    -webkit-tap-highlight-color: transparent;
    border-radius: var(--radius-sm);
    min-width: 52px;
  }
  .bottom-nav-item:active { background: var(--surface-2); }
  .bottom-nav-item svg { width: 20px; height: 20px; stroke: currentColor; fill: none; }
  .bottom-nav-item.active { color: var(--purple); }

  /* Main content mobile */
  .main {
    padding: 1rem;
    padding-top: 1rem;
  }

  .page-header { margin-bottom: 1rem; }
  .page-header h2 { font-size: 1.25rem; }

  /* Stats 2x2 */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .stat-card { padding: 0.75rem 0.6rem; }
  .stat-card .stat-val { font-size: 1.1rem; }

  /* Search form: stack */
  .search-row { flex-direction: column; }
  .input-group input[type="number"] { width: 100%; flex: 1; }
  .pages-control { width: 100%; }
  .pages-control .pages-input { flex: 1; width: auto; }
  .btn-primary { width: 100%; }

  /* Offers grid: 2 columns on mobile */
  .offers-grid { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
  .offer-info { padding: 0.6rem 0.65rem; }
  .offer-title { font-size: 0.75rem; margin-bottom: 0.25rem; }
  .offer-price { font-size: 0.78rem; }
  .offer-desc { display: none; }
  .offer-bids { font-size: 0.62rem; }
  .offer-gallery-badge { font-size: 0.55rem; padding: 0.1rem 0.3rem; }

  /* Connection test */
  .conn-test { flex-wrap: wrap; font-size: 0.78rem; padding: 0.75rem 1rem; }

  /* Runs table: make scrollable */
  .table-wrap { border-radius: var(--radius-sm); }

  /* Card padding reduce */
  .card { padding: 1rem; margin-bottom: 0.75rem; }

  /* Filter bar mobile */
  .filter-bar { gap: 0.35rem; }
  .filter-search-wrap { min-width: 120px; }
  .filter-sort { min-width: 80px; font-size: 0.72rem; padding: 0.5rem 0.6rem; }
  .filter-toggle { padding: 0.5rem 0.7rem; font-size: 0.72rem; }
  .filter-panel { grid-template-columns: 1fr 1fr; gap: 0.6rem; padding: 0.75rem; }
  .filter-chips { gap: 0.25rem; }
  .filter-chip { font-size: 0.62rem; padding: 0.15rem 0.4rem; }
  .filter-results { font-size: 0.68rem; }
  .filter-group .range-inputs input { font-size: 0.72rem; padding: 0.3rem 0.4rem; }

  /* ── Modal: full-screen bottom sheet on mobile ── */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
    background: rgba(0,0,0,0.4);
  }
  .modal-backdrop.open { display: flex; }

  .modal {
    max-width: 100%;
    width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: var(--radius) var(--radius) 0 0;
    animation: sheetUp 0.35s cubic-bezier(.16,1,.3,1);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: var(--safe-b);
  }
  .modal.modal-lg { max-width: 100%; }

  @keyframes sheetUp {
    from { transform: translateY(100%); opacity: 0.5; }
    to   { transform: translateY(0); opacity: 1; }
  }

  /* Modal handle bar */
  .modal-top::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--text-muted);
    border-radius: 2px;
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
  }
  .modal-top { position: relative; padding-top: 1.75rem; }

  .modal-body { padding: 1rem; }

  /* Detail modal adjustments */
  .detail-gallery { margin: -1rem -1rem 1rem; }
  .detail-hero { margin: -1rem -1rem 1rem; }

  .detail-price { font-size: 1.35rem; }
  .detail-info-grid { grid-template-columns: 1fr; gap: 0.5rem; }

  /* Gallery: full-width on mobile */
  .gallery-main { aspect-ratio: 3/2; border-radius: 0; }
  .gallery-nav { width: 36px; height: 36px; }
  .gallery-nav svg { width: 18px; height: 18px; }
  .gallery-prev { left: 0.5rem; }
  .gallery-next { right: 0.5rem; }
  .gallery-zoom-btn { width: 34px; height: 34px; }
  .gallery-zoom-btn svg { width: 16px; height: 16px; }
  .gallery-thumb { flex: 0 0 48px; height: 36px; }

  /* Hide desktop toggle */
  .mobile-toggle { display: none !important; }
}

/* ── Mobile < 400px (very small screens) ────────────────────── */
@media (max-width: 400px) {
  .offers-grid { grid-template-columns: 1fr; }
  .offer-desc { display: -webkit-box; }
}

/* ── Desktop toggle hidden ──────────────────────────────────── */
@media (min-width: 769px) {
  .mobile-toggle { display: none !important; }
  .bottom-nav { display: none !important; }
  .sidebar-overlay { display: none !important; }
}

/* ── Desktop: offer card hover only ─────────────────────────── */
@media (hover: hover) {
  .offer-card:hover { transform: translateY(-2px); box-shadow: 0 4px 20px rgba(124, 92, 255, 0.12); }
}
@media (hover: none) {
  .offer-card:hover { transform: none; box-shadow: none; }
}

/* ── Zoom overlay (fullscreen gallery) ──────────────────────── */
.zoom-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 3000;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.zoom-overlay.open { display: flex; align-items: center; justify-content: center; }

.zoom-overlay img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  touch-action: none;
  will-change: transform;
}

.zoom-overlay .zoom-close {
  position: absolute;
  top: calc(12px + var(--safe-t));
  right: calc(12px + var(--safe-r));
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 3001;
  backdrop-filter: blur(8px);
  -webkit-tap-highlight-color: transparent;
}
.zoom-overlay .zoom-close svg { width: 20px; height: 20px; stroke: #fff; fill: none; }

.zoom-overlay .zoom-counter {
  position: absolute;
  bottom: calc(16px + var(--safe-b));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 0.75rem;
  font-family: var(--mono);
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 12px;
  backdrop-filter: blur(4px);
  z-index: 3001;
}

/* Swipe hint animation */
@keyframes swipeHint {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-8px); }
}

/* ── Utilities ──────────────────────────────────────────────── */
.muted { color: var(--text-muted); }
.dim   { color: var(--text-dim); }
.mono  { font-family: var(--mono); }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
