/* Shared theme + UI utilities for Bandai TCG Digest dashboard pages.
   Canonical tokens use --bg-primary / --accent-* naming; aliases below keep
   older per-page rules (set.html, card.html) working against one source. */
:root {
  --bg-primary: #0a0c14;
  --bg-secondary: #12151f;
  --bg-card: #181c2a;
  --bg-elevated: #1e2334;
  --text-primary: #e8eaf0;
  --text-secondary: #8b92a8;
  --text-muted: #9098ae;
  --accent-blue: #4e7cff;
  --accent-purple: #a78bfa;
  --accent-orange: #fb923c;
  --accent-green: #34d399;
  --accent-red: #f87171;
  --gradient: linear-gradient(135deg, #4e7cff, #a78bfa);
  --border: #252a3a;
  --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.35);
  --bottom-tab-height: 56px;

  /* Aliases for legacy per-page variable names */
  --bg: var(--bg-primary);
  --card: var(--bg-card);
  --text: var(--text-primary);
  --muted: var(--text-muted);
  --chip: var(--bg-secondary);
  --green: var(--accent-green);
  --red: var(--accent-red);
  --blue: var(--accent-blue);
  --warn-bg: rgba(251, 146, 60, 0.1);
  --warn-border: rgba(251, 146, 60, 0.35);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

@view-transition { navigation: auto; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.has-bottom-tabs {
  padding-bottom: calc(var(--bottom-tab-height) + env(safe-area-inset-bottom, 0px));
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 1000;
  padding: 0.75rem 1.25rem;
  background: var(--accent-blue);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  border-radius: 0 0 8px 0;
}
.skip-link:focus {
  position: fixed;
  top: 0;
  left: 0;
  width: auto;
  height: auto;
  overflow: visible;
}

/* Nav */
.topnav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(10, 12, 20, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.8rem 2rem;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.5rem;
}
.topnav .logo {
  font-size: 1.1rem; font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 0.35rem 0.55rem;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  margin-left: auto;
}
.nav-toggle:hover { border-color: var(--accent-blue); }

.topnav .nav-links { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.topnav a { color: var(--text-secondary); text-decoration: none; font-size: 0.85rem; transition: color 0.18s ease; }
.topnav a:hover { color: var(--text-primary); }
.topnav a.active { color: var(--accent-blue); font-weight: 600; }

@media (max-width: 768px) {
  .topnav {
    padding: 0.55rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
  }
  .nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
    margin-left: auto;
  }
  .topnav .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.5rem 0 0.25rem;
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
  }
  .topnav .nav-links.open { display: flex; }
  .topnav .nav-links a {
    padding: 0.65rem 0;
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  .topnav .nav-links .nav-divider {
    height: 1px;
    background: var(--border);
    margin: 0.35rem 0;
  }
  .topnav .nav-links .nav-more-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding: 0.5rem 0 0.15rem;
  }
}

@media (min-width: 769px) {
  .nav-divider,
  .nav-more-label,
  .topnav .nav-links a.nav-more {
    display: none !important;
  }
}

/* Breadcrumbs */
.breadcrumbs {
  font-size: 0.82rem;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
}
.breadcrumbs ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.breadcrumbs li + li::before {
  content: '/';
  margin-right: 0.35rem;
  color: var(--text-muted);
}
.breadcrumbs a {
  color: var(--accent-blue);
  text-decoration: none;
}
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs [aria-current="page"] { color: var(--text-secondary); }

/* Table scroll hints */
.board-scroll-hint {
  margin: 0.4rem 0 0;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
}
.board-scroll-hint[hidden] { display: none !important; }

/* Set detail — rarity analytics table */
.analytics-table .table-wrap.analytics-table-scroll {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.analytics-table thead th:first-child,
.analytics-table tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--bg-card);
  box-shadow: 1px 0 0 var(--border);
}
.analytics-table thead th:first-child { z-index: 3; }
.topnav a.nav-search {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.1rem;
  line-height: 0;
}
.topnav a.nav-search .nav-icon { width: 1.15rem; height: 1.15rem; }
.topnav a.nav-search.active { font-weight: 400; }

.data-freshness-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.35rem 1.5rem 0;
}
.data-freshness-bar {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}
@media (max-width: 768px) {
  .data-freshness-wrap { padding: 0.3rem 0.75rem 0; }
  .data-freshness-bar { font-size: 0.68rem; }
}

