:root {
  --bg: #0c1118;
  --bg-elev: #121a24;
  --bg-panel: #182433;
  --text: #e8eef4;
  --muted: #8494a8;
  --accent: #6ec8e8;
  --accent-dim: #3a8fb0;
  --border: #243244;
  --highlight: #2a4458;
  --danger: #e86b6b;
  --warn: #e0b45a;
  --ok: #6ed9a0;
  --font: "Sora", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background:
    radial-gradient(1000px 520px at 8% -8%, #16324a 0%, transparent 55%),
    radial-gradient(800px 420px at 100% 0%, #1a2838 0%, transparent 50%),
    linear-gradient(180deg, #0e1620 0%, var(--bg) 40%);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: rgba(12, 17, 24, 0.88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand a {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 1.4rem;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-decoration: none;
  text-transform: uppercase;
}

.brand .version {
  margin-left: 0.5rem;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0;
  text-transform: none;
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.topbar nav a {
  color: var(--muted);
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.92rem;
}

.topbar nav a:hover,
.topbar nav a.active {
  color: var(--text);
  background: var(--bg-panel);
}

.topbar nav a.active { color: var(--accent); }

.summary {
  padding: 0.65rem 1.25rem;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
}

.summary strong { color: var(--text); font-weight: 500; }

.summary[hidden] { display: none !important; }

main {
  padding: 1.25rem;
  padding-bottom: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.hero-panel {
  max-width: 640px;
  margin: 1.5rem auto 2rem;
}

.hero-panel h1 {
  font-family: var(--mono);
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 0.5rem;
  color: var(--accent);
}

.hero-panel .lede {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.45;
  margin: 0 0 1.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: var(--bg-panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.85rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn:hover { border-color: var(--accent-dim); }

.btn.view-btn.active,
.btn.view-btn.btn-accent {
  background: var(--accent);
  color: #0c1118;
  border-color: var(--accent);
  font-weight: 600;
}

.btn-accent:hover {
  filter: brightness(1.05);
  text-decoration: none;
}

.btn-lg {
  padding: 0.65rem 1.4rem;
  font-size: 1rem;
  margin-top: 0.75rem;
}

.banner {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}

.banner.error { background: #2a1515; color: var(--danger); }
.banner.ok { background: #152a20; color: var(--ok); }
.banner[hidden] { display: none !important; }

.upload-form { margin-top: 1rem; }

.upload-block {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
}

.upload-block h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.muted { color: var(--muted); font-size: 0.9rem; }

.file-drop {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
}

.file-drop:hover { border-color: var(--accent-dim); }

.file-drop input { max-width: 100%; color: var(--muted); }

.parse-preview {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
}

.parse-preview dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1rem;
  margin: 0;
}

.parse-preview dt { color: var(--muted); }
.parse-preview dd { margin: 0; color: var(--text); }

.toolbar { margin-bottom: 1rem; }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.85rem;
}

.pos-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.55rem;
}

.chk {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
}

.chk input { accent-color: var(--accent); }

.search {
  min-width: 200px;
  flex: 1;
  max-width: 320px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
  color: var(--text);
  font: inherit;
}

.search:focus {
  outline: none;
  border-color: var(--accent-dim);
}

.min-gp-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.min-gp-input {
  width: 3.25rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.4rem;
  color: var(--text);
  font: inherit;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev);
  margin-bottom: 0.5rem;
  max-width: 100%;
  scrollbar-width: thin;
}

.floating-hscroll {
  position: fixed;
  bottom: 0;
  z-index: 50;
  height: 18px;
  overflow-x: auto;
  overflow-y: hidden;
  background: rgba(12, 17, 24, 0.95);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(6px);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.35);
}

.floating-hscroll[hidden] {
  display: none !important;
}

.floating-hscroll-spacer {
  height: 1px;
  pointer-events: none;
}

.floating-hscroll::-webkit-scrollbar {
  height: 14px;
}
.floating-hscroll::-webkit-scrollbar-thumb {
  background: var(--accent-dim);
  border-radius: 6px;
  border: 2px solid rgba(12, 17, 24, 0.95);
}
.floating-hscroll::-webkit-scrollbar-track {
  background: var(--bg-panel);
}

.data-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  white-space: nowrap;
}

.data-table th,
.data-table td {
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--border);
  text-align: right;
}

.data-table th:first-child,
.data-table td:first-child,
.data-table th.left,
.data-table td.left {
  text-align: left;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-panel);
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

.data-table th[title] {
  cursor: help;
}

.data-table th[data-sort="asc"]::after { content: " ↑"; color: var(--accent); }
.data-table th[data-sort="desc"]::after { content: " ↓"; color: var(--accent); }

.data-table tbody tr:hover { background: rgba(110, 200, 232, 0.06); }

.data-table th .col-filter-btn {
  margin-left: 0.2rem;
  padding: 0 0.2rem;
  font-size: 0.7rem;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
}

.data-table th .col-filter-btn.active { color: var(--accent); }

.col-filter-menu {
  position: absolute;
  z-index: 30;
  min-width: 9rem;
  max-height: 16rem;
  overflow: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.col-filter-menu label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.3rem;
  font-size: 0.82rem;
  color: var(--text);
  cursor: pointer;
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-top: 1.5rem;
}

.panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

@media (max-width: 640px) {
  main { padding: 0.85rem; }
  .search { max-width: none; }
}

.hint-row {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
}

.data-table tbody tr[data-player-name] { cursor: context-menu; }

.player-card-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow: auto;
}

.player-card {
  position: relative;
  width: min(960px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem 1.5rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.player-card-close {
  position: absolute;
  top: 0.75rem;
  right: 0.9rem;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.player-card-close:hover { color: var(--text); }

.player-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.15rem;
  padding-right: 1.5rem;
}

.player-card-header h2 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
}

.player-card-identity { margin: 0; }

.player-card-tabs {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.player-card-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  margin-bottom: -1px;
  cursor: pointer;
}

.player-card-tab:hover { color: var(--text); }

.player-card-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.player-card-cols {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 1.25rem;
  margin-top: 1rem;
}

.player-card-cols.solo { grid-template-columns: 1fr; }
.player-card-cols.solo .player-card-aside { display: none; }

@media (max-width: 720px) {
  .player-card-cols { grid-template-columns: 1fr; }
}

.player-card-panel h3,
.player-card-aside h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.player-card-aside ul {
  margin: 0 0 1rem;
  padding-left: 1.1rem;
  font-family: var(--mono);
  font-size: 0.82rem;
}

.pct-list {
  max-height: 420px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.8rem;
}

.pct-row {
  display: grid;
  grid-template-columns: 5.5rem 3.5rem 2.8rem 1fr 5rem;
  gap: 0.4rem;
  align-items: center;
  padding: 0.2rem 0;
}

.pct-label { color: var(--muted); text-align: right; }
.pct-val { text-align: right; font-variant-numeric: tabular-nums; }
.pct-pct { text-align: right; font-variant-numeric: tabular-nums; }

.pct-bar {
  height: 0.55rem;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--tier, #3b82f6) calc(var(--pct) * 1%), #2a2f3a 0);
}

.pct-tier { font-size: 0.72rem; }

.player-card-stats-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.35rem;
}

.player-card-stats-head h3 { margin: 0; }

.stats-list {
  max-height: 420px;
  overflow: auto;
}

.rating-rows {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.2rem 0.75rem;
  font-family: var(--mono);
  font-size: 0.8rem;
}

.rating-rows-rank {
  grid-template-columns: 1fr;
  max-width: 28rem;
}

.rating-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.15rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.rating-row-rank {
  display: grid;
  grid-template-columns: 4.5rem 5rem 1fr;
  align-items: baseline;
  gap: 0.5rem;
}

.rating-label { color: var(--muted); }
.rating-val { font-weight: 600; color: var(--text); text-align: right; }

.stat-rank {
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.stat-rank .muted {
  font-weight: 400;
  opacity: 0.75;
}

/* ——— Players page + viz card ——— */

.players-page {
  max-width: 1100px;
}

.players-search-bar {
  position: relative;
}

.search-wide {
  max-width: 28rem;
  flex: 1 1 16rem;
}

.players-results {
  position: absolute;
  left: 1.25rem;
  right: 1.25rem;
  top: calc(100% - 0.35rem);
  z-index: 30;
  max-height: 22rem;
  overflow: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  padding: 0.35rem;
}

.players-result {
  display: grid;
  grid-template-columns: 1.6rem 1fr auto;
  gap: 0.55rem;
  align-items: center;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.92rem;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
}

.players-result:hover,
.players-result:focus-visible {
  background: var(--highlight);
  outline: none;
}

.players-result-kind {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(110, 200, 232, 0.12);
  border-radius: 4px;
  text-align: center;
  padding: 0.15rem 0;
}

.players-result-name { font-weight: 500; }

.players-result-meta {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.players-no-match {
  margin: 0.5rem 0.75rem;
}

.players-empty {
  margin: 2rem 0 0;
  font-size: 0.95rem;
}

.players-detail { margin-top: 1.25rem; }

.players-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.25rem;
}

.players-stats-grid .panel { margin-top: 0; }

.players-stats-grid .stats-list {
  max-height: 520px;
}

@media (max-width: 800px) {
  .players-stats-grid { grid-template-columns: 1fr; }
  .players-results { left: 0.85rem; right: 0.85rem; }
}

.player-viz-card {
  background:
    linear-gradient(160deg, #152436 0%, #0f1824 42%, #0c1420 100%);
  border: 1px solid #2a3d55;
  border-radius: 14px;
  padding: 1.35rem 1.5rem 1rem;
  box-shadow:
    0 0 0 1px rgba(110, 200, 232, 0.06),
    0 18px 48px rgba(0, 0, 0, 0.35);
}

.player-viz-header {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.15rem;
}

.player-viz-team {
  flex: 0 0 auto;
  min-width: 3.25rem;
  height: 3.25rem;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: rgba(110, 200, 232, 0.1);
  border: 1px solid rgba(110, 200, 232, 0.35);
  border-radius: 10px;
}

.player-viz-header-main { flex: 1; min-width: 0; }

.player-viz-name {
  margin: 0;
  font-size: clamp(1.55rem, 3.5vw, 2.15rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-transform: uppercase;
}

.player-viz-rule {
  height: 3px;
  width: min(12rem, 40%);
  margin: 0.55rem 0 0.65rem;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-dim) 70%, transparent 100%);
}

.player-viz-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.player-viz-meta strong {
  color: #a8b8c8;
  font-weight: 600;
  margin-right: 0.25rem;
}

.player-viz-body {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 720px) {
  .player-viz-body { grid-template-columns: 1fr; }
}

.player-viz-identity {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: stretch;
  min-width: 5.5rem;
}

.player-viz-hero {
  min-width: 5.5rem;
  border-radius: 10px;
  padding: 0.65rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.player-viz-hero-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.85;
}

.player-viz-hero-val {
  font-family: var(--mono);
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1.1;
}

.player-viz-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.6rem, 1fr));
  gap: 0.45rem;
}

