/* a1 — set intelligence. Matte dark, lilac/cream accents. No gradients, no glow.
 * Tokens mirror the Demo Gate design system. */
:root {
  --bg: #0b0b0d;
  --surface: #131316;
  --surface-2: #1a1a1f;
  --border: #232329;
  --text: #f2f2f4;
  --muted: #8e8e98;
  --lilac: #cdbcf2;      /* pale accent — UI chrome only */
  --cream: #efe7cf;      /* pale accent — UI chrome only */
  --st-good: #0ca30c;
  --st-warn: #fab219;
  --s-crowd: #8f6ae8;    /* data series: crowd */
  --s-audio: #bd8b31;    /* data series: audio / drops */
  --danger: #d96a6a;
  --r: 18px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column;
}
#shell { display: flex; flex-direction: column; min-height: 100vh; }
.hidden { display: none !important; }

/* ---------- gate ---------- */
.gate {
  position: fixed; inset: 0; background: var(--bg); z-index: 50;
  display: flex; align-items: center; justify-content: center;
}
.gate-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 40px 44px; width: 360px; text-align: center;
}
.gate-card .wordmark { justify-content: center; margin-bottom: 10px; }
.gate-card form { display: flex; gap: 8px; margin-top: 18px; }
.gate-card input { flex: 1; }
.gate-error { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 16px; }

