:root {
  --bg: #0f1115;
  --fg: #e8eaed;
  --muted: #9aa0a6;
  --accent: #7cacf8;
  --panel: #1a1d24;
  --border: #2a2f3a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

.view-meta {
  font-size: 0.75rem;
  margin-right: auto;
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.top-nav a {
  color: var(--muted);
  text-decoration: none;
}

.top-nav a:hover {
  color: var(--fg);
}

.top-nav-user {
  color: var(--fg);
  font-weight: 600;
}

.top-nav-logout {
  display: inline;
  margin: 0;
}

.top-nav-logout button {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.top-nav-logout button:hover {
  color: var(--fg);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg, #0f1115);
  border-style: outset;
  border-width: 3px;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  cursor: pointer;
}

.btn-primary:active {
  border-style: inset;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 0.4rem 0.85rem;
  font-size: 0.9rem;
  cursor: pointer;
  margin-top: 0.75rem;
}

.btn-secondary:disabled {
  opacity: 0.6;
  cursor: wait;
}

.panel {
  max-width: 36rem;
  margin: 1.5rem auto;
  padding: 1.25rem 1.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
}

.login-page h1,
.alias-page h1 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
}

.login-page h2,
.alias-page h2 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.login-section {
  margin-bottom: 1.5rem;
}

.login-section:last-of-type {
  margin-bottom: 0.75rem;
}

.account-current {
  margin: 0.25rem 0 0.5rem;
  font-size: 1.1rem;
}

.oauth-provider-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.oauth-provider-list a {
  text-align: center;
  text-decoration: none;
  margin-top: 0;
}

.alias-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.alias-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  background: var(--bg);
}

.alias-item.alias-current {
  border-color: var(--accent);
}

.alias-name {
  font-weight: 600;
}

.alias-badge {
  font-size: 0.75rem;
  color: var(--accent);
  text-transform: lowercase;
}

.alias-switch {
  margin: 0;
}

.alias-switch .btn-secondary {
  margin-top: 0;
}

.alias-claim label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.alias-claim input[type="text"] {
  width: 100%;
  padding: 0.5rem 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  font: inherit;
}

.alias-claim input[type="text"]:focus {
  outline: 1px solid var(--accent);
  border-color: var(--accent);
}

#alias-status {
  margin: 0.4rem 0 0.75rem;
  min-height: 1.25em;
}

#alias-status.alias-ok {
  color: #8fd19e;
}

#alias-status.alias-bad {
  color: #e8a0a0;
}

.login-actions {
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.login-actions .btn-secondary {
  margin-top: 0;
}

.login-back {
  margin: 1rem 0 0;
}

.login-back a {
  color: var(--muted);
  text-decoration: none;
}

.login-back a:hover {
  color: var(--fg);
}

.fetch-entity-form {
  margin-top: 0.5rem;
}

code {
  font-size: 0.85em;
  background: var(--bg);
  padding: 0.1em 0.35em;
  border-radius: 0;
}

.vote-fields {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.vote-fields label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.vote-fields input {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg);
  color: var(--fg);
}

.rank-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.rank-list li {
  margin-bottom: 0;
  padding: 0.35rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 0;
  border-bottom-width: 0;
}

.rank-list .rank-row {
  background: var(--rank-bg, transparent);
  border-color: var(--rank-border, transparent);
  color: var(--rank-fg, var(--fg));
}

.rank-list .rank-row.is-compared {
  position: relative;
  z-index: 1;
  box-shadow:
    inset 0 0 0 3px var(--accent),
    inset 0 0 0 5px color-mix(in oklch, var(--rank-fg, var(--fg)) 70%, transparent);
  filter: saturate(1.15) brightness(1.04);
}

.rank-list li:last-child {
  border-bottom-width: 1px;
}

.rank-num {
  color: inherit;
  opacity: 0.72;
}

#parser-panel {
  display: flex;
  flex-direction: column;
}

#parser-input {
  width: 90%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--accent);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
}

#parser-input:focus-visible {
  outline: 0;
}

#parser-form .btn-primary {
  width: 10%;
  margin-top: 0.5rem;
}

.breadcrumbs {
  font-size: 1rem;
  margin-top: 1rem;
  margin-bottom: 1rem;
  color: var(--muted);
}

.breadcrumbs a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

.breadcrumbs .separator {
  color: var(--muted);
}

.rank-list a {
  color: inherit;
  text-decoration: none;
}

.rank-list a:hover {
  text-decoration: underline;
}

.entity-card h2 {
  margin-top: 0;
}

.reddit-post-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.reddit-post-thumb-link {
  flex-shrink: 0;
  line-height: 0;
}

