:root {
  /* Single dark theme, matching markets.css. */
  color-scheme: dark;
  --ledger: #10151e;
  --ink: #f1f4f9;
  --cobalt: #8299ef;
  --cobalt-strong: #a6b6f7;
  --cobalt-soft: #202b4e;
  --tide: #51b9c2;
  --tide-soft: #13373c;
  --amber: #e3ad56;
  --amber-soft: #3c2d17;
  --risk: #e07886;
  --risk-soft: #44242c;
  --surface: #171d28;
  --surface-raised: #1d2431;
  --surface-subtle: #242c3a;
  --surface-hover: #202836;
  --text: #f1f4f9;
  --muted: #abb5c4;
  --faint: #7f8a9b;
  --line: #303a4a;
  --line-strong: #465267;
  --focus: #9aacf5;
  --positive: #65c7cf;
  --negative: #ed8995;
  --shadow-soft: 0 12px 40px rgba(0, 0, 0, 0.28);
  --font-sans: "Avenir Next", Avenir, "Century Gothic", Futura, Montserrat, Inter, ui-sans-serif,
    -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, "Liberation Mono",
    monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(rgba(56, 88, 199, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 88, 199, 0.025) 1px, transparent 1px),
    var(--ledger);
  background-size: 36px 36px;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 42%, transparent);
  outline-offset: 2px;
}

/* --- Auth gate (same look as markets) --- */

.auth-gate {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 34%, color-mix(in srgb, #5865f2 12%, transparent), transparent 32%),
    var(--ledger);
}

.auth-card {
  width: min(430px, 100%);
  padding: 42px 36px 34px;
  text-align: center;
}

.auth-logo {
  width: 78px;
  height: 78px;
  margin-bottom: 22px;
  object-fit: contain;
}

.auth-eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.auth-card h1 {
  margin: 0;
  font-size: clamp(1.8rem, 7vw, 2.5rem);
  font-weight: 650;
  letter-spacing: -0.045em;
}

.auth-detail {
  max-width: 34ch;
  margin: 14px auto 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
}

.auth-error {
  margin: 18px 0 0;
  border: 1px solid color-mix(in srgb, var(--risk) 35%, var(--line));
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--risk);
  background: color-mix(in srgb, var(--risk) 7%, transparent);
  font-size: 0.86rem;
  line-height: 1.45;
}

.discord-login {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: min(290px, 100%);
  min-height: 48px;
  margin-top: 24px;
  border-radius: 12px;
  color: #fff;
  background: #5865f2;
  box-shadow: 0 8px 24px rgba(88, 101, 242, 0.22);
  font-weight: 650;
  text-decoration: none;
  transition: background 140ms ease, transform 140ms ease;
}

.discord-login:hover {
  background: #4752c4;
  transform: translateY(-1px);
}

.auth-requirement {
  margin: 16px 0 0;
  color: var(--faint);
  font-size: 0.74rem;
}

body.auth-pending .labels-shell,
body.auth-required .labels-shell,
body.authenticated .auth-gate {
  display: none;
}

/* --- Shell + header --- */

.labels-shell {
  min-height: 100vh;
}

/* --- Layout, tabs, panels --- */

main {
  max-width: 1060px;
  margin: 0 auto;
  padding: clamp(18px, 3vw, 32px) clamp(14px, 3vw, 32px) 64px;
}

.labels-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.tab-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 0.86rem;
  font-weight: 650;
}

.tab-button:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

.tab-button[aria-selected="true"] {
  color: var(--ink);
  border-color: var(--cobalt);
  background: var(--cobalt-soft);
}

.tab-count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 0.7rem;
  text-align: center;
}

.panel-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: clamp(16px, 3vw, 26px);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.panel-card h2 {
  margin: 0 0 6px;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.panel-help {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
  max-width: 72ch;
}

/* --- Forms --- */

textarea,
input[type="text"],
input[type="search"],
select,
.yam-select-trigger {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-raised);
  color: var(--text);
}

textarea {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  resize: vertical;
}

textarea::placeholder,
input::placeholder {
  color: var(--faint);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field > span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.form-field-wide {
  grid-column: 1 / -1;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.form-row-end {
  justify-content: flex-end;
}

.anon-option {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-raised);
}

.anon-option:has(input:checked) {
  border-color: color-mix(in srgb, var(--amber) 45%, var(--line));
  background: color-mix(in srgb, var(--amber) 8%, var(--surface-raised));
}

.anon-option-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 650;
}

