/* QBank Converter — modern minimalist operator UI (PRD §8.1).
 * Brilliant Board Review brand: cardinal red accent, light theme, one radius scale.
 */

/* The `hidden` attribute must always win. Without this, elements that also
 * carry a class with an explicit `display` (.flex-between, .btn-group, .card,
 * grids…) ignore `hidden` — the UA rule [hidden]{display:none} has lower
 * specificity than a class selector — and stay visible when JS sets .hidden. */
[hidden] { display: none !important; }

:root {
  /* neutrals — zinc */
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-secondary: #3f3f46;   /* zinc-700 — readable body-secondary */
  --text-muted: #6b6b73;       /* darkened from zinc-400 (#a1a1aa) which failed contrast */

  /* single accent — Brilliant Board cardinal red (#8C1515), locked app-wide */
  --accent: #8c1515;
  --accent-hover: #6e1010;
  --accent-light: #f7e8e8;
  --accent-ring: rgba(140, 21, 21, 0.18);

  /* semantic */
  --success: #15803d;
  --success-light: #dcfce7;
  --warning: #b45309;
  --warning-light: #fef3c7;
  --danger: #b91c1c;
  --danger-light: #fee2e2;

  /* shape & depth */
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(24, 24, 27, 0.05);
  --shadow-lg: 0 8px 24px rgba(24, 24, 27, 0.08);

  /* Inter is the Brilliant Board identity font; falls back to the system sans
     stack when Inter isn't available locally (no external font dependency). */
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono",
          Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* This app is intentionally light-theme only — declare it so a dark-mode
   browser renders form controls/scrollbars in light and never auto-inverts. */
html { font-size: 16px; -webkit-font-smoothing: antialiased; color-scheme: light; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h2 { letter-spacing: -0.02em; }

code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--surface-2);
  border-radius: 4px;
  padding: 1px 5px;
}

/* ── layout ─────────────────────────────────────────────────── */

.container { max-width: 1392px; margin: 0 auto; padding: 0 24px; width: 100%; }

/* ── header ─────────────────────────────────────────────────── */

header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  height: 68px;
  display: flex;
  align-items: center;
  position: sticky; top: 0; z-index: 20;
}
header .container {
  display: flex; align-items: center; justify-content: space-between;
}
/* Brand lockup: Brilliant Board logo + the tool name it powers. */
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 48px; width: auto; display: block; }
.brand-sep { width: 1px; height: 24px; background: var(--border-strong); }
.brand-tool {
  font-size: 1.0625rem; font-weight: 750; letter-spacing: -0.015em;
  color: var(--text);
}
/* "Converter" in cardinal red — echoes the logo + the sign-in title. */
.brand-tool span { color: var(--accent); }
header nav { display: flex; gap: 4px; }
header nav a {
  font-size: 0.875rem; color: var(--text-secondary);
  padding: 6px 12px; border-radius: var(--radius-sm);
}
header nav a:hover {
  color: var(--text); background: var(--surface-2); text-decoration: none;
}
/* Current page — teal accent, so "you are here" reads distinctly from hover. */
header nav a.active {
  color: var(--accent); font-weight: 600;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
/* Signed-in avatar + account dropdown, right-aligned after the workflow links. */
header nav .nav-user-menu {
  position: relative; display: inline-flex; align-items: center;
  margin-left: 8px; padding-left: 12px; border-left: 1px solid var(--border);
}
header nav .nav-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-weight: 650; font-size: 0.875rem;
  border: none; padding: 0; cursor: pointer; text-transform: uppercase;
  transition: box-shadow 0.12s ease;
}
header nav .nav-avatar:hover,
header nav .nav-avatar[aria-expanded="true"] {
  box-shadow: 0 0 0 3px var(--accent-ring);
}
/* Dropdown card — anchored to the avatar, above page content. */
.nav-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 240px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 0; overflow: hidden; z-index: 40;
}
.nav-dropdown-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px; background: var(--accent-light);
}
.nav-dropdown-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-weight: 650; font-size: 1rem;
  text-transform: uppercase;
}
.nav-dropdown-id { min-width: 0; }
.nav-dropdown-name {
  font-weight: 650; color: var(--text); font-size: 0.9375rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-dropdown-role {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 3px;
  font-size: 0.8125rem; font-weight: 600; color: var(--accent);
}
.nav-dropdown-role svg { width: 14px; height: 14px; }
.nav-dropdown-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 12px 16px; border: none; background: none; cursor: pointer;
  font-size: 0.875rem; font-weight: 550; color: var(--danger);
}
.nav-dropdown-item svg { width: 16px; height: 16px; flex: 0 0 auto; }
.nav-dropdown-item:hover { background: var(--danger-light); }