.reddit-post-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 0;
  border: 1px solid var(--border);
}

.reddit-post-url a {
  word-break: break-all;
}

.reddit-post-figure {
  margin: 0.75rem 0;
}

.reddit-post-image {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 0;
  border: 1px solid var(--border);
}

.scope-name {
  color: var(--accent);
  font-weight: 600;
}

.rank-heading {
  margin: 0.75rem 0 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.rank-gap {
  text-align: center;
  margin: 0;
}

h1 {
  margin: 0;
}

.vote-cta {
  margin: 0.75rem 0;
}

.rank-row {
  will-change: transform;
}

.scope-theme {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, color-mix(in oklch, var(--accent) 24%, transparent), transparent 34rem),
    var(--bg);
  color: var(--fg);
  padding: 1rem;
}

.scope-theme .demo-panel {
  background: color-mix(in oklch, var(--panel) 86%, transparent);
  border: 1px solid var(--border);
}

.rank-row-enter {
  animation: rank-row-enter 260ms ease;
}

@keyframes rank-row-enter {
  from {
    opacity: 0;
    transform: translateY(0.35rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.vote-page {
  --vote-hud-height: 4.75rem;
  padding-bottom: calc(var(--vote-hud-height) + 0.75rem);
}

.vote-page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 1.25rem;
  align-items: start;
}

.vote-hud {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  border-top: 2px solid var(--border);
  background: color-mix(in oklch, var(--panel) 92%, var(--bg));
  box-shadow: 0 -0.35rem 1.25rem rgba(0, 0, 0, 0.4);
  padding: 0.45rem 0.75rem;
  backdrop-filter: blur(8px);
}

.vote-hud-inner {
  max-width: 56rem;
  margin: 0 auto;
  display: grid;
  /* Fixed side columns so ratio text / buttons never resize the slider track. */
  grid-template-columns: var(--vote-ratio-col) minmax(0, 1fr) var(--vote-actions-col);
  gap: 0.5rem 0.65rem;
  align-items: center;
  --vote-ratio-col: 12.5rem;
  --vote-actions-col: 11.5rem;
}

.vote-hud #vote-compare-form {
  margin: 0;
}

.vote-hud .vote-ratio-readout {
  margin: 0;
  width: var(--vote-ratio-col);
  min-width: var(--vote-ratio-col);
  text-align: right;
  white-space: nowrap;
}

.vote-hud .vote-ratio-readout .small {
  display: none;
}

.vote-hud .vote-compare-actions {
  margin-top: 0;
  justify-content: flex-end;
  gap: 0.5rem;
  width: var(--vote-actions-col);
  min-width: var(--vote-actions-col);
  flex-shrink: 0;
}

.vote-hud .btn-primary,
.vote-hud .btn-secondary,
.vote-hud .vote-compare-next {
  padding: 0.35rem 0.65rem;
  font-size: 0.875rem;
}

.vote-compare-shell {
  min-width: 0;
}

.vote-ranking-panel {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow: auto;
}

.vote-ranking-panel h2 {
  margin: 0 0 0.25rem;
}

.vote-ranking-panel #ranking-panel {
  padding: 0;
  border: 0;
  background: transparent;
}

.vote-compare-scope {
  margin: 0.5rem 0 1rem;
}

.vote-compare-pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: start;
  margin: 1rem 0;
}

.vote-compare-vs {
  align-self: center;
  font-size: 1.25rem;
  color: var(--muted);
  font-weight: 600;
}

.vote-compare-side {
  min-height: 120px;
}

.vote-compare-side .entity-section {
  margin: 0;
}

.vote-compare-nav {
  margin: 1rem 0 0.5rem;
}

.vote-compare-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.vote-compare-actions .btn-secondary {
  margin-top: 0;
  display: inline-block;
  text-decoration: none;
  line-height: 1.4;
}

.vote-compare-actions .vote-compare-next.is-disabled {
  opacity: 0.6;
  cursor: default;
}

.vote-hud .vote-ratio-readout strong {
  display: inline-block;
  min-width: 3ch;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-size: 1.1rem;
}

.vote-compare-next {
  color: var(--accent);
  text-decoration: none;
}

.vote-compare-next.is-disabled {
  color: var(--muted);
}

.vote-compare-back {
  text-decoration: none;
}

.vote-compare-back:hover {
  text-decoration: underline;
}

.vote-hud-slider {
  display: block;
  margin: 0;
  min-width: 0;
}

.vote-hud-slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 1.5rem;
  margin: 0;
  background: transparent;
  cursor: pointer;
  --vote-track-muted: color-mix(in oklch, var(--muted) 55%, var(--bg));
}

