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

:root {
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --bg: #f5f5f7;
  --card: #ffffff;
  --border: #d2d2d7;
  --border-light: #e8e8ed;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --keep: #1a7f37;
  --keep-bg: #f0faf3;
  --reject: #d93025;
  --reject-bg: #fff0ef;
  --unsure: #b45309;
  --unsure-bg: #fffbeb;
  --pending: #86868b;
}

body {
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ─── HEADER ─────────────────────────────────────────────────────────────── */
#header {
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
}
#header h1 { font-size: 0.95rem; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; color: var(--text); }
#stats { display: flex; gap: 20px; font-size: 0.8rem; flex-wrap: wrap; }
.stat { display: flex; align-items: center; gap: 5px; }
.stat-label { color: var(--muted); }
.stat-val { font-weight: 600; color: var(--text); }
.stat-val.kept { color: var(--keep); }
.stat-val.rejected { color: var(--reject); }
.stat-val.unsure { color: var(--unsure); }
.stat-val.pending { color: var(--pending); }

#progress-bar-wrap {
  width: 100%;
  height: 2px;
  background: var(--border-light);
  position: absolute;
  bottom: 0; left: 0;
}
#progress-bar {
  height: 100%;
  background: var(--blue);
  transition: width 0.4s ease;
  width: 0%;
}

/* ─── LAYOUT ─────────────────────────────────────────────────────────────── */
#app { display: flex; flex: 1; min-height: 0; }

/* ─── SIDEBAR ────────────────────────────────────────────────────────────── */
#sidebar {
  width: 210px;
  min-width: 210px;
  background: #fff;
  border-right: 1px solid var(--border-light);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
}
#sidebar h2 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.sidebar-counts { display: flex; flex-direction: column; gap: 6px; }
.sidebar-count { display: flex; justify-content: space-between; font-size: 0.8rem; }
.sidebar-count span:first-child { color: var(--muted); }
.sidebar-count span:last-child { font-weight: 600; color: var(--text); }

.export-btns { display: flex; flex-direction: column; gap: 5px; }
.btn-export {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.77rem;
  cursor: pointer;
  text-align: left;
  color: var(--blue);
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
  font-weight: 500;
}
.btn-export:hover { background: #f0f6ff; border-color: var(--blue); }

.btn-find-pending {
  border: none;
  background: var(--blue);
  color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
  width: 100%;
}
.btn-find-pending:hover { background: var(--blue-hover); }

/* ─── MAIN CONTENT ───────────────────────────────────────────────────────── */
#main {
  flex: 1;
  min-width: 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

/* ─── UPLOAD ─────────────────────────────────────────────────────────────── */
#upload-zone {
  border: 1.5px dashed var(--border);
  background: var(--card);
  border-radius: 16px;
  padding: 56px 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
#upload-zone.drag-over { border-color: var(--blue); background: #f0f6ff; }
#upload-zone h2 { font-size: 1.05rem; font-weight: 600; color: var(--text); margin-bottom: 8px; letter-spacing: -0.02em; }
#upload-zone p { font-size: 0.85rem; color: var(--muted); }
#file-input { display: none; }

/* ─── PAPER CARD ─────────────────────────────────────────────────────────── */
#paper-card {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 24px 28px;
  display: none;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

#paper-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-nav {
  border: 1px solid var(--border);
  background: none;
  border-radius: 8px;
  padding: 5px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  color: var(--blue);
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}
.btn-nav:hover { background: #f0f6ff; border-color: var(--blue); }
#paper-counter { font-size: 0.82rem; color: var(--muted); }
#jump-wrap { display: flex; align-items: center; gap: 6px; margin-left: auto; }
#jump-wrap label { font-size: 0.78rem; color: var(--muted); }
#jump-input {
  width: 58px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
}
#jump-btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: none;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  color: var(--blue);
  font-weight: 500;
  transition: background 0.15s;
}
#jump-btn:hover { background: #f0f6ff; }