.player-viz-tile {
  border-radius: 8px;
  padding: 0.55rem 0.5rem 0.45rem;
  min-height: 3.6rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.25rem;
}

.player-viz-tile-na {
  background: #1a2430;
  color: var(--muted);
  border: 1px dashed #2e3d50;
}

.player-viz-tile-context {
  opacity: 0.92;
  outline: 1px dashed rgba(148, 163, 184, 0.35);
  outline-offset: -1px;
}

.player-viz-context-label {
  grid-column: 1 / -1;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-top: 0.35rem;
}

.player-viz-tile-label {
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  opacity: 0.9;
}

.player-viz-tile-val {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1;
}

.player-viz-footer {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(42, 61, 85, 0.8);
  font-size: 0.72rem;
  color: var(--muted);
}

.player-viz-tile.tip,
.player-viz-hero.tip {
  cursor: help;
  position: relative;
}

.player-viz-tile.tip:hover,
.player-viz-hero.tip:hover {
  filter: brightness(1.06);
  outline: 1px solid rgba(244, 247, 251, 0.35);
  outline-offset: 1px;
}

/* Rich hover tip (supplements native title for long copy) */
.player-viz-card .tip[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.45rem);
  transform: translateX(-50%);
  width: min(18rem, 70vw);
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  background: #0a1018;
  border: 1px solid #3a5168;
  color: #e8eef4;
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.35;
  text-transform: none;
  letter-spacing: 0;
  text-align: left;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 40;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.player-viz-card .tip[data-tip]:hover::after,