/* Center-anchored fill: the accent grows from the midpoint toward the thumb,
   so the highlighted mass always sits on the *winning* side (the side the
   thumb was dragged toward). Left winning => accent on the left half. */
.vote-hud-slider input[type="range"][data-winner="even"]::-webkit-slider-runnable-track {
  height: 0.65rem;
  border-radius: 0;
  border: 2px solid var(--border);
  background: var(--vote-track-muted);
}

.vote-hud-slider input[type="range"][data-winner="left"]::-webkit-slider-runnable-track {
  height: 0.65rem;
  border-radius: 0;
  border: 2px solid var(--border);
  background: linear-gradient(
    to right,
    var(--vote-track-muted) 0%,
    var(--vote-track-muted) var(--vote-slider-pct, 50%),
    var(--accent) var(--vote-slider-pct, 50%),
    var(--accent) 50%,
    var(--vote-track-muted) 50%,
    var(--vote-track-muted) 100%
  );
}

.vote-hud-slider input[type="range"][data-winner="right"]::-webkit-slider-runnable-track {
  height: 0.65rem;
  border-radius: 0;
  border: 2px solid var(--border);
  background: linear-gradient(
    to right,
    var(--vote-track-muted) 0%,
    var(--vote-track-muted) 50%,
    var(--accent) 50%,
    var(--accent) var(--vote-slider-pct, 50%),
    var(--vote-track-muted) var(--vote-slider-pct, 50%),
    var(--vote-track-muted) 100%
  );
}

.vote-hud-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 1.1rem;
  height: 1.35rem;
  margin-top: -0.42rem;
  border: 2px solid var(--fg);
  border-radius: 0;
  background: var(--accent);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.vote-hud-slider input[type="range"][data-winner="left"]::-moz-range-track,
.vote-hud-slider input[type="range"][data-winner="right"]::-moz-range-track,
.vote-hud-slider input[type="range"][data-winner="even"]::-moz-range-track {
  height: 0.65rem;
  border-radius: 0;
  border: 2px solid var(--border);
}

.vote-hud-slider input[type="range"][data-winner="even"]::-moz-range-track {
  background: var(--vote-track-muted);
}

.vote-hud-slider input[type="range"][data-winner="left"]::-moz-range-track {
  background: linear-gradient(
    to right,
    var(--vote-track-muted) 0%,
    var(--vote-track-muted) var(--vote-slider-pct, 50%),
    var(--accent) var(--vote-slider-pct, 50%),
    var(--accent) 50%,
    var(--vote-track-muted) 50%,
    var(--vote-track-muted) 100%
  );
}

.vote-hud-slider input[type="range"][data-winner="right"]::-moz-range-track {
  background: linear-gradient(
    to right,
    var(--vote-track-muted) 0%,
    var(--vote-track-muted) 50%,
    var(--accent) 50%,
    var(--accent) var(--vote-slider-pct, 50%),
    var(--vote-track-muted) var(--vote-slider-pct, 50%),
    var(--vote-track-muted) 100%
  );
}

.vote-hud-slider input[type="range"]::-moz-range-progress {
  background: transparent;
}

.vote-hud-slider input[type="range"]::-moz-range-thumb {
  width: 1.1rem;
  height: 1.35rem;
  border: 2px solid var(--fg);
  border-radius: 0;
  background: var(--accent);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.vote-edge-history-title {
  margin: 1.5rem 0 0.5rem;
  font-size: 1rem;
}

.vote-edge-history {
  list-style: none;
  padding: 0;
  margin: 0;
}

.vote-edge-history-row {
  margin-bottom: 0.75rem;
}

.vote-edge-meta {
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

/* Read-only sliders in vote history — same track/thumb styling as the HUD. */
.vote-edge-slider {
  display: block;
  margin-top: 0.15rem;
}

.vote-edge-slider input[type="range"] {
  pointer-events: none;
  cursor: default;
}

.vote-edge-slider input[type="range"]:disabled {
  opacity: 1;
}

.vote-edge-legend {
  margin: 0 0 0.5rem;
}

@media (max-width: 900px) {
  .vote-page-grid {
    grid-template-columns: 1fr;
  }

  .vote-ranking-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 640px) {
  .vote-page {
    --vote-hud-height: 7.5rem;
  }

  .vote-hud-inner {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 0.35rem;
    --vote-ratio-col: 100%;
    --vote-actions-col: 100%;
  }

  .vote-hud .vote-ratio-readout,
  .vote-hud .vote-compare-actions {
    width: auto;
    min-width: 0;
  }

  .vote-hud .vote-compare-actions {
    justify-content: center;
  }

  .vote-hud {
    padding-bottom: max(0.45rem, env(safe-area-inset-bottom));
  }
}