/* Rank Anything — design system. Extends the Big Board aesthetic (dark,
   DM Sans/DM Mono, cyan accent, radial glow) into the generic app. */

[data-theme="dark"] {
  --bg: #0d1017;
  --bg-soft: #111620;
  --panel: #141923;
  --panel-strong: #1a2030;
  --text: #edf1f7;
  --muted: #8a96b0;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --accent-tint: rgba(56, 189, 248, 0.12);
  /* Primary-action pair: 8.7:1 on dark (axe AA gate) */
  --accent-btn-bg: #38bdf8;
  --on-accent: #0b1220;
  --border: #2e3d58;
  --shadow: rgba(0, 0, 0, 0.4);
  --danger: #f87171;
  --success: #34d399;
  --amber: #f59e0b;
  --amber-tint: rgba(245, 158, 11, 0.15);
  --cat-1: #f87171; --cat-2: #34d399; --cat-3: #60a5fa; --cat-4: #fb923c;
  --cat-5: #a78bfa; --cat-6: #f472b6; --cat-7: #facc15; --cat-8: #2dd4bf;
  --r-sm: 6px;
  --r-lg: 12px;
}

[data-theme="light"] {
  --bg: #f0f4f8;
  --bg-soft: #e8edf3;
  --panel: #ffffff;
  --panel-strong: #f5f8fb;
  --text: #1a2233;
  --muted: #5a6780;
  --accent: #0284c7;
  --accent-strong: #0369a1;
  --accent-tint: rgba(2, 132, 199, 0.10);
  /* Primary-action pair: 5.9:1 on light (axe AA gate) */
  --accent-btn-bg: #0369a1;
  --on-accent: #ffffff;
  --border: #d1d9e6;
  --shadow: rgba(0, 0, 0, 0.12);
  --danger: #dc2626;
  --success: #059669;
  --amber: #d97706;
  --amber-tint: rgba(217, 119, 6, 0.12);
  --cat-1: #dc2626; --cat-2: #059669; --cat-3: #2563eb; --cat-4: #ea580c;
  --cat-5: #7c3aed; --cat-6: #db2777; --cat-7: #ca8a04; --cat-8: #0d9488;
  --r-sm: 6px;
  --r-lg: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "DM Sans", sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

[data-theme="dark"] body {
  background:
    radial-gradient(1200px 500px at 15% -10%, rgba(56, 189, 248, 0.14), transparent 60%),
    radial-gradient(900px 400px at 100% 0%, rgba(52, 211, 153, 0.09), transparent 55%),
    linear-gradient(160deg, #0b0e14 0%, #0d1017 60%, #0f1220 100%);
  background-attachment: fixed;
}

.shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

/* === header / toolbar === */
.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.wordmark {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
}

.wordmark .tick { color: var(--accent); }

.board-title {
  font-size: 24px;
  font-weight: 700;
  margin: 6px 0 2px;
}

.board-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 16px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: 14px;
}

.toolbar .spacer { flex: 1; }

.btn {
  font: 500 13px "DM Sans", sans-serif;
  color: var(--text);
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 12px;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.btn:hover { border-color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.primary { background: var(--accent-btn-bg); border-color: var(--accent-btn-bg); color: var(--on-accent); font-weight: 600; }
.btn:disabled { opacity: 0.45; cursor: default; }

.view-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.view-switch .btn {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.view-switch .btn[aria-pressed="true"] {
  background: var(--accent-tint);
  color: var(--accent);
}

.search-input {
  font: 400 13px "DM Sans", sans-serif;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  min-width: 170px;
}

.search-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.filter-chip {
  font: 500 12px "DM Sans", sans-serif;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
}

.filter-chip[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-tint);
}

/* === board table === */
.board-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.board-table th {
  text-align: left;
  font: 600 11px "DM Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-strong);
}

.board-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.item-row { cursor: grab; }
.item-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.item-row.kb-lifted { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-tint); }
.item-row.drop-before td { border-top: 2px solid var(--accent); }
.item-row.drop-after td { border-bottom: 2px solid var(--accent); }
.item-row.starred .item-name { font-weight: 700; }

.col-rank {
  font-family: "DM Mono", monospace;
  color: var(--muted);
  width: 46px;
}

.col-num { font-family: "DM Mono", monospace; color: var(--muted); }
.col-actions { text-align: right; width: 80px; }

.icon-btn {
  font-size: 14px;
  background: transparent;
  color: var(--muted);
  border: 0;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--r-sm);
}

.icon-btn:hover { color: var(--text); background: var(--panel-strong); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); }
.icon-btn.danger:hover { color: var(--danger); }
.icon-btn[aria-pressed="true"] { color: var(--amber); }

.enum-badge {
  font: 600 11px "DM Mono", monospace;
  color: var(--badge-color);
  border: 1px solid var(--badge-color);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

.note-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-left: 8px;
  vertical-align: middle;
}

.tier-btn {
  font: 600 12px "DM Mono", monospace;
  color: var(--amber);
  background: transparent;
  border: 1px dashed var(--amber);
  border-radius: var(--r-sm);
  width: 20px;
  height: 20px;
  line-height: 1;
  cursor: pointer;
  margin-right: 8px;
  opacity: 0;
  transition: opacity 160ms ease;
}

