/* Self-hosted pixel font (Press Start 2P, OFL) — no external CDN. */
@font-face {
  font-family: 'Press Start 2P';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/press-start-2p.woff2') format('woff2');
}

/* terraria-texturepacks.com — Terraria-style dark theme.
   Visual language: night-blue canvas, wood header, grass/dirt terrain divider,
   "inventory slot" beveled panels, pixel headings, grass-green primary actions.
   Ad slots keep fixed min-heights to prevent Cumulative Layout Shift (Module G). */

:root {
  /* Surfaces */
  --bg: #0d1426;          /* night canvas */
  --panel: #1a2240;       /* inventory-slot panel face */
  --inset: #141a30;       /* recessed slot / ad placeholder */
  --footer: #191f33;

  /* Wood (header / terrain) */
  --wood: #3a2817;
  --wood-edge: #5a4128;
  --wood-dark: #1f140a;
  --dirt: #6b4a2b;

  /* Bevel edges (light = top/left, dark = bottom/right) */
  --bevel-light: #4d5c92;
  --bevel-dark: #29335c;

  /* Accents */
  --grass: #5fbf4f;
  --grass-light: #8ee07a;
  --grass-dark: #3c8f30;
  --gold: #ffce54;
  --gold-dim: #e8c878;
  --gold-bg: #241a08;
  --gold-edge: #5a4410;
  --danger: #e2655a;

  /* Text */
  --text: #eef1ff;
  --text-2: #9aa3c4;
  --text-muted: #6f78a0;

  --radius: 0;            /* pixel/blocky: square corners by default */
  --maxw: 1120px;
  --pixel: 'Press Start 2P', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--grass); text-decoration: none; }