/* Game toggle */
.game-toggle { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; justify-content: center; }
.game-btn {
  padding: 0.5rem 1.5rem; border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--text-secondary); cursor: pointer;
  font-size: 0.9rem; font-weight: 500;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}
.game-btn:hover { color: var(--text-primary); transform: translateY(-1px); }
.game-btn.active { background: var(--bg-card); color: var(--text-primary); border-color: var(--accent-blue); }
.game-btn.pokemon.active { border-color: var(--accent-orange); color: var(--accent-orange); }
.game-btn.onepiece.active { border-color: var(--accent-green); color: var(--accent-green); }

/* Page header */
.page-header { text-align: center; margin-bottom: 2rem; }
.page-header h1 {
  font-size: 1.6rem; margin-bottom: 0.3rem;
  background: var(--gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.page-header p { color: var(--text-muted); font-size: 0.9rem; }

/* Board sections */
.board {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.5rem; margin-bottom: 1.5rem;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.board:hover { border-color: #2f3650; box-shadow: var(--shadow-soft); }
.board-header { margin-bottom: 1rem; }
.board-header h2 { font-size: 1.15rem; margin-bottom: 0.3rem; }
.board-header p { color: var(--text-muted); font-size: 0.85rem; }
.board-header .proof-note { color: var(--text-secondary); font-size: 0.78rem; margin-top: 0.25rem; }

/* Signed value coloring (shared across the app) */
.val-pos { color: var(--accent-green); }
.val-neg { color: var(--accent-red); }
.val-flat { color: var(--text-muted); }

/* Tooltip trigger cue for explained/calculated values */
.has-explain {
  cursor: help;
  border-bottom: 1px dotted var(--text-muted);
  text-decoration: none;
}
th.has-explain { border-bottom-style: dotted; }

/* Tippy.js dark theme to match dashboard */
.tippy-box[data-theme~='tcg'] {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  font-size: 0.78rem;
  line-height: 1.45;
}
.tippy-box[data-theme~='tcg'] .tippy-content { padding: 0.55rem 0.7rem; }
.tippy-box[data-theme~='tcg'] code {
  font-family: 'Courier New', monospace;
  color: var(--accent-purple);
}
.tippy-box[data-theme~='tcg'][data-placement^='top'] > .tippy-arrow::before { border-top-color: var(--bg-elevated); }
.tippy-box[data-theme~='tcg'][data-placement^='bottom'] > .tippy-arrow::before { border-bottom-color: var(--bg-elevated); }
.tippy-box[data-theme~='tcg'][data-placement^='left'] > .tippy-arrow::before { border-left-color: var(--bg-elevated); }
.tippy-box[data-theme~='tcg'][data-placement^='right'] > .tippy-arrow::before { border-right-color: var(--bg-elevated); }

/* TCGplayer external link styling */
a.tcg-link { color: inherit; text-decoration: none; }
a.tcg-link:hover { color: var(--accent-blue); }

/* Set / product thumbnails in leaderboard + sealed tables */
.set-cell,
.product-cell {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}
.set-cell-text,
.product-cell-text {
  min-width: 0;
  flex: 1;
}
.set-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}
.product-thumb {
  width: 44px;
  height: 44px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}
.product-cell .product-label,
.product-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(78, 124, 255, 0.1);
  color: var(--accent-blue);
}
.product-badge.etb { background: rgba(167, 139, 250, 0.1); color: var(--accent-purple); }
.product-badge.starter { background: rgba(52, 211, 153, 0.12); color: var(--accent-green); }
.product-badge.blister { background: rgba(251, 146, 60, 0.1); color: var(--accent-orange); }
.product-badge.collector { background: rgba(52, 211, 153, 0.1); color: var(--accent-green); }
.product-pack-note {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.12rem;
}

/* Set detail hero */
.set-hero-visuals {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
.set-hero-icon {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}
.set-hero-product {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

/* Trust badges */
.trust-badges { display: flex; gap: 0.2rem; flex-wrap: wrap; margin-top: 0.15rem; }
.trust-badge {
  font-size: 0.58rem; padding: 0.05rem 0.26rem; border-radius: 3px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em;
}
.trust-sourced { background: rgba(52, 211, 153, 0.15); color: var(--accent-green); }
.trust-estimated { background: rgba(251, 146, 60, 0.15); color: var(--accent-orange); }
.trust-pack-cost { background: rgba(167, 139, 250, 0.15); color: var(--accent-purple); }
.trust-priced { background: rgba(78, 124, 255, 0.15); color: var(--accent-blue); }
.trust-insufficient { background: rgba(248, 113, 113, 0.18); color: var(--accent-red); }
.trust-low-priced { background: rgba(248, 113, 113, 0.15); color: var(--accent-red); }
.trust-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.35rem; }
.trust-meta-item { color: var(--text-secondary); }
.trust-meta-sep { margin: 0 0.35rem; color: var(--text-muted); }

/* Footer */
.footer {
  text-align: center; padding: 2rem; color: var(--text-muted);
  font-size: 0.82rem; border-top: 1px solid var(--border); margin-top: 2rem;
}
.footer a { color: var(--accent-blue); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.nav-toggle:focus-visible,
.game-btn:focus-visible,
.tab:focus-visible,
.pagination button:focus-visible,
.showcase-tile:focus-visible,
a.set-row:focus-visible,
.card-tile-link:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* Rarity odds table: compact horizontal layout (all viewports) */
.analytics-table table.rarity-odds-table {
  font-size: 0.72rem;
}
.analytics-table table.rarity-odds-table th,
.analytics-table table.rarity-odds-table td {
  padding: 0.3rem 0.35rem;
  vertical-align: top;
}
.analytics-table table.rarity-odds-table td:first-child {
  max-width: 10rem;
  line-height: 1.2;
}
.analytics-table table.rarity-odds-table .pull-odds {
  font-size: 0.68rem;
  line-height: 1.25;
  white-space: normal;
}

@media (max-width: 768px) {
  .game-btn,
  .tab,
  .pagination button {
    min-height: 44px;
  }

  .analytics-table table.rarity-stack-table {
    min-width: 0;
    table-layout: auto;
  }
  .analytics-table table.rarity-stack-table thead {
    display: none;
  }
  .analytics-table table.rarity-stack-table tbody tr {
    display: block;
    border-bottom: 1px solid var(--border);
    padding: 0.45rem 0.5rem;
  }
  .analytics-table table.rarity-stack-table tbody td {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.2rem 0;
    border: none;
    background: transparent !important;
    position: static;
    box-shadow: none;
    white-space: normal;
  }
  .analytics-table table.rarity-stack-table tbody td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex-shrink: 0;
  }
  .analytics-table table.rarity-stack-table tbody td:first-child {
    font-weight: 600;
    padding-bottom: 0.35rem;
    margin-bottom: 0.15rem;
    border-bottom: 1px dashed var(--border);
  }
  .analytics-table table.rarity-stack-table tbody td:first-child::before {
    display: none;
  }

  /* Rarity odds table: keep compact horizontal table (avoid 5-line stacked rows) */
  .analytics-table table.rarity-odds-table {
    min-width: 0;
    table-layout: auto;
    font-size: 0.68rem;
  }
  .analytics-table table.rarity-odds-table thead {
    display: table-header-group;
  }
  .analytics-table table.rarity-odds-table tbody tr {
    display: table-row;
    padding: 0;
    border-bottom: none;
  }
  .analytics-table table.rarity-odds-table tbody td {
    display: table-cell;
    padding: 0.22rem 0.3rem;
    border-bottom: 1px solid var(--border);
    background: transparent !important;
    position: static;
    box-shadow: none;
    white-space: normal;
    vertical-align: top;
  }
  .analytics-table table.rarity-odds-table tbody td::before {
    display: none;
  }
  .analytics-table table.rarity-odds-table tbody td:first-child {
    font-weight: 600;
    padding-bottom: 0.22rem;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border);
    max-width: 5.5rem;
    line-height: 1.2;
  }
  .analytics-table table.rarity-odds-table .pull-odds {
    font-size: 0.62rem;
    line-height: 1.25;
  }
  .analytics-table table.rarity-odds-table th {
    padding: 0.3rem 0.25rem;
    font-size: 0.58rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ── User menu (nav) ────────────────────────────────────────────────── */

.user-menu {
  position: relative;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gradient);
  color: white;
  border: none;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.user-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 200px;
  padding: 0.5rem 0;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  z-index: 200;
}

.user-dropdown.open {
  display: block;
}

.user-dropdown-header {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
}

.user-dropdown-header strong {
  display: block;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.user-dropdown-header small {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.dropdown-item {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.dropdown-item:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}

/* ── Skeleton loaders ─────────────────────────────────────────────── */

@keyframes skel-shimmer {
  to { background-position: -200% 0; }
}

.skel {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, #252b40 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.2s ease-in-out infinite;
  border-radius: 6px;
}

.board-skeleton .skel-title { height: 1rem; width: 55%; margin-bottom: 0.45rem; }
.board-skeleton .skel-text { height: 0.65rem; width: 80%; }
.skel-table { margin-top: 0.65rem; display: flex; flex-direction: column; gap: 0.45rem; }
.skel-row { display: grid; grid-template-columns: 26px 1fr 64px; gap: 0.5rem; align-items: center; }
.skel-rank { height: 0.75rem; width: 18px; }
.skel-name { height: 0.85rem; }
.skel-val { height: 0.75rem; width: 48px; justify-self: end; }
.skel-search-row { height: 2.5rem; width: 100%; }
.set-detail-skeleton { display: flex; flex-direction: column; gap: 1rem; }
.set-detail-skeleton .skel-hero { height: 5rem; }
.set-detail-skeleton .skel-kpi-row { height: 3.5rem; }
.set-detail-skeleton .skel-chart { height: 12rem; margin-top: 0.75rem; }
.set-detail-skeleton .skel-grid { height: 14rem; }

/* ── Table touch feedback ─────────────────────────────────────────── */

tr:hover td { background: rgba(78, 124, 255, 0.05); }
tr:active td { background: rgba(78, 124, 255, 0.1); }
a.set-row:active { background: rgba(78, 124, 255, 0.12); }
.card-tile-link:active { transform: scale(0.98); }
.showcase-tile:active { transform: scale(0.98); }

.value-col,
.price-col,
.ev-col {
  font-variant-numeric: tabular-nums;
}

/* ── Mobile bottom tab bar ────────────────────────────────────────── */

.bottom-tab-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 150;
  background: rgba(10, 12, 20, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 0.35rem 0.5rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
  grid-template-columns: repeat(4, 1fr);
  gap: 0.25rem;
}

.bottom-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  padding: 0.35rem 0.25rem;
  min-height: 44px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.65rem;
  font-weight: 500;
  border-radius: 8px;
  transition: color 0.15s ease, background 0.15s ease;
}

.bottom-tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  opacity: 0.9;
}

.bottom-tab.active {
  color: var(--accent-blue);
  background: rgba(78, 124, 255, 0.1);
}

.bottom-tab:active {
  background: rgba(78, 124, 255, 0.15);
}

#userArea {
  min-width: 32px;
  min-height: 32px;
}

/* ── Robinhood-style compact lists (mobile) ───────────────────────── */

.rh-list {
  display: flex;
  flex-direction: column;
}

  .rh-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.55rem;
    align-items: center;
    width: 100%;
    max-width: 100%;
    padding: 0.55rem 1rem;
    min-height: 52px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  box-sizing: border-box;
}

.rh-row.rh-row--menu {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
}

.rh-row:last-child { border-bottom: none; }

.rh-row:active { background: rgba(78, 124, 255, 0.08); }

.rh-row-thumb-wrap {
  flex-shrink: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rh-row-thumb-wrap--card { width: 36px; height: 50px; }
.rh-row-thumb-wrap--sealed { width: 44px; height: 44px; }

.rh-row-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rh-row-thumb-wrap--sealed .rh-row-thumb { object-fit: contain; }

.rh-row-main {
  min-width: 0;
  overflow: hidden;
}

.rh-row-title {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.rh-row-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.1rem;
}

.rh-row-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  justify-self: end;
}

.rh-row-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  margin: -0.35rem -0.5rem -0.35rem 0;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  border-radius: 8px;
  cursor: pointer;
}