/* Hamburger toggle — hidden on desktop, shown on tablet/mobile. */
.nav-toggle {
  display: none; flex-direction: column; justify-content: center; gap: 4px;
  width: 38px; height: 38px; padding: 8px; background: none; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.nav-toggle span {
  display: block; height: 2px; width: 100%; background: var(--text);
  border-radius: 2px; transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 820px) {
  .nav-toggle { display: flex; }
  header .container { position: relative; }
  header nav {
    position: absolute; top: calc(100% + 8px); right: 0;
    min-width: 220px; flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 8px; box-shadow: var(--shadow-lg);
    z-index: 30;
  }
  header nav:not(.open) { display: none; }
  header nav a { padding: 10px 12px; font-size: 0.9375rem; }
  /* In the collapsed mobile menu, stack the account card inline (no floating
     dropdown) so it flows with the other links. */
  header nav .nav-user-menu {
    border-left: none; border-top: 1px solid var(--border);
    margin: 4px 0 0; padding: 8px 0 0; display: block;
  }
  header nav .nav-avatar { display: none; }  /* the card header already shows it */
  .nav-dropdown {
    position: static; box-shadow: none; border: none; padding: 0;
    min-width: 0; overflow: visible;
  }
  .nav-dropdown[hidden] { display: block; }  /* always visible when stacked */
  .nav-dropdown-head { border-radius: var(--radius-sm); padding: 12px; }
  .nav-dropdown-item { padding: 12px 4px; }
}

/* Narrow phones: keep the logo, drop the tool label so the header stays tidy. */
@media (max-width: 460px) {
  .brand-sep, .brand-tool { display: none; }
  .brand-logo { height: 42px; }
}

/* ── login / sign-in ────────────────────────────────────────── */

.login-brand { text-align: center; margin: 56px 0 28px; }
.login-logo { height: 76px; width: auto; }
.login-title {
  margin-top: 18px; font-size: 1.5rem; font-weight: 750;
  letter-spacing: -0.02em; color: var(--text); line-height: 1.15;
}
/* Two-tone product name — "Converter" in cardinal red echoes the logo. */
.login-title span { color: var(--accent); }
.login-sub {
  margin-top: 8px; font-size: 0.875rem; color: var(--text-muted);
}

footer {
  text-align: center;
  padding: 40px 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

/* ── page headings ──────────────────────────────────────────── */

.page-title { font-size: 1.5rem; font-weight: 700; margin: 40px 0 6px; }
.page-lede { font-size: 0.9375rem; color: var(--text-secondary); margin-bottom: 28px; }

/* ── cards ──────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 1rem; font-weight: 650; margin-bottom: 16px;
}
/* Numbered STEP headings (New Conversion) — emphasized so the process reads as
   clear, distinct steps: teal badge + larger bold title + a divider rule. */
.card-title:has(.step-no) {
  display: flex; align-items: center; gap: 12px;
  font-size: 1.1875rem; font-weight: 700; letter-spacing: -0.01em;
  margin: -2px 0 20px; padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.card-title .step-no {
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 0.875rem; font-weight: 700;
  box-shadow: 0 1px 2px var(--accent-ring);
}

/* ── hero (index) ───────────────────────────────────────────── */

/* Wide enough that all four hero buttons sit on one desktop line; the heading
   and paragraph keep their own readable max-width. The button row still
   flex-wraps as the viewport narrows. */
.hero { text-align: left; padding: 72px 0 40px; max-width: 100%; }
.hero h2 {
  font-size: 2.125rem; font-weight: 750; line-height: 1.15;
  margin-bottom: 14px; max-width: 620px;
}
.hero p {
  font-size: 1.0625rem; color: var(--text-secondary); margin-bottom: 28px;
  text-align: justify;
}
.hero .btn { font-size: 0.9375rem; padding: 0 22px; }

.steps-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px; padding-bottom: 56px;
}
.step-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.step-card .step-index {
  font-family: var(--mono); font-size: 0.75rem; color: var(--accent);
  margin-bottom: 8px; display: block;
}
.step-card h3 { font-size: 0.9375rem; font-weight: 650; margin-bottom: 6px; }
.step-card p { font-size: 0.8438rem; color: var(--text-secondary); }

/* ── buttons ─────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  /* One fixed height for EVERY button app-wide (matches .form-control), so
     mixed rows of buttons/links/inputs always line up. Size variants change
     only the font and horizontal padding, never the height. */
  height: 38px; padding: 0 20px; border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 550; font-family: var(--font);
  border: 1px solid transparent; cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease,
              transform 0.05s ease;
  text-decoration: none; line-height: 1.4; white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); text-decoration: none; }

