:root, [data-theme="dark"] {
  --bg: #0e0f13;
  --panel: #171920;
  --line: #262933;
  --text: #e7e8ec;
  --muted: #8a8f9c;
  --accent: #7aa2ff;
}

/* Dawn: warm, pale morning light. */
[data-theme="dawn"] {
  --bg: #fbf3ec;
  --panel: #fffaf5;
  --line: #ecdccd;
  --text: #3b2f2a;
  --muted: #9a7f70;
  --accent: #e0745a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}

header, nav, main, footer { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

header { display: flex; align-items: center; gap: 12px; padding-top: 20px; }
h1 { font-size: 18px; margin: 0; }
#count { color: var(--muted); flex: 1; }

button, input, select {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
}
button { cursor: pointer; }
button:hover, select:hover { border-color: var(--accent); }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

nav { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 16px; padding-bottom: 16px; }
#search { flex: 1; min-width: 180px; }

main {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.preview {
  aspect-ratio: 1;
  border-radius: 6px;
  display: grid;
  place-items: center;
}
.preview img { width: 80%; height: 80%; object-fit: contain; }
[data-bg="check"] .preview {
  background: repeating-conic-gradient(#8884 0 25%, transparent 0 50%) 0 0 / 16px 16px;
}
[data-bg="dark"] .preview { background: #1d1f27; }
[data-bg="light"] .preview { background: #f2f2f2; }

.name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { color: var(--muted); font-size: 12px; }

.id {
  font: 12px ui-monospace, Consolas, monospace;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 4px 6px;
}
.id.none { color: var(--muted); cursor: default; }

footer { color: var(--muted); padding-top: 24px; padding-bottom: 32px; }
a { color: var(--accent); }

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 6px 12px; border-radius: 6px;
  opacity: 0; transition: opacity .15s; pointer-events: none;
}
#toast.show { opacity: 1; }
