/* ─────────────────────────────────────────────────────────────────────
   PV-Atlas Rating Platform · responsive stylesheet
   Desktop unchanged; mobile breakpoints @ 768px (tablet) and 480px (phone).
   ───────────────────────────────────────────────────────────────────── */

:root {
  --bg: #f8f9fb;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --gray: #9ca3af;
  --indigo: #4338ca;
  --violet: #8b5cf6;
}

* { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.45;
}

/* ── Header ───────────────────────────────────────────────────── */

header {
  background: white; border-bottom: 1px solid var(--border);
  padding: 6px 0; position: sticky; top: 0; z-index: 10;
}
.header-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 12px;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 6px;
}
.logo { font-weight: 700; color: var(--blue); text-decoration: none; font-size: 1.05em; }
.rater-info { font-size: 0.88em; color: var(--muted); display: flex; align-items: center; gap: 12px; }
.rater-info .logout {
  color: var(--muted); text-decoration: none;
  border: 1px solid var(--border); padding: 4px 10px; border-radius: 4px;
  min-height: 32px; display: inline-flex; align-items: center;
}
.lang-toggle a {
  color: var(--muted); text-decoration: none;
  border: 1px solid var(--border); padding: 4px 10px; border-radius: 4px;
  min-height: 32px; display: inline-flex; align-items: center;
  font-size: 0.88em;
}
.lang-toggle a strong { color: var(--blue); }
.lang-toggle a:hover { border-color: var(--blue); }

.lang-hint { padding: 8px 12px; background: #f0f9ff;
  border: 1px solid #bae6fd; border-radius: 6px; margin-bottom: 12px; }
.lang-hint a { color: var(--blue); text-decoration: none; margin-left: 6px;
  font-weight: 500; }
.lang-hint a:hover { text-decoration: underline; }

main { max-width: 1200px; margin: 6px auto; padding: 0 12px; }
footer { max-width: 1200px; margin: 12px auto 0; padding: 8px 12px; color: var(--muted); font-size: 0.78em; }

/* ── Card ───────────────────────────────────────────────────── */

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 14px; margin-bottom: 8px;
}

h1 { margin: 0 0 6px; font-size: 1.2em; line-height: 1.25; }
h2 { margin: 4px 0; border-bottom: none; padding-bottom: 0; font-size: 1em; }
h3 { margin: 8px 0 4px; color: var(--text); font-size: 0.9em; }
small { color: var(--muted); font-weight: normal; }
p { margin: 4px 0 6px; }

/* ── Forms ───────────────────────────────────────────────────── */

form label { display: block; margin: 12px 0; font-weight: 500; }
form input[type=text], form input:not([type]) {
  width: 100%; padding: 12px; font-size: 1em;
  border: 1px solid var(--border); border-radius: 6px;
  /* prevent iOS zoom on focus */
  font-size: max(1em, 16px);
}
form textarea {
  width: 100%; padding: 12px; font-size: max(1em, 16px);
  border: 1px solid var(--border); border-radius: 6px; resize: vertical;
  min-height: 90px; font-family: inherit; line-height: 1.5;
}
button[type=submit] {
  background: var(--blue); color: white; border: none;
  padding: 14px 28px; font-size: 1em; font-weight: 600;
  border-radius: 6px; cursor: pointer;
  min-height: 48px;     /* touch target */
}
button[type=submit]:hover { background: var(--blue-dark); }
button[type=submit]:active { transform: translateY(1px); }

/* ── Home page task grid ───────────────────────────────────── */

