:root {
  --bg: #12081f;
  --panel: #1e1030;
  --panel-2: #2a1a42;
  --border: #3a2760;
  --orange: #ff7a1a;
  --violet: #a78bfa;
  --text: #f3eefc;
  --muted: #b9a8d9;
  --field-border: #7a66b0; /* >= 3:1 against both the field fill and the panel (WCAG 1.4.11) */
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow-x: hidden;
}
a { color: var(--violet); }
a:hover { color: var(--orange); }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
/* Headings that only receive focus from script (not in the tab order) need no ring. */
h1:focus, h2:focus { outline: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap;
}
.skip-link {
  position: absolute; left: 12px; top: -64px; z-index: 10; padding: 10px 16px; border-radius: 8px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--orange); text-decoration: none;
}
.skip-link:focus { top: 12px; }

.hero {
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at 70% 0%, #3b1a63 0%, var(--bg) 70%);
  border-bottom: 1px solid var(--border);
}
.hero-art { position: absolute; top: 0; right: 0; bottom: 0; width: min(640px, 55%); height: 100%; opacity: 0.6; }
/* Scrim keeps the art from competing with the text. */
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(18,8,31,0.94) 0%, rgba(18,8,31,0.8) 45%, rgba(18,8,31,0) 85%);
}
.hero-text { position: relative; z-index: 1; max-width: 1200px; margin: 0 auto; padding: 40px 20px 28px; }
.eyebrow { margin: 0; color: var(--violet); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.8rem; }
h1 { margin: 4px 0; font-size: clamp(2rem, 7vw, 3.5rem); color: var(--orange); text-shadow: 0 0 24px rgba(255,122,26,0.45); line-height: 1.1; }
.tagline { margin: 0 0 14px; color: var(--text); font-size: 1.1rem; }
.meta-line { margin: 0; color: var(--muted); font-size: 0.9rem; max-width: 70ch; }

main { max-width: 1200px; margin: 0 auto; padding: 20px; }