.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-light); }

.btn-warning { background: transparent; color: var(--warning); border-color: var(--warning); }
.btn-warning:hover:not(:disabled) { background: var(--warning-light); }

.btn-sm { padding: 0 14px; font-size: 0.8125rem; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── forms ───────────────────────────────────────────────────── */

.form-group { margin-bottom: 20px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label {
  display: block; font-size: 0.875rem; font-weight: 550;
  margin-bottom: 6px;
}
.form-group .hint,
.hint {
  font-size: 0.8125rem; color: var(--text-secondary); margin-top: 5px;
  line-height: 1.5;
}
.form-control {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-size: 0.875rem; font-family: var(--font);
  background: var(--surface); color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.form-control-sm { padding: 5px 8px; font-size: 0.8125rem; }
select.form-control { cursor: pointer; }

.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.form-grid-tight {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 16px;
}

.checkbox-row {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 0.875rem; color: var(--text); cursor: pointer;
}
.checkbox-row input { margin-top: 4px; accent-color: var(--accent); }

.inline-error {
  color: var(--danger); font-size: 0.8125rem; margin-top: 8px;
}

/* ── choice cards (auth / input pickers) ────────────────────── */

.choice-row { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.choice {
  flex: 1; min-width: 210px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
  cursor: pointer; user-select: none; background: var(--surface);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.choice:hover { border-color: var(--border-strong); }
.choice.active { border-color: var(--accent); background: var(--accent-light); }
.choice input { margin-right: 8px; accent-color: var(--accent); }
.choice .choice-title { font-weight: 600; font-size: 0.9063rem; }
.choice .choice-sub { font-size: 0.8125rem; color: var(--text-secondary); margin-top: 3px; }

.subpanel { margin-top: 4px; }

.auth-status { font-size: 0.8125rem; margin-top: 6px; color: var(--text-secondary); }
.auth-status .ok { color: var(--success); font-weight: 600; }
.auth-status .warn { color: var(--warning); font-weight: 600; }
.auth-status .acct-email { font-weight: 600; color: var(--text); }
.auth-status .acct-plan {
  font-size: 0.6875rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.03em; color: var(--accent);
  background: var(--accent-light); border-radius: 999px; padding: 1px 8px;
  margin-left: 2px; vertical-align: middle;
}

/* ── scan result / small tables ─────────────────────────────── */

.scan-result { margin-top: 14px; }
.table {
  width: 100%; border-collapse: collapse; font-size: 0.8438rem;
}
.table th {
  text-align: left; padding: 7px 10px; color: var(--text-secondary);
  font-weight: 550; border-bottom: 1px solid var(--border-strong);
}
.table td { padding: 7px 10px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: none; }

/* ── framed scan result (Source step) ───────────────────────────── */
.scan-table-wrap {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--surface);
}
.scan-table-wrap .table { font-size: 0.875rem; }
.scan-table-wrap .table thead th {
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  padding: 9px 14px; font-size: 0.6875rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted);
}
.scan-table-wrap .table td { padding: 11px 14px; vertical-align: middle; }
.scan-table-wrap .table tbody tr { transition: background 0.12s ease; }
.scan-table-wrap .table tbody tr:hover { background: var(--surface-2); }
.scan-file-name { font-weight: 600; color: var(--text); }
.scan-file-sys { color: var(--text-secondary); }
.scan-qnum { font-variant-numeric: tabular-nums; font-weight: 600; }
.scan-summary {
  display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap;
  padding: 10px 14px; background: var(--surface-2);
  border-top: 1px solid var(--border);
  font-size: 0.8125rem; color: var(--text-secondary);
}
.scan-summary .sep { color: var(--border-strong); }
.scan-summary strong { color: var(--text); font-variant-numeric: tabular-nums; }
.scan-summary a { color: var(--accent); }

/* ── reviewer report ──────────────────────────────────────────────────────── */
.report-head { margin: 8px 0 24px; }
.report-head-top {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.report-title { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }

/* Metadata panel: a tinted card with a teal accent bar; label/value rows so
   each source folder and the generated time sit on their own line. */
.report-meta {
  display: grid; grid-template-columns: auto 1fr; gap: 11px 20px;
  margin: 0; padding: 15px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius); font-size: 0.8125rem;
}
.report-meta dt {
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em;
  font-size: 0.6875rem; font-weight: 700; padding-top: 2px; white-space: nowrap;
}
.report-meta dd { margin: 0; color: var(--text-secondary); }
.report-note { margin-top: 10px; font-size: 0.8125rem; color: var(--text-muted); line-height: 1.5; }
.report-source-list { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.report-source-list li { display: flex; align-items: flex-start; gap: 9px; }
.report-source-list li::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0; margin-top: 6px;
}
.report-source-list .src-path {
  font-family: var(--mono, monospace); word-break: break-all;
  color: var(--text); line-height: 1.5;
}
.report-sources { margin-top: 12px; display: flex; gap: 6px; flex-wrap: wrap; }

/* ── file upload ─────────────────────────────────────────────── */

.upload-zone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  padding: 32px; text-align: center; cursor: default;
  transition: border-color 0.15s ease, background 0.15s ease;
  background: var(--surface);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent); background: var(--accent-light);
}
.upload-zone p { color: var(--text-secondary); font-size: 0.875rem; }
.upload-zone input[type="file"] { display: none; }

.file-list { margin-top: 12px; }
.file-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; background: var(--surface-2); border-radius: var(--radius-sm);
  margin-bottom: 6px; font-size: 0.875rem;
}
.file-item .file-name { font-weight: 550; }
.file-item .file-system { color: var(--text-secondary); font-size: 0.8125rem; }
.file-item .file-remove {
  color: var(--text-muted); cursor: pointer; font-size: 1.25rem; line-height: 1;
  padding: 0 4px; border-radius: 4px;
}
.file-item .file-remove:hover { color: var(--danger); }
/* removable rows in the folder scan preview */
.cell-right { text-align: right; width: 1%; white-space: nowrap; }
.cell-center { text-align: center; }
/* `.table th` sets text-align:left (higher specificity), so re-assert on the th. */
.table th.cell-right { text-align: right; }
.table th.cell-center { text-align: center; }
.table .file-remove {
  color: var(--text-muted); cursor: pointer; font-size: 1.25rem; line-height: 1;
  padding: 0 6px; border-radius: 4px; user-select: none;
}
.table .file-remove:hover { color: var(--danger); background: var(--danger-light); }

