:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #f5f6f8;
  --line: #e8eaed;
  --line-strong: #d1d5db;
  --ink: #1a1d21;
  --muted: #5f6872;
  --faint: #8b929c;
  --accent: #25614f;
  --accent-soft: #e8f2ed;
  --danger: #b33a2f;
  --danger-soft: #fef0ee;
  --warn: #946300;
  --warn-soft: #fff8e8;
  --ok: #2f6f48;
  --ok-soft: #eaf5ef;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --radius: 8px;
  --radius-sm: 6px;
  --control-h: 34px;
  --control-h-sm: 30px;
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button, input, a {
  font: inherit;
}

/* ── Shell ── */

.app-shell {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  height: 100vh;
  min-width: 0;
  overflow: hidden;
}

body.has-pdf .app-shell {
  grid-template-columns: 290px minmax(560px, 1fr) minmax(400px, 40vw);
}

/* ── Rail (Sidebar) ── */

.rail {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--line);
}

.brand {
  padding: 18px 18px 14px;
}

.brand-title {
  font-size: 20px;
  line-height: 1.2;
  font-weight: 800;
  color: var(--ink);
}

.brand-subtitle {
  margin-top: 3px;
  color: var(--faint);
  font-size: 12px;
}

.run-panel {
  padding: 14px 16px;
  background: var(--surface);
}

.entry-title {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
}

.entry-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}
.entry-actions:has(:only-child) {
  grid-template-columns: 1fr;
}

.entry-actions button,
.upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--control-h);
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--accent);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s;
}
.entry-actions button:hover,
.upload-btn:hover { background: var(--accent-soft); }

.upload-btn.disabled {
  cursor: not-allowed;
  opacity: 0.4;
  pointer-events: none;
}

.upload-btn input {
  display: none;
}

.entry-divider {
  height: 1px;
  margin: 12px 0;
  background: var(--line);
}

.mode-toggle {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink);
  cursor: pointer;
}

.mode-toggle input {
  width: 16px;
  min-height: 16px;
  margin-top: 2px;
  padding: 0;
  accent-color: var(--accent);
}

.mode-toggle span {
  display: grid;
  gap: 2px;
}

.mode-toggle strong {
  font-size: 13px;
  line-height: 1.2;
}

.mode-toggle small,
.run-summary {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.run-summary {
  margin: 0 0 10px;
}

.issue-category-tabs {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface) 92%, var(--surface-soft));
  box-shadow: var(--shadow-sm);
}

.issue-category-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.issue-category-tab strong {
  min-width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 11px;
}

.issue-category-tab.active,
.issue-category-tab:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.issue-category-tab.active strong,
.issue-category-tab:hover strong {
  background: var(--accent);
  color: white;
}

/* ── Presets: pill-shaped tags, visually distinct from rule list ── */

.preset-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.preset-row button {
  border: 0;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 12px;
  cursor: pointer;
  transition: all .15s;
}
.preset-row button.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
}

/* ── Rule groups: flat text list ── */

.rule-group-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 10px;
  padding: 0;
}

.rule-group-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 3px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  background: transparent;
  transition: all .15s;
}
.rule-group-chip:hover {
  background: var(--surface-soft);
}

.rule-group-chip:has(input:checked) {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 750;
}

.rule-group-chip:has(input:disabled) {
  opacity: .4;
  cursor: not-allowed;
}

.rule-group-chip input {
  display: none;
}

.rule-group-chip .chip-name::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--line-strong);
  margin-right: 6px;
  flex-shrink: 0;
  vertical-align: middle;
  transition: background .15s;
}
.rule-group-chip:has(input:checked) .chip-name::before {
  background: var(--accent);
}

.rule-group-status {
  font-size: 10px;
  margin-left: auto;
}
.rule-group-status.running { color: var(--accent); font-weight: 700; }
.rule-group-status.done { color: var(--ok); }
.rule-group-status.error { color: var(--danger); }

/* ── AI check panel: no border, clean layout ── */

.ai-check-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 10px;
  margin-top: 4px;
  padding: 6px 8px;
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  font-size: 11px;
}

.ai-check-label {
  color: var(--muted);
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
  width: 100%;
  margin-bottom: 2px;
}

.ai-check-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 0;
  cursor: pointer;
  font-size: 11px;
  color: var(--muted);
  transition: color .15s;
}
.ai-check-chip:has(input:checked) {
  color: var(--accent);
  font-weight: 600;
}

.ai-check-chip input {
  width: 12px;
  height: 12px;
  accent-color: var(--accent);
}

/* ── Controls ── */

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

input {
  width: 100%;
  min-height: 36px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  background: var(--surface-soft);
  color: var(--ink);
  transition: box-shadow .15s;
}
input:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

button, .head-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-h);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  background: var(--surface-soft);
  color: var(--ink);
  cursor: pointer;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s;
}
button:hover { background: var(--line); }