.filter-bar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px;
  margin-bottom: 20px;
}
.field > span { line-height: 1.2; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: var(--muted); flex: 1 1 220px; min-width: 0; }
.field input, .field select {
  width: 100%; min-width: 0; height: 42px; padding: 0 12px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--field-border); border-radius: 8px;
}
.field input::placeholder { color: var(--muted); opacity: 1; }
.field select {
  -webkit-appearance: none; appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23a78bfa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.filter-fields { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; flex: 1 1 100%; }
.filter-toggle { display: none; font: inherit; color: var(--text); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
.filter-bar.compact { padding: 8px 12px; margin-bottom: 12px; }
.filter-bar.compact .field input, .filter-bar.compact .field select { height: 34px; }
.filter-bar.compact .btn { padding: 6px 14px; }
.filter-bar.compact .field > span { font-size: 0.75rem; }
.filter-bar.compact .result-count:empty { display: none; }
.btn {
  height: 42px; padding: 0 16px; font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--violet); border-radius: 8px; cursor: pointer;
}
.btn:hover { background: var(--violet); color: var(--bg); }
.result-count { flex: 1 1 100%; margin: 0; color: var(--muted); font-size: 0.9rem; }

.ticker-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.ticker-card {
  display: block; width: 100%; text-align: left; font: inherit; color: var(--text);
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 16px;
  cursor: pointer; transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.ticker-card { text-decoration: none; }
.ticker-card:hover .ticker-sym, .ticker-card:focus-visible .ticker-sym { text-decoration: underline; }
.ticker-card:hover, .ticker-card:focus-visible { transform: translateY(-4px); border-color: var(--orange); box-shadow: 0 8px 24px rgba(255,122,26,0.18); }
.ticker-sym { display: block; font-size: 1.6rem; font-weight: 700; color: var(--orange); }
.ticker-analyst {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  color: var(--muted); font-size: 0.85rem; line-height: 1.3; height: 2.6em; overflow-wrap: anywhere;
}
.counts { margin: 10px 0; padding: 0; list-style: none; font-size: 0.85rem; }
.counts strong { color: var(--text); }
.counts li { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 0.75rem; line-height: 1.35;
  border: 1px solid var(--chip, var(--violet));
  color: color-mix(in srgb, var(--chip, var(--violet)) 45%, #fff);
  background: color-mix(in srgb, var(--chip, var(--violet)) 16%, transparent);
  overflow-wrap: anywhere;
}

.detail-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.detail-head h2 { margin: 0; color: var(--orange); font-size: 2rem; }
.detail-head .ticker-analyst { display: block; height: auto; overflow: visible; flex: 1 1 200px; }
.detail-stats { color: var(--muted); font-size: 0.9rem; margin: 0 0 16px; }

.group { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 14px; }
.group > summary { cursor: pointer; padding: 12px 16px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.group > summary::-webkit-details-marker { display: none; }
.group > summary::before {
  content: ""; width: 0; height: 0; flex: none; border-left: 7px solid var(--orange);
  border-top: 5px solid transparent; border-bottom: 5px solid transparent; transition: transform 0.15s;
}
.group[open] > summary::before { transform: rotate(90deg); }
.group > summary .count { color: var(--muted); font-weight: 400; }
.group-body { padding: 0 12px 12px; display: grid; gap: 10px; }

.finding { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.finding-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; font-size: 0.8rem; color: var(--muted); }
.finding-text { margin: 0 0 8px; overflow-wrap: anywhere; }
.numbers { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; padding: 0; list-style: none; }
.numbers li { font-family: ui-monospace, Menlo, Consolas, "DejaVu Sans Mono", monospace; font-size: 0.8rem; padding: 1px 8px; border-radius: 6px; background: var(--bg); border: 1px solid var(--border); color: var(--orange); }
.section-tag { padding: 1px 8px; border-radius: 4px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase; }
.match-note { margin: 0 0 8px; font-size: 0.8rem; color: var(--violet); font-style: italic; }
.expand { font: inherit; font-size: 0.85rem; color: var(--text); background: rgba(167,139,250,0.16); border: 1px solid var(--violet); border-radius: 6px; padding: 5px 12px; cursor: pointer; }
.expand:hover { background: var(--violet); color: var(--bg); }
.proof { margin-top: 10px; border-left: 3px solid var(--orange); padding-left: 12px; }
.proof blockquote { max-width: 80ch; margin: 0 0 8px; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; font-style: italic; }
.proof blockquote.quote-table { font-family: ui-monospace, Menlo, Consolas, "DejaVu Sans Mono", monospace; font-style: normal; font-size: 0.85rem; white-space: pre-wrap; }
.proof dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 0.8rem; color: var(--muted); }
.proof dd { margin: 0; font-family: ui-monospace, Menlo, Consolas, "DejaVu Sans Mono", monospace; overflow-wrap: anywhere; }
.back { display: inline-block; margin-bottom: 14px; }
.ticker-tag { color: var(--orange); font-weight: 700; text-decoration: none; }

.results { display: grid; gap: 10px; }
.view-nav { display: flex; gap: 8px; margin-bottom: 14px; }
.view-nav a { padding: 8px 16px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); text-decoration: none; }
.view-nav a:hover { border-color: var(--violet); color: var(--text); }
.view-nav a.active { border-color: var(--orange); color: var(--orange); background: var(--panel); }
.grave .label { margin: 0 0 4px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.badge-removed { padding: 1px 8px; border-radius: 6px; border: 1px solid #ff4d6d; color: #ff4d6d; font-size: 0.75rem; }
.grave > .label { color: #d6c9ee; }
.afterlife { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border); color: #8f80ad; }
.afterlife .label, .afterlife .finding-text { color: #8f80ad; }
.afterlife-note { margin: 0; font-size: 0.8rem; color: #8f80ad; font-style: italic; }
.afterlife.ghost { border-style: dashed; border-color: rgba(255,122,26,0.4); }
.afterlife.ghost .label { color: #c9894d; }
.afterlife.ghost p:last-child { margin: 0; }
.error-state, .empty-state {
  text-align: center; padding: 40px 20px; border: 1px dashed var(--orange); border-radius: 14px; background: var(--panel);
}
.error-state { border-color: #ff4d6d; }
.empty-title { font-size: 1.3rem; color: var(--orange); margin: 0 0 6px; }

.footer { max-width: 1200px; margin: 20px auto 0; padding: 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.85rem; }
.footer p { margin: 4px 0; }
.back-to-top {
  position: fixed; right: 16px; bottom: 16px; z-index: 5; font: inherit; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--orange); border-radius: 999px; padding: 8px 16px; cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.back-to-top:hover { background: var(--orange); color: var(--bg); }
[hidden] { display: none !important; }

@media (max-width: 1024px) { .ticker-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .ticker-grid { grid-template-columns: minmax(0, 1fr); }
  main { padding: 12px; }
  .hero-text { padding: 28px 14px 64px; }
  .proof dl { grid-template-columns: 1fr; }
  .filter-toggle { display: block; flex: 1 1 100%; font-weight: 600; padding: 2px 0; }
  .filter-toggle::after { content: " \25BE"; color: var(--violet); }
  .filter-bar.open .filter-toggle::after { content: " \25B4"; }
  .filter-fields { display: none; }
  .filter-bar.open .filter-fields { display: flex; }
  .filter-bar.open .filter-toggle { margin-bottom: 4px; }
  .filter-bar { gap: 8px; padding: 10px 12px; }
  .btn { height: auto; padding: 4px 12px; font-size: 0.85rem; align-self: flex-start; }
  .filter-bar.compact .btn { padding: 4px 12px; }
  .graveyard { font-size: 15px; }
  .graveyard .finding { padding: 10px; }
  .afterlife { padding: 8px 10px; }
}
@media (max-width: 600px) {
  .hero-bat { display: none; }
  .hero-art { opacity: 0.35; width: 100%; }
  .hero::after { background: linear-gradient(180deg, rgba(18,8,31,0.9) 0%, rgba(18,8,31,0.75) 100%); }
}