.player-viz-card .tip[data-tip]:focus-visible::after {
  opacity: 1;
}

.player-viz-identity .player-viz-hero.tip[data-tip]::after {
  left: 0;
  transform: none;
  width: min(16rem, 72vw);
}

.players-glossary {
  margin-top: 1.5rem;
}

.players-glossary summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  list-style: none;
}

.players-glossary summary::-webkit-details-marker { display: none; }

.players-glossary summary::before {
  content: "▸ ";
  color: var(--accent);
  font-family: var(--mono);
}

.players-glossary[open] summary::before { content: "▾ "; }

.glossary-body {
  margin-top: 0.85rem;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text);
}

.glossary-body h3 {
  margin: 1rem 0 0.4rem;
  font-size: 0.92rem;
  color: var(--accent);
}

.glossary-body h3:first-child { margin-top: 0; }

.glossary-body p,
.glossary-body ul {
  margin: 0.35rem 0 0.65rem;
  color: #c5d0dc;
}

.glossary-body ul {
  padding-left: 1.2rem;
}

.glossary-formula {
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 0.55rem 0.75rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--accent);
}

.glossary-dl {
  margin: 0.35rem 0 0.75rem;
  display: grid;
  gap: 0.35rem 1rem;
}

.glossary-dl > div {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 0.5rem;
  font-size: 0.84rem;
}