#decision-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: 20px;
}
.badge-kept { color: var(--keep); background: var(--keep-bg); }
.badge-rejected { color: var(--reject); background: var(--reject-bg); }
.badge-unsure { color: var(--unsure); background: var(--unsure-bg); }
.badge-pending { color: var(--pending); background: #f5f5f7; }

#paper-title { font-size: 1.1rem; font-weight: 600; line-height: 1.4; color: var(--text); letter-spacing: -0.02em; }
#paper-meta { font-size: 0.8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 12px; }
#paper-meta span { white-space: nowrap; }

.abstract-wrap { position: relative; }
#paper-abstract {
  font-size: 0.875rem;
  line-height: 1.7;
  color: #3d3d3f;
  max-height: 240px;
  overflow: hidden;
  position: relative;
}
#paper-abstract.expanded { max-height: none; }
.abstract-fade {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 64px;
  background: linear-gradient(transparent, white);
  pointer-events: none;
}
#paper-abstract.expanded + .abstract-fade { display: none; }
#toggle-abstract {
  font-size: 0.78rem;
  color: var(--blue);
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px 0;
  font-family: inherit;
  font-weight: 500;
  margin-top: 4px;
}
#toggle-abstract:hover { text-decoration: underline; }

.collapsible-section { border-top: 1px solid var(--border-light); padding-top: 12px; }
.collapsible-toggle {
  font-size: 0.78rem;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}
.collapsible-toggle:hover { color: var(--blue); }
.collapsible-content { display: none; padding-top: 10px; font-size: 0.82rem; color: var(--muted); line-height: 1.6; }
.collapsible-content.open { display: block; }
.collapsible-content a { color: var(--blue); text-decoration: none; }
.collapsible-content a:hover { text-decoration: underline; }

/* ─── DECISION BUTTONS ───────────────────────────────────────────────────── */
#decision-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding-top: 4px;
}
.btn-decision {
  padding: 9px 18px;
  border: 1.5px solid transparent;
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s, opacity 0.15s;
  display: flex;
  align-items: center;
  gap: 7px;
}
.btn-decision:hover { filter: brightness(0.94); }
.btn-decision.active { outline: 2.5px solid var(--blue); outline-offset: 2px; }

#btn-keep      { background: var(--keep-bg);   color: var(--keep);   border-color: #b7dfbf; }
#btn-rtitle    { background: var(--reject-bg); color: var(--reject); border-color: #f5b5b0; }
#btn-rabstract { background: var(--reject-bg); color: var(--reject); border-color: #f5b5b0; opacity: 0.85; }
#btn-rfull     { background: var(--reject-bg); color: var(--reject); border-color: #f5b5b0; opacity: 0.7; }
#btn-unsure    { background: var(--unsure-bg); color: var(--unsure); border-color: #f5d9a0; }

.kbd {
  display: inline-block;
  background: rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.14);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.68rem;
  font-family: monospace;
  line-height: 1.5;
  color: inherit;
  opacity: 0.8;
}

/* ─── NOTES ──────────────────────────────────────────────────────────────── */
#notes-label { font-size: 0.7rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.09em; margin-bottom: 6px; }
#paper-notes {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.84rem;
  font-family: inherit;
  resize: vertical;
  min-height: 64px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
#paper-notes:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,113,227,0.15); background: #fff; }

/* ─── KEYBOARD HINTS ─────────────────────────────────────────────────────── */
#kbd-hints {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.72rem;
  color: var(--muted);
  border-top: 1px solid var(--border-light);
  padding-top: 12px;
}
.kbd-hint { display: flex; align-items: center; gap: 5px; }

/* ─── TOAST ──────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 28px;
  right: 28px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}
.toast {
  background: rgba(29,29,31,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  padding: 11px 18px;
  font-size: 0.84rem;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  animation: slideIn 0.22s ease;
  max-width: 300px;
}
@keyframes slideIn {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.toast.fade-out { animation: fadeOut 0.3s ease forwards; }
@keyframes fadeOut {
  to { opacity: 0; transform: translateY(8px); }
}

/* ─── RESET BUTTON ───────────────────────────────────────────────────────── */
.btn-reset {
  background: none;
  border: 1px solid #f5b5b0;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.77rem;
  cursor: pointer;
  text-align: left;
  color: var(--reject);
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
  font-weight: 500;
  width: 100%;
  margin-top: 4px;
}
.btn-reset:hover { background: var(--reject-bg); border-color: var(--reject); }

/* ─── CONFIRM MODAL ──────────────────────────────────────────────────────── */
#confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10000;
  align-items: center;
  justify-content: center;
}
#confirm-overlay.open { display: flex; }
#confirm-dialog {
  background: #fff;
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 360px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
#confirm-dialog h3 { font-size: 1rem; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
#confirm-dialog p { font-size: 0.85rem; color: var(--muted); line-height: 1.6; }
#confirm-dialog .dialog-btns { display: flex; gap: 10px; justify-content: flex-end; }
#confirm-cancel {
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: none;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: background 0.15s;
}
#confirm-cancel:hover { background: var(--bg); }
#confirm-ok {
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  background: var(--reject);
  color: #fff;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s;
}
#confirm-ok:hover { filter: brightness(0.92); }