.item-row:hover .tier-btn, .item-row:focus-within .tier-btn { opacity: 1; }
.tier-btn:focus-visible { opacity: 1; outline: 2px solid var(--amber); }

.tier-row td {
  background: var(--amber-tint);
  padding: 4px 12px;
}

.tier-label {
  font: 600 12px "DM Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--amber);
  background: transparent;
  border: 0;
  width: 100%;
}

.tier-label:focus-visible { outline: 1px solid var(--amber); }

/* === tier grid view === */
.tier-grid { display: flex; flex-direction: column; gap: 10px; }

.tier-lane {
  display: grid;
  grid-template-columns: 110px 1fr;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.tier-lane-label {
  font: 600 12px "DM Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--amber);
  background: var(--amber-tint);
  padding: 14px 12px;
  display: flex;
  align-items: center;
}

.tier-lane-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  min-height: 52px;
}

.chip {
  font: 500 13px "DM Sans", sans-serif;
  color: var(--text);
  background: var(--panel-strong);
  border: 1px solid var(--badge-color, var(--border));
  border-radius: 999px;
  padding: 6px 12px;
  cursor: grab;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.chip.kb-lifted { outline: 2px solid var(--accent); background: var(--accent-tint); }

.chip-rank {
  font: 500 11px "DM Mono", monospace;
  color: var(--muted);
}

.view-hint { color: var(--muted); font-size: 12px; margin-top: 12px; }

/* === pairwise === */
.duel {
  display: grid;
  grid-template-columns: 1fr 56px 1fr;
  align-items: stretch;
  gap: 12px;
  margin: 28px 0;
}

.duel-card {
  font: 600 20px "DM Sans", sans-serif;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 44px 24px;
  cursor: pointer;
  text-align: center;
  transition: border-color 160ms ease, transform 160ms ease;
}

.duel-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.duel-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.duel-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 14px "DM Mono", monospace;
  color: var(--muted);
}

.progress-track {
  height: 6px;
  background: var(--panel-strong);
  border-radius: 999px;
  overflow: hidden;
  margin: 16px 0;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 200ms ease;
}

.pairwise-result-list {
  list-style: none;
  margin: 16px 0;
  padding: 0;
  counter-reset: pw;
}

.pairwise-result-list li {
  counter-increment: pw;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 9px 14px;
  margin-bottom: 6px;
  font-size: 14px;
}

.pairwise-result-list li::before {
  content: counter(pw);
  font: 500 12px "DM Mono", monospace;
  color: var(--muted);
  display: inline-block;
  width: 32px;
}

/* === home / gallery === */
.hero { margin: 40px 0 28px; }

.hero h1 {
  font-size: 34px;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.hero p { color: var(--muted); font-size: 15px; margin: 0; }

.paste-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  margin: 20px 0 36px;
}

.paste-panel textarea {
  width: 100%;
  min-height: 130px;
  font: 400 14px "DM Mono", monospace;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px;
  resize: vertical;
}

.paste-panel textarea:focus-visible { outline: 2px solid var(--accent); }

.paste-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  gap: 12px;
}

.paste-hint { color: var(--muted); font-size: 12px; }

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.gallery-card {
  display: block;
  text-decoration: none;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  transition: border-color 160ms ease, transform 160ms ease;
}

.gallery-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.gallery-card:focus-visible { outline: 2px solid var(--accent); }

.gallery-card h3 { margin: 0 0 4px; font-size: 15px; }
.gallery-card p { margin: 0 0 10px; color: var(--muted); font-size: 12.5px; line-height: 1.45; }

.gallery-card .meta {
  font: 500 11px "DM Mono", monospace;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.gallery-card .meta .count { color: var(--accent); }

.section-label {
  font: 600 12px "DM Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 30px 0 12px;
}

/* === shared bits === */
.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 48px 20px;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: var(--r-lg);
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 12px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: none;
  z-index: 9999;
}

.toast.visible { opacity: 1; transform: translateY(0); }

.banner {
  display: none;
  background: var(--accent-tint);
  border: 1px solid var(--accent);
  color: var(--text);
  font-size: 13px;
  border-radius: var(--r-sm);
  padding: 9px 12px;
  margin-bottom: 12px;
}

.banner.active { display: block; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

dialog.note-dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  width: min(420px, 90vw);
}

dialog.note-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }

dialog.note-dialog textarea {
  width: 100%;
  min-height: 90px;
  font: 400 13px "DM Sans", sans-serif;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px;
}

.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

.site-footer {
  margin-top: 48px;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.site-footer a { color: var(--muted); }

/* embed */
body.embed { background: var(--bg); }
.embed .shell { padding: 12px; max-width: none; }
.embed-cta {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  color: var(--accent);
}

@media (max-width: 640px) {
  .duel { grid-template-columns: 1fr; }
  .duel-vs { padding: 4px 0; }
  .tier-lane { grid-template-columns: 1fr; }
  .tier-lane-label { padding: 8px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