/* ── progress ────────────────────────────────────────────────── */

.progress-bar {
  width: 100%; height: 8px; background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; background: var(--accent); border-radius: 999px;
  transition: width 0.4s ease;
}
.progress-bar-fill.success { background: var(--success); }
.progress-bar-fill.error { background: var(--danger); }

.progress-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px; margin: 16px 0;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.stat-card .stat-value {
  font-size: 1.25rem; font-weight: 700; font-family: var(--mono);
  letter-spacing: -0.01em;
}
.stat-card .stat-label {
  font-size: 0.71875rem; color: var(--text-secondary); text-transform: uppercase;
  letter-spacing: 0.05em; margin-top: 2px;
}

/* ── log panel ───────────────────────────────────────────────── */

.log-panel {
  background: #18181b; color: #d4d4d8; border-radius: var(--radius-sm);
  padding: 14px 16px; font-family: var(--mono); font-size: 0.8125rem;
  line-height: 1.55; max-height: 260px; overflow-y: auto;
}
.log-panel .log-entry { white-space: pre-wrap; word-break: break-word; }
.log-panel .log-error { color: #fca5a5; }

/* ── results ─────────────────────────────────────────────────── */

.results-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 24px;
}
.result-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
}
.result-card .result-value {
  font-size: 1.625rem; font-weight: 700; line-height: 1.2;
  font-family: var(--mono); letter-spacing: -0.02em;
}
.result-card .result-label {
  font-size: 0.71875rem; color: var(--text-secondary); text-transform: uppercase;
  letter-spacing: 0.05em; margin-top: 4px;
}
.result-card .result-sub {
  font-size: 0.75rem; color: var(--text-secondary); margin-top: 6px;
  line-height: 1.35;
}
/* Started timestamp: date over time, with a gap, so it never cramps */
.result-value .ts-date { display: block; }
.result-value .ts-time {
  display: block; margin-top: 3px;
  font-size: 0.8125rem; font-weight: 600; color: var(--text-secondary);
}

