:root {
  --bg: #fafafa;
  --fg: #1a1a1a;
  --muted: #57606a;          /* bumped from #666 → WCAG-AA on white */
  --accent: #0366d6;
  --accent-hover: #0258b8;
  --error: #b91c1c;          /* bumped from #cb2431 → still red, less neon */
  --error-bg: #fee2e2;       /* tint background for priority-high badge */
  --success: #16a34a;        /* bumped from #28a745 → slightly deeper */
  --success-bg: #dcfce7;
  --warning: #b45309;        /* deep amber, used as text on tinted bg */
  --warning-bg: #fef3c7;     /* light amber tint */
  --neutral-bg: #f1f5f9;     /* light slate for priority-low tint */
  --neutral-fg: #334155;
  --border: #e1e4e8;
  --code-bg: #f6f8fa;
  --diff-add: #e6ffed;
  --diff-remove: #ffeef0;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.5;
}
code { background: var(--code-bg); padding: 0.1em 0.3em; border-radius: 3px; font-size: 90%; }
.muted { color: var(--muted); font-size: 0.9em; }
.error { color: var(--error); }

/* Login */
.login {
  max-width: 30em;
  margin: 4em auto;
  padding: 2em;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
}
.login h1 { margin-top: 0; }
.login-button {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  margin-top: 1em;
  padding: 0.6em 1.2em;
  background: #24292f;
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.95em;
}
.login-button:hover { background: #1b1f23; }
.login-button svg { width: 1.4em; height: 1.4em; fill: white; }

/* Access-denied panel — same card as login, but left-aligned and
   bigger so the gating explanation + request instructions read
   comfortably instead of being centered marketing copy. */
.login.access-denied { text-align: left; max-width: 38em; }
.access-denied-headline { font-weight: 600; }
.access-denied-details { font-size: 0.95em; line-height: 1.5; }
.access-denied-details p { margin: 0.8em 0; }
.access-denied-details code { background: var(--code-bg); padding: 0.05em 0.3em; border-radius: 3px; }
.login.access-denied .login-button { display: block; margin: 1.5em auto 0; text-align: center; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 1em;
  padding: 0.5em 1em;
  background: white;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.topbar .brand { font-weight: 600; }
.topbar .tabs { display: flex; gap: 0.25em; }
.topbar .tab {
  padding: 0.3em 0.8em;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95em;
}
.topbar .tab.active { color: var(--fg); border-color: var(--border); background: var(--code-bg); }
.topbar #session-info { flex: 1; min-width: 12em; }
.topbar #user-info { min-width: 10em; }
.topbar button {
  padding: 0.3em 0.8em;
  background: white;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}
.topbar button:disabled { opacity: 0.5; cursor: not-allowed; }
#finish-session { background: var(--success); color: white; border-color: var(--success); }
#finish-session:disabled { background: white; color: var(--fg); }

/* Layout */
.layout { display: flex; height: calc(100vh - 50px); }
.panel { display: flex; flex: 1; min-height: 0; }
.panel[hidden] { display: none; }
.sidebar {
  width: 20em;
  border-right: 1px solid var(--border);
  background: white;
  overflow-y: auto;
  padding: 1em;
  flex-shrink: 0;
}
.sidebar h2 { font-size: 1em; margin: 0 0 0.5em 0; }
.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar li {
  padding: 0.4em 0.6em;
  border-radius: 4px;
  cursor: pointer;
}
.sidebar li:hover { background: var(--code-bg); }
.sidebar li.active { background: var(--accent); color: white; }
.sidebar .slug-group { padding: 0; }
.sidebar .slug-header {
  display: block;
  padding: 0.4em 0.6em;
  font-size: 0.85em;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  border-radius: 4px;
}
.sidebar .slug-header:hover { background: var(--code-bg); color: var(--fg); }
.sidebar .slug-header::before {
  content: "▾";
  display: inline-block;
  width: 1em;
  margin-right: 0.3em;
  transition: transform 0.15s ease;
}
.sidebar .slug-group.collapsed .slug-header::before { content: "▸"; }
.sidebar .slug-group.collapsed .slug-files { display: none; }
.sidebar .slug-files { list-style: none; padding: 0 0 0 0.6em; margin: 0; }
.sidebar li.active .slug-header { color: rgba(255,255,255,0.7); }

.content { flex: 1; padding: 1em 2em; overflow-y: auto; }
.content-wide { padding: 2em; max-width: 80em; }

/* Transcript */
.transcript-header {
  display: flex;
  align-items: baseline;
  gap: 1em;
  margin-bottom: 1em;
  padding-bottom: 1em;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.transcript-header .path { font-family: monospace; font-size: 0.9em; color: var(--muted); }

.turn {
  padding: 0.75em 0;
  border-bottom: 1px solid var(--border);
}
.turn-header {
  display: flex;
  align-items: center;
  gap: 0.6em;
  font-size: 0.85em;
  color: var(--muted);
  margin-bottom: 0.25em;
  flex-wrap: wrap;
}
.turn-header .save-turn {
  margin-left: auto;
  padding: 0.2em 0.7em;
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85em;
}
.turn-header .save-turn:hover { background: var(--accent-hover); }
.turn-header .save-status { font-size: 0.8em; }
.review-marker {
  background: var(--code-bg);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  font-size: 0.85em;
}
.turn-asr { background: var(--code-bg); padding: 0.5em; border-radius: 4px; white-space: pre-wrap; margin: 0.5em 0; }
.turn-textarea {
  width: 100%;
  min-height: 4em;
  padding: 0.5em;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 1em;
  resize: vertical;
  margin: 0.3em 0;
}
.turn-textarea:focus { outline: none; border-color: var(--accent); }

/* Glossary */
.suggestions { list-style: none; padding: 0; }
.suggestion {
  padding: 1em;
  margin-bottom: 0.5em;
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  border-left: 4px solid var(--border);
}
.suggestion.priority-high { border-left-color: var(--error); }
.suggestion.priority-medium { border-left-color: var(--warning); }
.suggestion.priority-low { border-left-color: var(--neutral-fg); }
.suggestion.accepted { opacity: 0.55; border-left-color: var(--success); background: var(--success-bg); }
.suggestion.rejected { opacity: 0.45; text-decoration: line-through; border-left-color: var(--muted); }
.suggestion-header { display: flex; gap: 0.6em; align-items: baseline; margin-bottom: 0.5em; }
.suggestion-header .priority {
  font-size: 0.75em;
  padding: 0.15em 0.55em;
  border-radius: 10px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.priority-high { background: var(--error-bg); color: var(--error); }
.priority-medium { background: var(--warning-bg); color: var(--warning); }
.priority-low { background: var(--neutral-bg); color: var(--neutral-fg); }
.suggestion-en { color: var(--success); margin: 0.5em 0; font-style: italic; font-weight: 500; }
.suggestion-input {
  width: 20em;
  padding: 0.4em;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-right: 0.5em;
}
.suggestion button {
  padding: 0.3em 0.8em;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  background: white;
}
.suggestion .accept-btn { background: var(--success); color: white; border-color: var(--success); }
.suggestion .reject-btn { background: white; color: var(--error); border-color: var(--error); }
.suggestion-status { margin-left: 0.5em; }

/* Diff */
.diff-form { display: flex; align-items: center; gap: 0.5em; margin-bottom: 1em; flex-wrap: wrap; }
.diff-form input { padding: 0.4em; border: 1px solid var(--border); border-radius: 4px; min-width: 30em; font-family: monospace; }
.diff-form button { padding: 0.4em 1em; background: var(--accent); color: white; border: 0; border-radius: 4px; cursor: pointer; }
.diff-file { background: white; border: 1px solid var(--border); border-radius: 4px; padding: 1em; margin-bottom: 1em; }
.diff-file h3 { margin: 0 0 0.5em 0; font-family: monospace; font-size: 0.9em; }
.diff-file pre {
  background: var(--code-bg);
  padding: 0.75em;
  border-radius: 4px;
  font-size: 0.85em;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
}

/* Admin */
.admin-section { background: white; border: 1px solid var(--border); border-radius: 4px; padding: 1.5em; margin-bottom: 1em; }
.admin-section h2 { margin: 0 0 1em 0; font-size: 1.1em; }
.admin-stats { display: grid; grid-template-columns: max-content 1fr; gap: 0.4em 1.5em; margin: 0; }
.admin-stats dt { color: var(--muted); font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.05em; }
.admin-stats dd { margin: 0; font-family: monospace; }
.admin-history { width: 100%; border-collapse: collapse; }
.admin-history th, .admin-history td { padding: 0.5em 0.75em; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9em; }
.admin-history th { background: var(--code-bg); font-weight: 600; font-size: 0.8em; text-transform: uppercase; color: var(--muted); }
.admin-history td { font-family: monospace; }
.admin-history .action { padding: 0.1em 0.5em; border-radius: 3px; font-size: 0.85em; }
.action-sync-completed { background: var(--success); color: white; }
.action-sync-failed { background: var(--error); color: white; }
.action-sync-request { background: var(--code-bg); color: var(--fg); }

/* PRs */
.pr-list { list-style: none; padding: 0; }
.pr-row {
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.75em 1em;
  margin-bottom: 0.5em;
  cursor: pointer;
}
.pr-row:hover { border-color: var(--accent); }
.pr-row-main { display: flex; gap: 0.5em; align-items: baseline; margin-bottom: 0.3em; }
.pr-row-meta { display: flex; gap: 0.5em; flex-wrap: wrap; font-size: 0.85em; }
.badge {
  display: inline-block;
  padding: 0.1em 0.5em;
  border-radius: 10px;
  font-size: 0.75em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  background: var(--code-bg);
  color: var(--fg);
}
.badge-approve { background: var(--success); color: white; }
.badge-changes { background: var(--error); color: white; }
.badge-approved { background: var(--success); color: white; }
.badge-contested { background: var(--error); color: white; }
.badge-conflict { background: #d29922; color: white; }
.badge-voted { background: var(--accent); color: white; }

.pr-detail { background: white; border: 1px solid var(--border); border-radius: 4px; padding: 1.5em; margin-top: 1em; }
.pr-detail-header { display: flex; align-items: baseline; gap: 1em; margin-bottom: 0.5em; }
.pr-detail-header h2 { margin: 0; }
.pr-detail-meta { display: flex; gap: 1em; flex-wrap: wrap; padding-bottom: 1em; border-bottom: 1px solid var(--border); margin-bottom: 1em; font-size: 0.9em; }
.pr-reviews { width: 100%; border-collapse: collapse; margin: 0.5em 0; }
.pr-reviews th, .pr-reviews td { padding: 0.4em 0.6em; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9em; }
.pr-reviews th { background: var(--code-bg); font-size: 0.8em; text-transform: uppercase; color: var(--muted); }
.dismiss-review-btn { padding: 0.2em 0.6em; background: white; color: var(--error); border: 1px solid var(--error); border-radius: 4px; cursor: pointer; font-size: 0.85em; }
.vote-panel { display: flex; gap: 0.5em; align-items: center; flex-wrap: wrap; }
.vote-panel textarea { flex: 1; min-width: 20em; padding: 0.4em; border: 1px solid var(--border); border-radius: 4px; font-family: inherit; resize: vertical; }
.vote-panel button { padding: 0.4em 0.8em; border: 0; border-radius: 4px; cursor: pointer; }
.vote-panel .vote-pro { background: var(--success); color: white; }
.vote-panel .vote-con { background: var(--error); color: white; }
.vote-status { margin-left: 0.5em; }

/* Conceptual Maps */
.maps-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(28em, 1fr)); gap: 1em; }
.map-card { background: white; border: 1px solid var(--border); border-radius: 4px; padding: 1.25em; }
.map-card h3 { margin: 0 0 0.25em 0; }
.map-card p { margin: 0.5em 0; }
.map-nodes { display: flex; flex-wrap: wrap; gap: 0.4em; margin-top: 0.5em; }
.node {
  background: var(--code-bg);
  padding: 0.2em 0.6em;
  border-radius: 10px;
  font-size: 0.85em;
  font-family: monospace;
}

/* Suggestion (rich Nathan Brine context) */
.suggestion details { margin: 0.5em 0; }
.suggestion details summary { cursor: pointer; padding: 0.3em 0; }
.suggestion details label {
  display: block;
  margin: 0.4em 0;
  font-size: 0.85em;
  color: var(--muted);
}
.suggestion details input,
.suggestion details textarea {
  display: block;
  width: 100%;
  margin-top: 0.2em;
  padding: 0.4em;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.95em;
  resize: vertical;
}

/* Transcript header: title + path + turn count + actions on the right. */
.transcript-header {
  display: flex;
  align-items: baseline;
  gap: 0.8em;
  flex-wrap: wrap;
}
.transcript-header h1 { margin: 0; }
.transcript-header-actions { margin-left: auto; }
.btn {
  display: inline-block;
  padding: 0.35em 0.9em;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
  font-size: 0.9em;
  background: white;
  color: var(--fg);
}
.btn-primary { background: var(--fg); color: white; border-color: var(--fg); }
.btn-primary:hover { background: #000; border-color: #000; }

/* Audio: persistent player bar + per-turn play button. Pure
   client-side — the curator picks a local audio file via the
   browser's native file picker; the bar + per-turn buttons give
   in-browser playback of that local file. */

.turn-play {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 0.5em;
  font-size: 0.85em;
  cursor: pointer;
  margin-left: 0.4em;
  color: var(--fg);
  line-height: 1.4;
}
.turn-play:hover:not(:disabled) { border-color: var(--fg); }
.turn-play:disabled { opacity: 0.4; cursor: not-allowed; }
.turn-play.playing {
  background: var(--fg);
  color: white;
  border-color: var(--fg);
}

.audio-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.5em 1em;
  background: white;
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.05);
  z-index: 10;
}
.audio-bar input[type="range"] { flex: 1; min-width: 6em; }
.audio-bar select {
  padding: 0.2em 0.4em;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: white;
  font-size: 0.9em;
}
.audio-bar #audio-time { font-variant-numeric: tabular-nums; min-width: 8em; text-align: right; }
.audio-btn {
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25em 0.6em;
  cursor: pointer;
  font-size: 0.9em;
  line-height: 1.2;
}
.audio-btn:hover { border-color: var(--fg); }
.audio-btn-toggle.active {
  background: var(--fg);
  color: white;
  border-color: var(--fg);
}
/* Lift the main layout so the fixed audio bar doesn't cover the
   last row of the transcript content when the bar is visible. */
body.audio-active .layout { padding-bottom: 4em; }
