:root {
  --ground: #f3f5f7;
  --surface: #ffffff;
  --ink: #1b2430;
  --ink-soft: #5b6674;
  --line: #d5dae0;
  --line-strong: #aab3bd;
  --accent: #0f6e68;
  --accent-ink: #ffffff;
  --high: #2e7d4f;
  --medium: #b7791f;
  --low: #b3403a;
  --danger: #b3403a;
  --focus: #0f6e68;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #161b22;
    --surface: #1f2630;
    --ink: #e6eaf0;
    --ink-soft: #9aa5b3;
    --line: #313a46;
    --line-strong: #4a5563;
    --accent: #3fb3aa;
    --accent-ink: #0d1614;
    --high: #5cc48a;
    --medium: #e0a94a;
    --low: #e46b63;
    --danger: #e46b63;
    --focus: #3fb3aa;
  }
}

* { box-sizing: border-box; }
html { background: var(--ground); }
body {
  margin: 0;
  font: 15px/1.5 "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--ground);
}
.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.masthead { max-width: 62ch; margin-bottom: 32px; }
.masthead h1 { font-size: 30px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 8px; }
.masthead p { margin: 0; color: var(--ink-soft); }

.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line-strong); margin-bottom: 16px; }
.tab {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent;
  margin-bottom: -1px; padding: 8px 14px; font: inherit; font-weight: 500;
  color: var(--ink-soft); cursor: pointer;
}
.tab.is-active { color: var(--ink); border-bottom-color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

textarea, input[type="text"], select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px;
}
textarea:focus, input:focus, select:focus { outline: 2px solid var(--focus); outline-offset: 1px; border-color: transparent; }
#text { width: 100%; min-height: 220px; resize: vertical; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 13px; line-height: 1.55; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 160px; padding: 24px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--line-strong); border-radius: 6px; background: var(--surface);
}
.dropzone.is-over { border-color: var(--accent); border-style: solid; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.dropzone-file { color: var(--accent); font-weight: 500; }
.hint { color: var(--ink-soft); font-size: 14px; margin: 10px 0 0; }

.controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-soft); }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

button { font: inherit; }
button.primary, .toolbar button, #add {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  padding: 9px 16px; border-radius: 4px; font-weight: 500; cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:disabled { opacity: .55; cursor: progress; }
button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.status { min-height: 1.5em; margin: 12px 0 0; color: var(--ink-soft); }
.status.is-error { color: var(--danger); }

.results { margin-top: 40px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px; }
.toolbar h2 { font-size: 20px; font-weight: 600; margin: 0; }
.toolbar-actions { display: flex; gap: 8px; }
.legend { color: var(--ink-soft); font-size: 13px; margin: 8px 0 12px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin: 0 4px 0 10px; vertical-align: 0; }
.legend .dot:first-child { margin-left: 0; }
.dot.high { background: var(--high); }
.dot.medium { background: var(--medium); }
.dot.low { background: var(--low); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; min-width: 1120px; }
th, td { text-align: left; vertical-align: top; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { font-weight: 500; font-size: 13px; color: var(--ink-soft); white-space: nowrap; background: var(--surface); }
th small { font-weight: 400; }
tbody tr:last-child td { border-bottom: 0; }
td input, td select, td textarea { width: 100%; padding: 6px 8px; font-size: 14px; }
td textarea { resize: vertical; min-height: 60px; line-height: 1.4; }
.col-n { width: 56px; } .col-type { width: 84px; } .col-authors { width: 190px; } .col-title { width: 260px; }
.col-journal { width: 180px; } .col-year { width: 68px; } .col-vol { width: 60px; } .col-issue { width: 64px; }
.col-pages { width: 96px; } .col-doi { width: 170px; } .col-del { width: 40px; }
.n { display: flex; align-items: center; gap: 6px; padding-top: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.n .dot { margin: 0; }
.src { display: block; font-size: 11px; color: var(--ink-soft); margin-top: 2px; }
.raw { grid-column: 1 / -1; }
tr.raw-row td { padding: 0 6px 10px 62px; border-bottom: 1px solid var(--line); }
tr.raw-row details summary { cursor: pointer; font-size: 12px; color: var(--ink-soft); }
tr.raw-row pre { margin: 4px 0 0; white-space: pre-wrap; font: 12px/1.5 "IBM Plex Mono", ui-monospace, monospace; color: var(--ink-soft); }
.del { background: none; border: 0; color: var(--ink-soft); cursor: pointer; font-size: 18px; line-height: 1; padding: 6px; border-radius: 4px; }
.del:hover { color: var(--danger); }

.section-text { margin-top: 20px; color: var(--ink-soft); }
.section-text pre { white-space: pre-wrap; font: 12px/1.5 "IBM Plex Mono", ui-monospace, monospace; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 12px; max-height: 320px; overflow: auto; }

@media (max-width: 600px) {
  .page { padding: 24px 16px 60px; }
  .masthead h1 { font-size: 24px; }
  .controls, .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-actions { justify-content: stretch; }
  .toolbar-actions button { flex: 1; }
}
@media (prefers-reduced-motion: no-preference) {
  .tab, button.primary { transition: background-color .15s, border-color .15s; }
}
