:root {
  --bg: #1a1b1e; --card: #25262b; --line: #35373d; --text: #f1f2f4; --muted: #a0a3ab;
  --accent: #5865f2; --good: #3ba55d; --warn: #faa61a; --bad: #ed4245;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f2f3f5; --card: #fff; --line: #dcdee3; --text: #1c1d21; --muted: #5d606a; color-scheme: light; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
button { font: inherit; color: inherit; cursor: pointer; }
main { max-width: 640px; margin: 0 auto; padding: 0 12px calc(24px + env(safe-area-inset-bottom)); }

.center { min-height: 100dvh; display: grid; place-content: center; text-align: center; gap: 16px; padding: 24px; }
.center h1 { margin: 0; font-size: 1.8rem; }
.center p { margin: 0; color: var(--muted); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 22px;
  border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; text-decoration: none; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: .9rem; }
.err { color: var(--bad); }

header.top { position: sticky; top: 0; z-index: 5; margin: 0 -12px; padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: var(--bg); border-bottom: 1px solid var(--line); }
.top .row { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.me { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: .9rem; color: var(--muted); }
.me img { width: 28px; height: 28px; border-radius: 50%; }
.me span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 8px; }
.progress { margin: 8px 0; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--good); transition: width .3s; }
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tab { flex: 1 0 auto; min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 20px; background: transparent; white-space: nowrap; }
.tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.banner { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--warn); font-size: .9rem; }

.card { margin-top: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.gallery { position: relative; background: #000; }
.slides { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }
.slides::-webkit-scrollbar { display: none; }
.slides img { flex: 0 0 100%; width: 100%; max-height: 70dvh; object-fit: contain; scroll-snap-align: center; aspect-ratio: 4/3; background: #000; cursor: zoom-in; }
.count { position: absolute; top: 10px; right: 10px; padding: 2px 10px; border-radius: 12px; background: rgba(0,0,0,.65); color: #fff; font-size: .8rem; }
.dots { position: absolute; bottom: 8px; left: 0; right: 0; display: flex; gap: 6px; justify-content: center; pointer-events: none; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.4); }
.dots i.on { background: #fff; }
.body { padding: 12px 14px 14px; }
.body h2 { margin: 0 0 4px; font-size: 1.15rem; overflow-wrap: anywhere; }
.body h2 .by { font-weight: 400; color: var(--muted); }
.author { color: var(--muted); font-size: .85rem; margin: 0 0 4px; }
.desc { margin: 0; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.desc.open { -webkit-line-clamp: unset; display: block; }
.more { padding: 6px 0; background: none; border: 0; color: var(--accent); }

.vote { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.vote .status { display: flex; justify-content: space-between; align-items: center; min-height: 32px; margin-bottom: 8px; font-size: .9rem; color: var(--muted); }
.status b { color: var(--good); font-size: 1rem; }
.scores { display: grid; grid-template-columns: repeat(var(--n, 10), minmax(0, 1fr)); gap: 3px; }
.scores button { min-height: 44px; min-width: 0; padding: 0; border-radius: 8px; border: 1px solid var(--line); background: transparent; font-weight: 700; font-size: .95rem; }
.scores button[aria-pressed="true"] { background: var(--good); border-color: var(--good); color: #fff; }
.scores button:disabled { opacity: .45; cursor: not-allowed; }
.own { color: var(--warn); }

.list { margin: 14px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.list li { display: flex; align-items: center; gap: 12px; padding: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.list img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background: #000; }
.list .t { flex: 1; min-width: 0; }
.list .t strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .t small { color: var(--muted); }
.list .n { font-weight: 700; font-size: 1.1rem; min-width: 3ch; text-align: right; }
.rank { font-weight: 700; color: var(--muted); width: 2ch; text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 48px 12px; }
.admin { margin-top: 14px; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; display: grid; gap: 10px; }
.admin h3 { margin: 0; }
.admin .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.manual { margin-top: 14px; }
.manual input[type="text"], .manual textarea { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
.manual label { font-size: .9rem; color: var(--muted); }
.manual .btn { justify-self: start; }

#lightbox { border: 0; padding: 0; background: #000; width: 100vw; height: 100dvh; max-width: none; max-height: none; }
#lightbox img { width: 100%; height: 100%; object-fit: contain; display: block; }
#lightbox::backdrop { background: #000; }
#toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0;
  padding: 10px 18px; border-radius: 22px; background: #111; color: #fff; font-size: .9rem; pointer-events: none; transition: .2s; z-index: 50; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--bad); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
