:root {
  --bg: #f7f6f3;
  --panel: #ffffff;
  --text: #1d1c1a;
  --muted: #6d6a64;
  --line: #e4e1db;
  --accent: #9c3d2e;
  --accent-soft: #f4e3df;
  --mark: #fde9a8;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --panel: #1f1e1c;
    --text: #ecebe8;
    --muted: #9b978f;
    --line: #34322f;
    --accent: #e08a76;
    --accent-soft: #3a2621;
    --mark: #5c4a12;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo",
    "Microsoft YaHei", "PingFang SC", sans-serif;
}
.top {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 16px max(16px, calc((100vw - 1100px) / 2)) 10px;
}
h1 { font-size: 18px; margin: 0 0 10px; font-weight: 700; }
h1 .sub { font-weight: 400; color: var(--muted); font-size: 14px; margin-left: 6px; }
.search input[type="search"] {
  width: 100%;
  font: inherit; font-size: 17px;
  padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--text);
}
.search input[type="search"]:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.controls { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; color: var(--muted); font-size: 14px; }
.controls label { display: inline-flex; align-items: center; gap: 6px; }
.controls select {
  font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px;
}
.status { margin-top: 8px; font-size: 13px; color: var(--muted); min-height: 1.5em; }
.bar { height: 2px; margin-top: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.bar span {
  display: block; height: 100%; width: 100%; background: var(--accent);
  transform: scaleX(0); transform-origin: left; transition: transform .2s;
}
.bar.done { visibility: hidden; }

main { padding: 8px max(16px, calc((100vw - 1100px) / 2)) 32px; }
.results { width: 100%; border-collapse: collapse; table-layout: fixed; }
.results th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.results td {
  padding: 9px 10px; border-bottom: 1px solid var(--line);
  vertical-align: top; overflow-wrap: anywhere; cursor: copy;
}
.results tbody tr:hover td { background: var(--panel); }
.results td:hover { color: var(--accent); }
.results td.missing { color: var(--muted); cursor: default; }
.meta { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.new {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .02em;
  color: var(--accent); background: var(--accent-soft);
  border-radius: 4px; padding: 0 5px; margin-right: 6px;
}
.cat {
  display: inline-block; font-size: 11px; line-height: 16px;
  color: var(--muted); border: 1px solid var(--line);
  border-radius: 4px; padding: 0 5px; margin-right: 4px;
}
.meta > span:not(.cat):not(.new) { margin-left: 2px; }
mark { background: var(--mark); color: inherit; border-radius: 2px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }
.foot { padding: 0 16px 24px; text-align: center; font-size: 12px; color: var(--muted); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 6px 14px; border-radius: 6px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  .results thead { display: none; }
  .results, .results tbody, .results tr, .results td { display: block; width: 100%; }
  .results tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  .results td { border: 0; padding: 2px 0; }
  .results td::before {
    content: attr(data-l); display: inline-block; width: 2.4em;
    font-size: 11px; color: var(--muted);
  }
}