.rh-row-menu-btn:hover,
.rh-row-menu-btn:focus-visible {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.rh-row-price {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
}

.rh-row-change {
  font-size: 0.72rem;
  font-weight: 500;
  margin-top: 0.1rem;
}

.rh-row-change.up { color: var(--accent-green); }
.rh-row-change.down { color: var(--accent-red); }
.rh-row-change.flat { color: var(--text-muted); }

.rh-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.rh-ticker {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  white-space: nowrap;
  padding: 0.45rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.rh-ticker::-webkit-scrollbar { display: none; }

.rh-ticker-stat {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.rh-ticker-stat strong {
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.rh-ticker-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
  flex-shrink: 0;
}

/* Card / product — scrollable market tables */
  .market-panels-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.75rem;
  }
.panel--market {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.section-count {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.75rem;
}
.market-table-wrap {
  flex: 1;
  min-height: 0;
  max-height: min(280px, 38vh);
  overflow: auto;
  padding: 0 0.75rem 0.5rem;
  -webkit-overflow-scrolling: touch;
}
.market-table-foot {
  padding: 0.4rem 0 0.15rem;
  font-size: 0.68rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 0.35rem;
}
.market-buy-link {
  color: var(--blue);
  text-decoration: none;
  font-size: 0.72rem;
}
.market-buy-link:hover { text-decoration: underline; }
.market-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.74rem;
}
.market-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--card);
  text-align: left;
  color: var(--muted);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.28rem 0.3rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.market-table td {
  padding: 0.24rem 0.3rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-variant-numeric: tabular-nums;
}
.market-table .num { text-align: right; font-family: 'Courier New', monospace; font-size: 0.72rem; }

/* Card hero — image + chart side by side */
.card-hero-grid {
  display: grid;
  grid-template-columns: minmax(130px, 185px) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  gap: 0.65rem 1rem;
  padding: 0.85rem 1rem;
  align-items: start;
}
.card-hero-grid .hero-img {
  grid-row: 1 / 3;
  width: 100%;
  max-width: 185px;
}
.card-hero-meta { grid-column: 2; min-width: 0; }
.card-hero-chart {
  grid-column: 2;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.12);
  overflow: hidden;
  min-height: 200px;
  display: flex;
  flex-direction: column;
}
.card-hero-chart .section-head {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
}
.card-hero-chart .chart-canvas-box {
  flex: 1;
  min-height: 180px;
  height: auto;
  padding: 0.4rem 0.55rem 0.55rem;
}
.compact-metrics-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1rem 0.65rem;
}
.compact-metrics-row .kpi {
  min-width: 100px;
  flex: 1 1 100px;
  padding: 0.4rem 0.6rem;
}
.compact-metrics-row .kpi .value { font-size: 0.95rem; }
.panel--compact .price-grid {
  padding: 0.5rem 0.75rem;
  gap: 0.35rem;
}
.panel--compact .price-cell {
  padding: 0.4rem 0.55rem;
}
.panel--compact .price-cell .value { font-size: 0.9rem; }