button.primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}
button.primary:hover { opacity: .92; }

.advanced-actions {
  margin-top: 6px;
}

.advanced-actions summary {
  cursor: pointer;
  color: var(--faint);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.8;
}

.advanced-actions summary:hover { color: var(--accent); }

.stage-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  margin-top: 4px;
}

.stage-actions button {
  min-height: var(--control-h-sm);
  padding: 0 8px;
  background: transparent;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
}
.stage-actions button:hover { background: var(--accent-soft); }

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

.status {
  min-height: 32px;
  margin-top: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

/* ── Rail file list ── */

.rail-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 6px;
}

.rail-heading {
  color: var(--faint);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.rail-actions {
  display: flex;
  gap: 4px;
}

.rail-action-btn {
  min-height: 24px;
  padding: 0 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.rail-action-btn:hover { background: var(--accent-soft); }
.rail-action-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.paper-check {
  width: 15px;
  height: 15px;
  margin: 0 6px 0 0;
  padding: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

.paper-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  overflow: auto;
  padding: 0 12px 16px;
}

.paper-item {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  background: transparent;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: background .15s;
}
.paper-item:hover { background: var(--surface-soft); }

.paper-item.active {
  background: var(--accent-soft);
}

.paper-title-row {
  display: flex;
  align-items: center;
  gap: 0;
  min-width: 0;
}

.paper-name {
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--ink);
}
.paper-item.active .paper-name { font-weight: 750; }

.paper-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
  min-width: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border-radius: 4px;
  max-width: 100%;
  padding: 1px 6px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge.a, .grade-a { background: var(--warn-soft); color: var(--warn); }
.badge.b, .grade-b { background: var(--danger-soft); color: var(--danger); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.rule-status { background: #eef0f6; color: #3b5578; }
.badge.source-source { background: var(--accent-soft); color: var(--accent); }
.badge.source-sample { background: #eef0ff; color: #3b4c94; }
.badge.ai-candidate { background: var(--warn-soft); color: #805900; }

/* ── Workspace ── */

.workspace {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 20px 22px 32px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .04em;
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.28;
}

h2 {
  font-size: 16px;
  line-height: 1.35;
}

h3 {
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted);
}

#paperMeta, .panel-head p, #issueCountLabel {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.head-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.head-actions a {
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
  background: transparent;
}
.head-actions a:hover {
  background: var(--accent-soft);
}

/* ── Overview / Metrics ── */

.overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(104px, 1fr));
  gap: 8px;
}

.metric, .current-summary {
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.metric {
  padding: 12px 14px;
}

.metric strong {
  display: block;
  font-size: 22px;
  line-height: 1.1;
}

.metric span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.current-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.current-summary strong {
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.summary-primary {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex: 0 0 auto;
}

.summary-primary span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.summary-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.summary-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.summary-pill.warn { background: var(--warn-soft); color: var(--warn); }
.summary-pill.danger { background: var(--danger-soft); color: var(--danger); }
.summary-pill.ok { background: var(--ok-soft); color: var(--ok); }

/* ── Tabs ── */

.tabs {
  display: flex;
  gap: 0;
  position: sticky;
  top: -22px;
  z-index: 4;
  margin: 14px 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.tab {
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--faint);
  font-weight: 700;
  font-size: 13px;
  padding: 8px 14px;
  transition: all .15s;
}
.tab:hover { color: var(--muted); }

.tab.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 800;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ── Panels ── */

.panel {
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.issue-panel .panel-head {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.issue-panel .filter-bar {
  justify-content: flex-start;
  margin: 0;
}

/* ── Filter bar: tab-style ── */

.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  margin: 0 0 8px;
}

.filter-group {
  display: flex;
  gap: 0;
}

.filter-sep {
  width: 1px;
  height: 16px;
  background: var(--line);
  margin: 0 8px;
  flex: 0 0 auto;
}

.filter {
  min-height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--faint);
  font-size: 12px;
  font-weight: 700;
  transition: all .15s;
}
.filter:hover {
  background: var(--surface-soft);
  color: var(--muted);
}

.filter.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
}

.queue-action {
  color: var(--accent);
  font-weight: 750;
}
.queue-action:hover { background: var(--accent-soft); }

.completion-summary {
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  padding: 7px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.sync-summary {
  margin: -2px 0 8px;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.45;
}

.search {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}
.search input {
  background: var(--surface-soft);
  font-size: 13px;
}

.issue-list {
  display: grid;
  gap: 14px;
}

.issue-section {
  display: grid;
  gap: 8px;
}

.issue-section-title {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface) 86%, var(--surface-soft));
  color: var(--muted);
  box-shadow: var(--shadow-sm);
}

.issue-section-title strong {
  color: var(--ink);
  font-size: 13px;
}

.issue-section-title span {
  font-size: 11px;
  font-weight: 700;
}

.issue-section-body {
  display: grid;
  gap: 10px;
}

/* ── Source preview ── */

.source-preview-panel {
  margin-bottom: 14px;
}

.source-preview-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  max-height: 300px;
  overflow: auto;
}

