:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1a1c1f;
  --muted: #6b7280;
  --border: #e2e5ea;
  --accent: #1db954;
  --accent-dark: #169c46;
  --accent-soft: #e6f7ec;
  --warn: #b45309;
  --warn-soft: #fff4e0;
  --bad: #b91c1c;
  --bad-soft: #fde8e8;
  --skip: #6b7280;
  --skip-soft: #eceef1;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121417;
    --card: #1b1e23;
    --text: #e8eaed;
    --muted: #9aa3ad;
    --border: #2b3038;
    --accent-soft: #163d25;
    --warn-soft: #3d2a10;
    --bad-soft: #3d1717;
    --skip-soft: #2b3038;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
footer { text-align: center; padding: 12px 0 24px; font-size: .85rem; }
h2 { font-size: 1.15rem; margin: 0 0 8px; display: flex; align-items: center; gap: 10px; }
.step {
  display: inline-flex; width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: #fff; align-items: center; justify-content: center; font-size: .9rem;
}
.hint, .muted { color: var(--muted); font-size: .92rem; }
a { color: var(--accent-dark); }
code { background: var(--skip-soft); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
code.uri { padding: 8px 10px; word-break: break-all; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); display: inline-block; }
.auth { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.banner {
  background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad);
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px;
}
.banner.info { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 18px;
}
textarea, input[type="text"], input[type="number"] {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
textarea { font-family: ui-monospace, Consolas, monospace; font-size: .9rem; resize: vertical; }
input[type="number"] { width: 80px; }
label { font-size: .92rem; }
label.inline-field { display: inline-flex; align-items: center; gap: 8px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.grid label { display: flex; flex-direction: column; gap: 4px; }
.grid label.check { flex-direction: row; align-items: center; gap: 8px; }
@media (max-width: 700px) { .grid { grid-template-columns: 1fr; } }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0; }
.row input[type="text"] { flex: 1; min-width: 200px; }
.controls { margin-top: 12px; }
.spacer { flex: 1; }

button, .btn {
  font: inherit; cursor: pointer; border-radius: 8px; padding: 8px 14px;
  border: 1px solid var(--border); background: var(--card); color: var(--text); text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { border-color: var(--muted); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover, .btn.primary:hover { background: var(--accent-dark); }
button.ghost { background: transparent; }
button.small { padding: 4px 10px; font-size: .85rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
.file-btn { position: relative; overflow: hidden; display: inline-flex; align-items: center;
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.prompt-box { margin: 10px 0 14px; border: 1px dashed var(--border); border-radius: 8px; padding: 8px 12px; }
.prompt-box summary { cursor: pointer; color: var(--muted); }
.prompt-box textarea { margin: 8px 0; }

.error { background: var(--bad-soft); color: var(--bad); border-radius: 8px; padding: 10px 12px; margin-top: 10px; white-space: pre-wrap; }
.success { background: var(--accent-soft); border-radius: 8px; padding: 12px 14px; margin-top: 10px; }
.success a { font-weight: 600; }

.progress { position: relative; height: 22px; background: var(--skip-soft); border-radius: 6px; overflow: hidden; margin: 6px 0 12px; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.progress span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: .8rem; }

.summary { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.pill { padding: 3px 10px; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.pill.matched, .badge.matched { background: var(--accent-soft); color: var(--accent-dark); }
.pill.uncertain, .badge.uncertain { background: var(--warn-soft); color: var(--warn); }
.pill.not_found, .badge.not_found { background: var(--bad-soft); color: var(--bad); }
.pill.skipped, .badge.skipped, .badge.pending { background: var(--skip-soft); color: var(--skip); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: .8rem; font-weight: 600; white-space: nowrap; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .85rem; }
td.num { color: var(--muted); width: 32px; }
td .sub { display: block; color: var(--muted); font-size: .82rem; }
td select { width: 100%; max-width: 420px; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 6px; }
td .research { display: flex; gap: 6px; min-width: 220px; }
td .research input { flex: 1; }
tr.skipped td:not(.num) { opacity: .6; }
