/* CNCMaps portal — dark command-console theme */
:root {
  --bg: #0b0e13;
  --bg-raise: #121722;
  --surface: #161d2b;
  --surface-2: #1c2536;
  --border: #263043;
  --border-strong: #34415a;
  --text: #e8ecf4;
  --text-dim: #93a0b4;
  --accent: #e23d2e;
  --accent-hover: #f0553f;
  --gold: #e8b23a;
  --ok: #4cc26a;
  --ra2: #e23d2e;
  --yr: #a45de2;
  --ts: #58a843;
  --fs: #e0862c;
  --radius: 10px;
  --font-display: "Chakra Petch", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
/* our display:flex/grid classes must not defeat the hidden attribute */
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
p a, .footer a, .muted a { color: #7fb2ff; text-decoration: none; }
p a:hover, .footer a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: 0.02em; line-height: 1.2; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: 0.85em; }
.muted { color: var(--text-dim); font-size: 0.92em; }

.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.container.narrow { max-width: 860px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11, 14, 19, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; gap: 28px; height: 60px; }
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 700; font-size: 20px;
  text-decoration: none; letter-spacing: 0.06em;
}
.brand em { color: var(--accent); font-style: normal; }
.brand-mark { width: 26px; height: 26px; color: var(--accent); }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  padding: 7px 14px; border-radius: 8px; text-decoration: none;
  color: var(--text-dim); font-weight: 500; font-size: 14px;
}
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a.active { color: var(--text); background: var(--surface-2); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 18px; border-radius: 8px; border: 1px solid transparent;
  font: 600 14px var(--font-body); text-decoration: none; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface); border-color: var(--text-dim); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 26px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: default; pointer-events: none; }

/* ---------- hero / search ---------- */
.hero {
  padding: 56px 0 36px;
  background:
    radial-gradient(1200px 400px at 20% -10%, rgba(226, 61, 46, 0.16), transparent 60%),
    radial-gradient(900px 400px at 90% -20%, rgba(232, 178, 58, 0.10), transparent 60%);
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.hero h1 { margin: 0 0 8px; font-size: clamp(26px, 4vw, 40px); }
.hero-sub { margin: 0 0 24px; color: var(--text-dim); max-width: 640px; }
.searchbar {
  display: flex; align-items: center; gap: 10px; max-width: 560px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 12px; padding: 6px 6px 6px 14px;
}
.searchbar:focus-within { border-color: var(--accent); }
.search-icon { width: 20px; height: 20px; color: var(--text-dim); flex: none; }
.searchbar input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font: 15px var(--font-body);
}

/* ---------- filters ---------- */
.filterbar {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  justify-content: space-between; margin-bottom: 22px;
}
.filter-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border-strong);
  font-size: 13px; font-weight: 600; text-decoration: none; color: var(--text-dim);
}
.chip:hover { color: var(--text); border-color: var(--text-dim); }
.chip-active { color: var(--text); background: var(--surface-2); border-color: var(--accent); }
.chip-ra2.chip-active { border-color: var(--ra2); }
.chip-yr.chip-active { border-color: var(--yr); }
.chip-ts.chip-active { border-color: var(--ts); }
.chip-fs.chip-active { border-color: var(--fs); }
.filter-selects { display: flex; gap: 8px; }

select, input[type="text"], input[type="search"], input[type="number"], textarea {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 8px 12px; font: 14px var(--font-body); outline: none;
}
select:focus, input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }

