:root {
  --bg: #0a1114;
  --panel: #121c20;
  --panel2: #18262b;
  --line: #243840;
  --text: #eaf4f4;
  --muted: #8ba3a8;
  --accent: #2ee6d0;
  --accent-dark: #0b2f2c;
  --danger: #ff6b6b;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top { background: var(--bg); padding: 10px 14px 8px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.logo { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: #04201d; font-weight: 800; }
.brand-name { font-weight: 800; letter-spacing: .08em; }
.search, select, input[type=text], input[type=number], input[type=url], input[type=password], textarea {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none;
}
.search:focus, select:focus, input:focus, textarea:focus { border-color: var(--accent); }
.tabs { display: flex; gap: 6px; margin: 8px 0; }
.tabs button { flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px; font-size: 13px; }
.tabs button.on { background: var(--accent-dark); border-color: var(--accent); color: var(--accent); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #04201d; font-weight: 600; }
.row { display: flex; gap: 8px; }
.row select { flex: 1; min-width: 0; padding: 8px 10px; font-size: 13px; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--muted); font-size: 13px; }

main { padding: 10px 14px 40px; }
.count { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 820px) { .grid { grid-template-columns: repeat(5, 1fr); } main, .top { max-width: 980px; margin: 0 auto; } }
.card { display: block; width: 100%; align-self: start; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; }
.poster { position: relative; aspect-ratio: 2 / 3; border-radius: 12px; overflow: hidden; background: var(--panel); border: 1px solid var(--line); }
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster .ph { position: absolute; inset: 0; display: flex; align-items: flex-end; padding: 10px; font-weight: 800; font-size: 17px; line-height: 1.15; }
.badge { position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.65); border-radius: 999px; padding: 2px 8px; font-size: 11px; color: var(--accent); }
.marks { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.marks span { background: rgba(0,0,0,.65); border-radius: 999px; width: 22px; height: 22px; display: grid; place-items: center; font-size: 12px; }
.card.seen .poster { opacity: .55; }
.card-title { margin-top: 6px; font-weight: 600; font-size: 14px; line-height: 1.25; }
.card-sub { color: var(--muted); font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 50px 10px; }

.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 20; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto; z-index: 21; background: var(--panel); border-radius: 18px 18px 0 0; padding: 16px 16px calc(18px + env(safe-area-inset-bottom, 0)); max-width: 640px; margin: 0 auto; }
.sheet-head { display: flex; gap: 14px; }
.sheet .poster { width: 110px; flex: none; }
.sheet h2 { margin: 0 0 4px; font-size: 20px; line-height: 1.2; }
.meta { color: var(--muted); font-size: 13px; margin: 2px 0; }
.status { color: var(--accent); }
.desc { margin: 14px 0; white-space: pre-wrap; }
.btn { display: block; width: 100%; border: 1px solid var(--line); background: var(--panel2); border-radius: 12px; padding: 12px; text-align: center; margin-top: 8px; cursor: pointer; }
.btn.primary { background: var(--accent); color: #04201d; border-color: var(--accent); font-weight: 700; }
.btn.on { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .5; }
.btn.danger { color: var(--danger); }
.btns { display: flex; gap: 8px; }
.btns .btn { margin-top: 8px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #000; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 30; }

/* admin */
.wrap { max-width: 640px; margin: 0 auto; padding: 14px; }
.wrap h1 { font-size: 20px; margin: 4px 0 12px; }
.field { margin-bottom: 12px; }
.field label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
textarea { min-height: 110px; resize: vertical; }
.item { display: flex; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; margin-bottom: 8px; }
.item .thumb { width: 44px; height: 66px; border-radius: 6px; background: var(--panel2); object-fit: cover; flex: none; }
.item .info { flex: 1; min-width: 0; }
.item .info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .info span { color: var(--muted); font-size: 12px; }
.item button { border: 1px solid var(--line); background: var(--panel2); border-radius: 8px; padding: 8px 10px; }
.preview { width: 100px; aspect-ratio: 2/3; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; margin-bottom: 8px; background: var(--panel2); }
.err { color: var(--danger); margin: 8px 0; min-height: 1em; }
