
  @import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,wght@0,400;0,600;0,700;1,400&family=DM+Sans:wght@400;500;600;700&display=swap');

  :root {
    --bg: #fafaf8;
    --surface: #ffffff;
    --border: #e2e0dc;
    --text: #1a1a18;
    --text-secondary: #6b6964;
    --accent: #2c5f2d;
    --accent-light: #e8f0e8;
    --warn: #b35c00;
    --warn-light: #fff3e0;
    --danger: #a3342a;
    --danger-light: #fde8e6;
    --info: #2a5fa3;
    --info-light: #e6eefa;
    --keep: #2c5f2d;
    --keep-light: #e8f0e8;
    --remove: #a3342a;
    --remove-light: #fde8e6;
  }

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

  body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
    overflow-x: hidden;
  }

  /* ── Layout shell ── */
  .app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
  }
  .main-panel {
    flex: 1;
    overflow-y: auto;
    min-width: 0;
    transition: flex 0.25s ease;
  }
  .side-panel {
    width: 0;
    overflow: hidden;
    border-left: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease;
    flex-shrink: 0;
  }
  .side-panel.open { width: 50vw; }
  .side-panel-bar {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: var(--text);
    color: var(--bg);
    gap: 8px;
    flex-shrink: 0;
  }
  .side-panel-bar .sp-url {
    flex: 1;
    font-size: 12px;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .side-panel-bar button {
    background: rgba(255,255,255,0.15);
    border: none;
    color: var(--bg);
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-family: 'DM Sans', sans-serif;
  }
  .side-panel-bar button:hover { background: rgba(255,255,255,0.25); }
  .side-panel iframe {
    flex: 1;
    border: none;
    width: 100%;
  }

  /* ── Left decision panel ── */
  .decision-panel {
    width: 0;
    overflow: hidden;
    border-right: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
    transition: width 0.25s ease;
    display: flex;
    flex-direction: column;
  }
  .decision-panel.open { width: 240px; }
  .decision-panel-inner {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    min-width: 240px;
  }
  .dp-toggle {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 6px 6px 0;
    padding: 8px 4px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    color: var(--text-secondary);
    transition: left 0.25s ease;
    box-shadow: 2px 0 6px rgba(0,0,0,0.06);
  }
  .dp-toggle.shifted { left: 240px; }
  .dp-toggle:hover { color: var(--text); background: var(--bg); }
  .dp-heading {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 10px;
  }
  .dp-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
    padding: 5px 6px;
  }
  .dp-stat:hover { background: var(--bg); }
  .dp-stat .dp-label { color: var(--text); }
  .dp-stat .dp-count { font-weight: 700; font-variant-numeric: tabular-nums; }
  .dp-stat.keep .dp-count { color: var(--keep); }
  .dp-stat.cut .dp-count { color: var(--remove); }
  .dp-stat.pending .dp-count { color: var(--text-secondary); }
  .dp-divider { border-top: 1px solid var(--border); margin: 10px 0; }
  .dp-bar {
    height: 6px;
    border-radius: 3px;
    background: var(--bg);
    overflow: hidden;
    margin: 8px 0 12px;
    display: flex;
  }
  .dp-bar-keep { background: var(--keep); }
  .dp-bar-cut { background: var(--remove); }
  .dp-bar-pending { background: var(--border); }
  .dp-book-item {
    padding: 5px 6px;
    border-radius: 4px;
    cursor: pointer;
    border-bottom: 1px solid #f0efed;
  }
  .dp-book-item:hover { background: var(--bg); }
  .dp-book-item:last-child { border-bottom: none; }
  .dp-book-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
  }
  .dp-book-roman { font-size: 10px; font-weight: 700; color: var(--text-secondary); letter-spacing: 0.02em; }
  .dp-book-title { font-size: 11px; color: var(--text); line-height: 1.3; margin-top: 1px; }
  .dp-book-counts { display: flex; gap: 6px; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 10px; flex-shrink: 0; }
  .dp-book-counts .bk { color: var(--keep); }
  .dp-book-counts .bc { color: var(--remove); }
  .dp-book-counts .bp { color: var(--text-secondary); }

  /* ── Diversity section in decision panel ── */
  .dp-diversity-dim { margin-bottom: 8px; }
  .dp-diversity-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 2px;
  }
  .dp-diversity-label .dp-skew-warn { color: var(--warn); font-size: 9px; }
  .dp-stacked-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--bg);
  }
  .dp-stacked-bar > div { transition: width 0.3s ease; min-width: 0; }
  .dp-diversity-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 8px;
    font-size: 9px;
    color: var(--text-secondary);
    margin-top: 2px;
  }
  .dp-diversity-legend span::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 3px;
    vertical-align: middle;
  }

  /* ── Diversity modal ── */
  .diversity-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
  }
  .diversity-modal.open { display: flex; }
  .diversity-modal-content {
    background: var(--surface);
    border-radius: 12px;
    padding: 28px;
    max-width: 700px;
    width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  }
  .div-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
  }
  .div-modal-header h2 { font-size: 16px; font-weight: 700; }
  .div-scope-toggle {
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
  }
  .div-scope-toggle button {
    padding: 4px 12px;
    font-size: 11px;
    font-family: 'DM Sans', sans-serif;
    border: none;
    background: var(--surface);
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
  }
  .div-scope-toggle button.active { background: var(--text); color: var(--bg); }
  .div-scope-toggle button:not(:last-child) { border-right: 1px solid var(--border); }
  .div-dim-section { margin-bottom: 24px; }
  .div-dim-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); margin-bottom: 10px; }
  .div-row {
    display: grid;
    grid-template-columns: 120px 1fr 44px 44px 50px;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 12px;
    border-bottom: 1px solid #f5f4f2;
  }
  .div-row:last-child { border-bottom: none; }
  .div-row-label { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .div-bar-cell { position: relative; height: 14px; border-radius: 3px; background: var(--bg); overflow: hidden; }
  .div-bar-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; transition: width 0.3s ease; }
  .div-bar-baseline { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text); opacity: 0.35; border-radius: 1px; }
  .div-pct { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 11px; }
  .div-delta { text-align: right; font-variant-numeric: tabular-nums; font-size: 10px; font-weight: 600; }
  .div-delta.pos { color: var(--accent); }
  .div-delta.neg { color: var(--danger); }
  .div-delta.neutral { color: var(--text-secondary); }
  .div-count { text-align: right; font-variant-numeric: tabular-nums; font-size: 10px; color: var(--text-secondary); }

  /* ── Header ── */
  .header {
    background: var(--text);
    color: var(--bg);
    padding: 24px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .header h1 {
    font-family: 'Source Serif 4', serif;
    font-size: 24px;
    font-weight: 700;
  }
  .header .meta { font-size: 12px; opacity: 0.6; }
  .header-actions { display: flex; gap: 8px; }
  .header-actions button {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--bg);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
  }
  .header-actions button:hover { background: rgba(255,255,255,0.22); }

  /* ── Dashboard ── */
  .dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border);
  }
  .stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    cursor: pointer;
    transition: border-color 0.15s;
  }
  .stat-card:hover { border-color: var(--accent); }
  .stat-card.active { border-color: var(--accent); background: var(--accent-light); }
  .stat-card .label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 2px;
  }
  .stat-card .value {
    font-family: 'Source Serif 4', serif;
    font-size: 22px;
    font-weight: 700;
  }
  .stat-card .sub { font-size: 11px; color: var(--text-secondary); }

  /* ── Filters bar ── */
  .filters {
    padding: 10px 32px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  }
  .filters select, .filters input[type="text"] {
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg);
    color: var(--text);
  }
  .filters input[type="text"] { width: 180px; }
  .filter-group { display: flex; align-items: center; gap: 4px; position: relative; }
  .filter-group label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
  }

  /* Multi-select dropdown */
  .ms-trigger {
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    padding: 5px 22px 5px 8px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    min-width: 70px;
    position: relative;
    user-select: none;
  }
  .ms-trigger::after {
    content: '▾';
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: var(--text-secondary);
  }
  .ms-trigger.has-selection {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
  }
  .ms-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
    z-index: 200;
    min-width: 160px;
    max-height: 260px;
    overflow-y: auto;
    padding: 4px 0;
  }
  .ms-dropdown.open { display: block; }
  .ms-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.1s;
  }
  .ms-option:hover { background: #f4f3f1; }
  .ms-option input[type="checkbox"] {
    margin: 0;
    accent-color: var(--accent);
  }
  .ms-clear {
    padding: 5px 10px;
    font-size: 11px;
    color: var(--info);
    cursor: pointer;
    border-top: 1px solid #f0efed;
    text-align: center;
  }
  .ms-clear:hover { background: #f4f3f1; }
  .result-count { margin-left: auto; font-size: 12px; color: var(--text-secondary); }
  .clear-filters {
    font-size: 11px;
    color: var(--info);
    cursor: pointer;
    text-decoration: underline;
    background: none;
    border: none;
    font-family: 'DM Sans', sans-serif;
  }

  /* ── Column headers ── */
  .col-headers {
    display: grid;
    grid-template-columns: 120px minmax(180px, 1fr) 82px 46px 42px 42px 58px 54px 64px 36px;
    align-items: center;
    padding: 8px 16px 8px 32px;
    gap: 6px;
    border-bottom: 1px solid var(--border);
    background: #f4f3f1;
    position: sticky;
    top: 42px;
    z-index: 99;
  }
  .col-header {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
  }
  .col-header:hover { color: var(--text); }
  .col-header .sort-arrow { font-size: 9px; opacity: 0.4; }
  .col-header.sorted .sort-arrow { opacity: 1; color: var(--accent); }

  /* ── Quote list ── */
  .quote-list { padding: 0 0 40px; }

  .quote-row {
    background: var(--surface);
    border-bottom: 1px solid #f0efed;
    overflow: hidden;
    transition: background 0.1s;
  }
  .quote-row:hover { background: #f9f8f6; }
  .quote-row.expanded { background: #f7f6f3; }
  .quote-row.flagged-keep { border-left: 3px solid var(--keep); }
  .quote-row.flagged-remove { border-left: 3px solid var(--remove); }

  .row-summary {
    display: grid;
    grid-template-columns: 120px minmax(180px, 1fr) 82px 46px 42px 42px 58px 54px 64px 36px;
    align-items: center;
    padding: 10px 16px 10px 32px;
    gap: 6px;
    cursor: pointer;
    user-select: none;
  }
  .contributor-name { font-weight: 600; font-size: 13px; }
  .quote-preview {
    font-family: 'Source Serif 4', serif;
    font-style: italic;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
  }
  .entry-id { font-size: 10px; color: var(--text-secondary); font-family: monospace; }

  /* ── Flag buttons ── */
  .flag-btn-group { display: flex; gap: 3px; flex-shrink: 0; }
  .flag-btn {
    height: 28px;
    padding: 0 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    transition: all 0.1s;
    color: var(--text-secondary);
    white-space: nowrap;
  }
  .flag-btn:hover { background: #f0efed; }
  .flag-btn.active-keep { background: var(--keep-light); border-color: var(--keep); color: var(--keep); }
  .flag-btn.active-remove { background: var(--remove-light); border-color: var(--remove); color: var(--remove); }

  /* ── Badges ── */
  .badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    text-align: center;
    white-space: nowrap;
  }
  .badge-exact { background: #e8f0e8; color: #2c5f2d; }
  .badge-near_match { background: #e8f5e8; color: #3a7d44; }
  .badge-somewhat_matching { background: var(--warn-light); color: var(--warn); }
  .badge-very_different { background: var(--danger-light); color: var(--danger); }
  .badge-not_found { background: #f0efed; color: #6b6964; }
  .badge-error { background: var(--danger-light); color: var(--danger); }
  .badge-fab-none { background: #e8f0e8; color: #2c5f2d; }
  .badge-fab-low { background: #e8f5e8; color: #3a7d44; }
  .badge-fab-medium { background: var(--warn-light); color: var(--warn); }
  .badge-fab-high { background: var(--danger-light); color: var(--danger); }
  .badge-align-aligned { background: #e8f0e8; color: #2c5f2d; }
  .badge-align-stretch { background: var(--warn-light); color: var(--warn); }
  .badge-align-misaligned { background: var(--danger-light); color: var(--danger); }
  .badge-align-pending { background: #f0efed; color: #6b6964; }
  .badge-conf-high { background: #e8f0e8; color: #2c5f2d; }
  .badge-conf-medium { background: var(--warn-light); color: var(--warn); }
  .badge-conf-low { background: var(--danger-light); color: var(--danger); }
  .badge-rules-pass { background: #e8f0e8; color: #2c5f2d; }
  .badge-rules-fail { background: var(--danger-light); color: var(--danger); }
  .badge-rules-review { background: var(--warn-light); color: var(--warn); }
  .badge-rules-pending { background: #f0efed; color: #6b6964; }

  /* ── PM-first note ── */
  .pmfirst-note-text {
    font-family: 'Source Serif 4', serif;
    font-size: 13px;
    line-height: 1.65;
    color: var(--text);
    padding: 12px 16px;
    background: #f0f5f0;
    border-radius: 6px;
    border-left: 3px solid var(--accent);
    margin-bottom: 8px;
  }

  /* ── Rules detail ── */
  .rules-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-top: 8px;
  }
  .rule-card {
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 12px;
  }
  .rule-card h4 {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 4px;
  }
  .rule-card .rule-verdict { font-weight: 600; margin-bottom: 4px; }
  .rule-card .rule-rationale { color: var(--text-secondary); line-height: 1.4; }

  .icon-confirmed { color: var(--accent); font-weight: 700; }
  .icon-unconfirmed { color: var(--danger); font-weight: 700; }

  /* ── Editorial note ── */
  .editorial-note-section {
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 14px;
  }
  .editorial-note-section h3 {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 6px;
  }
  .editorial-note-text {
    font-family: 'Source Serif 4', serif;
    font-size: 13px;
    line-height: 1.65;
    color: var(--text);
    padding: 12px 16px;
    background: #f5f4f0;
    border-radius: 6px;
    border-left: 3px solid var(--info);
    margin-bottom: 8px;
  }
  .note-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 11px;
    color: var(--text-secondary);
    flex-wrap: wrap;
  }
  .note-meta .label { font-weight: 600; }
  .alignment-rationale {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
    font-style: italic;
  }

  /* ── Expanded detail ── */
  .row-detail {
    display: none;
    border-top: 1px solid var(--border);
    padding: 20px 32px;
    background: #fafaf8;
  }
  .quote-row.expanded .row-detail { display: block; }

  .detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }
  .detail-section h3 {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
  }
  .quote-full {
    font-family: 'Source Serif 4', serif;
    font-size: 15px;
    line-height: 1.6;
    padding: 14px;
    background: #fff;
    border-radius: 6px;
    margin-bottom: 10px;
    border-left: 3px solid var(--accent);
  }
  .canonical-wording {
    font-family: 'Source Serif 4', serif;
    font-size: 13px;
    line-height: 1.5;
    padding: 10px;
    background: var(--warn-light);
    border-radius: 6px;
    margin-top: 8px;
    border-left: 3px solid var(--warn);
  }
  .canonical-wording .cw-label {
    font-family: 'DM Sans', sans-serif;
    font-size: 10px;
    font-weight: 700;
    color: var(--warn);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 3px;
  }
  .detail-field { margin-bottom: 6px; }
  .detail-field .label { font-size: 11px; font-weight: 600; color: var(--text-secondary); }
  .detail-field .value { font-size: 13px; }

  .ref-list { margin-top: 12px; }
  .ref-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px;
    padding: 7px 0;
    border-bottom: 1px solid #f0efed;
    align-items: start;
  }
  .ref-item:last-child { border-bottom: none; }
  .ref-num {
    font-size: 10px; font-weight: 700; color: var(--text-secondary);
    background: #f0efed; width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  }
  .ref-link {
    color: var(--info);
    text-decoration: none;
    font-size: 12px;
    word-break: break-all;
    cursor: pointer;
  }
  .ref-link:hover { text-decoration: underline; }
  .ref-title { font-weight: 500; font-size: 12px; }
  .ref-snippet { font-size: 11px; color: var(--text-secondary); font-style: italic; margin-top: 2px; }
  .ref-match-type { font-size: 9px; font-weight: 600; text-transform: uppercase; margin-left: 6px; }

  .flag-row-detail {
    display: flex; align-items: flex-start; gap: 6px; padding: 3px 0; font-size: 12px;
  }
  .flag-icon-detail { font-size: 13px; flex-shrink: 0; }

  /* ── Export modal ── */
  .modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 500;
    align-items: center;
    justify-content: center;
  }
  .modal-overlay.open { display: flex; }
  .modal {
    background: var(--surface);
    border-radius: 10px;
    padding: 24px;
    max-width: 520px;
    width: 90%;
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
  }
  .modal h2 {
    font-family: 'Source Serif 4', serif;
    font-size: 20px;
    margin-bottom: 12px;
  }
  .modal p { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }
  .modal-btns { display: flex; gap: 8px; flex-wrap: wrap; }
  .modal-btns button {
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
  }
  .modal-btns button:hover { background: var(--bg); }
  .modal-btns button.primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
  }
  .modal-btns button.primary:hover { background: #245025; }

  @media (max-width: 1000px) {
    .side-panel.open { width: 100vw; position: fixed; right: 0; top: 0; bottom: 0; z-index: 200; }
    .decision-panel, .dp-toggle { display: none; }
    .col-headers, .row-summary { grid-template-columns: 100px 1fr 70px 50px 50px 60px; }
    .detail-grid { grid-template-columns: 1fr; }
  }
  /* ── Auth gate ── */
  .auth-gate {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
  }
  .auth-gate h2 {
    font-family: 'Source Serif 4', serif;
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
  }
  .auth-gate p {
    color: var(--text-secondary);
    font-size: 13px;
    max-width: 320px;
    text-align: center;
  }
  .auth-gate button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 24px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: box-shadow 0.15s;
  }
  .auth-gate button:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
  .auth-gate .auth-error { color: var(--danger); font-size: 12px; }
  .auth-gate .auth-status { color: var(--text-secondary); font-size: 12px; }
  .sync-badge {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
  }
  .sync-badge.online { background: var(--accent); }
  .sync-badge.offline { background: var(--warn); }
  .sync-badge.error { background: var(--danger); }

  .reassign-badge {
    font-family: 'DM Sans', sans-serif;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-left: 4px;
  }
  .reassign-badge.reassigned {
    color: var(--warn);
  }

  /* ── Mobile: hidden by default on desktop ── */
  .mobile-decision-panel { display: none; }
  .mobile-filter-summary { display: none; }
  .mobile-action-bar { display: none; }
  .mobile-back-bar { display: none; }

  /* ══════════════════════════════════════════════ */
  /* MOBILE — max-width: 600px                     */
  /* ══════════════════════════════════════════════ */
  @media (max-width: 600px) {
    /* Header */
    .header { flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px; }
    .header h1 { font-size: 18px; }
    .header .meta { font-size: 11px; }
    .header-actions button.backup-btn { display: none; }

    /* Dashboard */
    .dashboard { padding: 10px 16px; gap: 6px; }
    .stat-card { padding: 8px; }
    .stat-card .value { font-size: 18px; }

    /* Mobile decision panel */
    .mobile-decision-panel {
      display: block;
      position: sticky;
      top: 0;
      z-index: 102;
      background: var(--surface);
      border-bottom: 1px solid var(--border);
      padding-bottom: 4px;
    }
    .mob-counts {
      display: flex;
      justify-content: space-around;
      padding: 8px 16px;
      font-size: 13px;
      font-weight: 600;
    }
    .mob-counts span { cursor: pointer; }
    .mob-book-strip {
      display: flex;
      overflow-x: auto;
      gap: 8px;
      padding: 4px 16px 4px;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: none;
    }
    .mob-book-strip::-webkit-scrollbar { display: none; }
    .mob-book-card {
      flex-shrink: 0;
      width: 160px;
      padding: 8px 10px;
      border: 1px solid var(--border);
      border-radius: 6px;
      background: var(--bg);
      text-align: left;
      font-size: 10px;
      line-height: 1.3;
    }
    .mob-book-card.active { border-color: var(--accent); background: var(--accent-light); }
    .mob-book-roman { font-weight: 700; font-size: 14px; display: block; }
    .mob-book-theme { color: var(--text); font-weight: 600; display: block; margin-top: 2px; }
    .mob-book-question { font-style: italic; color: var(--text-secondary); display: block; margin-top: 3px; font-size: 10px; line-height: 1.3; }
    .mob-book-counts { color: var(--text-secondary); font-size: 9px; display: block; margin-top: 3px; }
    .mob-book-card { cursor: pointer; }

    /* Mobile filter summary */
    .mobile-filter-summary {
      display: block;
      padding: 8px 16px;
      font-size: 11px;
      color: var(--text-secondary);
      cursor: pointer;
      border-top: 1px solid var(--border);
    }
    .mobile-filter-summary .active-filters { font-weight: 600; color: var(--text); }
    .mobile-filter-summary { display: flex; justify-content: space-between; align-items: center; }
    .mob-visible-count { font-size: 10px; color: var(--text-secondary); }
    .filters { display: none; }
    .filters.mobile-expanded { display: flex; padding: 8px 16px; gap: 6px; }
    .filters.mobile-expanded input[type="text"] { width: 100%; }

    /* Column headers: hide */
    .col-headers { display: none; }

    /* Quote rows: stacked */
    .row-summary {
      grid-template-columns: auto 1fr;
      padding: 10px 16px;
      gap: 2px 10px;
    }
    .flag-btn-group { grid-row: 1 / 4; align-self: center; flex-direction: column; }
    .flag-btn { height: 44px; padding: 0 10px; font-size: 12px; }
    .row-summary > div:nth-child(n+3):nth-child(-n+9) { display: none; }
    .row-summary > div:last-child { display: none; }

    /* Detail mode */
    body.mobile-detail-mode .quote-list { display: none; }
    body.mobile-detail-mode .mobile-detail-view { display: block; }
    body.mobile-detail-mode .dashboard { display: none; }
    .mob-back-link { display: none; }
    body.mobile-detail-mode .mob-back-link { display: block; padding: 8px 16px; font-weight: 600; color: var(--info); cursor: pointer; border-top: 1px solid var(--border); }
    .mobile-detail-view { display: none; padding: 16px; }
    .mobile-detail-view .detail-grid { grid-template-columns: 1fr; }
    .mobile-detail-view .detail-section { padding: 0; margin-bottom: 16px; }

    /* Mobile back bar (inside decision panel) */

    /* Mobile action bar */
    body.mobile-detail-mode .mobile-action-bar {
      display: flex;
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      padding: 10px 16px;
      background: var(--surface);
      border-top: 1px solid var(--border);
      box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
      align-items: center;
      gap: 6px;
      z-index: 200;
    }
    .mobile-action-bar .flag-btn { height: 44px; flex: 0 0 auto; }
    .mobile-action-bar select { flex: 1; min-width: 0; height: 44px; font-size: 12px; border-radius: 6px; border: 1px solid var(--border); font-family: 'DM Sans', sans-serif; }
    .mobile-action-bar .note-btn { height: 44px; width: 44px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; }

    /* Hide desktop decision panel */
    .decision-panel, .dp-toggle { display: none; }

    /* Padding bottom for action bar */
    body.mobile-detail-mode .main-panel { padding-bottom: 70px; }
  }