a:hover { color: var(--grass-light); text-decoration: underline; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* Pixel headings — logo + section/page titles. Body stays sans for legibility. */
h1, h2 { font-family: var(--pixel); font-weight: 400; line-height: 1.5; color: var(--text); }
h1 { font-size: 18px; margin: 0 0 14px; }
h2 { font-size: 13px; color: var(--gold); margin: 0 0 12px; }
h3 { font-size: 1rem; font-weight: 500; margin: 8px 0 4px; }

/* ── Header (Terraria forest splash, tiles horizontally) ─────── */
.site-header {
  background-color: #2c3d2c;
  /* Dark overlay keeps nav text readable over the bright forest scene. */
  background-image: linear-gradient(rgba(13,20,38,.5), rgba(13,20,38,.62)), url('/img/header-splash.webp');
  background-repeat: no-repeat, repeat-x;
  background-position: center, center;
  background-size: cover, auto 100%;
  image-rendering: pixelated;
  border-top: 2px solid #1c2a1c;
  border-bottom: 3px solid #0c160c;
}
.nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 12px 16px; min-height: 60px; }
.site-header .brand, .site-header .nav-links a, .site-header .link-btn { text-shadow: 0 1px 2px rgba(0,0,0,.7); }
.brand { font-family: var(--pixel); font-size: 16px; color: var(--grass); }
.brand:hover { text-decoration: none; }
.brand span { color: var(--gold); }
.nav-toggle { display: none; }
.nav-burger { display: none; cursor: pointer; color: #cdd3e8; font-size: 24px; line-height: 1; margin-left: auto; padding: 0 4px; }
.nav-collapse { display: flex; align-items: center; gap: 16px; flex: 1; }
.nav-search { flex: 1; }
.nav-search input {
  width: 100%; max-width: 280px; padding: 8px 12px;
  background: var(--bg); color: var(--text); font: inherit;
  border: 2px solid var(--bevel-dark); border-top-color: #15192e; border-radius: 0;
}
.nav-search input::placeholder { color: var(--text-muted); }
.nav-links { display: flex; align-items: center; gap: 14px; }
.nav-links a { color: #cdd3e8; font-size: 13px; }
.nav-links a:hover { color: var(--grass); }
.link-btn { background: none; border: none; color: var(--gold); cursor: pointer; font: inherit; font-size: 13px; }
.inline { display: inline; }

/* ── Terrain divider (grass over dirt) ───────────────────────── */
.ground-grass { height: 8px; background: var(--grass); }
.ground-dirt { height: 14px; background: var(--dirt); border-bottom: 2px solid var(--wood); }

/* ── Inventory-slot bevel (shared panel look) ────────────────── */
.pack-card, .claim-item, .versions, .description, .form,
.ad-sidebar, .ad-header, .ad-affiliate {
  border: 2px solid var(--bevel-dark);
  border-top-color: var(--bevel-light);
  border-left-color: var(--bevel-light);
}

/* ── Ad slots (fixed heights → no CLS) ───────────────────────── */
.ad-slot {
  display: flex; align-items: center; justify-content: center;
  margin: 16px auto; overflow: hidden; background: var(--inset);
  color: var(--text-muted); font-size: 12px; text-align: center;
}
/* An empty slot (no banner and no ad unit) collapses entirely — no empty box. */
.ad-slot:not(:has(a, ins, img)) {
  display: none !important; min-height: 0; margin: 0; border: 0;
}
.ad-header { min-height: 90px; }
.ad-sidebar { min-height: 600px; width: 300px; max-width: 100%; } /* Half Page (300x600) */
.ad-sidebar-bottom { min-height: 250px; } /* Medium Rectangle (300x250) */
.ad-affiliate { min-height: 90px; flex: 1; }
.ad-slot img { max-width: 100%; height: auto; display: block; }
/* A responsive AdSense <ins> measures its parent's width. As a flex child it
   collapses to width:0 → "No slot size for availableWidth=0". For ad slots,
   drop the flex layout so the container keeps its block width and let the <ins>
   fill it. */
.ad-slot:has(ins.adsbygoogle) { display: block; }
.ad-slot ins.adsbygoogle { display: block; width: 100%; }

/* ── Sidebar popular lists ───────────────────────────────────── */
.popular {
  background: var(--panel); padding: 12px 14px; margin: 14px 0;
  border: 2px solid var(--bevel-dark); border-top-color: var(--bevel-light); border-left-color: var(--bevel-light);
}
.popular-title { font-family: var(--pixel); font-size: 10px; color: var(--gold); margin: 14px 0 8px; }
.popular-title:first-child { margin-top: 0; }
.popular-cards { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.pop-card {
  display: flex; gap: 8px; padding: 6px; background: var(--inset);
  border: 2px solid var(--bevel-dark); border-top-color: var(--bevel-light); border-left-color: var(--bevel-light);
}
.pop-thumb { flex: 0 0 auto; width: 64px; height: 48px; overflow: hidden; background: var(--bg); }
.pop-thumb img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.pop-noimg { display: grid; place-items: center; width: 100%; height: 100%; color: var(--text-muted); font-size: 10px; }
.pop-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.pop-name { color: var(--text); font-size: 13px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-name:hover { color: var(--grass); }
.pop-dls { color: var(--text-muted); font-size: 11px; }
.pop-btn { align-self: flex-start; padding: 3px 8px; font-size: 11px; margin-top: 2px; }

/* ── Layout ──────────────────────────────────────────────────── */
.layout-with-sidebar { display: grid; grid-template-columns: 1fr 300px; gap: 28px; padding: 24px 16px; }
.content.narrow { max-width: 560px; }
.center { text-align: center; }
.lead { color: var(--text-2); font-size: 1rem; }
@media (max-width: 880px) {
  .layout-with-sidebar { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* ── Pack grid + cards ───────────────────────────────────────── */
.pack-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.pack-card { background: var(--panel); padding: 8px; transition: border-color .12s; }
.pack-card:hover { border-color: var(--grass); border-top-color: var(--grass-light); border-left-color: var(--grass-light); }
.pack-card h3 { color: var(--text); }
.pack-card a, .pack-card a:hover { text-decoration: none; }
.thumb { aspect-ratio: 16/9; background: var(--inset); overflow: hidden; image-rendering: pixelated; }
.thumb img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.thumb-placeholder { display: grid; place-items: center; height: 100%; color: var(--text-muted); font-size: .85rem; }
.meta { color: var(--text-muted); font-size: .85rem; margin: 4px 2px; }
.author { color: var(--text-2); }
.badge.unclaimed {
  display: inline-block; font-size: 10px; background: var(--gold); color: #4a3a06;
  padding: 2px 6px; margin: 0 2px; border-radius: 0;
}

/* ── Buttons (beveled) ───────────────────────────────────────── */
.btn {
  display: inline-block; padding: 10px 14px; font: inherit; font-size: 13px; cursor: pointer;
  color: var(--text); background: #202a4a; border-radius: 0;
  border: 2px solid var(--bevel-dark); border-top-color: var(--bevel-light); border-left-color: var(--bevel-light);
}
.btn:hover { text-decoration: none; background: #283360; }

.btn-download {
  font-family: var(--pixel); font-size: 15px; letter-spacing: .5px; color: #0c2b08;
  background: var(--grass); padding: 16px 22px; border: 3px solid var(--grass-dark);
  border-top-color: var(--grass-light); border-left-color: var(--grass-light);
  text-shadow: 0 1px 0 rgba(255,255,255,.35);
}
.btn-download:hover { background: var(--grass-light); }
/* Make the main download CTA on the detail page extra prominent. */
.download-row .btn-download { font-size: 17px; padding: 18px 26px; }

.btn-support {
  color: var(--gold); background: var(--gold-bg);
  border: 2px solid var(--gold-edge); border-top-color: #8a691a; border-left-color: #8a691a;
}
.btn-support:hover { background: #2e2109; }

.btn-claim { color: #cdd3e8; }
.btn-steam { color: #fff; background: #1b2838; border-color: #0b0f16; border-top-color: #2a475e; border-left-color: #2a475e; }
.btn-steam:hover { background: #2a475e; }
.author-link { color: inherit; }
.author-link:hover { color: var(--grass); }
.btn-approve { color: #0c2b08; background: var(--grass); border-color: var(--grass-dark); border-top-color: var(--grass-light); border-left-color: var(--grass-light); }
.btn-reject { color: #fff; background: #7d2b27; border-color: #4a1714; border-top-color: #a8443e; border-left-color: #a8443e; }

.download-row { display: flex; align-items: stretch; gap: 16px; flex-wrap: wrap; margin: 18px 0; }
.download-row .btn-download { display: flex; align-items: center; }

/* Affiliate native banner (Module G · Slot 3) */
.ad-affiliate { background: #1c1608; border-color: var(--gold-edge); border-top-color: #8a691a; border-left-color: #8a691a; padding: 8px 12px; }
.affiliate-text { color: var(--gold); font-size: 13px; }

/* ── Pack detail ─────────────────────────────────────────────── */
.mirror-note {
  background: var(--gold-bg); border-left: 3px solid var(--gold-dim);
  color: var(--gold-dim); font-size: 12px; padding: 8px 12px; margin: 0 0 16px;
}
.gallery { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.gallery img { max-height: 200px; border: 2px solid var(--bevel-dark); image-rendering: pixelated; }
.video-link { align-self: center; }
.description { background: var(--panel); padding: 14px 16px; margin: 18px 0; }
.description :is(p, li) { color: #bcc4e0; }
.description a { color: var(--grass); }
/* Limit inline image width so embedded images never overflow the column. */
.description img, .md-preview img { max-width: 100%; width: auto; height: auto; max-height: 480px; border: 2px solid var(--bevel-dark); }

/* ── Tables (version history, claims) ────────────────────────── */
.versions { background: var(--panel); padding: 4px 14px 8px; margin-top: 8px; overflow-x: auto; }
.versions table { width: 100%; border-collapse: collapse; }
.versions th, .versions td { text-align: left; padding: 9px 6px; font-size: 13px; }
.versions th { color: var(--text-muted); font-size: 11px; font-weight: 400; border-bottom: 2px solid var(--bevel-dark); }
.versions td { color: #cdd3e8; border-bottom: 2px solid #1f273f; }

/* ── Forms ───────────────────────────────────────────────────── */
.form { background: var(--panel); padding: 16px; }
.form label { display: block; margin: 12px 0; color: var(--text-2); font-size: 14px; }
.form input, .form textarea {
  width: 100%; margin-top: 6px; padding: 9px 12px; font: inherit;
  background: var(--bg); color: var(--text);
  border: 2px solid var(--bevel-dark); border-top-color: #15192e; border-radius: 0;
}
.hint { color: var(--text-muted); font-size: .85rem; }
.alert.error {
  background: #2a1416; border-left: 3px solid var(--danger);
  color: #f0b8b3; padding: 10px 14px; margin: 12px 0;
}

/* SSO buttons */
.sso { margin-top: 18px; }
.sso p { color: var(--text-muted); font-size: 13px; }
.sso-discord { background: #5865f2; color: #fff; border-color: #3c47c4; border-top-color: #7b86f6; border-left-color: #7b86f6; }
.sso-github  { background: #24292e; color: #fff; border-color: #101316; border-top-color: #444b53; border-left-color: #444b53; }
.sso-google  { background: #ffffff; color: #1f1f1f; border-color: #c9ccd1; border-top-color: #fff; border-left-color: #fff; }
.sso-steam   { background: #1b2838; color: #c7d5e0; border-color: #0c1620; border-top-color: #3a5a78; border-left-color: #3a5a78; }

/* ── Claim popup ─────────────────────────────────────────────── */
.modal-claim { text-align: left; max-width: 440px; }
.modal-claim h2 { text-align: center; margin: 0 0 10px; }
.claim-sso { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.claim-sso .btn { width: 100%; }
.claim-or { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 12px; margin: 14px 0 12px; }
.claim-or::before, .claim-or::after { content: ""; flex: 1; height: 1px; background: var(--bevel-dark); }
.claim-form textarea { width: 100%; min-height: 96px; resize: vertical; margin-bottom: 10px; }
.claim-form .btn { width: 100%; }

/* ── Before/after comparison slider ──────────────────────────── */
.compare { margin: 0 0 18px; }
/* The "after" image (in normal flow) defines the frame size; the "before" image
   is overlaid and revealed from the left via clip-path driven by the range. */
.compare-frame { position: relative; width: 100%; overflow: hidden; user-select: none; border: 3px solid var(--bevel-dark); background: var(--inset); line-height: 0; }
.compare-after { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.compare-before { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; clip-path: inset(0 50% 0 0); }
.compare-handle { position: absolute; top: 0; bottom: 0; left: 50%; width: 3px; background: var(--gold); transform: translateX(-1.5px); pointer-events: none; }
.compare-handle span { position: absolute; top: 50%; left: 50%; width: 30px; height: 30px; transform: translate(-50%, -50%); background: var(--gold); color: #1a1206; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; line-height: 1; }
.compare-handle span::before { content: "⇆"; }
.compare-range { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; }
.compare-tag { position: absolute; top: 8px; padding: 2px 8px; font-size: 11px; line-height: 1.4; color: #fff; background: rgba(0,0,0,.6); pointer-events: none; }
.compare-tag-before { left: 8px; }
.compare-tag-after { right: 8px; }

/* ── Connected accounts (profile) ────────────────────────────── */
.sso-list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.sso-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--inset); border: 2px solid var(--bevel-dark); padding: 8px 10px; }
.sso-list .sso-name { font-weight: bold; }
.sso-list .sso-badge.ok { color: #7ed67e; font-size: 13px; }

/* ── Admin collapsible config list ───────────────────────────── */
.config-list > summary { cursor: pointer; list-style: revert; }
.config-list > summary h2 { margin: 0; }
.config-list[open] > summary { margin-bottom: 8px; }

/* ── Card rating ─────────────────────────────────────────────── */
.card-rating { display: flex; align-items: center; gap: 6px; margin: 2px 0 0; font-size: 12px; color: var(--text-muted); }
.card-stars { letter-spacing: 1px; }
.card-stars .cstar { color: #3a3f52; }
.card-stars .cstar.on { color: var(--gold, #f2c14e); }

/* ── AI summary (above the original description) ─────────────── */
.ai-summary { }
.ai-summary-label { margin: 0 0 4px; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--gold, #f2c14e); }
.ai-summary > :not(.ai-summary-label) { color: var(--text, #cdd3e8); }
.ai-divider { border: 0; border-top: 2px dashed var(--bevel-dark); margin: 14px 0; }

/* ── Star rating (pixel-art) ─────────────────────────────────── */
.rating { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 2px; }
.rating .stars { display: inline-flex; gap: 2px; }
.rating .star { padding: 0; background: none; border: 0; cursor: pointer; line-height: 0; }
.rating .star svg { width: 26px; height: 26px; image-rendering: pixelated; fill: #3a3f52; stroke: #12141f; stroke-width: .4; transition: fill .1s; }
.rating .star.on svg { fill: var(--gold, #f2c14e); }
.rating .star:disabled { cursor: default; }
.rating .star:not(:disabled):hover svg { fill: #ffd76a; }
.rating-meta { color: var(--text-muted); font-size: 13px; }
.rating-meta b { color: var(--gold, #f2c14e); }
.rating-login { font-size: 12px; }

/* ── Crawler live progress ───────────────────────────────────── */
.crawl-progress { margin: 12px 0; }
.crawl-bar { height: 16px; background: var(--inset); border: 2px solid var(--bevel-dark); overflow: hidden; }
.crawl-bar span { display: block; height: 100%; width: 0; background: var(--gold); transition: width .4s ease; }
.crawl-progress .hint { margin: 6px 0 0; }
.crawl-progress.stuck .crawl-bar span { background: #e0574a; }
.crawl-progress.stuck .hint { color: #e0574a; }

/* ── Maintenance jobs (admin) ────────────────────────────────── */
.jobs-status { margin: 10px 0; }
.job-row { padding: 4px 0; border-bottom: 1px dashed var(--bevel-dark); }
.job-row:last-child { border-bottom: 0; }
.job-row .hint { display: inline; margin: 0 0 0 4px; }
.job-phase { text-transform: uppercase; font-size: .75em; padding: 1px 6px; border: 2px solid var(--bevel-dark); background: var(--inset); }
.job-phase.running { background: var(--gold); color: #000; }
.job-phase.done { background: #4a8f3c; color: #fff; }
.job-phase.error { background: #e0574a; color: #fff; }
.job-err { color: #e0574a; }

/* ── Claims (admin) ──────────────────────────────────────────── */
.claim-item { background: var(--panel); padding: 14px; margin: 12px 0; }
.proof { background: var(--bg); padding: 10px; white-space: pre-wrap; color: #cdd3e8; font-size: 13px; }

/* ── Toolbar / pagination ────────────────────────────────────── */
.toolbar { display: flex; gap: 12px; margin: 12px 0; }
.toolbar a { color: var(--text-2); }
.toolbar a.active { color: var(--gold); }
.pagination { display: flex; gap: 16px; align-items: center; margin: 24px 0; color: var(--text-2); }

/* ── Footer ──────────────────────────────────────────────────── */
.site-footer {
  background: var(--footer); border-top: 3px solid var(--wood);
  color: var(--text-muted); margin-top: 40px; padding: 16px 0; font-size: .9rem;
}
.site-footer a { color: var(--text-2); }
.lang-form { margin-bottom: 8px; }
.lang-form select { background: var(--bg); color: var(--text); border: 2px solid var(--bevel-dark); padding: 4px 8px; }
.translated-note { color: var(--text-muted); font-size: 12px; margin: 0 0 8px; padding: 6px 10px; background: var(--inset); border-left: 3px solid var(--accent-2, var(--grass)); }

/* ── Admin area ──────────────────────────────────────────────── */
.admin-crumb { color: var(--text-muted); font-size: 13px; margin: 0 0 8px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin: 8px 0 24px; }
.stat-card {
  background: var(--panel); padding: 16px; display: flex; flex-direction: column; gap: 6px; text-decoration: none;
  border: 2px solid var(--bevel-dark); border-top-color: var(--bevel-light); border-left-color: var(--bevel-light);
}
.stat-card:hover { border-color: var(--grass); text-decoration: none; }
.stat-num { font-family: var(--pixel); font-size: 18px; color: var(--gold); }
.stat-label { color: var(--text-2); font-size: 13px; }
.admin-nav { list-style: none; padding: 0; }
.admin-nav li { padding: 9px 0; border-bottom: 2px solid #1f273f; color: var(--text-2); }

.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; background: var(--panel); }
.admin-table th, .admin-table td { text-align: left; padding: 10px 8px; font-size: 13px; border-bottom: 2px solid #1f273f; }
.admin-table th { color: var(--text-muted); font-size: 11px; font-weight: 400; }
.admin-table td { color: #cdd3e8; }
.admin-table code { color: var(--text-2); font-size: 12px; }
.actions { display: flex; gap: 8px; white-space: nowrap; }
.btn-small { padding: 5px 10px; font-size: 12px; }
.pill { background: #202a4a; color: #cdd3e8; padding: 2px 8px; font-size: 11px; }
.truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Form extras (admin + auth) */
.form select {
  width: 100%; margin-top: 6px; padding: 9px 12px; font: inherit;
  background: var(--bg); color: var(--text); border: 2px solid var(--bevel-dark); border-top-color: #15192e; border-radius: 0;
}
.form .checkbox { display: flex; align-items: center; gap: 8px; }
.form .checkbox input { width: auto; margin: 0; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.cf-turnstile { margin: 12px 0; }

/* ── Markdown editor ─────────────────────────────────────────── */
.field { margin: 12px 0; }
.field-label { display: block; color: var(--text-2); font-size: 14px; margin-bottom: 6px; }
.md-editor {
  border: 2px solid var(--bevel-dark); border-top-color: var(--bevel-light); border-left-color: var(--bevel-light);
  background: var(--bg);
}
.md-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  padding: 6px; background: var(--panel); border-bottom: 2px solid var(--bevel-dark);
}
.md-btn {
  font: inherit; font-size: 12px; cursor: pointer; color: #cdd3e8;
  background: #202a4a; padding: 5px 9px; border: 2px solid var(--bevel-dark);
  border-top-color: var(--bevel-light); border-left-color: var(--bevel-light); border-radius: 0;
}
.md-btn:hover { background: #283360; }
.md-imgbtn { display: inline-flex; align-items: center; }
.md-sep { width: 2px; align-self: stretch; background: var(--bevel-dark); margin: 0 4px; }
.md-status { color: var(--text-muted); font-size: 12px; margin-left: auto; padding: 0 6px; }
.md-status.is-error { color: #f0b8b3; }
.md-input {
  width: 100%; display: block; border: none; resize: vertical; min-height: 200px;
  padding: 12px; font: 14px/1.6 ui-monospace, "Cascadia Code", Consolas, monospace;
  background: var(--bg); color: var(--text);
}
.md-input:focus { outline: 2px solid var(--grass-dark); outline-offset: -2px; }
.md-preview { padding: 12px 14px; min-height: 200px; }
.md-toggle { margin-left: 4px; }

/* ── Badges / categories ─────────────────────────────────────── */
.badges, .card-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 0; }
.badge.cap { text-transform: capitalize; }
.badge-cat { background: #233a5e; color: #bcd5ff; }
a.badge-cat:hover { background: #2c4a78; text-decoration: none; }
.badge-ver { background: #2c3252; color: #cdd3e8; }
.cap { text-transform: capitalize; }
.cat-filter { flex-wrap: wrap; }

/* Run status */
.run-running { background: #3a2c09; color: #ffce54; }
.run-success { background: #1e3a1e; color: #9be884; }
.run-failed  { background: #3a1616; color: #f0b8b3; }
.alert.ok { background: #16301a; border-left: 3px solid var(--grass); color: #bdf0c8; padding: 10px 14px; margin: 12px 0; }

/* Account + sections */
.account-profile, .account-packs { margin-top: 18px; }
.footer-links a { white-space: nowrap; }
details summary { cursor: pointer; color: var(--grass); font-size: 12px; }
details pre { margin-top: 6px; }

/* ── Modern upload form ──────────────────────────────────────── */
.form-card {
  border: 2px solid var(--bevel-dark); border-top-color: var(--bevel-light); border-left-color: var(--bevel-light);
  background: var(--panel); padding: 14px 16px 18px; margin: 0 0 16px;
}
.form-card legend {
  font-family: var(--pixel); font-size: 11px; color: var(--gold);
  padding: 0 8px; margin-left: -4px;
}
.opt { color: var(--text-muted); font-size: 12px; font-weight: 400; }
.req { color: var(--grass); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.btn-block { display: block; width: 100%; text-align: center; }
.upload-form .field-label { font-size: 14px; }

.upload-progress { display: flex; align-items: center; gap: 10px; margin: 14px 0; }
.upload-track { flex: 1; height: 14px; background: var(--inset); border: 2px solid var(--bevel-dark); overflow: hidden; }
.upload-bar { height: 100%; width: 0; background: var(--grass); transition: width .15s; }
.upload-pct { font-family: var(--pixel); font-size: 11px; color: var(--gold); min-width: 44px; text-align: right; }

/* Tag chips */
.tag-preview, .tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tag-chip {
  display: inline-block; font-size: 12px; padding: 3px 10px;
  background: #233a5e; color: #bcd5ff; border-radius: 12px;
}
a.tag-chip:hover { background: #2c4a78; text-decoration: none; }

/* ── Drag & drop upload ──────────────────────────────────────── */
.dropzone {
  margin-top: 6px; padding: 18px; text-align: center;
  background: var(--bg); border: 2px dashed var(--bevel-dark);
  transition: border-color .12s, background .12s;
}
/* JS-enhanced: overlay the native input so click/drop/validation stay native. */
.dropzone.dz-on { position: relative; cursor: pointer; }
.dropzone.dz-on [data-dz-input] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}
.dropzone.dz-on .dz-ui { position: relative; pointer-events: none; }
/* Previews sit above the overlay input so remove buttons are clickable. */
.dropzone.dz-on .dz-previews { pointer-events: auto; }
.dz-item { position: relative; }
.dz-remove {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; line-height: 1;
  display: grid; place-items: center; cursor: pointer; font-size: 12px;
  color: #fff; background: #7d2b27; border: 1px solid #a8443e; border-radius: 0;
}
.dz-remove:hover { background: #a8443e; }
.dropzone:hover { border-color: var(--bevel-light); }
.dropzone.is-drag { border-color: var(--grass); background: #11220f; }
.dropzone.has-files { text-align: left; }
.dz-prompt { color: var(--text-2); margin: 0; font-size: 14px; }
.dz-prompt strong { color: var(--text); }
.dz-ico { display: block; font-size: 26px; margin-bottom: 6px; opacity: .8; }
.dz-link { color: var(--grass); text-decoration: underline; }
.dz-previews { margin-top: 12px; }
.dz-previews:empty { margin-top: 0; }
.dz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.dz-item {
  display: flex; align-items: center; gap: 10px; padding: 6px;
  background: var(--panel); border: 2px solid var(--bevel-dark);
}
.dz-grid .dz-item { flex-direction: column; align-items: stretch; gap: 6px; }
.dz-thumb { width: 56px; height: 56px; object-fit: cover; image-rendering: pixelated; }
.dz-grid .dz-thumb { width: 100%; height: 80px; }
.dz-fileicon {
  width: 56px; height: 56px; display: grid; place-items: center; flex: 0 0 auto;
  background: var(--inset); color: var(--gold); font: 700 12px var(--pixel, monospace);
}
.dz-meta { display: flex; flex-direction: column; min-width: 0; }
.dz-name { color: var(--text); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dz-grid .dz-name { white-space: normal; word-break: break-word; }
.dz-size { color: var(--text-muted); font-size: 12px; }

/* ── Image slider ────────────────────────────────────────────── */
.slider { margin: 16px 0; }
.slider-main {
  position: relative; background: var(--inset); text-align: center; overflow: hidden;
  border: 2px solid var(--bevel-dark); border-top-color: var(--bevel-light); border-left-color: var(--bevel-light);
}
.slide { display: none; }
.slide.active { display: inline-block; }
/* Always show the whole image; size up to the column width / most of the
   viewport height so Steam screenshots appear large and uncropped. */
img.slide { max-width: 100%; max-height: 78vh; width: auto; height: auto; vertical-align: middle; image-rendering: pixelated; }
.slide-video { color: var(--gold); font-size: 16px; text-decoration: none; }
.slide-video.active { display: grid; place-items: center; width: 100%; min-height: 260px; }
.slider-nav {
  position: absolute; top: 50%; transform: translateY(-50%); cursor: pointer;
  width: 38px; height: 54px; font-size: 26px; color: #fff; line-height: 1;
  background: rgba(13,20,38,.7); border: 2px solid var(--bevel-dark);
}
.slider-nav.prev { left: 6px; } .slider-nav.next { right: 6px; }
.slider-nav:hover { background: rgba(13,20,38,.95); border-color: var(--grass); }
.slider-thumbs { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; padding-bottom: 4px; }
.slider-thumb {
  flex: 0 0 auto; width: 76px; height: 48px; padding: 0; cursor: pointer; overflow: hidden;
  background: var(--inset); border: 2px solid var(--bevel-dark);
}
.slider-thumb.active { border-color: var(--grass); }
.slider-thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-vid { display: grid; place-items: center; width: 100%; height: 100%; color: var(--gold); }

/* ── Audio previews (themed player) ──────────────────────────── */
.audio-previews { margin: 24px 0; }
.audio-group {
  font-family: var(--pixel); font-size: 11px; color: var(--gold);
  margin: 20px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--bevel-dark);
}
.audio-group-tracks { display: flex; flex-direction: column; gap: 12px; }
.track {
  display: flex; align-items: center; gap: 14px; padding: 10px 12px;
  background: var(--panel); border: 2px solid var(--bevel-dark);
  border-top-color: var(--bevel-light); border-left-color: var(--bevel-light);
}
.track.playing { border-color: var(--grass); border-top-color: var(--grass-light); border-left-color: var(--grass-light); }
.track-play {
  flex: 0 0 auto; width: 40px; height: 40px; cursor: pointer; font-size: 14px; line-height: 1;
  color: #0c2b08; background: var(--grass); border: 2px solid var(--grass-dark);
  border-top-color: var(--grass-light); border-left-color: var(--grass-light);
}
.track-play:hover { background: var(--grass-light); }
.track-body { flex: 1; min-width: 0; }
.track-name { display: block; color: var(--text); font-size: 14px; margin-bottom: 6px; }
.track-bar { height: 10px; background: var(--inset); border: 2px solid var(--bevel-dark); cursor: pointer; overflow: hidden; }
.track-prog { height: 100%; width: 0; background: var(--grass); }
.track-time { flex: 0 0 auto; color: var(--text-muted); font-size: 12px; min-width: 38px; text-align: right; font-family: ui-monospace, monospace; }

/* ── Pack header (below the gallery) ─────────────────────────── */
.pack-header { margin: 18px 0 10px; }
.pack-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pack-title { font-size: 30px; line-height: 1.4; margin: 0; word-break: break-word; }
.pack-header .meta { margin-top: 8px; }

/* ── Dates + comments ────────────────────────────────────────── */
.meta.dates { font-size: 13px; }
.comments { margin-top: 26px; }
.comment-form textarea { width: 100%; }
.comment-form button { margin-top: 8px; }
.comment-list { list-style: none; margin: 16px 0 0; padding: 0; }
.comment {
  padding: 10px 12px; margin-bottom: 10px; background: var(--panel);
  border: 2px solid var(--bevel-dark); border-top-color: var(--bevel-light); border-left-color: var(--bevel-light);
}
.comment-head { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; }
.comment-author { color: var(--text); font-weight: 500; font-size: 13px; }
.comment-badge { background: var(--gold); color: #4a3a06; font-size: 10px; padding: 1px 5px; }
.comment-date { color: var(--text-muted); font-size: 12px; }
.comment-del { color: var(--danger); font-size: 12px; margin-left: auto; }
.comment-body { color: #bcc4e0; font-size: 14px; margin: 0; white-space: pre-wrap; word-break: break-word; }

/* ── Add to list + lists ─────────────────────────────────────── */
.add-to-list { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0; }
.add-to-list select, .add-to-list input[type="text"] {
  padding: 6px 10px; background: var(--bg); color: var(--text);
  border: 2px solid var(--bevel-dark); border-top-color: #15192e; border-radius: 0;
}
.account-lists { margin-top: 18px; }
.list-create { margin-top: 10px; }
.list-item { position: relative; }
.list-item-remove { position: absolute; top: 8px; right: 8px; }

/* ── Similar packs ───────────────────────────────────────────── */
.similar { margin-top: 26px; }
.similar h2 { margin-bottom: 12px; }

/* ── Danger zone ─────────────────────────────────────────────── */
.danger-zone { border-color: #5a1f1c; border-top-color: #8a3530; border-left-color: #8a3530; }
.danger-zone h2 { color: var(--danger); }

/* ── Detail-bottom + popup ads ───────────────────────────────── */
.ad-detail-bottom {
  min-height: 90px; margin-top: 26px;
  border: 2px solid var(--bevel-dark); border-top-color: var(--bevel-light); border-left-color: var(--bevel-light);
}
.ad-popup { min-height: 200px; margin: 14px 0; background: var(--inset); }

/* ── Download popup modal ────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000; padding: 16px;
  background: rgba(0,0,0,.72); display: flex; align-items: center; justify-content: center;
}
.modal-overlay[hidden] { display: none; }
body.modal-open { overflow: hidden; }
.modal {
  position: relative; width: 100%; max-width: 460px; text-align: center; padding: 24px;
  background: var(--panel); border: 3px solid var(--bevel-dark);
  border-top-color: var(--bevel-light); border-left-color: var(--bevel-light);
}
.modal h2 { font-size: 14px; }
.modal-close {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; cursor: pointer;
  color: #cdd3e8; background: #202a4a; border: 2px solid var(--bevel-dark); font-size: 14px;
}
.modal-close:hover { background: #283360; }
.modal-support { display: inline-block; margin: 4px 0 12px; }
.modal-hint { color: var(--text-muted); font-size: 12px; margin-bottom: 0; }

/* ── Gallery editing ─────────────────────────────────────────── */
.gallery-edit h2 { margin-top: 0; }
.gallery-edit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-bottom: 16px; }
.ge-item { background: var(--inset); border: 2px solid var(--bevel-dark); padding: 6px; text-align: center; }
.ge-item img { width: 100%; height: 84px; object-fit: cover; image-rendering: pixelated; }
.ge-video { color: var(--gold); font-size: 12px; padding: 8px 4px; word-break: break-all; }
.ge-item form { margin-top: 6px; }
.gallery-add, .gallery-add-video { margin-top: 12px; padding: 0; background: none; border: none; }

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .nav-burger { display: block; }
  .nav-collapse { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 10px; }
  #nav-toggle:checked ~ .nav-collapse { display: flex; }
  .nav-search input { max-width: none; width: 100%; }
  .nav-links { flex-direction: column; align-items: flex-start; gap: 10px; }

  h1 { font-size: 16px; }
  .pack-title { font-size: 20px; }
  .download-row { flex-direction: column; align-items: stretch; }
  .download-row .btn-download { justify-content: center; }

  /* Stack admin tables into labelled cards */
  .admin-table thead { display: none; }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; }
  .admin-table tr {
    margin-bottom: 12px; padding: 6px;
    border: 2px solid var(--bevel-dark); border-top-color: var(--bevel-light); border-left-color: var(--bevel-light);
  }
  .admin-table td { border: none; padding: 6px 4px; display: flex; justify-content: space-between; gap: 12px; }
  .admin-table td::before { content: attr(data-label); color: var(--text-muted); font-size: 11px; }
  .actions { justify-content: flex-start; }
  .truncate { max-width: none; }
}