.task-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px; margin-top: 14px;
}
.task-card {
  display: block; background: white; border: 1px solid var(--border);
  border-radius: 8px; padding: 18px; text-decoration: none; color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
  min-height: 100px;
}
.task-card:hover { border-color: var(--blue); }
.task-card:active { background: #f0f4ff; }
.task-card.done { background: #f0fdf4; border-color: var(--green); }
.task-card-label { font-weight: 600; margin-bottom: 8px; font-size: 1.02em; }
.task-card-progress strong { font-size: 1.55em; color: var(--blue); }
.progress-bar {
  height: 6px; background: var(--border); border-radius: 3px;
  margin-top: 8px; overflow: hidden;
}
.progress-bar-fill { height: 100%; background: var(--blue); transition: width 0.3s; }
.task-card-status { color: var(--green); font-size: 0.92em; margin-top: 8px; }
.empty-stream { color: var(--muted); font-size: 0.9em; margin-top: 4px; }

/* Language picker on login page */
.lang-picker {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 14px 12px; margin: 16px 0 8px;
}
.lang-picker legend { padding: 0 6px; font-weight: 600; color: var(--text); }
.lang-option {
  display: block; padding: 12px 10px; margin: 6px 0;
  border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; min-height: 52px;
}
.lang-option:hover { border-color: var(--blue); background: #fafbff; }
.lang-option input[type=radio] {
  width: 20px; height: 20px; vertical-align: -4px; margin-right: 10px; cursor: pointer;
}
.lang-option strong { font-size: 1.02em; }
.lang-option em {
  display: block; color: var(--muted); font-size: 0.86em;
  font-style: normal; margin-top: 4px; padding-left: 30px; line-height: 1.5;
}
.lang-option:has(input[type=radio]:checked) {
  background: #eef2ff; border-color: var(--blue);
}

/* ── Rating card ───────────────────────────────────────────── */

.rate-card { max-width: 900px; margin: 0 auto; padding-bottom: 70px; }
.rate-header {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; flex-wrap: wrap; margin-bottom: 4px;
}
.rate-progress {
  background: var(--blue); color: white; padding: 3px 10px; border-radius: 12px;
  font-size: 0.78em; font-weight: 500; white-space: nowrap;
}

.triple-block {
  padding: 6px 10px; background: #eef2ff; border: 1px solid #c7d2fe;
  border-radius: 6px; margin-bottom: 6px;
}
.triple-line {
  font-size: 1.02em; line-height: 1.55; word-break: break-word;
}
.triple-line.zh {
  margin-top: 6px; padding-top: 6px;
  border-top: 1px dashed #c7d2fe;
  color: var(--indigo); font-size: 0.96em;
}

.type-pill {
  display: inline-block; background: #6366f1; color: white;
  padding: 2px 10px; border-radius: 12px; font-size: 0.78em;
  margin: 0 3px; vertical-align: 1px;
}
.type-pill.zh { background: var(--violet); }

.genre-pill {
  display: inline-block; background: var(--blue); color: white;
  padding: 2px 10px; border-radius: 12px; font-size: 0.78em;
}

.meta { color: var(--muted); font-size: 0.85em; margin-top: 6px; line-height: 1.6; }
.meta span { display: inline-block; margin-right: 14px; }
code {
  background: #f3f4f6; padding: 1px 6px; border-radius: 3px;
  font-family: ui-monospace, "Cascadia Code", monospace; font-size: 0.9em;
  word-break: break-all;
}

/* ── Evidence blockquotes ───────────────────────────────────── */

blockquote.evidence {
  background: #f8f9fb; border-left: 3px solid var(--blue);
  padding: 6px 10px; margin: 4px 0;
  font-family: ui-serif, Georgia, serif; line-height: 1.45;
  font-size: 0.92em;
}
blockquote.evidence footer { margin-top: 4px; }
blockquote.evidence.zh {
  background: #fffbeb; border-left-color: var(--amber);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.zh-label {
  display: inline-block; background: #f0f0ff; color: var(--indigo);
  padding: 2px 8px; border-radius: 4px; font-size: 0.75em;
  font-weight: 600; margin-right: 6px; margin-bottom: 4px;
  letter-spacing: 0.02em;
}
.zh-block {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed #c7d2fe;
  color: #1e1b4b; font-size: 0.95em; line-height: 1.6;
}

/* ── QA blocks (R2) ───────────────────────────────────────── */

.qa-block {
  padding: 10px 12px; background: #f0f9ff; border: 1px solid #bae6fd;
  border-radius: 6px; margin-bottom: 10px;
}
.qa-block.answer { background: #fff7ed; border-color: #fed7aa; }
.qa-block-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
  font-size: 0.85em; color: var(--muted);
}
.qa-block-head strong { color: var(--text); font-size: 1em; }
.qa-instruction, .qa-response { font-size: 0.98em; line-height: 1.55; word-break: break-word; }
.prov-details summary { font-size: 0.85em; color: var(--blue); margin: 8px 0; }
.prov-details pre.provenance { margin-top: 6px; }
.qa-instruction.zh, .qa-response.zh {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px dashed var(--border);
  color: #1e1b4b; font-size: 0.95em; line-height: 1.65;
}
pre.provenance {
  background: #f3f4f6; padding: 12px; border-radius: 6px;
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.82em; max-height: 250px; overflow: auto;
  white-space: pre-wrap; word-break: break-all;
}

/* ── R4 candidate list ───────────────────────────────────── */

.candidate-list { margin: 12px 0; }
.candidate {
  background: white; border: 1px solid var(--border);
  border-radius: 6px; padding: 14px; margin-bottom: 12px;
}
.candidate-header label {
  display: flex; align-items: flex-start; gap: 10px;
  cursor: pointer; padding: 4px 0;
}
.candidate input[type=checkbox] {
  width: 22px; height: 22px; margin: 2px 0 0; flex-shrink: 0;
  cursor: pointer;
}
.candidate-header-zh {
  margin-top: 4px; padding-top: 4px;
  border-top: 1px dashed var(--border);
  color: var(--indigo); font-size: 0.95em;
}
.superseded { color: var(--red); font-weight: 500; font-size: 0.8em; }

/* ── Verdict picker ───────────────────────────────────── */

.verdict-grid {
  display: grid;
  /* 4 verdicts per row on R1; 5-6 on R2/R4 fit naturally  */
  grid-template-columns: repeat(4, 1fr);
  gap: 4px; margin: 4px 0 6px;
}
.verdict-grid.five-col { grid-template-columns: repeat(5, 1fr); }
.verdict-grid.six-col  { grid-template-columns: repeat(6, 1fr); }
.verdict {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 6px;
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 38px;
  user-select: none;
  position: relative;
}
.verdict:hover { border-color: var(--blue); background: #fafbff; }
.verdict:active { background: #f0f4ff; }
.verdict input[type=radio] {
  width: 16px; height: 16px;
  margin: 0; cursor: pointer; flex-shrink: 0;
}
.verdict span {
  font-weight: 600; font-size: 0.88em;
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Two visual groups: left = ✓/⚠ (支持组), right = ✗/? (不支持组) */
.verdict.correct {
  background: #f0fdf4;
  border-color: #bbf7d0;
  border-left: 3px solid var(--green);
}
.verdict.partial {
  background: #fffbeb;
  border-color: #fde68a;
  border-left: 3px solid var(--amber);
}
.verdict.incorrect {
  background: #fef2f2;
  border-color: #fecaca;
  border-left: 3px solid var(--red);
}
.verdict.cannot {
  background: #f9fafb;
  border-color: var(--border);
  border-left: 3px solid var(--gray);
}
.verdict:hover { filter: brightness(0.97); border-color: var(--blue); }

.verdict:has(input[type=radio]:checked) {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
  font-weight: 700;
}

/* visual gap between 支持组 and 不支持组 (2nd and 3rd verdict) */
.verdict-grid > .verdict:nth-child(2) { margin-right: 8px; }
.verdict-grid.five-col > .verdict:nth-child(3) { margin-right: 8px; margin-left: 0; }
.verdict-grid.six-col  > .verdict:nth-child(2) { margin-right: 8px; }

/* Rationale shows only when a disagreement verdict is selected */
.rate-form textarea[name=rationale] {
  display: none;
}
.rate-form[data-verdict=partially_correct] textarea[name=rationale],
.rate-form[data-verdict=incorrect] textarea[name=rationale],
.rate-form[data-verdict=no_wrong_winner] textarea[name=rationale],
.rate-form[data-verdict=no_should_have_kept_multiple] textarea[name=rationale],
.rate-form[data-verdict=no_all_spurious] textarea[name=rationale],
.rate-form[data-verdict=reject_factual_error] textarea[name=rationale],
.rate-form[data-verdict=reject_not_grounded] textarea[name=rationale],
.rate-form[data-verdict=reject_off_topic] textarea[name=rationale] {
  display: block;
  margin-top: 6px;
  animation: slide-in 0.18s ease-out;
}
@keyframes slide-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Info button + dialog inside verdict */
.verdict .info-btn {
  flex-shrink: 0; width: 18px; height: 18px; padding: 0;
  border: 1px solid var(--border); background: white;
  border-radius: 50%; color: var(--muted);
  font-size: 0.7em; cursor: pointer; line-height: 1;
}
.verdict .info-btn:hover { background: var(--blue); color: white; border-color: var(--blue); }
.verdict .info-btn:active { transform: scale(0.95); }

.info-dialog {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 18px 22px; max-width: 420px; width: 92vw;
  box-shadow: 0 6px 24px rgba(0,0,0,0.15);
}
.info-dialog::backdrop { background: rgba(0,0,0,0.4); }
.info-dialog h4 { margin: 0 0 10px; font-size: 1.05em; color: var(--text); }
.info-dialog p { margin: 0 0 14px; color: var(--text); line-height: 1.55; }
.info-dialog form { margin: 0; }
.info-dialog form button {
  background: var(--blue); color: white; border: none;
  padding: 8px 18px; border-radius: 6px; font-weight: 500;
  cursor: pointer; min-height: 38px;
}
.info-dialog form button:hover { background: var(--blue-dark); }
.info-dialog.wide { max-width: 560px; }
.info-dialog .orig-text {
  background: #f8f9fb; border-left: 3px solid var(--blue);
  padding: 10px 14px; margin: 0 0 10px;
  font-family: ui-serif, Georgia, serif; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
  max-height: 50vh; overflow-y: auto;
}

.link-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--blue); cursor: pointer; padding: 3px 10px;
  border-radius: 4px; font-size: 0.85em;
}
.link-btn:hover { border-color: var(--blue); background: #eef2ff; }

/* tighter evidence meta — keep all items on one line */
.meta.evidence-meta {
  margin-top: 4px; font-size: 0.82em;
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 4px 10px;
}
.meta.evidence-meta > * { margin: 0; flex-shrink: 0; }
.meta.evidence-meta > span:not(.genre-pill) {
  overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.meta.evidence-meta .link-btn { margin-left: auto; }

.verdict-row-label {
  font-weight: 600; color: var(--muted); font-size: 0.82em;
  margin: 4px 0 2px; text-transform: uppercase; letter-spacing: 0.04em;
}

/* navigation buttons (prev / submit / next) */
.nav-actions {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
}
.nav-btn {
  flex: 0 0 auto; padding: 9px 12px;
  color: var(--muted); text-decoration: none;
  border: 1px solid var(--border); border-radius: 6px;
  background: white; font-size: 0.9em; min-height: 40px;
  display: inline-flex; align-items: center;
}
.nav-btn:hover { border-color: var(--blue); color: var(--blue); }
.nav-btn.disabled { color: var(--gray); cursor: not-allowed; background: #f9fafb; }
.primary-btn {
  flex: 1; background: var(--blue); color: white; border: none;
  padding: 10px 16px; font-weight: 600; border-radius: 6px;
  cursor: pointer; min-height: 42px; font-size: 0.95em;
}
.primary-btn:hover { background: var(--blue-dark); }
.form-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px; font-size: 0.84em;
}
.rated-tag {
  color: var(--amber); font-size: 0.84em;
  padding: 2px 8px; background: #fffbeb; border-radius: 4px;
}

/* ── Form actions ───────────────────────────────────── */

.form-actions {
  display: flex; gap: 8px; align-items: center; margin-top: 8px;
  flex-wrap: wrap;
}
.link-primary { color: var(--blue); font-weight: 500; text-decoration: none;
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; }
.link-secondary { color: var(--muted); text-decoration: none;
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; }

.hint { color: var(--muted); font-size: 0.9em; }

/* ── Admin table ───────────────────────────────────── */

.admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.admin-table {
  width: 100%; min-width: 540px;
  border-collapse: collapse; margin: 12px 0;
}
.admin-table th, .admin-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  text-align: left; white-space: nowrap;
}
.admin-table th { background: #f9fafb; font-weight: 600; font-size: 0.92em; }
.kappa.good { color: var(--green); }
.kappa.ok   { color: var(--amber); }
.kappa.low  { color: var(--red); }

.done-card { text-align: center; padding: 50px 20px; }
.done-card h1 { color: var(--green); }

details { margin-top: 16px; }
details summary { cursor: pointer; color: var(--blue); font-weight: 500; padding: 6px 0; }
details ol, details ul { padding-left: 22px; line-height: 1.7; }


/* ═════════════════════════════════════════════════════════════
   TABLET — narrower padding, single-column task grid
   ═════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  main { padding: 0 12px; margin: 14px auto; }
  .card { padding: 18px 18px; border-radius: 6px; }

  h1 { font-size: 1.35em; }
  h2 { font-size: 1.12em; margin-top: 22px; }
  h3 { font-size: 1em; margin-top: 18px; }

  .task-grid { grid-template-columns: 1fr; gap: 12px; }

  /* tablet: keep horizontal layout — 4 verdicts in one row */
  .verdict-grid          { grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .verdict-grid.five-col { grid-template-columns: repeat(5, 1fr); }
  .verdict-grid.six-col  { grid-template-columns: repeat(6, 1fr); }
  .verdict { padding: 5px; }

  .rate-card { padding-bottom: 24px; }

  .meta span { display: block; margin: 2px 0; }

  pre.provenance { font-size: 0.78em; max-height: 200px; }
}


/* ═════════════════════════════════════════════════════════════
   PHONE — large tap targets, sticky bottom action bar, single-col
   ═════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
  header { padding: 10px 0; }
  .header-inner { padding: 0 12px; }
  .logo { font-size: 0.98em; }
  .rater-info { font-size: 0.8em; width: 100%; justify-content: space-between; }

  main { padding: 0 10px; margin: 12px auto; }
  .card { padding: 14px 14px; border-radius: 6px; }

  h1 { font-size: 1.2em; line-height: 1.4; }
  h2 { font-size: 1.05em; margin-top: 18px; }
  h3 { font-size: 0.95em; margin-top: 14px; }

  .triple-block { padding: 12px; }
  .triple-line { font-size: 1.02em; line-height: 1.75; }
  .triple-line.zh { font-size: 0.95em; }

  .qa-block { padding: 12px; }
  .qa-instruction, .qa-response { font-size: 0.98em; }

  blockquote.evidence { padding: 10px 12px; font-size: 0.95em; }

  .candidate { padding: 12px; }
  .candidate input[type=checkbox] { width: 24px; height: 24px; }

  /* phone: ultra-compact — verdicts in one row at very small widths */
  .verdict-grid          { grid-template-columns: repeat(4, 1fr); gap: 3px; }
  .verdict-grid.five-col { grid-template-columns: repeat(5, 1fr); }
  .verdict-grid.six-col  { grid-template-columns: repeat(6, 1fr); }
  .verdict { padding: 5px 3px; min-height: 36px; gap: 3px; }
  .verdict span { font-size: 0.78em; }
  .verdict input[type=radio] { width: 14px; height: 14px; }
  .verdict .info-btn { width: 16px; height: 16px; font-size: 0.65em; }

  /* sticky bottom action bar so submit is always reachable */
  .rate-form {
    padding-bottom: 80px;
  }
  .form-actions {
    position: fixed; left: 0; right: 0; bottom: 0;
    background: white; border-top: 1px solid var(--border);
    padding: 12px 14px; margin: 0; gap: 8px;
    box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.04);
    z-index: 5; justify-content: space-between;
  }
  .form-actions button[type=submit] {
    flex: 1; padding: 14px 16px;
  }
  .form-actions .link-secondary {
    flex: 0 0 auto; padding: 0 12px;
    border: 1px solid var(--border); border-radius: 6px;
    background: white; min-height: 48px;
  }

  /* status pill smaller */
  .rate-progress { padding: 4px 10px; font-size: 0.8em; }

  /* admin table */
  .admin-table-wrap { margin: 0 -14px; }
  .admin-table { min-width: 480px; font-size: 0.88em; }
  .admin-table th, .admin-table td { padding: 8px 10px; }

  pre.provenance { font-size: 0.75em; max-height: 180px; margin: 0 -4px; }

  /* footer smaller */
  footer { margin: 18px auto; padding: 12px 14px; font-size: 0.85em; }
}


/* iOS safe-area (notch) bottom padding for fixed action bar */
@supports (padding: max(0px)) {
  @media (max-width: 480px) {
    .form-actions {
      padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
    .rate-form {
      padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    }
  }
}

/* Verdict distribution table — small grey count alongside % */
.dist-count {
  color: #666;
  font-size: 0.85em;
  margin-left: 2px;
}

/* Login-page admin entry */
.admin-divider {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 22px 0 14px;
}
.admin-entry {
  text-align: center;
  font-size: 0.9em;
}
.admin-entry button.link-secondary {
  background: none;
  border: none;
  color: #4b5563;
  cursor: pointer;
  padding: 4px 10px;
  font-size: 0.9em;
}
.admin-entry button.link-secondary:hover {
  color: #111827;
  text-decoration: underline;
}
#admin-form {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
}
#admin-form input[name="token"] {
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  max-width: 220px;
}
#admin-form button {
  padding: 6px 12px;
}

/* ─── Admin chart styles ──────────────────────────────────────────────── */

/* Progress bars */
.rater-progress-block {
  margin: 14px 0 22px;
  padding: 10px 12px;
  background: #f9fafb;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}
.rater-name { font-size: 0.95em; margin-bottom: 8px; }
.rater-name .affil { color: #6b7280; font-weight: normal; }
.rater-name .lang-tag {
  display: inline-block; margin-left: 6px;
  font-size: 0.75em; padding: 2px 6px;
  background: #e0f2fe; color: #075985; border-radius: 3px;
}
.progress-row {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 0;
}
.progress-label {
  width: 32px; font-size: 0.85em; font-weight: 600;
  color: #4b5563; text-align: right;
}
.progress-track {
  position: relative; flex: 1;
  height: 22px; background: #f3f4f6;
  border-radius: 4px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: linear-gradient(90deg, #3b82f6, #06b6d4);
  transition: width 0.3s;
}
.progress-text {
  position: absolute; left: 8px; top: 0;
  height: 100%; display: flex; align-items: center;
  font-size: 0.82em; color: #1f2937; font-weight: 500;
  text-shadow: 0 0 2px white;
}

/* Verdict-distribution stacked bars */
.stream-title { margin: 18px 0 8px; font-size: 1.05em; }
.dist-chart {
  background: #fafafa;
  border: 1px solid #e5e7eb; border-radius: 6px;
  padding: 12px 14px;
}
.dist-row {
  display: flex; align-items: center; gap: 10px;
  margin: 6px 0;
}
.dist-rater {
  flex-shrink: 0; width: 180px;
  font-size: 0.88em; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dist-total {
  flex-shrink: 0; width: 36px; text-align: right;
  font-size: 0.78em; color: #6b7280; font-variant-numeric: tabular-nums;
}
.dist-bar {
  display: flex; flex: 1; height: 26px;
  border-radius: 4px; overflow: hidden;
  background: #e5e7eb;
}
.dist-seg {
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78em; font-weight: 600;
  color: white; text-shadow: 0 1px 2px rgba(0,0,0,0.35);
  white-space: nowrap; overflow: hidden;
  transition: width 0.3s;
}
.dist-legend {
  display: flex; flex-wrap: wrap; gap: 12px 18px;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed #d1d5db;
  font-size: 0.78em; color: #4b5563;
}
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-swatch {
  display: inline-block; width: 12px; height: 12px;
  border-radius: 2px; vertical-align: middle;
}

/* Per-verdict colors (used for both .dist-seg and .legend-swatch) */
.verdict-correct, .verdict-yes, .verdict-admit {
  background: #22c55e;
}
.verdict-partially_correct, .verdict-admit_minor_quibble {
  background: #fbbf24;
}
.verdict-incorrect, .verdict-no_all_spurious, .verdict-reject_factual_error {
  background: #ef4444;
}
.verdict-cannot_decide {
  background: #9ca3af;
}
.verdict-no_wrong_winner, .verdict-reject_not_grounded {
  background: #f97316;
}
.verdict-no_should_have_kept_multiple {
  background: #8b5cf6;
}
.verdict-reject_off_topic {
  background: #ec4899;
}

/* Fleiss κ horizontal bar with threshold markers */
.kappa-chart {
  background: #fafafa;
  border: 1px solid #e5e7eb; border-radius: 6px;
  padding: 14px;
}
.kappa-row {
  display: flex; align-items: center; gap: 12px;
  margin: 10px 0;
}
.kappa-label {
  flex-shrink: 0; width: 180px;
  font-size: 0.9em; font-weight: 500;
}
.kappa-bar-wrap {
  flex: 1; display: flex; align-items: center; gap: 10px;
}
.kappa-bar-track {
  position: relative; flex: 1;
  height: 16px; background: #f3f4f6;
  border-radius: 3px; overflow: visible;
  border: 1px solid #e5e7eb;
}
.kappa-fill {
  position: absolute; top: 0; left: 0;
  height: 100%; border-radius: 3px;
}
.kappa-fill.good { background: linear-gradient(90deg, #86efac, #22c55e); }
.kappa-fill.ok { background: linear-gradient(90deg, #fde68a, #f59e0b); }
.kappa-fill.low { background: linear-gradient(90deg, #fca5a5, #ef4444); }
.kappa-threshold {
  position: absolute; top: -3px; bottom: -3px; width: 2px;
  z-index: 2;
}
.kappa-threshold.ok { background: #f59e0b; }
.kappa-threshold.good { background: #22c55e; }
.kappa-threshold::after {
  content: attr(title);
  position: absolute; top: -16px; left: -10px;
  font-size: 0.65em; color: #6b7280;
}
.kappa-marker {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 14px; height: 14px;
  background: #1f2937; border: 2px solid white;
  border-radius: 50%; z-index: 3;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.kappa-value {
  flex-shrink: 0; min-width: 90px;
  font-size: 0.9em; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.kappa-value.good { color: #15803d; }
.kappa-value.ok { color: #b45309; }
.kappa-value.low { color: #b91c1c; }
.kappa-value.none { color: #9ca3af; font-weight: normal; }
.kappa-n {
  flex-shrink: 0; font-size: 0.75em; color: #6b7280;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 600px) {
  .dist-rater, .kappa-label { width: 110px; font-size: 0.8em; }
  .dist-total { display: none; }
  .kappa-n { display: none; }
  .progress-row { gap: 6px; }
}

/* Pre-rater banner shown when an LLM has seeded the form */
.prerater-banner {
  margin: 0 0 14px;
  padding: 10px 14px;
  background: linear-gradient(90deg, #fef3c7, #fde68a);
  border-left: 4px solid #f59e0b;
  border-radius: 4px;
  font-size: 0.88em;
  color: #78350f;
  line-height: 1.4;
}
.prerater-banner strong {
  color: #92400e;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 0.95em;
}

/* Document title in evidence-meta line (replaces bare doc_id) */
.doc-title {
  max-width: 540px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: #374151;
  cursor: help;  /* the title attribute holds the raw doc_id */
}
.doc-title .doc-meta {
  color: #6b7280; font-size: 0.9em; margin-left: 4px;
}

/* R2 question-quality flag (independent of verdict) */
.q-quality-flag {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 10px 0 6px;
  padding: 8px 10px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 4px;
  font-size: 0.85em;
  color: #78350f;
  line-height: 1.45;
  cursor: pointer;
}
.q-quality-flag input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
}
.q-quality-flag strong { color: #92400e; }
.q-quality-flag:hover { background: #fef3c7; }

/* Provenance cards (replaces raw JSON dump) */
.prov-details > summary {
  cursor: pointer;
  padding: 8px 12px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 4px;
  font-size: 0.92em;
  color: #075985;
  list-style: none;
}
.prov-details > summary::-webkit-details-marker { display: none; }
.prov-details > summary::before {
  content: "▸ ";
  display: inline-block;
  margin-right: 4px;
  transition: transform 0.15s;
}
.prov-details[open] > summary::before { content: "▾ "; }
.prov-details[open] > summary {
  border-bottom-left-radius: 0; border-bottom-right-radius: 0;
}
.prov-details .prov-hint {
  margin-left: 8px;
  color: #0369a1;
  font-size: 0.85em;
  font-weight: normal;
}

.prov-card {
  margin: 0;
  padding: 12px 14px;
  background: #fafafa;
  border: 1px solid #bae6fd;
  border-top: none;
}
.prov-card + .prov-card {
  border-top: 1px dashed #e0f2fe;
}
.prov-card-head {
  display: flex; flex-wrap: wrap;
  align-items: center; gap: 8px;
  margin-bottom: 8px;
  font-size: 0.85em;
}
.prov-num {
  display: inline-block;
  min-width: 28px; text-align: center;
  padding: 2px 6px;
  background: #0284c7; color: white;
  border-radius: 3px; font-size: 0.78em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.prov-conf {
  margin-left: auto;
  color: #6b7280;
  font-size: 0.85em;
  font-variant-numeric: tabular-nums;
}
.prov-quote {
  margin: 0;
  padding: 8px 12px;
  background: white;
  border-left: 3px solid #38bdf8;
  font-size: 0.92em;
  line-height: 1.5;
  color: #1f2937;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.prov-quote.orig {
  background: #fefce8;
  border-left-color: #facc15;
  margin-top: 4px;
}
.prov-orig {
  margin-top: 8px;
}
.prov-orig > summary {
  cursor: pointer;
  font-size: 0.8em;
  color: #6b7280;
  padding: 2px 0;
}

/* Hide the legacy raw-JSON pre if it sneaks in somewhere */
.provenance { display: none; }