@media (max-width: 768px) {
  .market-panels-row { grid-template-columns: 1fr; }
  .card-hero-grid {
    grid-template-columns: minmax(110px, 140px) minmax(0, 1fr);
  }
  .card-hero-grid .hero-img { max-width: 140px; }
}

@media (max-width: 520px) {
  .card-hero-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }
  .card-hero-grid .hero-img {
    grid-row: auto;
    max-width: 150px;
    margin: 0 auto;
  }
  .card-hero-meta,
  .card-hero-chart { grid-column: 1; }
}

@media (max-width: 768px) {
  body.has-bottom-tabs {
    overflow-x: clip;
  }

  .rh-row {
    padding: 0.45rem 1rem;
    min-height: 48px;
    gap: 0.5rem;
  }

  .rh-row-menu-btn {
    margin: -0.35rem 0;
  }

  .rh-row-thumb-wrap--card { width: 32px; height: 44px; }
  .rh-row-thumb-wrap--sealed { width: 40px; height: 40px; }

  .rh-row-title { font-size: 0.82rem; }
  .rh-row-sub { font-size: 0.68rem; }
  .rh-row-price { font-size: 0.85rem; }
  .rh-row-change { font-size: 0.68rem; }

  .bottom-tab-bar { display: grid; }

  .topnav .logo { font-size: 1rem; }

  .footer {
    padding: 1rem;
    font-size: 0.75rem;
    margin-top: 1rem;
  }

  .footer p:not(:first-child) { display: none; }

  th {
    min-height: 44px;
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
  }

  table { font-size: max(0.8rem, 12.8px); }

  .market-table-wrap {
    -webkit-overflow-scrolling: touch;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
  .market-table-wrap--listings .market-table th:nth-child(1),
  .market-table-wrap--listings .market-table td:nth-child(1) {
    max-width: 5.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .market-table-wrap--listings .market-table th:nth-child(4),
  .market-table-wrap--listings .market-table td:nth-child(4),
  .market-table-wrap--listings .market-table th:nth-child(5),
  .market-table-wrap--listings .market-table td:nth-child(5),
  .market-table-wrap--sales .market-table th:nth-child(4),
  .market-table-wrap--sales .market-table td:nth-child(4),
  .market-table-wrap--sales .market-table th:nth-child(5),
  .market-table-wrap--sales .market-table td:nth-child(5) {
    display: none;
  }

  .has-explain::after {
    content: ' ⓘ';
    font-size: 0.75em;
    color: var(--text-muted);
  }
}