/* ---------- map cards ---------- */
.card-grid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  margin-bottom: 36px;
}
.map-card {
  display: flex; flex-direction: column; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.map-card:hover {
  border-color: var(--border-strong); transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}
.card-thumb {
  position: relative; aspect-ratio: 2 / 1; background: #0d1119; overflow: hidden;
}
.card-thumb img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.25s ease;
}
.map-card:hover .card-thumb img { transform: scale(1.04); }
.thumb-placeholder {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 100%; color: var(--text-dim); font-size: 13px;
}
.badge {
  position: absolute; left: 10px; top: 10px;
  padding: 3px 9px; border-radius: 6px; font: 700 11px var(--font-display);
  letter-spacing: 0.08em; text-transform: uppercase; color: #fff;
  background: #555;
}
.badge-ra2 { background: var(--ra2); }
.badge-yr { background: var(--yr); }
.badge-ts { background: var(--ts); }
.badge-fs { background: var(--fs); }
.badge-unknown { background: #4a5568; }
.badge-mod { background: #2e6ba8; }
.chip-mod.chip-active { border-color: #2e6ba8; }
td .badge, .meta-table .badge { position: static; }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.card-body h3 {
  margin: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-meta { display: flex; gap: 10px; color: var(--text-dim); font-size: 12.5px; }
.card-meta span { background: var(--surface-2); padding: 2px 8px; border-radius: 5px; }
.card-foot { display: flex; align-items: center; gap: 8px; margin-top: 2px; font-size: 12.5px; }
.variant-tag { background: rgba(46, 107, 168, 0.25) !important; color: #8fbbe8; }
.group-versions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 0 0 14px;
}
.group-versions .chip { text-decoration: none; }
.card-date { margin-left: auto; }

/* ---------- stars ---------- */
.stars {
  --fill: 0%;
  position: relative; display: inline-block;
  font-size: 15px; letter-spacing: 2px; line-height: 1; color: #3a4356;
}
.stars::before { content: "★★★★★"; }
.stars::after {
  content: "★★★★★"; position: absolute; left: 0; top: 0;
  width: var(--fill); overflow: hidden; color: var(--gold); white-space: nowrap;
}
.stars-input { color: #3a4356; font-size: 26px; letter-spacing: 0; }
.stars-input::before, .stars-input::after { content: none; }
.stars-input button {
  background: none; border: none; color: inherit; font-size: inherit;
  cursor: pointer; padding: 0 3px; transition: color 0.1s, transform 0.1s;
}
.stars-input button.lit { color: var(--gold); }
.stars-input button:hover { transform: scale(1.15); }

/* ---------- pagination / empty ---------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 10px 0 40px; }
.scroll-status {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 24px 0 40px; color: var(--text-dim); font-size: 14px;
}
.empty-state { text-align: center; padding: 70px 0; color: var(--text-dim); }
.empty-state .btn { margin-top: 12px; }

/* ---------- upload ---------- */
.page-title { margin: 34px 0 6px; font-size: 30px; }
.dropzone {
  margin: 26px 0; padding: 52px 20px; text-align: center;
  border: 2px dashed var(--border-strong); border-radius: 14px;
  background: var(--bg-raise); cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.dragover {
  border-color: var(--accent); background: rgba(226, 61, 46, 0.06); outline: none;
}
.dz-icon { width: 52px; height: 52px; color: var(--text-dim); }
.dropzone.dragover .dz-icon { color: var(--accent); }
.dz-title { font: 600 18px var(--font-display); margin: 10px 0 2px; }
.dz-progress {
  height: 6px; max-width: 380px; margin: 18px auto 0;
  background: var(--surface-2); border-radius: 3px; overflow: hidden;
}
.dz-progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.dz-error { color: #ff7b6e; font-size: 14px; }

.publish-form { margin-bottom: 60px; }
.upload-fileinfo {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 16px; margin-bottom: 26px;
}
.upload-fileinfo svg { width: 22px; height: 22px; color: var(--ok); flex: none; }
.upload-fileinfo .btn { margin-left: auto; }

.form-grid, .opt-grid {
  display: grid; gap: 14px 18px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 14px;
}
.opt-field { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; }
.opt-field > span { color: var(--text-dim); font-weight: 500; display: flex; justify-content: space-between; }
.opt-field output { color: var(--text); font-weight: 600; }
.span2 { grid-column: span 2; }
@media (max-width: 560px) { .span2 { grid-column: span 1; } }

.opt-checks { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 13.5px; }
.opt-checks label { display: flex; align-items: center; gap: 8px; color: var(--text-dim); cursor: pointer; }
.opt-checks input { accent-color: var(--accent); width: 15px; height: 15px; }
input[type="range"] { accent-color: var(--accent); }

.opt-details {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 0 16px; margin: 18px 0; background: var(--bg-raise);
}
.opt-details summary {
  cursor: pointer; padding: 13px 0; font: 600 14px var(--font-display);
  letter-spacing: 0.03em; list-style: none; position: relative;
}
.opt-details summary::after {
  content: "▾"; position: absolute; right: 2px; color: var(--text-dim);
  transition: transform 0.15s;
}
.opt-details[open] summary::after { transform: rotate(180deg); }
.opt-details > *:not(summary) { margin-bottom: 14px; }

.publish-actions { display: flex; align-items: center; gap: 16px; margin-top: 22px; }

/* ---------- detail page ---------- */
.breadcrumb { margin: 22px 0 14px; color: var(--text-dim); font-size: 13.5px; }
.breadcrumb a { color: var(--text-dim); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb span { margin: 0 6px; }

.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 26px; margin-bottom: 50px; }
@media (max-width: 980px) { .detail-layout { grid-template-columns: 1fr; } }

.render-frame {
  position: relative; background:
    repeating-conic-gradient(#10151f 0% 25%, #0d1119 0% 50%) 0 0 / 24px 24px;
  border: 1px solid var(--border); border-radius: var(--radius);
  min-height: 280px; display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.render-frame img { display: block; max-width: 100%; height: auto; cursor: zoom-in; }
.zoom-hint {
  position: absolute; right: 10px; bottom: 10px;
  background: rgba(11, 14, 19, 0.8); color: var(--text-dim);
  border: 1px solid var(--border-strong); border-radius: 7px;
  padding: 5px 11px; font: 12px var(--font-body); cursor: zoom-in;
}
.zoom-hint:hover { color: var(--text); border-color: var(--text-dim); }
.render-pending, .render-failed { text-align: center; padding: 60px 20px; }
.render-failed { color: #ff9b91; }

.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -3px;
}
.spinner-lg { width: 34px; height: 34px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.variants { margin-top: 22px; }
.variants h3 { margin: 0 0 8px; font-size: 16px; }
.variants ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.variants li { display: flex; gap: 10px; font-size: 14px; }
.variants a { color: #7fb2ff; text-decoration: none; }
.variants a:hover { text-decoration: underline; }

.side-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 20px;
}
.map-title { margin: 0 0 4px; font-size: 24px; }
.rating-block { display: flex; align-items: center; gap: 12px; margin: 12px 0 16px; }

.meta-table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin: 6px 0 14px; }
.meta-table th {
  text-align: left; color: var(--text-dim); font-weight: 500;
  padding: 6px 12px 6px 0; white-space: nowrap; vertical-align: top; width: 1%;
}
.meta-table td { padding: 6px 0; }
.meta-table tr + tr { border-top: 1px solid var(--border); }
.map-desc { border-top: 1px solid var(--border); padding-top: 12px; }
.side-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.side-card .opt-details { margin: 10px 0; }
.job-progress { margin-top: 12px; font-size: 13.5px; color: var(--text-dim); }

/* ---------- comments ---------- */
.comments { margin-top: 36px; }
.comments h2 { font-size: 20px; }
.comment {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px; margin-bottom: 12px;
}
.comment header { display: flex; gap: 12px; align-items: baseline; margin-bottom: 4px; }
.comment p { margin: 0; }
.comment-form { margin-top: 24px; }
.comment-form h3 { margin: 0 0 12px; font-size: 16px; }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 7, 10, 0.96); display: flex; flex-direction: column;
}
.lightbox-canvas { flex: 1; overflow: hidden; cursor: grab; position: relative; }
.lightbox-canvas.grabbing { cursor: grabbing; }
.lightbox-canvas img {
  position: absolute; left: 0; top: 0; transform-origin: 0 0;
  user-select: none; -webkit-user-drag: none; image-rendering: auto;
}
.lightbox-close {
  position: absolute; top: 14px; right: 18px; z-index: 2;
  background: none; border: none; color: var(--text-dim);
  font-size: 34px; cursor: pointer; line-height: 1;
}
.lightbox-close:hover { color: #fff; }
.lightbox-help {
  margin: 0; padding: 10px; text-align: center;
  color: var(--text-dim); font-size: 12.5px;
}

/* ---------- browse ---------- */
.browse-grid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  margin: 24px 0 50px;
}
.browse-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.browse-thumb { position: relative; display: block; aspect-ratio: 5 / 2; background: #0d1119; }
.browse-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.browse-body { padding: 14px 18px 16px; }
.browse-body h3 { margin: 0 0 8px; font-size: 17px; display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.browse-body h3 a { text-decoration: none; color: var(--text); }
.browse-body h3 a:hover { color: var(--accent); }
.browse-cats { list-style: none; margin: 0; padding: 0; }
.browse-cats li {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 5px 0; font-size: 14px; border-top: 1px solid var(--border);
}
.browse-cats a { color: var(--text-dim); text-decoration: none; }
.browse-cats a:hover { color: var(--text); }

/* ---------- queue ---------- */
.queue-stats { display: flex; flex-wrap: wrap; gap: 14px; margin: 20px 0 8px; }
.stat-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 20px; min-width: 110px; display: flex; flex-direction: column; gap: 2px;
}
.stat-num { font: 600 24px var(--font-display); font-variant-numeric: tabular-nums; }
.stat-label { color: var(--text-dim); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-bad .stat-num { color: #ff7b6e; }
#queue-content h2 { font-size: 17px; margin: 26px 0 10px; }
.queue-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.queue-list li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.queue-list a { color: var(--text); text-decoration: none; }
.queue-list a:hover { color: var(--accent); }
.queue-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim);
  flex: none; display: inline-block;
}
.dot-bad { background: #ff7b6e; }
.queue-grid {
  display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  margin-bottom: 40px;
}
.queue-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; text-decoration: none; color: var(--text);
}
.queue-card:hover { border-color: var(--border-strong); }
.queue-card img { width: 100%; aspect-ratio: 2 / 1; object-fit: cover; display: block; }
.queue-noimg {
  aspect-ratio: 2 / 1; display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 12.5px; background: #0d1119;
}
.queue-card-body { padding: 8px 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.queue-card-body strong { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-card-body .muted { font-size: 12px; }

/* ---------- downloads ---------- */
.download-hero {
  display: flex; gap: 24px; align-items: center; justify-content: space-between;
  flex-wrap: wrap; margin: 26px 0;
}
.download-hero h2 { margin: 0 0 4px; }
.versions-table td { padding-right: 18px; }
.versions-table a { color: #7fb2ff; text-decoration: none; }

/* ---------- flash / footer ---------- */
.flash {
  margin: 14px 0; padding: 11px 16px; border-radius: 9px; font-size: 14px;
  border: 1px solid var(--border-strong); background: var(--surface);
}
.flash-success { border-color: rgba(76, 194, 106, 0.5); color: #8ee6a5; }
.flash-error { border-color: rgba(226, 61, 46, 0.5); color: #ff9b91; }

.footer { border-top: 1px solid var(--border); margin-top: 40px; padding: 26px 0 34px; }
.footer-inner { display: flex; flex-direction: column; gap: 6px; color: var(--text-dim); font-size: 13.5px; }

@media (max-width: 720px) {
  .nav-cta { display: none; }
  .topbar-inner { gap: 12px; }
  .hero { padding: 36px 0 26px; }
}
