:root {
  --bg: #fbfaf8;
  --fg: #1d1b1a;
  --muted: #77716c;
  --line: #e6e1dc;
  --card: #ffffff;
  --accent: #7b3fe4;
  --accent-fg: #fff;
  --danger: #c62828;
  --radius: 10px;
  --pride: linear-gradient(90deg, #e40303, #ff8c00, #ffed00, #008026, #24408e, #732982);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151413;
    --fg: #ece8e4;
    --muted: #9a938d;
    --line: #2d2a28;
    --card: #1d1c1a;
    --accent: #a77bf3;
    --accent-fg: #120b1d;
    --danger: #ef6b6b;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
body.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h1 .small { font-size: .9rem; font-weight: normal; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
code, .mono { font-family: ui-monospace, "JetBrains Mono", monospace; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.stripe { height: 4px; background: var(--pride); position: fixed; inset: 0 0 auto; z-index: 10; }

.top {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 18px 24px 12px; border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--fg); letter-spacing: -.01em; }
.top nav { display: flex; gap: 16px; }
.top nav a { color: var(--muted); }
.top nav a.on { color: var(--fg); font-weight: 600; }
.who { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.who img { border-radius: 50%; }
main { padding: 24px; max-width: 1200px; margin: 0 auto; }

input, select, textarea, button, .button {
  font: inherit; color: inherit; border-radius: 8px;
}
input, select, textarea {
  background: var(--card); border: 1px solid var(--line); padding: 7px 10px; width: 100%;
}
textarea { resize: vertical; }
input[type="checkbox"] { width: auto; }
label { display: block; margin-bottom: 12px; }
label.inline { display: flex; align-items: center; gap: 6px; }
button, .button {
  display: inline-block; cursor: pointer; padding: 7px 14px; border: 1px solid var(--line);
  background: var(--card); text-decoration: none; color: var(--fg); white-space: nowrap;
}
button:hover, .button:hover { border-color: var(--muted); text-decoration: none; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.danger { color: var(--danger); }
button.small { padding: 3px 8px; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; align-items: end; }
.row.wrap label { margin-bottom: 12px; }
.grow { flex: 1; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.card.narrow { max-width: 420px; width: 100%; }
.card > :last-child { margin-bottom: 0; }
details.card summary { cursor: pointer; font-weight: 600; }
details.card[open] summary { margin-bottom: 12px; }
.empty { padding: 48px 0; text-align: center; }
.badge { font-size: .75em; border: 1px solid var(--line); border-radius: 99px; padding: 1px 8px; margin-left: 6px; color: var(--muted); }

.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 18px;
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap; justify-content: space-between;
}
.drop p, .drop label { margin: 0; }
.drop select { width: auto; }
.drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.drop progress { width: 100%; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.chips a { border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; color: var(--fg); font-size: .9em; }
.chips a.on { border-color: var(--accent); color: var(--accent); }

.bulk {
  position: sticky; top: 8px; z-index: 5; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 12px;
  box-shadow: 0 4px 16px rgb(0 0 0 / .08);
}

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.grid.small { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.grid .more { grid-column: 1 / -1; justify-self: center; }
.tile { margin: 0; position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tile img { display: block; width: 100%; height: 180px; object-fit: cover; background: var(--line); }
.grid.small .tile img { height: 110px; }
.tile figcaption { display: flex; justify-content: space-between; padding: 6px 10px; font-size: .85em; }
.tile .pick { position: absolute; top: 6px; left: 6px; margin: 0; background: var(--card); border-radius: 6px; padding: 2px 5px; opacity: 0; }
.tile:hover .pick, .tile.sel .pick, .selecting .tile .pick { opacity: 1; }
.tile.sel { outline: 3px solid var(--accent); outline-offset: -1px; }
.library .tile { cursor: pointer; }
.library .tile.in { opacity: .4; }

.detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.detail .full img { max-width: 100%; height: auto; border-radius: var(--radius); display: block; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
.meta dd { margin: 0; }
@media (max-width: 800px) { .detail { grid-template-columns: 1fr; } main { padding: 16px; } }

.list { list-style: none; padding: 0; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.posts { list-style: none; padding: 0; }
.posts li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.posts img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; }

.editor { max-width: 720px; }
.picked { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.picked li { position: relative; }
.picked img { width: 120px; height: 120px; object-fit: cover; border-radius: 8px; display: block; }
.picked .ctl { position: absolute; bottom: 4px; left: 4px; right: 4px; display: flex; justify-content: center; gap: 4px; }
.picked .ctl button { padding: 0 6px; font-size: .8em; opacity: .9; }
.library { margin-top: 32px; }

.tokens { width: 100%; border-collapse: collapse; }
.tokens th, .tokens td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }

.preview-banner { background: var(--accent); color: var(--accent-fg); text-align: center; padding: 6px; font: 14px system-ui, sans-serif; }
.preview-banner a { color: inherit; text-decoration: underline; }

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