:root {
  --bg: #0f1115;
  --panel: #181b22;
  --border: #262b35;
  --text: #e6e8ee;
  --muted: #8a93a3;
  --accent: #4f8cff;
  --accent-hover: #6fa3ff;
  --error: #ff6b6b;
  --ok: #4caf50;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", sans-serif; }
header { padding: 24px 20px 8px; max-width: 920px; margin: 0 auto; }
header h1 { margin: 0 0 4px; font-size: 22px; }
header .muted { margin: 0; color: var(--muted); font-size: 13px; }
main { padding: 12px 20px 60px; max-width: 920px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
main[hidden] { display: none; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.card h2 { margin: 0; font-size: 16px; font-weight: 600; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; margin-bottom: 12px; }
input[type=url], .gate input[type=text] {
  flex: 1; min-width: 0; padding: 10px 12px; font: inherit;
  background: #0c0e13; border: 1px solid var(--border); color: var(--text); border-radius: 6px;
}
input[type=url]:focus, .gate input[type=text]:focus { outline: none; border-color: var(--accent); }
button {
  padding: 10px 16px; font: inherit; cursor: pointer;
  background: var(--accent); color: #fff; border: 0; border-radius: 6px;
  transition: background 0.15s;
}
button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); padding: 6px 12px; font-size: 13px; }
button.ghost:hover { color: var(--text); border-color: var(--accent); background: transparent; }
.error { margin-top: 12px; padding: 10px 12px; background: #2a1518; border: 1px solid #5a2025; border-radius: 6px; color: var(--error); font-size: 13px; }
.warning { margin-top: 10px; color: #ffb84d; font-size: 13px; }
#preview { margin-top: 16px; display: flex; gap: 14px; }
#preview img { width: 120px; height: 160px; object-fit: cover; border-radius: 6px; flex-shrink: 0; background: #000; }
#preview .meta { flex: 1; min-width: 0; }
#preview .meta .author { font-weight: 600; }
#preview .meta .desc { color: var(--muted); font-size: 13px; margin: 4px 0 8px; max-height: 4.5em; overflow: hidden; }
#preview .meta .spec { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
#preview .meta .spec .hd { color: var(--ok); font-weight: 600; }
.library { display: flex; flex-direction: column; gap: 10px; }
.library:empty::after { content: "尚无下载记录"; color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.tab { background: transparent; color: var(--muted); border: 0; padding: 8px 14px; font: inherit; cursor: pointer; border-radius: 0; border-bottom: 2px solid transparent; transition: color 0.15s, border-color 0.15s; }
.tab:hover { color: var(--text); background: transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
textarea { width: 100%; padding: 10px 12px; font: inherit; background: #0c0e13; border: 1px solid var(--border); color: var(--text); border-radius: 6px; resize: vertical; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
textarea:focus { outline: none; border-color: var(--accent); }
.muted-inline { color: var(--muted); font-size: 13px; margin-left: 8px; }
.batch-progress { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.batch-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: #0c0e13; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.batch-item .state { width: 70px; flex-shrink: 0; font-weight: 600; font-size: 12px; }
.batch-item .url { flex: 1; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-item .meta { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.batch-item.pending .state { color: var(--muted); }
.batch-item.running .state { color: var(--accent); }
.batch-item.done .state { color: var(--ok); }
.batch-item.failed .state { color: var(--error); }
.batch-item.failed .meta { color: var(--error); }
.batch-item.done.skipped .state { color: var(--muted); }
.batch-item.done.skipped .meta { color: var(--muted); }
select { padding: 10px 8px; font: inherit; background: #0c0e13; border: 1px solid var(--border); color: var(--text); border-radius: 6px; cursor: pointer; }
select:focus { outline: none; border-color: var(--accent); }
.lib-item { display: flex; gap: 12px; padding: 10px; background: #0c0e13; border: 1px solid var(--border); border-radius: 8px; }
.lib-item img { width: 90px; height: 120px; object-fit: cover; border-radius: 5px; flex-shrink: 0; background: #000; }
.lib-item .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lib-item .meta .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.lib-item .meta .author { font-weight: 600; }
.lib-item .meta .date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.lib-item .meta .desc { color: var(--muted); font-size: 13px; margin: 4px 0; max-height: 3em; overflow: hidden; }
.lib-item .meta .spec { font-size: 12px; color: var(--muted); margin-top: auto; }
.lib-item .meta .spec a { color: var(--accent); text-decoration: none; margin-right: 12px; }
.lib-item .meta .spec a:hover { text-decoration: underline; }
.lib-item .meta .spec .del { color: var(--error); cursor: pointer; background: none; border: 0; padding: 0; font: inherit; margin-right: 12px; }
.lib-item .meta .spec .del:hover { text-decoration: underline; }
.lib-item input[type=checkbox] { width: 18px; height: 18px; margin-right: 4px; flex-shrink: 0; align-self: center; accent-color: var(--accent); cursor: pointer; }
.lib-item.selected { border-color: var(--accent); background: #131822; }
button.ghost.danger { color: var(--error); border-color: #5a2025; }
button.ghost.danger:hover { color: var(--error); border-color: var(--error); background: #1a0d0f; }

.gate { max-width: 520px; margin: 40px auto; text-align: center; }
.gate h2 { margin-bottom: 8px; }
.gate p { color: var(--muted); }
.gate .qr-row { display: flex; justify-content: center; gap: 28px; margin: 18px 0 24px; }
.gate figure { margin: 0; }
.gate figure img { width: 180px; height: 180px; object-fit: contain; background: #fff; border-radius: 8px; }
.gate figcaption { font-size: 12px; color: var(--muted); margin-top: 6px; }
.gate form { justify-content: center; }
.gate input[type=text] { max-width: 360px; }
.ext-banner {
  margin-top: 10px; padding: 8px 10px; border-radius: 6px; font-size: 13px; line-height: 1.5;
  border: 1px solid var(--border);
}
.ext-banner.on { border-color: #2e5c39; background: #16241a; }
.ext-banner.off { border-color: #5c4a2e; background: #241f16; }
.ext-banner code { font-size: 12px; opacity: .85; }
.ext-banner .ext-steps { margin: 6px 0 4px; padding-left: 22px; }
.ext-banner .ext-steps li { margin: 2px 0; }
.ext-banner a { color: var(--accent); }
.route {
  font-size: 11px; padding: 1px 6px; border-radius: 10px; vertical-align: middle;
  border: 1px solid var(--border); color: var(--muted);
}
.route.ext { border-color: #2e5c39; color: #7fc48c; }
.pill { font-size: 11px; padding: 1px 6px; border-radius: 10px; background: #333; }
.pill.failed { background: #5c2e2e; }
.lib-item.browser .spec button {
  background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0 4px; font-size: inherit;
}