.glossary-dl dt {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.glossary-dl dd {
  margin: 0;
  color: #c5d0dc;
}

.glossary-foot { margin-top: 0.75rem !important; }

@media (max-width: 560px) {
  .glossary-dl > div { grid-template-columns: 1fr; gap: 0.1rem; }
}

/* —— Snippets (scouting Single layout, Nexer theme) —— */
.snippets-page {
  display: grid;
  gap: 0.85rem;
  max-width: 960px;
  padding: 0 0 2rem;
}

.snip-stage {
  position: relative;
  min-height: min(52vh, 420px);
  border: 2px dashed var(--border);
  border-radius: 6px;
  background: var(--bg-panel);
  cursor: pointer;
  overflow: hidden;
  outline: none;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.snip-stage:hover,
.snip-stage:focus-visible,
.snip-stage.is-drag {
  border-color: var(--accent-dim);
  transform: translateY(-1px);
}

.snip-stage-inner {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 2rem;
  gap: 0.35rem;
  transition: opacity 0.25s ease;
}

.snip-stage.has-image .snip-stage-inner {
  opacity: 0;
  pointer-events: none;
}

.snip-stage-kicker {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.snip-stage-title {
  margin: 0;
  font-weight: 600;
  font-size: clamp(1.85rem, 5vw, 2.75rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.snip-stage-copy {
  margin: 0.25rem 0 0.85rem;
  color: var(--muted);
  max-width: 28rem;
  justify-self: center;
}

.snip-stage-inner .btn {
  justify-self: center;
}

.snip-stage-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0a1018;
}

.snip-text-fallback {
  padding: 0.65rem 0.85rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.snip-text-fallback summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.9rem;
}

.snip-text {
  width: 100%;
  margin-top: 0.65rem;
  padding: 0.75rem 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.45;
  resize: vertical;
}

.snip-text-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

.snip-regen {
  margin: 0.65rem 0 0;
  font-size: 0.78rem;
}

.snip-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  padding: 0.35rem 0.1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.snip-status-progress {
  flex: 1;
  min-width: 0;
}

.snip-status-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.snip-status-pct {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-weight: 600;
  color: var(--accent);
}

.snip-status-track {
  position: relative;
  height: 6px;
  margin-top: 0.4rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  opacity: 0;
  transform: scaleY(0.6);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.snip-status-bar.is-busy .snip-status-track,
.snip-status-bar.is-done .snip-status-track {
  opacity: 1;
  transform: scaleY(1);
}

.snip-status-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--accent-dim);
  transition: width 0.08s linear;
}

.snip-status-bar.is-done .snip-status-fill {
  background: var(--accent);
}

.snip-count {
  font-family: var(--mono);
  font-size: 0.8rem;
  white-space: nowrap;
}

.snip-results-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.snip-results-head h2 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.snip-ghost {
  background: transparent;
  border: 0;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.snip-ghost:hover { color: var(--text); }

.snip-banner {
  margin: 0 0 0.85rem;
  padding: 0.9rem 1.05rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
}

.snip-banner-kicker {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted);
}

.snip-banner-title {
  margin: 0.15rem 0 0;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.15;
}

.snip-banner-copy {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.snip-banner-tier1 {
  border-color: rgba(110, 200, 232, 0.45);
  background: linear-gradient(105deg, rgba(58, 143, 176, 0.18), var(--bg-elev) 60%);
}

.snip-banner-tier1 .snip-banner-kicker { color: var(--accent); }

.snip-banner-pos {
  border-color: rgba(110, 217, 160, 0.4);
  background: linear-gradient(105deg, rgba(21, 42, 32, 0.9), var(--bg-elev) 60%);
}

.snip-banner-pos .snip-banner-kicker { color: var(--ok); }

.snip-banner-neg {
  border-color: rgba(232, 107, 107, 0.4);
  background: linear-gradient(105deg, rgba(42, 21, 21, 0.9), var(--bg-elev) 60%);
}

.snip-banner-neg .snip-banner-kicker { color: var(--danger); }

.snip-attr-list {
  display: grid;
  gap: 0.65rem;
}

.snip-attr-card {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr) auto;
  gap: 0.75rem 1rem;
  align-items: start;
  padding: 0.9rem 1.05rem;
  background: var(--bg-panel);
  border-left: 3px solid var(--border);
  border-radius: 0 6px 6px 0;
  animation: snip-slide 0.4s ease both;
}

.snip-attr-card:nth-child(odd) {
  border-left-color: var(--accent-dim);
}

.snip-attr-card--tier1 { border-left-color: var(--accent); }
.snip-attr-card--pos { border-left-color: var(--ok); }
.snip-attr-card--neg { border-left-color: var(--danger); }

@keyframes snip-slide {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.snip-attr-name {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.snip-pill {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.12rem 0.4rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  letter-spacing: 0.02em;
}

.snip-pill-tier1 { background: #1a2a3a; color: var(--accent); }
.snip-pill-pos { background: #152a20; color: var(--ok); }
.snip-pill-neg { background: #2a1515; color: var(--danger); }

.snip-snippet-hit {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.snip-denotes {
  margin: 0;
  font-weight: 600;
  color: var(--accent);
  font-size: 0.95rem;
}

.snip-score {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-weight: 600;
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.snip-empty {
  padding: 1.1rem;
  background: var(--bg-panel);
  color: var(--muted);
  border-radius: 6px;
}

.snip-raw {
  margin-top: 1.25rem;
  padding: 0.85rem 1rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.snip-raw summary {
  cursor: pointer;
  font-weight: 600;
}

.snip-ocr-pre {
  margin: 0.5rem 0 0;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 0.78rem;
  max-height: 220px;
  overflow: auto;
}

.snip-raw-matches {
  margin-top: 0.65rem;
  font-size: 0.82rem;
}

.snip-raw-matches ol {
  margin: 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 0.25rem;
}

@media (max-width: 720px) {
  .snip-attr-card {
    grid-template-columns: 1fr;
  }
  .snip-score { justify-self: start; }
}

/* Mode toggle */
.snip-mode-toggle {
  display: inline-flex;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
  padding: 0.25rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.snip-mode-btn {
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.9rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.45rem 0.95rem;
  border-radius: 4px;
  cursor: pointer;
}

.snip-mode-btn.is-active {
  background: var(--accent);
  color: #0a1018;
}

.snip-stage--rank {
  min-height: min(40vh, 320px);
}

#snip-single,
#snip-rank {
  display: grid;
  gap: 0.85rem;
}

#snip-single[hidden],
#snip-rank[hidden] {
  display: none !important;
}

/* Rank table */
.snip-rank-actions {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

.snip-rank-scoring {
  margin: 0 0 0.85rem;
  font-size: 0.88rem;
  line-height: 1.4;
}

.snip-rank-progress {
  margin-bottom: 0.85rem;
}

.snip-rank-progress-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.snip-rank-progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent-dim);
  transition: width 0.2s ease;
  border-radius: inherit;
}

#snip-rank-progress-label {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.snip-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-panel);
}

.snip-rank-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.snip-rank-table th,
.snip-rank-table td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.snip-rank-table th {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  background: var(--bg-elev);
}

.snip-rank-table tbody tr:last-child td {
  border-bottom: 0;
}

.snip-rank-num {
  font-weight: 600;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.snip-rank-score {
  font-weight: 700;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.snip-rank-name {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.snip-rank-name:hover { color: var(--text); }

.snip-rank-player-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.snip-rank-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  opacity: 0.55;
  cursor: pointer;
}

.snip-rank-edit:hover {
  color: var(--accent);
  opacity: 1;
  background: rgba(110, 200, 232, 0.12);
}

.snip-rank-edit .icon-edit {
  width: 1rem;
  height: 1rem;
  display: block;
}

.snip-rank-signals {
  font-size: 0.82rem;
  color: var(--muted);
  max-width: 28rem;
}

.snip-rank-row--tier1 {
  background: rgba(58, 143, 176, 0.12);
}

.snip-rank-row--pos {
  background: rgba(21, 42, 32, 0.45);
}

.snip-rank-row--neg {
  background: rgba(42, 21, 21, 0.45);
}

.snip-cell-neg { color: var(--danger); }

.snip-rank-detail-head {
  display: grid;
  grid-template-columns: minmax(120px, 200px) 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
  align-items: start;
}

.snip-rank-detail-thumb {
  width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0a1018;
}

.snip-rank-detail-thumb.is-zoomable {
  cursor: zoom-in;
}

.snip-rank-detail-thumb.is-zoomable:hover {
  border-color: var(--accent-dim);
}

.snip-rank-detail-title {
  margin: 0;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.snip-rank-detail-score {
  margin: 0.35rem 0 0;
}

.snip-rank-signal-breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.snip-rank-signal-col h4 {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
}

.snip-rank-signal-col--pos h4 { color: var(--ok); }
.snip-rank-signal-col--neg h4 { color: var(--danger); }

.snip-rank-signal-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}

.snip-rank-signal-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.86rem;
  padding: 0.2rem 0;
  border-bottom: 1px solid var(--border);
}

.snip-rank-signal-list li:last-child { border-bottom: 0; }

.snip-rank-signal-val {
  font-family: var(--mono);
  font-weight: 600;
  white-space: nowrap;
}

.snip-rank-signal-col--pos .snip-rank-signal-val { color: var(--ok); }
.snip-rank-signal-col--neg .snip-rank-signal-val { color: var(--danger); }

.snip-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  place-content: center;
  background: rgba(6, 10, 16, 0.88);
  padding: 1.5rem;
}

.snip-lightbox.is-open {
  display: grid;
}

.snip-lightbox-img {
  max-width: min(96vw, 1100px);
  max-height: 85vh;
  object-fit: contain;
  border-radius: 4px;
}

.snip-lightbox-caption {
  margin-top: 0.65rem;
  text-align: center;
  color: var(--muted);
}

.snip-lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 720px) {
  .snip-rank-detail-head {
    grid-template-columns: 1fr;
  }
  .snip-rank-signal-breakdown {
    grid-template-columns: 1fr;
  }
}