.anon-option-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--amber);
}

.anon-option-help {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.anon-option:has(input:checked) .anon-option-help {
  color: var(--amber);
}

.primary-button {
  min-height: 40px;
  padding: 0 22px;
  border: 1px solid var(--cobalt);
  border-radius: 10px;
  color: var(--ink);
  background: var(--cobalt-soft);
  font-weight: 700;
}

.primary-button:hover:not(:disabled) {
  border-color: var(--cobalt-strong);
  background: color-mix(in srgb, var(--cobalt-soft) 70%, var(--cobalt) 30%);
}

.ghost-button {
  min-height: 32px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 0.78rem;
  font-weight: 650;
}

.ghost-button:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--line-strong);
}

.status-line {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-raised);
  color: var(--muted);
  font-size: 0.85rem;
}

.status-line.is-error {
  border-color: color-mix(in srgb, var(--risk) 35%, var(--line));
  color: var(--risk);
  background: color-mix(in srgb, var(--risk) 7%, transparent);
}

.status-line.is-success {
  border-color: color-mix(in srgb, var(--positive) 35%, var(--line));
  color: var(--positive);
  background: color-mix(in srgb, var(--positive) 7%, transparent);
}

/* --- Lookup results --- */

.lookup-results {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
}

.wallet-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--surface-raised);
}

.wallet-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.wallet-address {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  word-break: break-all;
}

.wallet-chain {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.wallet-error {
  color: var(--risk);
  font-size: 0.84rem;
}

.wallet-empty {
  color: var(--faint);
  font-size: 0.84rem;
}

.label-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  font-size: 0.85rem;
}

.label-row-name {
  font-weight: 700;
}

.label-row-source,
.label-row-category {
  color: var(--faint);
  font-size: 0.74rem;
}

.label-row-confidence {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--tide-soft);
  color: var(--tide);
  font-size: 0.7rem;
  font-weight: 700;
}

.label-row-confidence.is-low {
  background: var(--amber-soft);
  color: var(--amber);
}

.label-row-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag-chip {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--cobalt-soft);
  color: var(--cobalt-strong);
  font-size: 0.7rem;
  font-weight: 650;
}

.label-row-by {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 0.74rem;
}

.submitter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.submitter-avatar {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border-radius: 999px;
  object-fit: cover;
  background: var(--surface-subtle);
}

.submitter-anon-mark {
  display: grid;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 0.68rem;
  font-weight: 800;
}

.anon-warning {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: lowercase;
}

.vote-card.is-anonymous {
  border-color: color-mix(in srgb, var(--amber) 40%, var(--line));
}

.label-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.report-button {
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--faint);
  background: transparent;
  font-size: 0.72rem;
  font-weight: 650;
}

.report-button:hover:not(:disabled) {
  color: var(--risk);
  border-color: color-mix(in srgb, var(--risk) 45%, var(--line));
}

.report-count {
  color: var(--risk);
  font-size: 0.72rem;
  font-weight: 700;
}

.section-label {
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* --- Browse --- */

.browse-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.browse-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.browse-chips button {
  min-height: 32px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}

.browse-chips button:hover {
  border-color: var(--cobalt);
  color: var(--ink);
}

.browse-chips button[aria-pressed="true"] {
  background: var(--cobalt-soft);
  border-color: var(--cobalt);
  color: var(--ink);
}

.browse-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: flex-end;
}

.browse-filter {
  display: flex;
  flex: 1 1 148px;
  flex-direction: column;
  gap: 5px;
  min-width: 132px;
  max-width: 220px;
}

.browse-filter-search {
  flex: 2 1 240px;
  max-width: none;
}

.browse-filter-label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.browse-filter:has(.yam-select:not(.is-placeholder):not(.is-disabled)) .browse-filter-label,
.browse-filter:has(input:not(:placeholder-shown)) .browse-filter-label {
  color: var(--cobalt);
}

.browse-filter:has(.yam-select.is-disabled) {
  opacity: 0.48;
}

.browse-filter:has(.yam-select.is-disabled) .yam-select-trigger:disabled {
  opacity: 1;
}

.browse-filter .yam-select,
.browse-filter select,
.browse-filter input {
  width: 100%;
  min-width: 0;
  max-width: none;
}

.browse-filter .yam-select-trigger,
.browse-filter input[type="search"] {
  min-height: 36px;
  padding: 0 10px;
}

