:root {
  --bg: #0f1115;
  --panel: #171a21;
  --line: #262a33;
  --text: #e8eaf0;
  --muted: #9aa1ae;
  --accent: #6aa7ff;
  --ok: #3ccf91;
  --warn: #ffb547;
  --bad: #ff6b6b;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
a { color: var(--accent); }
button { font: inherit; cursor: pointer; border: 0; border-radius: 8px; padding: 8px 14px; background: var(--accent); color: #0b1020; font-weight: 600; }
button.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); }
button:disabled { opacity: .5; cursor: default; }
input, select { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }

.bar { position: sticky; top: 0; z-index: 5; display: flex; gap: 16px; align-items: center; padding: 12px 20px; background: rgba(15,17,21,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; white-space: nowrap; }
.brand span { color: var(--muted); font-weight: 500; }
.search { display: flex; gap: 8px; flex: 1; max-width: 760px; }
.search input { flex: 1; padding: 9px 12px; }

.filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; padding: 10px 20px; color: var(--muted); }
.filters label { display: flex; gap: 6px; align-items: center; }
.filters input[type=number] { width: 90px; }
.toggle { color: var(--text); font-weight: 600; }

.status { padding: 0 20px; color: var(--muted); min-height: 20px; }
.status.error { color: var(--bad); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 20px; }
.chips:empty { display: none; }
.chip { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-weight: 500; }
.chip:hover { border-color: var(--accent); }

/* Masonry via CSS columns; aspect-ratio reserves space before thumbnails load. */
.grid { columns: 5 240px; column-gap: 14px; padding: 8px 20px 20px; }
.tile { break-inside: avoid; margin: 0 0 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tile .media { position: relative; display: block; width: 100%; background: #1d212a; cursor: zoom-in; padding: 0; border-radius: 0; }
.tile .media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .badge { position: absolute; top: 8px; left: 8px; }
.tile .meta { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 8px 10px; font-size: 12px; }
.tile .domain { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .note { padding: 0 10px 8px; }

.badge { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .02em; padding: 3px 8px; border-radius: 999px; }
.badge.filtered { background: rgba(60,207,145,.16); color: var(--ok); border: 1px solid rgba(60,207,145,.4); }
.badge.high { background: rgba(255,107,107,.16); color: var(--bad); border: 1px solid rgba(255,107,107,.45); }
.badge.unknown { background: rgba(255,181,71,.14); color: var(--warn); border: 1px solid rgba(255,181,71,.4); }
.tile .badge { backdrop-filter: blur(6px); background-color: rgba(15,17,21,.72); }
.note { color: var(--warn); font-size: 12px; margin: 0; }
.muted { color: var(--muted); }

.more { display: flex; justify-content: center; padding: 0 0 40px; }

dialog { width: min(1200px, 94vw); max-height: 92vh; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.7); }
.close { position: absolute; right: 10px; top: 8px; }
.close button { background: transparent; color: var(--text); font-size: 22px; padding: 2px 10px; }
.pv { display: grid; grid-template-columns: minmax(0, 1fr) 340px; min-height: 60vh; }
.pv-media { display: flex; align-items: center; justify-content: center; background: #0b0d11; }
.pv-media img { max-width: 100%; max-height: 88vh; object-fit: contain; }
.pv-side { padding: 22px; display: flex; flex-direction: column; gap: 6px; overflow: auto; }
.pv-side h2 { margin: 0 0 4px; font-size: 16px; padding-right: 26px; }
.use { margin-top: 14px; border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; gap: 10px; padding: 12px; }
.use label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.use label.check { flex-direction: row; align-items: center; color: var(--text); font-size: 13px; }
@media (max-width: 800px) { .pv { grid-template-columns: 1fr; } .bar { flex-wrap: wrap; } }
/* fieldsets default to min-width:min-content, which overflowed the 340px side panel */
.use { min-width: 0; }
.use input:not([type=checkbox]), .use button { width: 100%; }
.pv-side { min-width: 0; }
#pv-result { overflow-wrap: anywhere; }
.apikey { width: 180px; }
