:root {
  color-scheme: dark;
  --bg: #121216; --panel: #1b1b21; --line: #2a2a33; --text: #e8e8ee; --muted: #8b8b98;
  --accent: #6c9cff; --e: #e5484d; --q: #f5a524; --s: #3dd68c;
  /* цвета типов тегов как у gelbooru */
  --animated: #1a5cff;   /* обводка анимированных превью */
  --t-artist: #ff8a65; --t-character: #4fd18b; --t-copyright: #c48bff; --t-meta: #ffb74d; --t-general: var(--accent);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #0e0e11; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.muted { color: var(--muted); }
.error { color: var(--e); }
h1, h2, h3 { font-weight: 600; }
h2 { font-size: 16px; margin: 24px 0 10px; }
h2 .more { font-size: 13px; font-weight: 400; margin-left: 8px; }

/* шапка */
.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 14px; align-items: center; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: #fff; }
.brand img { border-radius: 5px; }
.search { position: relative; flex: 1; max-width: 760px; display: flex; gap: 6px; }
.search input { flex: 1; padding: 8px 11px; border: 1px solid var(--line); border-radius: 6px; background: #0e0e11; color: var(--text); font-size: 14px; outline: none; }
.search input:focus { border-color: var(--accent); }
.search button { padding: 8px 14px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.ac { position: absolute; left: 0; top: 100%; margin: 4px 0 0; padding: 4px 0; list-style: none; min-width: 260px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.ac li { display: flex; justify-content: space-between; gap: 16px; padding: 5px 11px; cursor: pointer; }
.ac li.active, .ac li:hover { background: #26262f; }
.ac li.meta { color: var(--t-meta); }
.ac small, .tags small, .cloud small { color: var(--muted); }
.icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.icon:hover { color: var(--text); border-color: var(--muted); }
.hint { margin: 6px 0; }

/* модалка настроек */
.modal { width: min(420px, 92vw); padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); }
.modal::backdrop { background: rgba(0,0,0,.6); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal h2 { margin: 0; font-size: 15px; }
.modal .icon { width: 28px; height: 28px; border: 0; }
.modal .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px 16px; }
.modal select { padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: #0e0e11; color: var(--text); font-size: 14px; }
.switch { display: flex; align-items: center; gap: 12px; padding: 16px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { position: relative; flex: none; width: 40px; height: 22px; border-radius: 11px; background: #3a3a46; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* теги по типам */
.tag.artist { color: var(--t-artist); } .tag.character { color: var(--t-character); }
.tag.copyright { color: var(--t-copyright); } .tag.meta { color: var(--t-meta); } .tag.general { color: var(--t-general); }

main { padding: 16px; max-width: 1600px; margin: 0 auto; min-height: calc(100vh - 120px); }
.links a { color: var(--muted); font-weight: 600; }
.bottom { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.bottom a { color: var(--muted); }
main.loading { opacity: .5; }

/* главная */
.hero h1 { margin: 8px 0 4px; font-size: 22px; }
.cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.cloud .pill { display: inline-flex; gap: 6px; padding: 4px 9px; background: var(--panel); border-radius: 6px; }

/* галерея */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.card { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 1; background: var(--panel); border-radius: 8px; overflow: hidden; }
.card .thumb { position: relative; display: flex; max-width: 100%; max-height: 100%; }
.card img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
/* анимированный контент: синяя обводка как у gelbooru/rule34 + чип с типом файла */
.card.animated img { outline: 3px solid var(--animated); outline-offset: -3px; }
.kind { position: absolute; left: 8px; top: 8px; display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 6px; border-radius: 5px; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); color: #fff; font: 700 10px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; letter-spacing: .05em; pointer-events: none; }
.kind svg { width: 9px; height: 9px; fill: currentColor; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.card .dot { position: absolute; right: 6px; top: 6px; box-shadow: 0 0 0 2px rgba(0,0,0,.5); }
.dot.explicit { background: var(--e); } .dot.questionable { background: var(--q); } .dot.safe { background: var(--s); }

.pager { display: flex; justify-content: center; gap: 6px; margin: 20px 0; }
.pager a, .pager span { padding: 6px 12px; border-radius: 6px; background: var(--panel); }
.pager .cur { background: var(--accent); color: #fff; }

/* навигация по выдаче на странице поста */
.postnav { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 0 12px; }
.postnav > span { display: flex; gap: 14px; }

/* теги */
.tagfilter { display: flex; gap: 6px; max-width: 560px; margin-bottom: 10px; }
.tagfilter input { flex: 1; padding: 8px 11px; border: 1px solid var(--line); border-radius: 6px; background: #0e0e11; color: var(--text); font-size: 14px; }
.tagfilter select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #0e0e11; color: var(--text); font-size: 14px; }
.tagfilter button { padding: 8px 14px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.tagtable { border-collapse: collapse; width: 100%; max-width: 760px; }
.tagtable th, .tagtable td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); }
.tagtable th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.tagtable td.artist { color: var(--t-artist); } .tagtable td.character { color: var(--t-character); }
.tagtable td.copyright { color: var(--t-copyright); } .tagtable td.meta { color: var(--t-meta); } .tagtable td.general { color: var(--muted); }

/* пост */
.post { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; }
.post aside h3 { margin: 12px 0 6px; font-size: 12px; text-transform: uppercase; color: var(--muted); }
.post aside h3 small { margin-left: 6px; font-weight: 400; }
.tags { list-style: none; margin: 0; padding: 0; }
.tags li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.post dl { margin: 0; } .post dt { font-size: 12px; color: var(--muted); margin-top: 6px; } .post dd { margin: 0; word-break: break-all; }
.stats dd { margin-bottom: 2px; }
.gate { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 320px; background: var(--panel); border-radius: 8px; }
.gate button { padding: 9px 16px; border: 0; border-radius: 6px; background: var(--e); color: #fff; font-weight: 600; cursor: pointer; }
.media .original { margin: 8px 0 0; font-size: 13px; }
.media img, .media video { max-width: 100%; max-height: 88vh; width: auto; height: auto; border-radius: 6px; background: #000; display: block; }

@media (max-width: 760px) {
  .top { flex-wrap: wrap; }
  .post { grid-template-columns: 1fr; }
  .post aside { order: 2; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
}