.browse-filter:has(.yam-select:not(.is-placeholder):not(.is-disabled)) .yam-select-trigger,
.browse-filter:has(input:not(:placeholder-shown)) input {
  border-color: color-mix(in srgb, var(--cobalt) 55%, var(--line));
}

.browse-results {
  overflow-x: auto;
}

.browse-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.browse-table th {
  text-align: left;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.browse-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.browse-table tbody tr:hover {
  background: var(--surface-raised);
}

.browse-address-cell {
  max-width: 220px;
}

.browse-address {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--cobalt);
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.78rem;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}

.browse-address:hover {
  text-decoration: underline;
}

.browse-label-cell {
  max-width: 320px;
  overflow-wrap: anywhere;
}

.browse-source-cell {
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

/* --- Votes --- */

.vote-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.vote-toolbar input[type="search"] {
  flex: 1 1 220px;
  min-height: 36px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-raised);
}

.segmented button {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.segmented button[aria-pressed="true"] {
  background: var(--cobalt-soft);
  color: var(--ink);
}

.vote-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.vote-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--surface-raised);
}

.vote-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 44px;
}

.vote-buttons button {
  width: 34px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
}

.vote-buttons button:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--line-strong);
}

.vote-buttons button.is-active-up {
  color: var(--positive);
  border-color: color-mix(in srgb, var(--positive) 55%, var(--line));
  background: color-mix(in srgb, var(--positive) 10%, var(--surface));
}

.vote-buttons button.is-active-down {
  color: var(--negative);
  border-color: color-mix(in srgb, var(--negative) 55%, var(--line));
  background: color-mix(in srgb, var(--negative) 10%, var(--surface));
}

.vote-score {
  font-size: 0.9rem;
  font-weight: 750;
}

.vote-score.is-positive {
  color: var(--positive);
}

.vote-score.is-negative {
  color: var(--negative);
}

.vote-body {
  flex: 1;
  min-width: 0;
}

.vote-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
}

.vote-label {
  font-size: 0.98rem;
  font-weight: 700;
}

.vote-category {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: capitalize;
}

.vote-confidence {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--tide-soft);
  color: var(--tide);
  font-size: 0.7rem;
  font-weight: 700;
}

.vote-address {
  margin: 4px 0 0;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--muted);
  word-break: break-all;
}

.vote-address[data-yam-address]:hover,
.wallet-address[data-yam-address]:hover {
  color: var(--cobalt);
  text-decoration: underline;
}

.vote-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.vote-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 4px;
  margin: 6px 0 0;
  color: var(--faint);
  font-size: 0.74rem;
}

.vote-date {
  color: inherit;
}

.vote-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 18px;
}

.pagination button {
  min-height: 34px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}

.pagination button:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--line-strong);
}

#vote-page-indicator {
  color: var(--muted);
  font-size: 0.8rem;
}

/* --- Import --- */

.import-results {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.import-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.import-pill {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-raised);
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--muted);
}

.import-pill.is-accepted {
  color: var(--positive);
  border-color: color-mix(in srgb, var(--positive) 40%, var(--line));
}

.import-pill.is-rejected {
  color: var(--risk);
  border-color: color-mix(in srgb, var(--risk) 40%, var(--line));
}

.import-errors {
  border: 1px solid color-mix(in srgb, var(--risk) 30%, var(--line));
  border-radius: 10px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--risk) 5%, transparent);
  max-height: 260px;
  overflow-y: auto;
}

.import-errors p {
  margin: 3px 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.import-errors code {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text);
}

.ai-instructions {
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-raised);
}

.ai-instructions summary {
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 650;
  font-size: 0.9rem;
}

.ai-instructions > :not(summary) {
  margin-left: 16px;
  margin-right: 16px;
}

.ai-instructions-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.copy-status {
  color: var(--positive);
  font-size: 0.78rem;
}

#ai-instructions-text {
  margin: 0 16px 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ledger);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-x: auto;
  user-select: all;
}

/* --- Toasts --- */

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 11px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 0.84rem;
  box-shadow: var(--shadow-soft);
}

.toast.is-error {
  border-color: color-mix(in srgb, var(--risk) 45%, var(--line));
  color: var(--risk);
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .vote-card {
    flex-direction: column;
  }

  .vote-buttons {
    flex-direction: row;
    min-width: 0;
  }
}