.download-list { list-style: none; }
.download-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 4px; border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.download-list li:last-child { border-bottom: none; }
.download-list li span { overflow-wrap: anywhere; }

/* ── alerts ──────────────────────────────────────────────────── */

.alert { border-radius: var(--radius); padding: 16px 20px; margin-bottom: 16px;
  font-size: 0.875rem; border: 1px solid; }
.alert-danger { border-color: var(--danger); background: var(--danger-light); color: var(--danger); }
.alert-warning { border-color: var(--warning); background: var(--warning-light); color: var(--warning); }
.alert-success { border-color: var(--success); background: var(--success-light); color: var(--success); }

/* ── badges / status ─────────────────────────────────────────── */

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 550; vertical-align: middle;
  /* Neutral pill by default so a modifier-less badge (e.g. a role tag) still
     reads as a status chip, not plain text. Colour modifiers override this. */
  background: var(--surface-2); color: var(--text-secondary);
  /* Always the sans font at normal tracking, so a badge never inherits a
     monospace / tight-letter-spacing container and looks compressed. */
  font-family: var(--font); letter-spacing: normal; white-space: nowrap;
  /* Title-case every pill (manifest found → Manifest Found, completed →
     Completed, will merge → Will Merge) app-wide. */
  text-transform: capitalize;
}
.badge-running   { background: var(--accent-light);  color: var(--accent); }
.badge-completed { background: var(--success-light); color: var(--success); }
.badge-failed    { background: var(--danger-light);  color: var(--danger); }
.badge-cancelled { background: var(--surface-2);     color: var(--text-secondary); }
.badge-pending   { background: var(--warning-light); color: var(--warning); }
.badge-paused    { background: var(--surface-2);     color: var(--text-secondary); }

/* ── responsive ──────────────────────────────────────────────── */