.source-preview-item {
  appearance: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  justify-items: stretch;
  justify-content: stretch;
  gap: 3px;
  width: 100%;
  min-width: 0;
  min-height: 36px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  padding: 8px 10px;
  text-align: left;
}

.source-preview-item.has-issue {
  background: var(--accent-soft);
}

.source-preview-item strong {
  color: var(--ink);
  font-size: 12px;
  line-height: 1.25;
}

.source-preview-item span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.source-preview-item p {
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.compact-empty {
  padding: 14px;
}

/* ── Issue cards ── */

.issue-card {
  border: 0;
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s;
}
.issue-card:hover {
  box-shadow: var(--shadow);
}

.issue-card.grade-a { border-left-color: #c98616; }
.issue-card.grade-b { border-left-color: #b24336; }
.issue-card.rule-locked { border-top: 2px solid #8aa6c4; }
.issue-card.rule-candidate { border-top: 2px solid #d4b265; }
.issue-card.rule-manual { border-top: 2px solid #ad82bf; }
.issue-card.reviewed {
  opacity: .58;
  background: var(--surface-soft);
}

.issue-card.queue-next {
  border-left-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 97, 79, 0.1);
}

.issue-card.pulse {
  animation: issue-pulse 0.9s ease-out;
}

@keyframes issue-pulse {
  0% { box-shadow: 0 0 0 0 rgba(37, 97, 79, 0.3); }
  100% { box-shadow: 0 0 0 8px rgba(37, 97, 79, 0); }
}

.issue-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.issue-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
}

.jump-btn {
  flex: 0 0 auto;
  min-height: 26px;
  padding: 0 8px;
  background: transparent;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}
.jump-btn:hover { background: var(--accent-soft); }

.issue-card.reviewed .jump-btn {
  color: var(--faint);
}

.issue-title {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.rule {
  font-weight: 800;
}

.issue-id {
  color: var(--faint);
  font-size: 11px;
}

.issue-evidence {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
}

.issue-problem-label {
  display: none;
}

.issue-location {
  margin: 4px 0 6px;
  color: var(--ink);
  line-height: 1.45;
}

.issue-location-title {
  display: block;
  font-size: 14px;
  font-weight: 800;
}

.issue-location-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.issue-location-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.issue-location-grid span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Issue body: vertical layout, no borders ── */

.issue-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}

.issue-block {
  min-width: 0;
  overflow: auto;
  border-radius: 0;
  background: transparent;
  padding: 0;
  font-size: 13px;
  line-height: 1.55;
}

.issue-block-label {
  display: block;
  margin-bottom: 3px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.issue-fix {
  color: var(--ok);
}

.issue-source {
  margin-top: 8px;
  max-height: 96px;
  overflow: auto;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  padding: 6px 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.issue-source summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
}

.issue-action {
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  padding: 6px 10px;
  color: var(--accent);
  font-size: 13px;
  line-height: 1.45;
}

.issue-card.reviewed .issue-action,
.issue-card.reviewed .issue-evidence,
.issue-card.reviewed .issue-source {
  color: var(--faint);
}

.rule-status-reason {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.issue-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 6px;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.4;
}

.verdict-state.active {
  color: var(--accent);
  font-weight: 800;
}

/* ── Verdict row: ghost buttons ── */

.verdict-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.verdict-row button {
  min-height: 28px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.verdict-row button:hover { background: var(--surface-soft); }

.verdict-row button[data-verdict="fixed"] {
  color: var(--ok);
}

.verdict-row button.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.empty {
  border-radius: var(--radius);
  padding: 24px;
  color: var(--muted);
  text-align: center;
  background: var(--surface-soft);
}

/* ── History ── */

.history-grid {
  display: grid;
  gap: 8px;
}

.history-item {
  position: relative;
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all .15s;
}
.history-item:hover {
  box-shadow: var(--shadow);
}

.history-item.viewing {
  background: var(--accent-soft);
  box-shadow: none;
}

.history-item .history-title {
  font-weight: 750;
  font-size: 14px;
  color: var(--ink);
}

.history-item .history-stats {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.history-item .history-meta {
  display: flex;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.history-item .history-date {
  color: var(--faint);
  font-size: 11px;
}

.history-item .history-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  min-height: 22px;
  min-width: 22px;
  padding: 0 4px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--faint);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: all .15s;
}
.history-item:hover .history-delete {
  opacity: 1;
}
.history-item .history-delete:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

/* ── Cross dedup ── */

.cross-dedup-list {
  display: grid;
  gap: 8px;
}

.cross-dedup-pair {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  font-size: 13px;
}

.cross-dedup-pair strong {
  color: var(--ink);
}

.cross-dedup-pair .dedup-papers {
  color: var(--muted);
  font-size: 12px;
}

.cross-dedup-pair .dedup-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.cross-dedup-pair .dedup-content {
  color: var(--muted);
  font-size: 12px;
  white-space: pre-wrap;
}

/* ── Lists ── */

.batch-list, .summary-list, .compact-list, .arrangement-list {
  display: grid;
  gap: 8px;
}

.summary-item, .batch-item, .example-item, .arrangement-item {
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.45;
}

.summary-item {
  cursor: pointer;
}

.summary-item.active {
  background: var(--accent-soft);
  box-shadow: none;
}

.summary-item strong, .batch-item strong, .example-item strong, .arrangement-item strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}

.summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.arrangement-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.arrangement-item {
  min-height: 134px;
}

.arrangement-meta {
  display: grid;
  gap: 4px;
  color: var(--muted);
}

.gap-panel {
  margin-top: 14px;
}

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

.evidence-grid .panel:last-child {
  grid-column: 1 / -1;
}

.eval-cols {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

ul {
  margin: 0;
  padding-left: 18px;
}

li {
  margin-bottom: 7px;
  line-height: 1.55;
}

.validation-box {
  min-height: 42px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  padding: 10px;
  font-size: 13px;
  line-height: 1.5;
}

.validation-box.pass { background: var(--ok-soft); }
.validation-box.fail { background: var(--danger-soft); }
.validation-summary { font-weight: 800; margin-bottom: 6px; }

/* ── PDF panel ── */

.pdf-panel {
  display: none;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100vh;
  box-shadow: -1px 0 0 var(--line);
  background: var(--surface);
  padding: 14px;
  overflow: hidden;
}

body.has-pdf .pdf-panel {
  display: flex;
}

.pdf-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex: 0 0 auto;
  margin-bottom: 12px;
}

.pdf-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.pdf-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.pdf-controls button {
  min-height: var(--control-h-sm);
  padding: 0 8px;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
}

.pdf-image-wrap {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  border-radius: var(--radius);
  background: var(--surface-soft);
  overflow: auto;
}

.pdf-empty {
  display: grid;
  place-items: center;
  min-height: 220px;
  height: 100%;
  padding: 24px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

#pdfPreviewImage {
  display: block;
  width: 100%;
  height: auto;
}

pre {
  min-height: 520px;
  margin: 0;
  overflow: auto;
  border-radius: var(--radius);
  background: #1d2521;
  color: #eff7f3;
  padding: 16px;
  white-space: pre-wrap;
  line-height: 1.6;
}

/* ── Responsive ── */

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 280px minmax(0, 1fr);
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }
  .overview, .evidence-grid { grid-template-columns: 1fr; }
  .metric-row, .arrangement-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pdf-panel {
    grid-column: 1 / -1;
    height: min(78vh, 760px);
    box-shadow: 0 -1px 0 var(--line);
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: flex;
    flex-direction: column;
    height: auto;
  }
  .workspace { order: 1; }
  .pdf-panel { order: 2; }
  .rail { order: 3; }
  .rail { max-height: none; }
  .paper-list { max-height: 300px; }
  .workspace { padding: 16px; }
  .page-head, .panel-head { display: grid; }
  .metric-row, .arrangement-list, .eval-cols { grid-template-columns: 1fr; }
  .issue-meta { grid-template-columns: 1fr; }
  .issue-top, .pdf-head { display: grid; }
  .issue-actions, .filters, .pdf-controls { justify-content: flex-start; }
  .issue-body { grid-template-columns: 1fr; }
  .current-summary { display: grid; }
  .source-preview-list { grid-template-columns: 1fr; }
  .pdf-panel { height: 72vh; }
}

/* ── Login page ── */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  width: 380px;
  max-height: 80vh;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-title {
  font-size: 22px;
  font-weight: 750;
  color: var(--ink);
  margin: 0;
}

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

.login-search input {
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  font-size: 14px;
  outline: none;
}

.login-search input:focus {
  box-shadow: 0 0 0 2px rgba(59,130,246,.25);
}

.login-colleague-list {
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.login-colleague-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink);
  text-align: left;
}

.login-colleague-item:hover {
  background: var(--surface-soft);
}

.login-uid {
  font-size: 12px;
  color: var(--faint);
  font-family: var(--mono);
}

.login-status {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  min-height: 20px;
}

.login-dev-btn {
  padding: 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--faint);
  font-size: 12px;
  cursor: pointer;
}

.login-dev-btn:hover {
  background: var(--line);
}

/* ── User info bar ── */

.user-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.logout-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.logout-btn:hover {
  background: var(--line);
  color: var(--ink);
}
