:root {
  --bg: #15161a;
  --surface: #1e2026;
  --surface-2: #272a32;
  --border: #33363f;
  --text: #e8e8ec;
  --muted: #9a9caa;
  --accent: #8b5cf6;
  --accent-hover: #a07cf8;
  --danger: #ef4444;
  --ok: #22c55e;
  --radius: 8px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
main { flex: 1; width: 100%; }
main.wrap { padding-top: 24px; padding-bottom: 48px; }
a { color: var(--accent-hover); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 12px; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.3rem; }
img { max-width: 100%; display: block; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; gap: 20px; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.logo { font-weight: 800; font-size: 1.5rem; color: var(--text); letter-spacing: -0.5px; }
.logo span { color: var(--accent); }
.logo:hover { text-decoration: none; }
.mainnav, .usernav { display: flex; gap: 16px; align-items: center; }
.mainnav a, .usernav a { color: var(--text); }
.usernav { margin-left: auto; }
.usernav form { margin: 0; }
.search { flex: 1; min-width: 180px; max-width: 380px; }
.search input { width: 100%; }

/* Forms */
input[type=text], input[type=email], input[type=password], input[type=search], input[type=url],
input[type=number], select, textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=file] { color: var(--muted); }
form input[type=checkbox] { align-self: flex-start; width: 18px; height: 18px; accent-color: var(--accent); }
.field { margin-bottom: 16px; display: flex; flex-direction: column; gap: 4px; }
.field label, form p label { font-weight: 600; font-size: 0.9rem; }
form p { display: flex; flex-direction: column; gap: 4px; margin: 0 0 16px; }
.errorlist { color: var(--danger); margin: 4px 0 0; padding-left: 18px; font-size: 0.9rem; }

.btn, button[type=submit], form button:not(.linklike) {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: var(--radius);
  padding: 9px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.btn:hover, form button:not(.linklike):hover { background: var(--accent-hover); text-decoration: none; }
.btn-small { padding: 5px 12px; font-size: 0.9rem; }
.btn-block { display: block; width: 100%; }
.btn-secondary { background: var(--surface-2); }
.btn-secondary:hover { background: var(--border); }
.btn-danger, form button.btn-danger { background: var(--danger); }
.btn-disabled { background: var(--surface-2); color: var(--muted); cursor: default; }
.linklike { background: none; border: 0; color: var(--accent-hover); padding: 0; font: inherit; cursor: pointer; }
.linklike.danger, .danger { color: var(--danger); }
.usernav .linklike { color: var(--text); }

/* Layout pieces */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 28px 0 14px; }
.section-head h1, .section-head h2 { margin: 0; }
.hero { padding: 40px 0 16px; }
.hero h1 { font-size: 2.2rem; }
.hero p { color: var(--muted); font-size: 1.1rem; }

.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { background: var(--surface-2); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 4px; margin-bottom: 8px; }
.messages .msg-error { border-color: var(--danger); }
.messages .msg-success { border-color: var(--ok); }
.notice { background: var(--surface-2); padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; }

/* Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
.card { display: block; color: var(--text); border-radius: var(--radius); overflow: hidden; background: var(--surface); border: 1px solid var(--border); transition: transform .1s, border-color .1s; }
.card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--accent); }
.card-cover { aspect-ratio: 315 / 250; background: var(--surface-2); }
.card-cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-placeholder { width: 100%; height: 100%; display: grid; place-items: center; font-size: 3rem; font-weight: 800; color: var(--border); }
.card-body { padding: 10px 12px 12px; }
.card-title { font-weight: 700; }
.card-tagline { color: var(--muted); font-size: 0.9rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { font-size: 0.8rem; color: var(--muted); margin-top: 6px; }

.badge { display: inline-block; background: var(--surface-2); border-radius: 4px; padding: 1px 6px; font-size: 0.75rem; }
.badge-public { color: var(--ok); }
.badge-draft { color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { background: var(--surface-2); color: var(--text); padding: 3px 10px; border-radius: 999px; font-size: 0.85rem; }
.tag:hover { background: var(--accent); text-decoration: none; }

/* Project page */
.project { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; }
.project-cover { border-radius: var(--radius); margin-bottom: 16px; max-height: 420px; object-fit: cover; width: 100%; }
.lead { font-size: 1.15rem; color: var(--muted); }
.prose { overflow-wrap: anywhere; }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 20px; }
.shots img { border-radius: var(--radius); }
.shots-small { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); margin: 0 0 16px; }
.shots-small figure { margin: 0; }
.upload-row { margin-bottom: 12px; }
.upload-row small { display: block; margin-top: 4px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* Dashboard */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; display: block; overflow-x: auto; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.edit-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.filelist { list-style: none; padding: 0; margin: 0 0 20px; }
.filelist li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.danger-zone { border-color: #5b2525; }

.profile { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 24px; }
.avatar { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; }
.sort { display: flex; gap: 12px; }
.sort a { color: var(--muted); }
.sort a.active { color: var(--text); font-weight: 600; }
.pager { display: flex; justify-content: center; gap: 20px; margin-top: 28px; color: var(--muted); }

.footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 0.9rem; padding: 20px 0; }

@media (max-width: 800px) {
  .project, .edit-layout { grid-template-columns: 1fr; }
  .usernav { margin-left: 0; }
  .search { max-width: none; order: 5; flex-basis: 100%; }
  .hero h1 { font-size: 1.7rem; }
}

/* Browser player */
.player { margin: 0 auto 24px; }
.player-frame { position: relative; width: 100%; background: #000 center / cover no-repeat; border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; }
.player-frame:not(.running)::before { content: ""; position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); }
.player-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.run-btn { position: relative; font-size: 1.2rem; padding: 14px 30px; }
.player-bar { display: flex; justify-content: space-between; align-items: center; padding: 6px 2px; font-size: 0.85rem; }
.file-actions { display: flex; gap: 14px; flex-shrink: 0; }

/* Ratings */
.rating-summary { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; flex-wrap: wrap; }
.stars-static {
  font-size: 1.2rem; letter-spacing: 2px;
  background: linear-gradient(90deg, #fbbf24 calc(var(--rating) / 5 * 100%), var(--border) 0);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.star-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.star-buttons { display: inline-flex; flex-direction: row-reverse; }
.star-buttons .star, form .star-buttons button.star { background: none; padding: 0 2px; font-size: 1.6rem; line-height: 1; color: var(--border); }
.star-buttons .star.on { color: #fbbf24; }
/* Hovering a star lights it and the ones before it (buttons are in reverse order in the DOM). */
.star-buttons:hover .star { color: var(--border); }
.star-buttons .star:hover, .star-buttons .star:hover ~ .star { color: #fbbf24 !important; background: none; }
.card-rating { color: #fbbf24; }

/* Comments */
.comments { max-width: 760px; margin-top: 36px; }
.comment-form { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; margin-bottom: 20px; }
.comment { border-top: 1px solid var(--border); padding: 14px 0; }
.comment-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.comment-time { font-size: 0.8rem; }
.comment-body { margin: 6px 0; overflow-wrap: anywhere; }
.comment-actions { display: flex; gap: 16px; align-items: flex-start; font-size: 0.9rem; }
.comment-actions form { margin: 0; }
.reply-box summary { list-style: none; cursor: pointer; }
.reply-box summary::-webkit-details-marker { display: none; }
.reply-box[open] { flex-basis: 100%; }
.reply-box .comment-form { margin: 8px 0 0; }
.replies { margin-left: 28px; border-left: 2px solid var(--border); padding-left: 16px; }
.replies .comment:first-child { border-top: 0; }

/* Legal & account */
.inline-form { margin: 0 0 16px; }
.data-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.data-actions form { margin: 0; }
.legal { max-width: 760px; }
.legal h2 { margin-top: 32px; }
.legal li { margin-bottom: 6px; }
.legal .operator-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; }
.footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.footer nav { display: flex; gap: 16px; flex-wrap: wrap; }
.footer a { color: var(--muted); }
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.report-link { font-size: 0.85rem; color: var(--muted); }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 0.95rem; }
label.check input { margin-top: 3px; flex-shrink: 0; }
.lang-switch { display: inline-flex; gap: 10px; margin: 0; }
.lang-switch .linklike { color: var(--muted); font-size: inherit; }
.lang-switch .linklike.active { color: var(--text); font-weight: 600; }
.dashboard-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* Featured & filters */
.grid-featured { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.filters { display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: center; margin: 0 0 20px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.filters label { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--muted); }
.filters select { width: auto; padding: 5px 8px; }
.filters label.check { color: var(--text); }
.clear-filters { font-size: 0.9rem; margin-left: auto; }

/* Collections & follows */
.collection-toggle { margin: 0 0 6px; }
.collection-toggle .linklike { color: var(--text); text-align: left; }
.collection-toggle .linklike.included { color: var(--ok); }
.new-collection { display: flex; gap: 8px; margin-top: 12px; }
.new-collection input { flex: 1; min-width: 0; padding: 6px 8px; }
.facts-follow { margin-top: 14px; }
.follow-form { margin: 0; }
.btn.following { color: var(--ok); }
.collection-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 20px; }
.profile-collections { margin-top: 32px; }
.card-wrap { display: flex; flex-direction: column; gap: 6px; }
.card-wrap form { margin: 0; }
.collection-settings { margin-top: 32px; }
/* Secondary buttons inside forms (the generic form-button rule above is more specific than .btn-secondary). */
form button.btn-secondary:not(.linklike) { background: var(--surface-2); }
form button.btn-secondary:not(.linklike):hover { background: var(--border); }

/* Devlog */
.project-devlog { margin-top: 32px; }
.devlog { max-width: 760px; }
.devlog-item { border-top: 1px solid var(--border); padding: 16px 0; }
.devlog-item h3 { margin: 0 0 4px; }
.devlog-meta { font-size: 0.85rem; margin: 0 0 8px; }
.devlog-full h1 { margin-top: 8px; }
.devlog-card { background: var(--surface-2); }
.devlog-card-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent-hover); margin-bottom: 6px; }
.panel.wide { max-width: 760px; }
.edit-links { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }

/* Stats: small multiples, one metric each (different scales, so no shared axis). */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.stat-card { margin: 0; }
.stat-label { font-size: 0.9rem; color: var(--muted); font-weight: 600; margin: 0; }
.stat-total { font-size: 2.2rem; font-weight: 700; margin: 4px 0 16px; font-variant-numeric: tabular-nums; }
.bar-chart { display: flex; align-items: flex-end; gap: 2px; height: 120px; border-bottom: 1px solid var(--border); }
.bar-slot { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; outline: none; }
.bar { width: 100%; min-height: 2px; background: var(--accent); border-radius: 4px 4px 0 0; }
.bar.empty { background: var(--border); }
.bar-slot:hover .bar, .bar-slot:focus .bar { background: var(--accent-hover); }
.bar-tip { display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); white-space: nowrap; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: 0.8rem; z-index: 2; pointer-events: none; }
.bar-slot:hover .bar-tip, .bar-slot:focus .bar-tip { display: block; }
.bar-axis { display: flex; justify-content: space-between; font-size: 0.75rem; margin-top: 6px; }
.stat-table { margin-top: 20px; }
.stat-table summary { cursor: pointer; font-weight: 600; }
.stat-table .table { margin-top: 12px; }

/* Versions */
.file-group { flex-wrap: wrap; }
.file-group .new-version, .file-group .older-versions { flex-basis: 100%; font-size: 0.9rem; }
.new-version summary, .older-versions summary, .changelog summary { cursor: pointer; color: var(--accent-hover); list-style: none; }
.new-version summary::-webkit-details-marker, .older-versions summary::-webkit-details-marker, .changelog summary::-webkit-details-marker { display: none; }
.new-version form { margin-top: 10px; }
.older-versions ul { list-style: none; padding: 0; margin: 8px 0 0; }
.older-versions li { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 6px 0; border-top: 1px solid var(--border); }
.older-versions li form { margin: 0; }
.upload-row .changelog, .upload-row .older-versions { margin-top: 6px; font-size: 0.85rem; }
.changelog div, .old-changelog { margin-top: 4px; flex-basis: 100%; }

/* Custom project page design. Panels keep the site's dark surface for readability. */
body.themed { background: var(--page-bg, var(--bg)) var(--page-bg-image, none) center top / cover no-repeat fixed; }
body.themed main { color: var(--page-text, var(--text)); }
body.themed main > * a:not(.btn):not(.tag):not(.card) { color: var(--page-accent, var(--accent-hover)); }
body.themed main .btn:not(.btn-secondary):not(.btn-danger):not(.btn-disabled),
body.themed main form button:not(.linklike):not(.btn-secondary):not(.btn-danger):not(.star) { background: var(--page-accent, var(--accent)); color: var(--page-button-text, #fff); }
body.themed main .panel, body.themed main .comments { color: var(--text); }
body.themed main .panel a:not(.btn):not(.tag) { color: var(--accent-hover); }
body.themed main .comments { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; }
body.themed main .project-main, body.themed main .devlog { text-shadow: none; }
.theme-form input[type=color] { width: 64px; height: 36px; padding: 2px; cursor: pointer; }
/* Secondary text follows the page's text colour; panels and the footer keep the site's own colours. */
body.themed main .muted, body.themed main .lead { color: color-mix(in srgb, var(--page-text, var(--text)) 72%, transparent); }
body.themed main .panel .muted, body.themed main .comments .muted { color: var(--muted); }
body.themed .footer { background: var(--bg); }

/* Notifications */
.bell { position: relative; text-decoration: none; font-size: 1.1rem; }
.bell:hover { text-decoration: none; }
.bell-count { position: absolute; top: -6px; right: -10px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 0.7rem; font-weight: 700; line-height: 18px; text-align: center; }
.notifications { list-style: none; padding: 0; max-width: 760px; }
.notification { border-top: 1px solid var(--border); }
.notification form { margin: 0; }
form button.notification-link, .notification-link { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; background: none; color: var(--muted); padding: 12px 8px 12px 16px; border-radius: 0; font-weight: 400; }
form button.notification-link:hover { background: var(--surface); }
.notification.unread .notification-link { color: var(--text); border-left: 3px solid var(--accent); padding-left: 13px; }
.notification.unread .notification-text { font-weight: 600; }
.notification.moderation .notification-link { border-left-color: var(--danger); }
.notification-message { color: var(--text); font-size: 0.95rem; margin-top: 4px; }
.notification-time { font-size: 0.8rem; }

/* Moderation */
.restricted-banner { background: #3b1d1d; border: 1px solid var(--danger); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px; }
.restricted-banner p { margin: 6px 0 0; }
