:root {
  --bg: #010a13;
  --panel: #0a1420;
  --sidebar: #091018;
  --ink: #f0e6d2;
  --muted: #a09b8c;
  --line: #3c3c41;
  --gold: #c8aa6e;
  --gold-dim: #785a28;
  --teal: #0ac8b9;
  --danger: #c84c4c;
  --new: #c8aa6e;
  --queued: #0ac8b9;
  --skipped: #5b5a56;
  --downloaded: #1e825a;
  --failed: #c84c4c;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Segoe UI", "Spiegel", sans-serif; }
body { min-height: 100vh; }
html {
  scrollbar-width: thin;
  scrollbar-color: #3a3224 var(--sidebar);
}
* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: #3a3224 transparent;
}
*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: #3a3224;
  border-radius: 99px;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--gold-dim);
}
*::-webkit-scrollbar-corner {
  background: transparent;
}

.app {
  display: grid;
  grid-template-columns: 268px 1fr;
  min-height: 100vh;
}

.filters {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 22px 18px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.filter-kicker {
  margin: 0;
  color: var(--gold);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 10px;
}
.filters h2 {
  margin: 6px 0 16px;
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
}
.filter-h {
  margin: 18px 0 8px;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}
.filter-h::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--gold);
  transform: rotate(45deg);
}
.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: #010a13;
  padding: 0 10px;
}
.search-icon {
  width: 12px;
  height: 12px;
  border: 1px solid var(--muted);
  border-radius: 50%;
  position: relative;
  flex: 0 0 12px;
}
.search-icon::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 1px;
  background: var(--muted);
  right: -4px;
  bottom: -1px;
  transform: rotate(40deg);
}
.search-wrap input,
#group-search {
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--ink);
  padding: 9px 0;
  outline: none;
}
#group-search {
  border: 1px solid var(--line);
  background: #010a13;
  padding: 7px 10px;
  margin-bottom: 8px;
}
.check-list { display: flex; flex-direction: column; gap: 2px; }
.filter-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-bottom: 8px;
}
.check-list-scroll {
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--line);
  padding: 6px 8px;
  background: #010a13;
}
#selected-groups-wrap { margin-top: 4px; }
.selected-groups {
  border: 1px solid var(--gold-dim);
  padding: 6px 8px;
  background: #1a150c;
  max-height: 160px;
  overflow: auto;
}
.selected-groups .filter-check { color: var(--ink); }
.filter-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 2px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}
.filter-check:hover { color: var(--ink); }
.filter-check input {
  appearance: none;
  width: 13px;
  height: 13px;
  margin: 0;
  border: 1px solid var(--gold);
  background: transparent;
  cursor: pointer;
  flex: 0 0 13px;
}
.filter-check input:checked { background: var(--gold); }
.filter-check input:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.check-actions { display: flex; gap: 6px; margin-bottom: 8px; }
.check-actions button,
.filters button,
.tabs button,
.pager button,
.actions button,
dialog button {
  background: #0a1420;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 7px 12px;
  border-radius: 0;
  cursor: pointer;
  font-size: 12px;
}
.check-actions button { padding: 4px 8px; color: var(--muted); }
.filter-note { color: var(--muted); font-size: 11px; line-height: 1.4; margin: 12px 0 0; }
.filter-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 auto;
  margin: 12px -18px 0;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line);
  background: var(--sidebar);
  position: sticky;
  bottom: 0;
}
.filter-actions-row { display: flex; gap: 8px; }
.filter-actions-row button { flex: 1; min-width: 0; }
button.primary { border-color: var(--gold); color: var(--gold); background: #1a150c; }
.tabs button.active,
button.primary:hover,
.tabs button:hover,
.filters button:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.stage { padding: 24px 28px 40px; min-width: 0; }
.top { display: flex; justify-content: space-between; gap: 24px; align-items: start; border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.kicker { margin: 0; color: var(--gold); letter-spacing: 0.16em; text-transform: uppercase; font-size: 11px; }
h1 { margin: 0; font-weight: 600; font-size: 28px; }
.upscale-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  max-width: 34em;
  line-height: 1.45;
  letter-spacing: 0.01em;
}
.upscale-note a {
  color: #9a7b45;
  text-decoration: none;
  border-bottom: 1px solid rgba(154, 123, 69, 0.35);
}
.upscale-note a:hover {
  color: var(--gold);
  border-bottom-color: var(--gold);
}
.lang-switch { display: flex; gap: 4px; justify-content: flex-end; margin-bottom: 8px; }
.lang-switch button { padding: 3px 8px; font-size: 11px; letter-spacing: 0.08em; }
.lang-switch button.on { border-color: var(--gold); color: var(--gold); }

.tabs { display: flex; gap: 8px; margin: 18px 0 12px; }
.pager { display: flex; gap: 8px; align-items: center; margin: 8px 0 16px; color: var(--muted); font-size: 13px; }
.infinite-sentinel { height: 1px; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.4; margin: 0; }
.hint:empty { display: none; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); overflow: hidden; }
.card:hover { border-color: var(--gold); }
.card img { width: 100%; height: 124px; object-fit: cover; display: block; background: #000; cursor: zoom-in; }
.card .body { padding: 10px; }
.card h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.card p { margin: 0; color: var(--muted); font-size: 12px; }
.badge { display: inline-block; margin-top: 8px; font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; }
.badge.new { color: var(--new); }
.badge.queued { color: var(--queued); }
.badge.skipped { color: var(--skipped); }
.badge.downloaded { color: var(--downloaded); }
.badge.failed { color: var(--failed); }
.actions { display: flex; gap: 6px; margin-top: 10px; }
.actions button { flex: 1; font-size: 12px; padding: 6px; }
.actions button.on,
#preview-queue.on {
  border-color: var(--gold);
  color: var(--gold);
  background: #1a150c;
}
.actions button[data-act="skipped"].on { border-color: var(--skipped); color: var(--ink); background: #1a1a18; }
.actions button:disabled,
dialog button:disabled { opacity: 0.4; cursor: default; }

dialog {
  border: 1px solid var(--gold-dim);
  background: #010a13;
  color: var(--ink);
  width: min(1100px, 94vw);
  max-height: 94vh;
  padding: 0;
  overflow: hidden;
}
dialog.fill[open] {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  inset: 0;
  display: flex;
  flex-direction: column;
}
dialog::backdrop { background: rgba(1, 10, 19, .82); }
.preview-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.preview-bar span { color: var(--muted); }
.preview-bar #preview-meta { margin-right: auto; }
#preview-fill.on { border-color: var(--gold); color: var(--gold); }
dialog img {
  width: 100%;
  max-height: 80vh;
  object-fit: contain;
  object-position: center;
  background: #000;
  display: block;
}
dialog.fill[open] img {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  max-height: none;
  min-height: 0;
  object-fit: contain;
}

body.universe-tab .skin-only { display: none; }
body.queue-tab .status-block { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .filters {
    position: relative;
    height: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .filter-scroll { overflow: visible; flex: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
