/* ── Reset & base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f9f7f4;
  --surface:   #ffffff;
  --border:    #e0dbd3;
  --text:      #1a1a18;
  --muted:     #706b61;
  --accent:    #5c4a2a;
  --accent-lt: #f0ead8;

  --high:   #1a7a3c;
  --high-bg:#e6f4ec;
  --med:    #7a6400;
  --med-bg: #faf3d0;
  --low:    #8b2000;
  --low-bg: #fdeee8;
  --none-bg:#f0f0f0;

  --accept-bg: #e6f4ec;
  --reject-bg: #fdeee8;
  --flag-bg:   #fff8e0;

  --font: "Georgia", "Times New Roman", serif;
  --mono: "SFMono-Regular", "Menlo", "Consolas", monospace;
  --radius: 6px;
}

/* ── Dark Mode ─────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:        #1a1a18;
  --surface:   #252523;
  --border:    #3a3a38;
  --text:      #f0f0f0;
  --muted:     #a0a0a0;
  --accent:    #c9b896;
  --accent-lt: #3d3426;

  --high:   #4ade80;
  --high-bg:#1a3d2a;
  --med:    #fbbf24;
  --med-bg: #3d341a;
  --low:    #f87171;
  --low-bg: #3d1a1a;
  --none-bg:#2a2a28;

  --accept-bg: #1a3d2a;
  --reject-bg: #3d1a1a;
  --flag-bg:   #3d341a;
}

[data-theme="dark"] header {
  background: #2d2a26;
}

[data-theme="dark"] header a {
  color: #d0c8b8;
}
[data-theme="dark"] header a:hover {
  color: #fff;
}

[data-theme="dark"] .hero {
  background: #2d2a26;
  color: #f0f0f0;
}
[data-theme="dark"] .hero .tagline {
  opacity: 0.85;
}

[data-theme="dark"] .feature-card {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .workflow-steps li::before {
  background: var(--accent);
  color: #1a1a18;
}

[data-theme="dark"] .team-person strong {
  color: var(--text);
}

[data-theme="dark"] .hero-btn.primary {
  background: var(--accent);
  color: #1a1a18;
}
[data-theme="dark"] .hero-btn.secondary {
  border-color: var(--accent);
  color: var(--accent);
}

/* Dark mode toggle button */
.theme-toggle {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  color: inherit;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  margin-left: 0.5rem;
}
.theme-toggle:hover {
  background: rgba(255,255,255,0.1);
}

[data-theme="dark"] .theme-toggle {
  border-color: rgba(255,255,255,0.2);
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
}

/* ── Header ─────────────────────────────────────────────────────────── */
header {
  background: var(--accent);
  color: #f9f7f4;
  padding: 1.4rem 2rem;
}
.header-inner { max-width: 960px; margin: 0 auto; }
header h1 { font-size: 1.5rem; font-weight: normal; letter-spacing: .02em; }
header .subtitle { font-size: .85rem; opacity: .75; margin-top: .25rem; }

