:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --text: #1c2430;
  --muted: #5d6878;
  --line: #dde2ea;
  --accent: #1f6fd1;
  --accent-text: #ffffff;
  --accent-soft: #e5effb;
  --good: #1d7a43;
  --bad: #b3261e;
  --warn: #8a5a00;
  --row-hover: #f7f9fc;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --panel: #1b2129;
    --text: #e6eaf0;
    --muted: #9aa5b4;
    --line: #2d3540;
    --accent: #5aa2ff;
    --accent-text: #0b1420;
    --accent-soft: #1d2b3d;
    --good: #5fcf8b;
    --bad: #ff8a80;
    --warn: #f2c14e;
    --row-hover: #212833;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 24px 16px 32px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  max-width: 1200px;
  margin-inline: auto;
}

a { color: var(--accent); }
code { font: 0.92em ui-monospace, "Cascadia Mono", Consolas, monospace; }

.top { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; }
.top h1 { margin: 0; font-size: 1.6rem; letter-spacing: -0.01em; }
.top p { margin: 2px 0 0; color: var(--muted); }

.banner {
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
}

main { display: grid; gap: 16px; grid-template-columns: 3fr 2fr; }
@media (max-width: 860px) { main { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 0;
}
.panel h2 { margin: 0; font-size: 1.1rem; }
.panel-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.hint { color: var(--muted); margin: 6px 0 10px; font-size: 0.93rem; }
.keys { grid-column: 1 / -1; }

button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  padding: 6px 14px;
  cursor: pointer;
}
button.secondary { background: transparent; color: var(--accent); }
button.primary { font-weight: 600; padding: 8px 22px; }
button:disabled { opacity: 0.45; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.list-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 8px; }
.list-tools .hint { margin: 0; }
select, input[type="text"] {
  font: inherit;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  max-width: 100%;
}

/* The chosen list: what it is, how much of it is in the folder, and (folded away) the titles that aren't. */
.list-bar { border: 1px solid var(--line); border-radius: 8px; background: var(--bg); padding: 8px 12px; margin: 0 0 8px; font-size: 0.93rem; }
.list-bar p { margin: 4px 0; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.list-bar p.note { display: block; }
.list-bar ul { margin: 4px 0; padding-left: 1.4em; max-height: 9em; overflow: auto; columns: 2 16em; }
.list-bar label { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.muted { color: var(--muted); }
.problem { color: var(--bad); margin: 0 0 8px; }
button.small { padding: 2px 10px; }
input[type="search"] {
  font: inherit;
  flex: 0 1 320px;
  min-width: 0;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

/* The two lists fill their panels, which share a row as tall as the window allows with the copy controls still in
   view, so a long list scrolls within the whole panel and both panels end level. */
.list-panel { display: flex; flex-direction: column; min-height: clamp(420px, calc(100vh - 380px), 1000px); }
.table-wrap { flex: 1 1 0; min-height: 160px; overflow: auto; }
@media (max-width: 860px) {
  .list-panel { min-height: 0; }
  .table-wrap { flex: none; max-height: 60vh; }
}
table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--panel); }
tbody tr:hover { background: var(--row-hover); }
td.number, th.number { text-align: right; white-space: nowrap; }
td.check, th.check { width: 28px; }
td .sub { display: block; color: var(--muted); font-size: 0.86rem; overflow-wrap: anywhere; }

/* A game's front cover beside its title, the height of a two-line row; an empty frame until (or unless) GameTDB has one. */
.game { display: flex; gap: 10px; align-items: center; min-width: 0; }
.game > :last-child { min-width: 0; }
.cover { flex: none; width: 30px; height: 42px; border-radius: 2px; background: var(--line); object-fit: cover; }
.no-covers .cover { display: none; }

button.link { background: none; border: none; padding: 0; color: var(--accent); text-decoration: underline; font: inherit; cursor: pointer; }

/* Column headings that sort the list: they look like headings, with an arrow on the one the list is sorted by. */
th button.sort { background: none; border: none; padding: 0; color: inherit; font: inherit; cursor: pointer; }
th button.sort:hover { color: var(--text); }
th[aria-sort="ascending"] button.sort::after { content: " ▲"; font-size: 0.75em; }
th[aria-sort="descending"] button.sort::after { content: " ▼"; font-size: 0.75em; }
.empty td { color: var(--muted); text-align: center; padding: 18px 8px; }

.state-waiting { color: var(--muted); }
.state-reading { color: var(--accent); }
.state-ready { color: var(--text); }
.state-busy { color: var(--accent); }
.state-done { color: var(--good); }
.state-failed { color: var(--bad); }
.state-skip { color: var(--muted); }

.copy { margin-top: 16px; }
.copy-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.option { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }
.progress { height: 8px; background: var(--accent-soft); border-radius: 4px; overflow: hidden; margin: 14px 0 6px; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
.progress.slim { height: 4px; margin: -4px 0 10px; }
.progress.indeterminate div { width: 30%; animation: sweep 1.4s ease-in-out infinite; }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
@media (prefers-reduced-motion: reduce) { .progress.indeterminate div { width: 100%; opacity: 0.4; animation: none; } }
.status { margin: 0 0 8px; min-height: 1.45em; }
details summary { cursor: pointer; color: var(--muted); }
pre#log { max-height: 260px; overflow: auto; font-size: 0.85rem; white-space: pre-wrap; margin: 8px 0 0; }

footer { color: var(--muted); font-size: 0.86rem; margin-top: 18px; }
