:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6b6b70;
  --border: #deded9;
  --link: #2a5fb0;
  --notice-bg: #fff4d6;
  --notice-text: #5c4300;
  --tag-general: #2a5fb0;
  --tag-artist: #b0471e;
  --tag-copyright: #8a3fb0;
  --tag-character: #1f8a4c;
  --tag-meta: #9a7b00;
  --ins: #1f8a4c;
  --del: #b0302a;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151517;
    --surface: #1e1e21;
    --text: #e8e8ea;
    --muted: #9a9aa2;
    --border: #34343a;
    --link: #7fa8ee;
    --notice-bg: #3a3014;
    --notice-text: #f3dd9c;
    --tag-general: #7fa8ee;
    --tag-artist: #f0956d;
    --tag-copyright: #cf9cef;
    --tag-character: #6fd39a;
    --tag-meta: #e6c95c;
    --ins: #6fd39a;
    --del: #f08a84;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 1.2rem 0 0.4rem; }
code { font-size: 0.9em; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 0 0.3em; }

header.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.25rem;
  padding: 0.6rem 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
header nav { display: flex; flex-wrap: wrap; gap: 0.9rem; }
.search { margin-left: auto; flex: 1 1 14rem; max-width: 28rem; }
input[type=search] {
  width: 100%; padding: 0.4rem 0.6rem; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
}
form.inline { max-width: 24rem; margin-bottom: 1rem; }

main { padding: 1rem 16px; max-width: 1400px; margin: 0 auto; }
footer { padding: 1.5rem 16px; color: var(--muted); font-size: 0.85rem; text-align: center; }

.with-sidebar { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 1.5rem; }
@media (max-width: 720px) {
  .with-sidebar { grid-template-columns: minmax(0, 1fr); }
  .with-sidebar > aside { order: 2; }
}

.taglist { list-style: none; margin: 0; padding: 0; }
.taglist li { overflow-wrap: anywhere; }
.count { color: var(--muted); font-size: 0.85em; }
.tag-general a, a.tag-general { color: var(--tag-general); }
.tag-artist a { color: var(--tag-artist); }
.tag-copyright a { color: var(--tag-copyright); }
.tag-character a { color: var(--tag-character); }
.tag-meta a { color: var(--tag-meta); }

.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem;
}
.card a {
  display: flex; align-items: center; justify-content: center; aspect-ratio: 1;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px; overflow: hidden;
}
.card img { max-width: 100%; max-height: 100%; display: block; }

.sensitive img { filter: blur(18px); transition: filter 0.15s; }
.sensitive:hover img, .sensitive:focus-within img, .sensitive:focus img { filter: none; }

figure.full { margin: 0; }
figure.full img { max-width: 100%; height: auto; display: block; }
.description { color: var(--muted); }

.info { display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.75rem; margin: 0; }
.info dt { color: var(--muted); }
.info dd { margin: 0; overflow-wrap: anywhere; }

.notice { background: var(--notice-bg); color: var(--notice-text); padding: 0.5rem 0.75rem; border-radius: 6px; }
.muted { color: var(--muted); }
.poolnav { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 0.75rem; }
.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin: 1.5rem 0; }

table { border-collapse: collapse; width: 100%; background: var(--surface); }
th, td { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
td.num { text-align: right; width: 5rem; font-variant-numeric: tabular-nums; }
.history ins { color: var(--ins); text-decoration: none; }
.history del { color: var(--del); }
@media (max-width: 720px) {
  table { display: block; overflow-x: auto; }
}

.queue-item { margin-bottom: 2rem; }

.narrow { max-width: 32rem; }
form.stack { display: grid; gap: 0.5rem; }
input[type=text] {
  padding: 0.45rem 0.6rem; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
}
button {
  justify-self: start; padding: 0.45rem 0.9rem; font: inherit; cursor: pointer;
  color: var(--bg); background: var(--link); border: 0; border-radius: 6px;
}
button.link { padding: 0; color: var(--link); background: none; }
button.link:hover { text-decoration: underline; }
.inline-form { display: inline; margin: 0; }
.queue-item h2 { text-transform: none; letter-spacing: 0; font-size: 1.05rem; color: var(--text); }
.me { color: var(--muted); }
.code-to-send code { font-size: 1.3rem; padding: 0.2em 0.5em; user-select: all; }
.flash { padding: 0.5rem 0.75rem; border-radius: 6px; margin: 0 0 1rem; }
.flash-ok { background: var(--surface); border: 1px solid var(--ins); }
.flash-refused { background: var(--notice-bg); color: var(--notice-text); }
button.secondary { color: var(--text); background: var(--surface); border: 1px solid var(--border); }
button.small, input.small { padding: 0.2rem 0.5rem; font-size: 0.85rem; }
input.small { width: 7rem; }
select {
  padding: 0.4rem 0.5rem; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
}
.controls { display: grid; gap: 0.75rem; }
.card-meta { margin: 0.3rem 0; font-size: 0.8rem; color: var(--muted); overflow-wrap: anywhere; }
.decide { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; margin-top: 0.75rem; }
.decide input[type=text] { width: 16rem; max-width: 100%; }
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1.5rem; }
.panel form { margin-bottom: 1rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.row input[type=text] { flex: 1 1 8rem; min-width: 0; }
details.edit, details.report { margin: 0.75rem 0; }
details > summary { cursor: pointer; color: var(--link); }
details > form, details > .panels { margin-top: 0.5rem; }
.marks { margin: 0.5rem 0; }
button[aria-pressed=true] { outline: 2px solid var(--link); outline-offset: 1px; }
.narrow.wide { max-width: 44rem; }
fieldset { border: 1px solid var(--border); border-radius: 6px; padding: 0.5rem 0.75rem 0.75rem; display: grid; gap: 0.4rem; min-width: 0; }
legend { color: var(--muted); padding: 0 0.3rem; }
.pre { white-space: pre-line; }