/* ─── ANALYTICS TOGGLE ───────────────────────────────────────────────────── */
.analytics-toggle {
  margin-left: auto;
  border: 1px solid var(--border);
  background: none;
  color: var(--text);
  border-radius: 8px;
  padding: 5px 13px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.analytics-toggle:hover { background: var(--bg); border-color: var(--blue); color: var(--blue); }
.analytics-toggle.active { background: #f0f6ff; border-color: var(--blue); color: var(--blue); }

/* ─── ANALYTICS PANEL ────────────────────────────────────────────────────── */
#analytics-panel {
  width: 0;
  min-width: 0;
  overflow: hidden;
  background: #fff;
  border-left: 1px solid var(--border-light);
  transition: width 0.28s cubic-bezier(.4,0,.2,1), min-width 0.28s cubic-bezier(.4,0,.2,1);
  flex-shrink: 0;
  position: relative;
}
#analytics-panel.open { width: 320px; min-width: 320px; }
.analytics-inner {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
#analytics-resize-handle {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 5px;
  cursor: col-resize;
  z-index: 10;
  transition: background 0.15s;
}
#analytics-resize-handle:hover,
#analytics-resize-handle.dragging { background: var(--blue); opacity: 0.35; }
.analytics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.analytics-header h2 { font-size: 0.95rem; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.analytics-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 6px;
  transition: background 0.15s;
  line-height: 1;
}
.analytics-close:hover { background: var(--bg); color: var(--text); }
.analytics-section h3 {
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 10px;
}

/* ─── CHARTS ─────────────────────────────────────────────────────────────── */
.chart-row { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; }
.chart-label {
  font-size: 0.72rem;
  color: var(--muted);
  width: 74px;
  min-width: 74px;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chart-bar-wrap {
  flex: 1;
  background: var(--bg);
  border-radius: 4px;
  height: 12px;
  overflow: hidden;
}
.chart-bar { height: 100%; border-radius: 4px; transition: width 0.5s ease; min-width: 2px; }
.bar-blue   { background: var(--blue); opacity: 0.7; }
.bar-green  { background: var(--keep); opacity: 0.65; }
.bar-gray   { background: #86868b; opacity: 0.45; }
.bar-red    { background: var(--reject); opacity: 0.65; }
.bar-multi  { background: linear-gradient(90deg, var(--keep) var(--k), var(--reject) var(--k), var(--reject) var(--r), var(--unsure) var(--r)); }
.chart-count { font-size: 0.69rem; color: var(--muted); min-width: 26px; text-align: right; font-variant-numeric: tabular-nums; }

/* ─── SUMMARY PILLS ──────────────────────────────────────────────────────── */
.summary-pills { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.summary-pill { font-size: 0.72rem; font-weight: 600; padding: 3px 9px; border-radius: 20px; }
.pill-kept     { background: var(--keep-bg);   color: var(--keep); }
.pill-rejected { background: var(--reject-bg); color: var(--reject); }
.pill-unsure   { background: var(--unsure-bg); color: var(--unsure); }
.pill-pending  { background: #f5f5f7;          color: var(--pending); }
.progress-track { height: 6px; background: var(--border-light); border-radius: 99px; overflow: hidden; }
.progress-fill  { height: 100%; border-radius: 99px; background: var(--blue); transition: width 0.5s ease; }
.analytics-note { font-size: 0.7rem; color: var(--muted); margin-top: 5px; }

/* ─── ANALYTICS TABS ─────────────────────────────────────────────────────── */
.analytics-tabs {
  display: flex;
  gap: 3px;
  background: var(--bg);
  border-radius: 10px;
  padding: 3px;
}
.atab {
  flex: 1 1 0;
  min-width: 0;
  border: none;
  background: none;
  border-radius: 7px;
  padding: 5px 2px;
  font-size: 0.67rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  text-align: center;
}
.atab.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.atab:hover:not(.active) { color: var(--text); }

/* ─── STAT CARDS ─────────────────────────────────────────────────────────── */
.stat-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 4px; }
.stat-card {
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-card.kept     { background: var(--keep-bg); }
.stat-card.rejected { background: var(--reject-bg); }
.stat-card.unsure   { background: var(--unsure-bg); }
.stat-card.pending  { background: #f5f5f7; }
.stat-card-val { font-size: 1.4rem; font-weight: 700; line-height: 1; }
.stat-card.kept     .stat-card-val { color: var(--keep); }
.stat-card.rejected .stat-card-val { color: var(--reject); }
.stat-card.unsure   .stat-card-val { color: var(--unsure); }
.stat-card.pending  .stat-card-val { color: var(--pending); }
.stat-card-lbl { font-size: 0.7rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }

/* ─── WORD CLOUD ─────────────────────────────────────────────────────────── */
.word-cloud { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; padding: 4px 0 10px; }
.cloud-word { color: var(--blue); font-weight: 600; cursor: default; transition: opacity 0.15s; }
.cloud-word:hover { opacity: 1 !important; }

/* ─── CHART LEGEND ───────────────────────────────────────────────────────── */
.chart-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 0.7rem; color: var(--muted); margin-bottom: 6px; }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 3px; vertical-align: middle; }

/* ─── NO DATA ────────────────────────────────────────────────────────────── */
.no-data { font-size: 0.8rem; color: var(--muted); padding: 8px 0; font-style: italic; }

/* ─── MAP TAB ────────────────────────────────────────────────────────────── */
.analytics-inner { position: relative; }
.map-filters { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.map-filter-label { font-size: 0.68rem; color: var(--muted); margin-right: 2px; }
.map-filter {
  border: 1px solid var(--border);
  background: none;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  color: var(--muted);
  transition: all 0.15s;
}
.map-filter.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.map-filter:not(.active):hover { border-color: var(--blue); color: var(--blue); }
.map-hint { font-size: 0.66rem; color: var(--muted); margin-bottom: 6px; }
#map-tooltip {
  position: absolute;
  display: none;
  background: rgba(29,29,31,0.92);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 0.68rem;
  line-height: 1.4;
  padding: 6px 10px;
  border-radius: 8px;
  max-width: 200px;
  pointer-events: none;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 8px; font-size: 0.68rem; color: var(--muted); }
.map-legend-item { display: flex; align-items: center; gap: 4px; }
.map-legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ─── UPLOAD FORMAT GUIDE ────────────────────────────────────────────────── */
.upload-guide {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--border-light);
  text-align: left;
}
.upload-guide h3 { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 700; margin-bottom: 12px; }
.guide-cols { display: flex; flex-wrap: wrap; gap: 7px; }
.guide-col { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.guide-col-name {
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 9px;
  font-family: monospace;
}
.guide-col-req { font-size: 0.62rem; color: var(--muted); }
.guide-col-req.req { color: var(--blue); font-weight: 600; }
.guide-note { font-size: 0.75rem; color: var(--muted); margin-top: 12px; line-height: 1.6; }
.guide-aliases { font-size: 0.7rem; color: var(--muted); margin-top: 8px; line-height: 1.7; }
.guide-aliases code { background: var(--bg); border-radius: 3px; padding: 1px 4px; font-size: 0.68rem; }

/* ─── SIDEBAR TOGGLE (mobile) ────────────────────────────────────────────── */
#sidebar-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 9px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  transition: background 0.15s;
  line-height: 1;
}
#sidebar-toggle:hover { background: var(--bg); }

#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.28);
  z-index: 49;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
#sidebar-overlay.open { display: block; }

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  #sidebar-toggle { display: flex; }

  #sidebar {
    position: fixed;
    top: 57px; bottom: 0; left: -290px;
    width: 280px; min-width: 280px;
    z-index: 50;
    transition: left 0.28s cubic-bezier(.4,0,.2,1), box-shadow 0.28s;
  }
  #sidebar.open {
    left: 0;
    box-shadow: 4px 0 24px rgba(0,0,0,0.13);
  }

  #header { padding: 10px 14px; gap: 12px; }
  #stats { gap: 8px; }
  .stat { gap: 3px; font-size: 0.75rem; }

  #main { padding: 14px; }
  #paper-card { padding: 14px 16px; }

  #jump-wrap { display: none; }
  #kbd-hints { display: none; }

  .btn-decision { padding: 10px 12px; min-height: 42px; font-size: 0.82rem; }
  #decision-row { gap: 6px; }

  .btn-nav { padding: 8px 14px; min-height: 36px; }

  #upload-zone { padding: 36px 20px; }

  #analytics-resize-handle { display: none; }
  #analytics-panel.open {
    position: fixed;
    inset: 0;
    width: 100% !important;
    min-width: 0 !important;
    z-index: 200;
    border-left: none;
  }

  #toast-container { bottom: 16px; right: 12px; left: 12px; }
  .toast { max-width: 100%; }

  #confirm-dialog { padding: 22px 20px; }
}

@media (max-width: 900px) and (min-width: 641px) {
  #sidebar { width: 185px; min-width: 185px; }
}