@media (max-width: 640px) {
  .hero { padding: 44px 0 28px; }
  .hero h2 { font-size: 1.5rem; }
  .container { padding: 0 16px; }
  .progress-stats, .results-summary { grid-template-columns: repeat(2, 1fr); }
  .choice { min-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ── utility ─────────────────────────────────────────────────── */

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 0.875rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.hidden { display: none; }

/* ── folder picker modal ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(24, 24, 27, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: min(620px, 100%);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 600; font-size: 0.9375rem; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}
.modal-close:hover { color: var(--text); }
.modal-path {
  padding: 8px 18px;
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  word-break: break-all;
}
.modal-list { overflow-y: auto; flex: 1; padding: 6px; }
.fm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
}
.fm-row:hover { background: var(--accent-light); }
.fm-up { color: var(--text-secondary); }
.fm-badge {
  font-size: 0.75rem;
  color: var(--accent);
  background: var(--accent-light);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}
.fm-empty { padding: 16px 12px; color: var(--text-muted); font-size: 0.875rem; }
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}
.fm-selected {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  word-break: break-all;
  flex: 1;
}
/* Scrollable padded body for content modals (e.g. the overwrite guard). */
.modal-body { padding: 18px; overflow-y: auto; }
.ow-files-label {
  font-size: 0.6875rem; font-weight: 650; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 7px;
}
.ow-files { list-style: none; display: flex; flex-direction: column; gap: 5px;
  max-height: 200px; overflow-y: auto; }
.ow-files li {
  font-family: var(--mono); font-size: 0.8125rem; color: var(--text-secondary);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 11px; overflow-wrap: anywhere;
}

/* ── print / PDF ──────────────────────────────────────────────────────────
   The reviewer report is rendered to PDF server-side (headless Chrome). A PDF
   page is narrower than the on-screen layout and cannot scroll, so wide tables
   would overflow and clip the right-most column (Status). Shrink the table to
   fit the page and let long names wrap so nothing is ever cut off. */
@page { margin: 12mm; }
@media print {
  html, body { background: #ffffff; }
  .container { max-width: none; padding: 0; }

  /* Fills / badge colours must actually print. */
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* Never clip a table; make it fit the printable width. word-break lets the
     column shrink so the whole table fits without overflowing the page. */
  .scan-table-wrap { overflow: visible; }
  .scan-table-wrap .table { font-size: 0.72rem; }
  .scan-table-wrap .table thead th,
  .scan-table-wrap .table td { padding: 6px 8px; }
  .table th, .table td, .scan-file-name { word-break: break-word; }

  /* Keep rows, tiles, and the meta panel from splitting across a page break. */
  tr, .result-card, .report-meta, .results-summary { break-inside: avoid; }
}

/* ── Correction review ─────────────────────────────────────────────────────*/
.review-banner { display: flex; align-items: center; justify-content: space-between;
  gap: 16px; }
.review-banner .btn { flex: 0 0 auto; }

.diff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin: 12px 0; }
.diff-col { min-width: 0; }
.diff-col-head { font-size: 0.8125rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text); margin-bottom: 6px; }
.diff-col pre { margin: 0; padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 0.8125rem; line-height: 1.5; white-space: pre-wrap;
  overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo,
  Consolas, monospace; }
.diff-line { display: block; padding: 1px 8px; border-radius: 3px; }
/* Unchanged lines sit back a little so the changed lines clearly stand out. */
.diff-eq  { color: var(--text-secondary); }
/* Changed lines: tinted block + a bold left accent bar + heavier text. */
.diff-add { background: var(--success-light); color: var(--success);
  box-shadow: inset 3px 0 0 var(--success); font-weight: 600; }
.diff-del { background: var(--danger-light); color: var(--danger);
  box-shadow: inset 3px 0 0 var(--danger); font-weight: 600; }
/* Display-only spacer drawn between question segments — never part of the text. */
.diff-gap { background: transparent; box-shadow: none; }

.review-card { margin-bottom: 16px; }
/* While Apply All Decisions is in flight the cards are read-only. */
.review-busy { pointer-events: none; opacity: 0.65; }
/* "3 of 12" chip so the reviewer always knows where they are in the queue. */
.review-serial {
  /* No uppercase transform — the label reads "1 of 2", not "1 OF 2". */
  font-size: 0.7rem; font-weight: 700; text-transform: none;
  letter-spacing: 0.04em; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 9px; margin-right: 8px;
  white-space: nowrap; vertical-align: middle;
}
.review-card.decided-accept  { border-left: 4px solid var(--success); }
.review-card.decided-edit    { border-left: 4px solid var(--accent); }
.review-card.decided-discard { border-left: 4px solid var(--warning); }
.review-card.decided-delete  { border-left: 4px solid var(--danger); }
.review-decision-tag { font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 2px 9px; border-radius: 999px; }
.review-edit-area { width: 100%; min-height: 320px; margin-top: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem; line-height: 1.5; }
/* The chosen decision button — makes it obvious which action is registered. */
.btn.is-selected { box-shadow: 0 0 0 2px var(--accent-ring); font-weight: 650; }
/* Compact stat tiles on the "Corrections applied" result card. */
.review-stats { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 4px; }
/* Tiles share the row equally (flex-basis 0 → width driven purely by the count),
   so every box is the same size regardless of its number or label length. */
.review-stat {
  flex: 1 1 120px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 16px;
}
.review-stat .v { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.review-stat .l {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); margin-top: 3px; white-space: nowrap;
}

/* Generation badge on the AI-correction column + "just regenerated" flash. */
.diff-col-head { display: flex; align-items: center; gap: 8px; }
.gen-badge {
  font-size: 0.68rem; font-weight: 650; text-transform: uppercase;
  letter-spacing: 0.03em; color: var(--accent); background: var(--accent-light);
  border-radius: 999px; padding: 2px 9px; white-space: nowrap;
}
.gen-badge.gen-working { color: var(--warning); background: var(--warning-light); }
@keyframes gen-flash {
  0%   { box-shadow: 0 0 0 3px var(--accent-ring); background: var(--accent-light); }
  100% { box-shadow: 0 0 0 0 transparent; background: transparent; }
}
.gen-flash { animation: gen-flash 1.4s ease-out; }

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