:root {
  --bg: #16171d;
  --panel: #1f2129;
  --panel-2: #282b35;
  --border: #353946;
  --text: #e6e6ea;
  --muted: #9a9cab;
  --link: #8fb6ff;
  --accent: #d8b46a;
  --danger: #ff7b7b;
  --ok: #7fd48a;
  --radius: 6px;

  /* tag categories */
  --cat-slot: #e0b060;
  --cat-rarity: #f0d77a;
  --cat-property: #7fb3d5;
  --cat-restriction: #ff9a8a;
  --cat-source: #8fd18f;
  --cat-set: #d9a3ff;
  --cat-general: #9ab4ff;
  --cat-color: #ff9ecf;
  --cat-details: #7ee0c8;
  --cat-material: #d9b38c;
  --cat-theme: #c7a6ff;
  --cat-meta: #b0b3c0;

  color-scheme: dark;
}

* { box-sizing: border-box; }
/* The `hidden` attribute must win over display rules like `.notice { display: flex }`, or elements
   the scripts hide (the notice bar, the upload preview) stay on screen. */
[hidden] { display: none !important; }
html { font-size: 14px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--panel-2); padding: 0.1em 0.35em; border-radius: 4px; font-size: 0.95em; }
h1 { font-size: 1.6rem; margin: 0 0 0.75rem; }
h2 { font-size: 1rem; margin: 1.1rem 0 0.4rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.ok { color: var(--ok); }
.hint { color: var(--muted); font-size: 0.9rem; }

button, .button, input, select {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.7rem;
}
button, .button { cursor: pointer; background: #3a3f52; }
button:hover, .button:hover { background: #474d64; text-decoration: none; }
button:disabled { opacity: 0.45; cursor: default; }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.link-button { background: none; border: none; padding: 0; color: var(--link); cursor: pointer; }
.link-button:hover { background: none; text-decoration: underline; }
.link-button.danger { color: var(--danger); }
.danger-button { background: #5c2626; border-color: #7a3434; }
.danger-button:hover { background: #733030; }
.row { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* header */
.site-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.6rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo { font-weight: 700; font-size: 1.25rem; color: var(--text); }
.logo span { color: var(--accent); }
.logo:hover { text-decoration: none; }
.nav { display: flex; gap: 0.9rem; }
/* Ko-fi's coral, darkened a little so white text keeps a 5:1 contrast ratio. */
.kofi-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: #c93a36;
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  box-shadow: 0 1px 3px #0006;
  transition: background 0.15s, transform 0.15s;
}
.kofi-button:hover { background: #b3302c; color: #fff; text-decoration: none; transform: translateY(-1px); }
.search { display: flex; gap: 0.4rem; flex: 1 1 22rem; min-width: 0; }
.search .tag-input-wrap { flex: 1; }
.search input { width: 100%; }
.user { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.avatar { width: 28px; height: 28px; border-radius: 50%; }
.badge { margin-left: 0.35rem; font-size: 0.75rem; padding: 0.05rem 0.4rem; border-radius: 999px; background: var(--accent); color: #222; }
.notice { background: #3b2a2a; color: var(--text); padding: 0.6rem 1rem; display: flex; gap: 1rem; justify-content: space-between; }

/* autocomplete */
.tag-input-wrap { position: relative; }
.autocomplete {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  margin: 2px 0 0;
  padding: 0.25rem 0;
  list-style: none;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px #0008;
  max-height: 22rem;
  overflow-y: auto;
}
.autocomplete li { display: flex; justify-content: space-between; padding: 0.25rem 0.6rem; cursor: pointer; }
.autocomplete li.active, .autocomplete li:hover { background: #3a3f52; }

/* layout */
main { flex: 1; padding: 1rem; max-width: 1600px; width: 100%; margin: 0 auto; }
.layout { display: grid; grid-template-columns: 16rem minmax(0, 1fr); gap: 1.25rem; }
.sidebar h2:first-child { margin-top: 0; }
@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { order: 2; }
}

/* tags */
.tag { font-weight: 500; }
.tag.current { text-decoration: underline; }
.lock { font-size: 0.75em; margin-right: 0.2rem; opacity: 0.8; }
.count { color: var(--muted); font-size: 0.85em; margin-left: 0.35rem; }
.cat-slot { color: var(--cat-slot); }
.cat-rarity { color: var(--cat-rarity); }
.cat-property { color: var(--cat-property); }
.cat-restriction { color: var(--cat-restriction); }
.cat-source { color: var(--cat-source); }
.cat-set { color: var(--cat-set); }
.cat-general { color: var(--cat-general); }
.cat-color { color: var(--cat-color); }
.cat-details { color: var(--cat-details); }
.cat-material { color: var(--cat-material); }
.cat-theme { color: var(--cat-theme); }
.cat-meta { color: var(--cat-meta); }

.tag-sidebar, .tag-list { list-style: none; padding: 0; margin: 0; }
.tag-sidebar li, .tag-list li { padding: 0.12rem 0; display: flex; align-items: center; flex-wrap: wrap; gap: 0.2rem; }
.tag-sidebar .mini { color: var(--muted); width: 1rem; text-align: center; }
.tag-list li.pending { opacity: 0.55; }
.vote { padding: 0 0.3rem; font-size: 0.7rem; line-height: 1.4; background: transparent; border-color: transparent; color: var(--muted); }
.vote.voted { color: var(--accent); border-color: var(--accent); }
.score { min-width: 1.4rem; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.flag { font-size: 0.75rem; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 0.3rem; }
.mod-tools { flex-basis: 100%; padding-left: 3.4rem; display: flex; gap: 0.5rem; align-items: center; font-size: 0.85rem; }
.mod-tools select { padding: 0.05rem 0.3rem; }

.add-tag { margin-top: 1rem; }
.add-tag input { width: 100%; margin-bottom: 0.4rem; }
.status:empty { display: none; }

/* result grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; }
.thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.6rem 0.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-align: center;
}
.thumb:hover { border-color: var(--accent); text-decoration: none; }
.thumb-img { width: 100%; height: 120px; display: flex; align-items: center; justify-content: center; }
.thumb-img img { max-width: 80px; max-height: 80px; }
.thumb.has-shot .thumb-img img { max-width: 100%; max-height: 120px; object-fit: cover; border-radius: 4px; }
.thumb-name { margin-top: 0.4rem; font-size: 0.9rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; }
.thumb-meta { color: var(--muted); font-size: 0.8rem; }
.rarity-2 .thumb-name, .rarity-text-2 { color: #9be29b; }
.rarity-3 .thumb-name, .rarity-text-3 { color: #8fb6ff; }
.rarity-4 .thumb-name, .rarity-text-4 { color: #c39bff; }
.rarity-7 .thumb-name, .rarity-text-7 { color: #ff9ecf; }
.empty { padding: 2rem; text-align: center; }

.pager { display: flex; justify-content: center; align-items: center; gap: 1.25rem; margin: 1.5rem 0; }
.pager .disabled { color: var(--muted); opacity: 0.5; }

/* item page */
.item-hero { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.item-hero .shot { max-width: min(100%, 520px); border-radius: var(--radius); border: 1px solid var(--border); }
.icon-large { width: 80px; height: 80px; }
table.info { border-collapse: collapse; margin-bottom: 1rem; }
table.info th { text-align: left; color: var(--muted); font-weight: 500; padding: 0.2rem 1.2rem 0.2rem 0; }
table.info td { padding: 0.2rem 0; }
.mod-panel { margin-top: 1.5rem; padding: 0.8rem; border: 1px dashed var(--border); border-radius: var(--radius); }
.mod-panel input { flex: 1; min-width: 12rem; }
.upload-preview { display: block; margin-top: 0.6rem; max-width: 240px; border-radius: var(--radius); border: 1px solid var(--border); }
.same-look { color: var(--muted); }

/* tags page & help */
.filters { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tag-table { border-collapse: collapse; width: 100%; max-width: 760px; }
.tag-table th, .tag-table td { text-align: left; padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--border); }
.tag-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.prose { max-width: 760px; }
.prose li { margin: 0.25rem 0; }

.site-footer { padding: 1rem; text-align: center; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--border); }
