:root {
  --bg: #f4f2ee; --panel: #ffffff; --ink: #1d1b22; --muted: #6c6875; --line: #e2ded6;
  --accent: #d6336c; --accent-ink: #fff; --accent-soft: #fde7ef; --ok: #2b8a3e; --err: #c92a2a;
  --cover-bg: #2a2733; --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15131a; --panel: #1f1c26; --ink: #ece9f1; --muted: #9a95a6; --line: #2f2b38;
    --accent: #ff5d8f; --accent-ink: #1a0610; --accent-soft: #3a1626; --ok: #69db7c; --err: #ff8787;
    --cover-bg: #0e0d12; --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 1.2em 0 .5em; }
h1 { font-size: 1.8rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; }
h1 small, h2 small { color: var(--muted); font-weight: 400; font-size: .6em; margin-left: .4em; }
img { max-width: 100%; display: block; }
code { background: var(--accent-soft); padding: 0 .3em; border-radius: 4px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.top { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top-in { display: flex; align-items: center; gap: 18px; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.logo { font-weight: 800; font-size: 1.15rem; color: var(--ink); letter-spacing: -.01em; }
.logo:hover { text-decoration: none; }
.logo-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px;
  background: var(--accent); color: var(--accent-ink); font-size: .8rem; margin-right: 4px; }
.plats { display: flex; gap: 4px; flex-wrap: wrap; }
.plats a { padding: 4px 10px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: .85rem; }
.plats a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.search { margin-left: auto; flex: 0 1 260px; }
.search input { width: 100%; }
.adminbar { display: flex; align-items: center; gap: 12px; font-size: .9rem; }

input, textarea, select { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=file] { padding: 6px; background: transparent; }
input[type=checkbox] { width: auto; }
label { display: block; font-weight: 600; font-size: .9rem; margin: 0 0 12px; }
label small { font-weight: 400; color: var(--muted); }
label > input, label > textarea, label > select { margin-top: 4px; font-weight: 400; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 4px 0; }
.hp { position: absolute; left: -9999px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px 4px; margin: 0 0 16px; }
legend { font-weight: 700; padding: 0 6px; }

.btn { display: inline-block; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px;
  padding: 9px 16px; font: inherit; font-weight: 700; cursor: pointer; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: progress; }
.btn.small { padding: 5px 11px; font-size: .85rem; }
.btn.big { padding: 12px 22px; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.danger { background: var(--err); color: #fff; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; font-size: .85rem; }
.linkbtn.danger { color: var(--err); }
.linkbtn:hover { text-decoration: underline; }

.flash { padding: 10px 14px; border-radius: 8px; margin: 16px 0; background: var(--accent-soft); white-space: pre-line; }
.flash.ok { border-left: 4px solid var(--ok); }
.flash.error { border-left: 4px solid var(--err); }
.empty { color: var(--muted); }
.hint { color: var(--muted); font-size: .9rem; }
.crumbs { color: var(--muted); font-size: .9rem; margin: 18px 0 0; }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 20px 0; box-shadow: var(--shadow); }
.panel > h1:first-child, .panel > h2:first-child { margin-top: 0; }
.panel.narrow { max-width: 420px; margin: 40px auto; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }

/* platform tiles */
.platform-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 24px; }
.platform-tile { display: grid; gap: 2px; padding: 18px; border-radius: var(--radius); background: var(--panel);
  border: 1px solid var(--line); color: var(--ink); box-shadow: var(--shadow); transition: transform .12s, border-color .12s; }
.platform-tile:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.pt-slug { font-weight: 900; font-size: 1.6rem; color: var(--accent); letter-spacing: .02em; }
.pt-name { font-weight: 600; }
.pt-count { color: var(--muted); font-size: .85rem; }

/* catalog cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; margin-bottom: 32px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  color: var(--ink); box-shadow: var(--shadow); display: flex; flex-direction: column; transition: transform .12s, border-color .12s; }
.card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.cover { aspect-ratio: 3 / 4; background: var(--cover-bg); display: grid; place-items: center; overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover span, .nocover { color: #fff; opacity: .35; font-weight: 900; font-size: 1.6rem; letter-spacing: .05em; }
.card-body { padding: 10px 12px 12px; }
.card-title { font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--muted); font-size: .8rem; margin-top: 4px; }
.meta.big { font-size: .95rem; }
.tag { background: var(--accent-soft); color: var(--accent); border-radius: 4px; padding: 0 6px; font-weight: 700; }

/* rom page */
.rom { display: grid; grid-template-columns: minmax(200px, 320px) 1fr; gap: 28px; margin-top: 12px; }
.rom-cover img, .nocover { border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; }
.nocover { aspect-ratio: 3/4; background: var(--cover-bg); display: grid; place-items: center; }
.rom-info h1 { margin-top: 0; overflow-wrap: anywhere; }
.desc { margin: 16px 0; }
.files { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.files li { display: flex; align-items: center; gap: 10px; }
.dl { flex: 1; display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 14px;
  background: var(--accent); color: var(--accent-ink); border-radius: 8px; font-weight: 700; min-width: 0; }
.dl:hover { text-decoration: none; filter: brightness(1.08); }
.dl::before { content: "⬇"; }
.fname { flex: 1; overflow-wrap: anywhere; }
.fsize { opacity: .8; font-weight: 500; white-space: nowrap; }
.fcount { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.shot img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; image-rendering: pixelated; background: var(--cover-bg); }
.shot:hover img { outline: 2px solid var(--accent); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: grid; place-items: center; z-index: 50; cursor: zoom-out; padding: 16px; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; image-rendering: pixelated; min-width: min(640px, 100%); object-fit: contain; }

/* comments */
.comments { max-width: 760px; }
.comment { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 10px 0; }
.comment.reply { margin: 10px 0 4px 18px; background: var(--bg); }
.comment.by-admin { border-left: 3px solid var(--accent); }
.comment.compact { margin: 8px 0; }
.c-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: .9rem; }
.c-head time { color: var(--muted); font-size: .8rem; margin-left: auto; }
.c-body { margin-top: 4px; overflow-wrap: anywhere; }
.c-actions { display: flex; gap: 14px; margin-top: 6px; }
.badge { background: var(--accent); color: var(--accent-ink); font-size: .7rem; font-weight: 800; padding: 1px 6px; border-radius: 4px; text-transform: uppercase; }
.replyform { margin: 10px 0 0 18px; display: grid; gap: 8px; justify-items: start; }
.comment-form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 20px 0 40px; }
.comment-form h3 { margin-top: 0; }

/* admin */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stats div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stats b { display: block; font-size: 1.6rem; }
.stats span { color: var(--muted); font-size: .85rem; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th, .tbl td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.tbl .right { text-align: right; white-space: nowrap; }
.tbl form { display: inline; margin-left: 10px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.inline-form input { width: auto; flex: 1 1 140px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 12px; }
.thumbs figure { margin: 0; width: 150px; font-size: .8rem; }
.thumbs img { width: 150px; height: 150px; object-fit: cover; border-radius: 8px; background: var(--cover-bg); }
.thumbs figcaption { color: var(--muted); margin-top: 4px; }
.orphan-list { max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin-bottom: 12px; }
.progress { margin: 12px 0; }
.progress .bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress .bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.progress .ptext { font-size: .85rem; color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; }
.danger-zone { border-color: var(--err); }
.danger-zone form { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.foot { color: var(--muted); font-size: .8rem; padding-top: 30px; padding-bottom: 30px; }

@media (max-width: 700px) {
  .rom { grid-template-columns: 1fr; }
  .rom-cover { max-width: 260px; }
  .search { flex-basis: 100%; margin-left: 0; order: 5; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  h1 { font-size: 1.5rem; }
}
