:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --line: #e4e1da;
  --text: #1f1e1c;
  --muted: #7a766e;
  --accent: #c2410c;
  --accent-soft: #fde8dc;
  --have: #15803d;
  --have-soft: #dcfce7;
  --zh: #b91c1c;
  --row: 44px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Hiragino Sans", "Noto Sans TC", "Noto Sans JP", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614; --panel: #201f1c; --line: #34322d; --text: #ece9e2; --muted: #9a958b;
    --accent: #fb923c; --accent-soft: #3b2417; --have: #4ade80; --have-soft: #14301f; --zh: #f87171;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 14px; display: flex; flex-direction: column; }
button, select, input { font: inherit; color: inherit; }

.top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.top h1 { font-size: 16px; margin: 0; white-space: nowrap; }
.top h1 small { font-weight: 400; color: var(--muted); margin-left: 4px; }
.search { flex: 1; display: flex; align-items: center; gap: 10px; max-width: 640px; }
.search input[type=search] { flex: 1; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-size: 15px; }
.search input[type=search]:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.chk { display: flex; align-items: center; gap: 4px; color: var(--muted); white-space: nowrap; cursor: pointer; }
.btn { padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.icon-btn { border: 0; background: none; font-size: 18px; cursor: pointer; padding: 4px 8px; color: var(--muted); }
#navToggle { display: none; }

.layout { flex: 1; display: flex; min-height: 0; }
.nav { width: 230px; overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); padding: 8px 0 24px; flex-shrink: 0; }
.nav h3 { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 14px 16px 4px; }
.nav a { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 6px 16px; color: inherit; text-decoration: none; border-left: 3px solid transparent; }
.nav a:hover { background: var(--bg); }
.nav a.on { background: var(--accent-soft); border-left-color: var(--accent); font-weight: 600; }
.nav a .n { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav a .cov { display: block; height: 3px; border-radius: 2px; background: var(--line); margin-top: 3px; overflow: hidden; }
.nav a .cov i { display: block; height: 100%; background: var(--zh); }
.nav .own { color: var(--have); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.ptitle { font-size: 16px; font-weight: 600; }
.muted { color: var(--muted); font-weight: 400; font-size: 13px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }

.thead, .row { display: grid; grid-template-columns: 1.1fr 1.1fr 1.4fr 70px 64px; gap: 12px; padding: 0 16px; align-items: center; }
.thead { height: 32px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); background: var(--panel); }
.list { flex: 1; overflow-y: auto; position: relative; outline: none; }
#rows { position: absolute; left: 0; right: 0; top: 0; }
.row { height: var(--row); border-bottom: 1px solid var(--line); cursor: pointer; }
.row:hover { background: var(--panel); }
.row.sel { background: var(--accent-soft); }
.row > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .c-zh { font-weight: 600; }
.row .c-zh .l1 { overflow: hidden; text-overflow: ellipsis; }
.row .sub, .row .fb { display: none; }
.row .none { color: var(--line); font-weight: 400; }
.row .c-en { color: var(--muted); }
.row .plat { font-size: 11px; color: var(--accent); margin-right: 6px; font-weight: 600; }
.row .c-rg { font-size: 12px; color: var(--muted); }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 10px; }
.tag.have { background: var(--have-soft); color: var(--have); }
.tag.miss { color: var(--muted); }
.tag.zh { background: var(--accent-soft); color: var(--zh); margin-left: 4px; }
mark { background: #fde047; color: #000; border-radius: 2px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.detail { width: 420px; flex-shrink: 0; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--line); padding: 18px 20px 40px; position: relative; }
.detail .close { position: absolute; right: 8px; top: 8px; }
.shots { display: flex; gap: 8px; margin: 10px 0 4px; overflow-x: auto; }
.shots figure { margin: 0; flex: 0 0 auto; display: none; text-align: center; }
.shots figure.ok { display: block; }
.shots img { display: block; height: 150px; max-width: 220px; object-fit: contain; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); image-rendering: auto; }
.shots figcaption { font-size: 11px; color: var(--muted); margin-top: 3px; }
.noshot { font-size: 12px; color: var(--muted); padding: 6px 0; }
.names { display: grid; gap: 10px; margin: 6px 0 18px; }
.name { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.name .lbl { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }
.name .val { font-size: 17px; font-weight: 600; margin-top: 2px; word-break: break-word; }
.name .val.empty-v { color: var(--muted); font-weight: 400; font-size: 14px; }
.name .alt { font-size: 12px; color: var(--muted); margin-top: 4px; }
.copy { border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 11px; padding: 0; }
.detail h4 { margin: 18px 0 6px; font-size: 13px; color: var(--muted); }
.links { display: flex; flex-wrap: wrap; gap: 6px; }
.links a { font-size: 12px; color: var(--accent); text-decoration: none; border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; }
.roms { width: 100%; border-collapse: collapse; font-size: 12px; }
.roms td { border-top: 1px solid var(--line); padding: 6px 4px; vertical-align: top; }
.roms .crc { font-family: ui-monospace, Menlo, monospace; white-space: nowrap; }
.roms .src { font-size: 10px; color: var(--muted); white-space: nowrap; }
.roms tr.have td { background: var(--have-soft); }

.scanbar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-top: 1px solid var(--line); background: var(--panel); font-size: 13px; }
.prog { width: 200px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
#scanProg { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.drop { position: fixed; inset: 0; background: rgba(194, 65, 12, .85); color: #fff; font-size: 28px; display: flex; align-items: center; justify-content: center; z-index: 50; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 8px; z-index: 60; }

@media (max-width: 1280px) {
  .layout:has(.detail:not([hidden])) .c-en, .layout:has(.detail:not([hidden])) .c-rg { display: none; }
  .layout:has(.detail:not([hidden])) .thead, .layout:has(.detail:not([hidden])) .row { grid-template-columns: 1fr 1fr 56px; }
  .detail { width: 380px; }
}
@media (max-width: 900px) {
  #navToggle { display: block; }
  .nav { position: fixed; top: 54px; bottom: 0; left: 0; z-index: 20; transform: translateX(-100%); transition: transform .2s; box-shadow: 2px 0 12px rgba(0,0,0,.15); }
  .nav.open { transform: none; }
  .top { gap: 8px; padding: 8px 10px; }
  .top h1, .chk { display: none; }
  #scanBtn { padding: 7px 10px; }
  .thead, .row, .layout:has(.detail:not([hidden])) .thead, .layout:has(.detail:not([hidden])) .row { grid-template-columns: 1fr 50px; }
  .c-jp, .c-en, .c-rg { display: none; }
  .row .c-zh .none { display: none; }
  .row .fb { display: inline; }
  .row .sub { display: block; font-size: 11px; font-weight: 400; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
  .detail { position: fixed; inset: 54px 0 0 0; width: auto; z-index: 30; }
}