/* ---------- header ---------- */
header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 30px;
}
.wordmark { font-size: 19px; font-weight: 700; letter-spacing: -0.3px; display: flex; align-items: baseline; }
.wordmark .dot { color: var(--lilac); font-weight: 500; }
.tagline { font-size: 12px; color: var(--muted); margin-top: 1px; letter-spacing: 0.2px; }
.brand { display: flex; flex-direction: column; }
.pills { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px; }
.pill {
  border: none; background: none; color: var(--muted); font-size: 13.5px; font-weight: 500;
  padding: 8px 20px; border-radius: 999px; cursor: pointer; font-family: inherit;
}
.pill.active { background: #fff; color: #0b0b0d; }
.header-right { min-width: 110px; text-align: right; display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.home-link { text-decoration: none; color: inherit; }
.home-link:hover .tagline { color: var(--lilac); }
.set-select {
  appearance: none; -webkit-appearance: none;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 30px 7px 14px; font: inherit; font-size: 13px;
  cursor: pointer; max-width: 260px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%238e8e98'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.set-select:focus { outline: none; border-color: var(--lilac); }
/* ---------- upload ---------- */
a.pill { text-decoration: none; display: inline-block; }
.upload-link {
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
}
.upload-link:hover { color: var(--text); border-color: var(--lilac); }
.upload-note { font-size: 13.5px; line-height: 1.55; max-width: 640px; }
.drop-zone {
  border: 1.5px dashed var(--border); border-radius: var(--r);
  padding: 34px 20px; text-align: center; margin: 14px 0; cursor: default;
}
.drop-zone.drag { border-color: var(--lilac); background: var(--surface-2); }
.drop-title { font-size: 14.5px; margin-bottom: 6px; }
.upload-fields { display: flex; gap: 8px; flex-wrap: wrap; }
.upload-fields input[type=text] {
  flex: 1; min-width: 200px; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px; padding: 10px 12px; font: inherit;
}
.upload-fields input[type=text]:focus { outline: none; border-color: var(--lilac); }
.upload-progress { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.bar.big { flex: 1; height: 8px; }
.q-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px;
}
.q-name { font-size: 14px; flex: 1; min-width: 160px; }
.q-status {
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.3px;
  border-radius: 999px; padding: 2px 9px; border: 1px solid var(--border); color: var(--muted);
}
.q-status.q-processing { color: var(--s-audio); border-color: var(--s-audio); }
.q-status.q-published { color: var(--s-crowd); border-color: var(--s-crowd); }
.q-status.q-failed { color: var(--danger); border-color: var(--danger); }
.q-link { color: var(--lilac); font-size: 13px; }

.id-badge {
  display: inline-block; font-size: 11.5px; font-weight: 600; letter-spacing: 0.3px;
  color: var(--s-audio); border: 1px solid var(--s-audio); border-radius: 999px;
  padding: 2px 9px; white-space: nowrap;
}
/* Cross-set recurrence: the same recording fingerprint-matched in another set. */
.cross-set {
  display: inline-block; font-size: 11.5px; letter-spacing: 0.2px;
  color: var(--muted); border: 1px dashed var(--border); border-radius: 999px;
  padding: 1px 8px; white-space: nowrap; vertical-align: 1px;
}
/* Long titles were running under the next column: the cell is white-space:nowrap
   and had a max-width but nothing to clip with, so the text simply overflowed.
   Fixed layout + ellipsis; the full title stays available via the title attr. */
/* Long titles ran under the next column. max-width on a <td> is only a hint
   under table-layout:auto - the cell grew past it anyway - so the clipping lives
   on an inner block element, which holds regardless of table layout. Full title
   stays reachable via the cell's title attribute. */
.tracks-table td.track-name { max-width: 300px; }
.tn-clip {
  display: block;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.moment-trackname { font-size: 13px; color: var(--muted); }
.moment-trackname .id-badge { vertical-align: 1px; }
.status-chip {
  font-size: 12px; color: var(--muted); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 12px; white-space: nowrap;
}
.status-chip.ok { color: var(--cream); }
.status-chip.sample { color: var(--cream); border-color: #3a3527; }

/* ---------- layout ---------- */
main { flex: 1; width: 100%; max-width: 1140px; margin: 0 auto; padding: 10px 24px 48px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 20px 22px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
h2 { font-size: 15.5px; font-weight: 600; letter-spacing: -0.2px; }
.small-cap { font-size: 12px; }
.muted { color: var(--muted); font-size: 13.5px; line-height: 1.55; }
.empty-card { padding: 44px 34px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* set identity block */
.set-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.set-title { font-size: 21px; font-weight: 700; letter-spacing: -0.4px; }
.set-sub { color: var(--muted); font-size: 13.5px; margin-top: 3px; }

/* ---------- controls ---------- */
input[type=text], input[type=password] {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 9px 12px; font-size: 14px; font-family: inherit; outline: none;
  width: 100%;
}
input:focus { border-color: #3a3a44; }
.btn {
  font-family: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer;
  border-radius: 10px; padding: 9px 16px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
}
.btn.primary { background: #fff; color: #0b0b0d; border-color: #fff; }
.btn.ghost { background: none; color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: #3a3a44; }
.btn.small { padding: 7px 13px; font-size: 12.5px; }

/* ---------- tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
@media (max-width: 700px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 13px 16px 14px; }
/* Caption first, value second. The number is the thing being read, so it gets the
   weight; the caption is a column header and stays recessive. */
.tile-cap { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.7px; }
.tile-num { font-size: 27px; font-weight: 700; letter-spacing: -0.5px; margin-top: 5px; line-height: 1.05; }
/* Context under the value - what the number is relative to. Muted by default;
   status colours only via the modifier classes, and always with words present. */
.tile-sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; min-height: 1em; }
.tile-sub.good { color: var(--st-good); }
.tile-sub.warn { color: var(--st-warn); }

/* ---------- status pills ----------
   Recognition state. Reserved status hues, and each pill always carries its word,
   so colour never encodes meaning on its own.
   "unidentified" is deliberately NOT critical/red: an unnamed track is the
   unreleased-ID signal - the valuable case - not an error. It takes the brand
   violet instead. Validated on this surface (#131316): CVD separation, the
   normal-vision floor and 3:1 contrast all pass for good/warn/violet. */
/* NOTE: not `.pill` - that class is already the nav tab in this stylesheet. */
.rec-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.3px;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  border: 1px solid currentColor;
}
.rec-pill::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
.rec-pill.identified   { color: var(--st-good); background: color-mix(in srgb, var(--st-good) 13%, transparent); }
.rec-pill.tentative    { color: var(--st-warn); background: color-mix(in srgb, var(--st-warn) 13%, transparent); }
.rec-pill.unidentified { color: var(--s-crowd); background: color-mix(in srgb, var(--s-crowd) 15%, transparent); }

/* ---------- charts ---------- */
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }
.chart text { font-family: inherit; }
.legend { display: flex; gap: 16px; margin-bottom: 8px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.round { border-radius: 999px; }

.tooltip {
  position: fixed; z-index: 60; pointer-events: none;
  background: #202027; border: 1px solid #33333c; border-radius: 8px;
  padding: 6px 10px; font-size: 12.5px; color: var(--text);
}
.tooltip .tip-cap { color: var(--muted); }

/* ---------- moments ---------- */
.moment-card { display: flex; gap: 20px; align-items: stretch; }
.moment-media {
  flex: 0 0 380px; background: #000; border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; position: relative; aspect-ratio: 16 / 9; align-self: center;
}
.moment-media video { width: 100%; height: 100%; display: block; object-fit: cover; background: #000; }
.clip-missing {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12.5px; background: var(--surface-2);
}
.moment-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.moment-top { display: flex; align-items: baseline; gap: 12px; }
.moment-rank { font-size: 30px; font-weight: 800; letter-spacing: -1px; color: var(--lilac); }
.moment-time { font-size: 16px; font-weight: 600; }
.moment-track { color: var(--muted); font-size: 12.5px; }
.moment-stats { display: flex; gap: 26px; margin: 12px 0 4px; }
.m-stat .m-num { font-size: 20px; font-weight: 700; letter-spacing: -0.4px; }
.m-stat .m-cap { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; margin-top: 2px; }
.moment-spark { margin-top: auto; }
.moment-spark .spark-cap { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 4px; }
.moment-card.flash { outline: 1px solid var(--lilac); outline-offset: -1px; }
@media (max-width: 900px) {
  .moment-card { flex-direction: column; }
  .moment-media { flex: none; width: 100%; max-width: 480px; align-self: flex-start; }
}

/* ---------- tracks table ---------- */
.tracks-scroll { overflow-x: auto; }
.tracks-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.tracks-table thead tr { background: rgba(255,255,255,0.028); }
.tracks-table th {
  text-align: left; font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.7px; padding: 6px 10px 10px 0; white-space: nowrap;
}
.tracks-table th.num, .tracks-table td.num { text-align: right; }
.tracks-table td { padding: 9px 10px 9px 0; font-size: 13.5px; border-top: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.tracks-table td.r { color: var(--muted); width: 34px; }
.tracks-table td.r strong { color: var(--text); }
.tracks-table .bar { background: var(--surface-2); border-radius: 999px; height: 6px; min-width: 110px; overflow: hidden; }
.tracks-table .bar div { background: var(--s-crowd); height: 100%; border-radius: 999px; }
.tracks-table .pct { color: var(--muted); width: 48px; text-align: right; font-size: 12.5px; padding-right: 22px; }

footer { text-align: center; color: #55555e; font-size: 12px; padding: 16px; }

@media (max-width: 900px) {
  header { flex-wrap: wrap; padding: 16px 20px; }
  main { padding: 6px 16px 40px; }
  .header-right { min-width: 0; }
}