/* ── Layout ─────────────────────────────────────────────────────────── */
main { max-width: 960px; margin: 0 auto; padding: 1.5rem 1.5rem 4rem; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.panel h2 {
  font-size: 1rem;
  font-weight: bold;
  color: var(--accent);
  margin-bottom: .9rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* ── Utility ────────────────────────────────────────────────────────── */
.row       { display: flex; align-items: center; }
.gap       { gap: .5rem; }
.muted     { color: var(--muted); }
.mono      { font-family: var(--mono); font-size: .8rem; }
.hidden    { display: none !important; }

.card-grid { display: flex; flex-direction: column; gap: .75rem; }

/* ── Buttons ────────────────────────────────────────────────────────── */
button { cursor: pointer; border: none; border-radius: var(--radius); font-family: inherit; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: .4rem 1rem;
  font-size: .88rem;
}
.btn-primary:hover { opacity: .88; }

.btn-small {
  background: var(--accent-lt);
  color: var(--accent);
  border: 1px solid var(--border);
  padding: .25rem .65rem;
  font-size: .78rem;
}
.btn-small:hover { background: #e8dfc8; }

select {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .35rem .6rem;
  font-family: var(--mono);
  font-size: .82rem;
  background: var(--surface);
  flex: 1;
  max-width: 520px;
}

/* ── Meta block ─────────────────────────────────────────────────────── */
.meta-block {
  background: #f4f1eb;
  border-radius: var(--radius);
  padding: .75rem 1rem;
  margin-top: .75rem;
  white-space: pre-wrap;
  max-height: 220px;
  overflow: auto;
}

/* ── Cards ──────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1rem;
}

.card-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: .4rem;
}

.card-title {
  font-weight: bold;
  font-size: .95rem;
}

/* ── Unified evidence review ───────────────────────────────────────── */
.evidence-card h3 {
  color: var(--accent);
  font-size: .9rem;
  overflow-wrap: anywhere;
  margin-bottom: .55rem;
}
.evidence-field {
  padding: .3rem 0;
  border-bottom: 1px dashed var(--border);
  white-space: pre-wrap;
}
.evidence-candidates {
  margin: .55rem 0;
  padding-left: 1.3rem;
}
.evidence-actions {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin-top: .7rem;
  flex-wrap: wrap;
}
.evidence-review-status { margin-left: .25rem; }
#panel-evidence[data-available="false"] #evidenceItems { display: none; }

/* ── Confidence badge (persons) ─────────────────────────────────────── */
.conf-badge {
  font-size: .72rem;
  font-family: var(--mono);
  padding: .15rem .45rem;
  border-radius: 3px;
}
.conf-high { background: var(--high-bg); color: var(--high); }
.conf-med  { background: var(--med-bg);  color: var(--med);  }
.conf-low  { background: var(--low-bg);  color: var(--low);  }

/* ── Pills (persons) ────────────────────────────────────────────────── */
.pills { display: flex; flex-wrap: wrap; gap: .3rem; margin: .4rem 0; }

.pill-neutral, .pill-group {
  font-size: .72rem;
  font-family: var(--mono);
  padding: .1rem .4rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.pill-group { background: #f0e8ff; color: #5a3a8a; border-color: #c8b0e8; }

.context {
  font-size: .82rem;
  color: var(--muted);
  font-style: italic;
  margin-top: .35rem;
  border-left: 2px solid var(--border);
  padding-left: .6rem;
}

/* ── Status badges (links) ──────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: .72rem;
  font-family: var(--mono);
  padding: .15rem .45rem;
  border-radius: 3px;
  vertical-align: middle;
}
.status-high { background: var(--high-bg); color: var(--high); }
.status-med  { background: var(--med-bg);  color: var(--med);  }
.status-low  { background: var(--low-bg);  color: var(--low);  }
.status-none { background: var(--none-bg); color: var(--muted);}

/* ── Stats bar ──────────────────────────────────────────────────────── */
.stats-bar {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  font-size: .82rem;
  background: #f4f1eb;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .9rem;
  margin-bottom: .75rem;
}
.stats-bar .sep    { color: var(--border); }
.stat-accepted     { color: var(--high); }
.stat-rejected     { color: var(--low); }
.stat-flagged      { color: #8b6f00; }
.stats-bar .btn-small { margin-left: 0; }
.stats-bar .btn-small:first-of-type { margin-left: auto; }

.name-prompt {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  font-size: .83rem;
  background: #f0f6ff;
  border: 1px solid #b8d4f0;
  border-radius: var(--radius);
  padding: .55rem .9rem;
  margin-bottom: .75rem;
}
.name-prompt input {
  font-family: var(--font);
  font-size: .82rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .25rem .5rem;
  width: 180px;
}
.name-prompt input:focus { outline: 1px solid var(--accent); border-color: var(--accent); }

/* ── Filter bar ─────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
  margin-bottom: .9rem;
}
.filter-label { font-size: .8rem; color: var(--muted); }
.filter-btn {
  font-size: .78rem;
  font-family: var(--mono);
  padding: .2rem .6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
}
.filter-btn:hover  { background: var(--accent-lt); color: var(--accent); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Link cards ─────────────────────────────────────────────────────── */
.link-card[data-status="no_match"] { border-left: 3px solid var(--border); }
.link-card[data-status="high"]     { border-left: 3px solid var(--high); }
.link-card[data-status="medium"]   { border-left: 3px solid var(--med); }
.link-card[data-status="low"]      { border-left: 3px solid var(--low); }

.no-match-note { font-size: .82rem; margin-top: .3rem; }

/* ── Candidate rows ─────────────────────────────────────────────────── */
.candidates { display: flex; flex-direction: column; gap: .5rem; margin-top: .5rem; }

.candidate-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fdfcfa;
  flex-wrap: wrap;
}

.candidate-row[data-decision="accept"] { background: var(--accept-bg); border-color: #9ed0b0; }
.candidate-row[data-decision="reject"] { background: var(--reject-bg); border-color: #e8bfb0; }
.candidate-row[data-decision="flag"]   { background: var(--flag-bg);   border-color: #e8d88a; }
.candidate-row[data-conflict="true"]   { border-left: 3px solid var(--low); }

.conflict-banner {
  background: var(--low-bg);
  border: 1px solid #e8bfb0;
  border-radius: var(--radius);
  padding: .6rem 1rem;
  font-size: .85rem;
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}
.filter-btn.conflict-btn { border-color: #e8bfb0; color: var(--low); }
.filter-btn.conflict-btn.active { background: var(--low); color: #fff; border-color: var(--low); }

.candidate-info {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.candidate-name  { font-weight: bold; font-size: .88rem; }
.score-badge     { font-family: var(--mono); font-size: .72rem; padding: .1rem .4rem; border-radius: 3px; }
.match-type      { font-family: var(--mono); font-size: .72rem; color: var(--muted); }
.candidate-type  { font-size: .75rem; }
.outremer-id     { font-family: var(--mono); font-size: .7rem; }

/* ── Adjudication controls ──────────────────────────────────────────── */
.adjudication {
  display: flex;
  align-items: center;
  gap: .35rem;
  flex-shrink: 0;
}

.adj-btn {
  font-size: 1rem;
  width: 2rem;
  height: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: .45;
  transition: opacity .1s, border-color .1s;
}
.adj-btn:hover   { opacity: .85; border-color: var(--accent); }
.adj-btn.active  { opacity: 1; border-color: transparent; }
.adj-btn.accept.active { background: var(--high-bg); }
.adj-btn.reject.active { background: var(--low-bg); }
.adj-btn.flag.active   { background: var(--flag-bg); }

.reject-group {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.reject-reason {
  font-family: var(--font);
  font-size: 0.75rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-width: 140px;
  transition: border-color 0.15s, background 0.15s;
}
.reject-reason:hover {
  border-color: var(--accent);
  background: var(--accent-lt);
}
.reject-reason:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(92, 74, 42, 0.15);
}

.group-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
  user-select: none;
}
.group-toggle:hover {
  background: var(--accent-lt);
  color: var(--accent);
}
.group-toggle input {
  cursor: pointer;
  accent-color: var(--accent);
}

.comment-input {
  font-family: var(--font);
  font-size: .78rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .3rem .5rem;
  width: 160px;
  background: var(--surface);
}
.comment-input:focus { outline: 1px solid var(--accent); border-color: var(--accent); }

/* ── Community votes ─────────────────────────────────────────────────── */
.community-votes {
  font-size: .75rem;
  font-family: var(--mono);
  display: inline-flex;
  gap: .35rem;
  align-items: center;
  margin-left: .3rem;
}
.community-votes.muted { color: var(--border); font-style: italic; }
.cv-accept   { color: var(--high); }
.cv-reject   { color: var(--low); }
.cv-flag     { color: #8b6f00; }
.cv-conflict { color: var(--low); margin-right: .2rem; }

/* ── Sync indicator ──────────────────────────────────────────────────── */
.sync-indicator {
  font-size: .8rem;
  width: 1.2rem;
  text-align: center;
  flex-shrink: 0;
}
.sync-pending { color: var(--muted); animation: spin .8s linear infinite; display: inline-block; }
.sync-ok      { color: var(--high); }
.sync-err     { color: var(--low); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Wikidata section ────────────────────────────────────────────────── */
.wikidata-section {
  margin-top: .5rem;
  border-top: 1px dashed var(--border);
  padding-top: .5rem;
}
.wd-label {
  font-size: .75rem;
  font-weight: bold;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .4rem;
}
/* A tie is a warning, not a detail: the label above it is uppercase and muted,
   so the count has to break out of that to be read at all. */
.wd-ambiguous {
  text-transform: none;
  letter-spacing: normal;
  font-weight: normal;
  color: var(--low);
}
.wd-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .35rem .5rem;
  border-radius: var(--radius);
  margin-bottom: .3rem;
  font-size: .83rem;
}
/* Adjudication-enabled Wikidata row: info left, buttons right */
.wd-adj-row {
  justify-content: space-between;
  flex-wrap: nowrap;
}
.wd-info {
  display: flex;
  align-items: center;
  gap: .45rem;
  flex-wrap: wrap;
  min-width: 0;
}
.wd-relevant { background: #f0f6ff; }
.wd-weak     { background: #fafafa; opacity: .8; }
.wd-name     { color: var(--accent); text-decoration: none; font-weight: bold; white-space: nowrap; }
.wd-name:hover { text-decoration: underline; }
.wd-qid      { font-family: var(--mono); font-size: .72rem; font-weight: normal; color: var(--muted); }
.wd-desc     { font-size: .78rem; color: var(--muted); }

/* ── Raw JSON ────────────────────────────────────────────────────────── */
#raw {
  background: #f4f1eb;
  border-radius: var(--radius);
  padding: .75rem 1rem;
  margin-top: .75rem;
  white-space: pre-wrap;
  max-height: 400px;
  overflow: auto;
}

/* ── Identity evidence on a candidate (M19.4 part 2, #94) ────────────────── */
.auth-evidence {
  flex-basis: 100%; margin-top: .3rem; font-size: .78rem; line-height: 1.9;
  display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .4rem;
}
.auth-evidence-label { text-transform: uppercase; letter-spacing: .05em; font-size: .66rem; color: var(--muted, #666); }
.auth-qid { font-weight: 600; text-decoration: none; }
.auth-status { border-radius: 10px; padding: .05rem .5rem; font-size: .72rem; }
.auth-asserted { background: #dcfce7; color: #166534; }
.auth-hypothesised { background: #fef3c7; color: #854d0e; }
.auth-none { background: #eee; color: #666; }
.auth-form { border-radius: 10px; padding: .05rem .5rem; font-size: .72rem; border: 1px solid transparent; }
.auth-form-omeka { background: #f1f5f9; color: #334155; }
.auth-form-hand { background: #e0e7ff; color: #3730a3; }
.auth-form-snapshot { background: #ecfdf5; color: #065f46; }
.auth-form-exact { border-color: currentColor; font-weight: 600; }
.auth-evidence-note { font-size: .72rem; }
