/* Colors live in assets/theme.css (shared with the demonlist). */

:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 8px;
  --selected: color-mix(in srgb, var(--accent) 14%, transparent);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 var(--font); font-variant-numeric: tabular-nums;
  min-height: 100vh; display: flex; flex-direction: column;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 22px; line-height: 1.25; margin: 0 0 4px; text-wrap: balance; }
h2 { font-size: 15px; margin: 0; }
h3 { font-size: 14px; margin: 0; }
p { margin: 0; }
.muted { color: var(--text-muted); }
code { font-size: 12.5px; }

/* Header */
.top { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; padding-block: 14px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; font-size: 18px; font-weight: 700; }
.brand img { display: block; }
.nav { display: flex; gap: 18px; flex-wrap: wrap; }
.nav a { color: var(--text-muted); text-decoration: none; font-weight: 500; padding-block: 4px; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; color: var(--text-muted);
}
.icon-btn:hover { color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

.menu { position: relative; }
.menu summary {
  list-style: none; cursor: pointer; padding: 5px 10px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); font-weight: 500; font-size: 13px;
}
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: "▾"; margin-left: 6px; color: var(--text-muted); font-size: 11px; }
.menu summary.on { border-color: var(--accent); }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 190px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 4px; display: flex; flex-direction: column; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.menu-list a, .menu-list button {
  display: block; text-align: left; padding: 7px 10px; border-radius: 6px; color: var(--text);
  text-decoration: none; background: none; border: 0; cursor: pointer; width: 100%;
}
.menu-list a:hover, .menu-list button:hover { background: var(--surface-hover); }
.menu-list form { margin: 0; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }

main { flex: 1; padding-bottom: 24px; }
.foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-block: 14px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 12.5px; }
.foot-links { display: flex; gap: 14px; }
.foot a { color: var(--text-muted); }

/* Messages */
.flash { margin-bottom: 12px; padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.flash.ok { border-color: var(--complete); }
.flash.err { border-color: var(--danger); }
.flash.warn { border-color: var(--warning); }

/* Buttons and forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); text-decoration: none; cursor: pointer; font-weight: 500;
}
.btn:hover { background: var(--surface-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.link { background: none; border-color: transparent; color: var(--accent); padding-inline: 4px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label, .lbl { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.field small { color: var(--text-muted); font-size: 12px; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=search], input[type=url], input[type=datetime-local], input[type=file], select, textarea {
  width: 100%; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
}
input[type=color] { width: 48px; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
textarea { min-height: 80px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline { display: inline; margin: 0; }

/* Page layouts */
.page { display: flex; flex-direction: column; gap: 14px; }
.page.narrow { max-width: 520px; margin-inline: auto; width: 100%; padding-top: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid-3 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); gap: 12px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card.flush { padding: 0; gap: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 13px; }
.card-head span, .card-head a { font-size: 12.5px; }
.card-head span { color: var(--text-muted); }
.card-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.empty { color: var(--text-muted); padding: 18px; text-align: center; font-size: 13px; }

/* Stats strip */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin: 0; }
.stats > div { background: var(--surface); padding: 12px 14px; }
.stats dt { font-size: 12px; color: var(--text-muted); }
.stats dd { margin: 2px 0 0; font-size: 20px; font-weight: 600; }

/* Filter bar */
.filters { display: flex; flex-direction: row; gap: 8px; flex-wrap: wrap; align-items: end; }
.filters .field { flex: 1 1 140px; }
.filters .field.wide { flex: 3 1 220px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 5px; border: 1px solid var(--border); font-size: 13px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

/* Level rows */
.llist { list-style: none; margin: 0; padding: 4px; }
.lrow {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 6px 10px; border-radius: 6px; text-decoration: none; color: inherit;
}
.lrow:hover { background: var(--surface-hover); }
.lrow img { width: 44px; height: 44px; display: block; }
.lmain { min-width: 0; display: flex; flex-direction: column; }
.lname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lsub { color: var(--text-muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lright { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-size: 13px; }
.stars { color: var(--points); font-weight: 600; }
.tag { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 0 6px; border-radius: 4px; border: 1px solid var(--border); color: var(--text-muted); }
.tag.epic { color: var(--epic); border-color: color-mix(in srgb, var(--epic) 45%, var(--border)); }
.tag.featured { color: var(--featured); border-color: color-mix(in srgb, var(--featured) 45%, var(--border)); }
.tag.rated { color: var(--text-muted); }
.tag.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.tag.ok { color: var(--complete); border-color: color-mix(in srgb, var(--complete) 45%, var(--border)); }

/* Level page */
.hero { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 16px; align-items: center; }
.hero img { width: 88px; height: 88px; }
.hero h1 { font-size: 26px; overflow-wrap: anywhere; }
.hero .line { color: var(--text-muted); margin-top: 2px; }
.hero .line b { color: var(--text); font-weight: 500; }
.rating-epic { color: var(--epic); font-weight: 600; }
.rating-featured { color: var(--featured); font-weight: 600; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px 20px; margin: 0; padding-top: 14px; border-top: 1px solid var(--border); }
.facts dt { font-size: 12px; color: var(--text-muted); }
.facts dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.facts dd.pts { color: var(--points); font-weight: 600; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; padding-top: 14px; border-top: 1px solid var(--border); }

/* Tables */
.tablewrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th, .t td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.t th { font-size: 12px; font-weight: 500; color: var(--text-muted); white-space: nowrap; }
.t td.num, .t th.num { text-align: right; }
.t tr:last-child td { border-bottom: 0; }
.t a { color: inherit; }
.t a:hover { color: var(--accent); }
.t .rk { color: var(--text-muted); width: 1%; white-space: nowrap; }
.t .pts { color: var(--points); font-weight: 600; }
.t .done { color: var(--complete); font-weight: 600; }
.t .nowrap { white-space: nowrap; }
.t .wrap { overflow-wrap: break-word; min-width: 9em; }

/* Comments */
.comments { list-style: none; margin: 0; padding: 0; }
.comment { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.comment:last-child { border-bottom: 0; }
.comment .meta { display: flex; gap: 10px; align-items: baseline; font-size: 12.5px; color: var(--text-muted); flex-wrap: wrap; }
.comment .meta .player { font-weight: 600; font-size: 13.5px; text-decoration: none; }
.comment .body { overflow-wrap: anywhere; white-space: pre-wrap; }
.comment .meta form { margin-left: auto; }

/* Pager */
.pager { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; padding: 10px; }
.pg { padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border); text-decoration: none; color: var(--text); font-size: 13px; }
.pg:hover { background: var(--surface-hover); }
.pg.current { background: var(--selected); border-color: var(--accent); }
.pg.gap { border-color: transparent; color: var(--text-muted); }

/* Player icons */
.who { display: flex; align-items: center; gap: 14px; min-width: 0; }
.gdicon.avatar { width: 56px; height: 56px; object-fit: contain; flex: none; }
.iconkit { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 16px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.iconkit img { width: 56px; height: 56px; object-fit: contain; }

/* Download menu */
.menu-list .menu-group { padding: 6px 10px 2px; font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.menu-list .menu-group + a { margin-top: 0; }
.menu-list .menu-sep { border-top: 1px solid var(--border); margin: 4px 0; }

/* Packs */
.pack-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; border: 1px solid var(--border); }

@media (max-width: 960px) {
  .split, .grid-3 { grid-template-columns: minmax(0, 1fr) !important; }
}
@media (max-width: 640px) {
  .top { gap: 12px; }
  .top-right { margin-left: 0; width: 100%; }
  .top-right .icon-btn { margin-left: auto; }
  .hero { grid-template-columns: 64px minmax(0, 1fr); }
  .hero img { width: 64px; height: 64px; }
  .hero h1 { font-size: 22px; }
  .lright .tag { display: none; }
  .menu-list { right: auto; left: 0; }
}

/* =====================================================================
   Added with notifications, song previews, demonlist ranks and the
   mobile layout. Colors come from the THEME block at the top.
   ===================================================================== */

/* Bell and counts */
.menu summary.icon-sum { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; }
.menu summary.icon-sum::after { display: none; }
.menu summary.icon-sum svg { width: 16px; height: 16px; display: block; }
.count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.notify-list { width: 340px; max-width: calc(100vw - 24px); padding: 4px; }
.notify-item { display: flex !important; align-items: center; gap: 10px; }
.notify-text { min-width: 0; display: flex; flex-direction: column; font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.notify-text small { color: var(--text-muted); font-size: 11.5px; margin-top: 2px; }
.notify-empty { padding: 10px; color: var(--text-muted); font-size: 13px; }
.notify-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.notify-foot form { border: 0 !important; margin: 0 !important; padding: 0 !important; }
.notify-foot a, .notify-foot button { width: auto !important; color: var(--accent) !important; font-size: 13px; }

/* Song preview */
.play-btn { display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; vertical-align: middle; }
.play-btn:hover, .play-btn.playing { border-color: var(--accent); color: var(--accent); }
.play-btn.broken { opacity: .5; }
.play-btn svg { width: 12px; height: 12px; }

/* Demonlist rank */
.tag.dl-rank { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); vertical-align: middle; }
.dl-link { text-decoration: none; }
.hero h1 .tag { font-size: 13px; }

/* Phones: navigation and tabs scroll sideways instead of squeezing or getting cut off. */
@media (max-width: 760px) {
  .top { gap: 10px 12px; }
  .brand { flex: 1; min-width: 0; }
  .brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav { order: 3; }
  .nav, .tabs { width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .nav::-webkit-scrollbar, .tabs::-webkit-scrollbar { display: none; }
  .nav { gap: 16px; padding-bottom: 2px; }
  .nav a, .tabs a { white-space: nowrap; flex: none; }
  .top-right { order: 2; margin-left: 0; width: 100%; flex-wrap: wrap; justify-content: flex-start; gap: 6px; }
  .top-right .icon-btn { margin-left: auto; }
  .menu summary { padding: 5px 9px; font-size: 12.5px; }
  .page-head { align-items: flex-start; }
  .page-head .tabs { width: auto; }
  .lrow { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; padding: 6px; }
  .lrow img { width: 40px; height: 40px; }
  .card { padding: 14px; }
  .card.flush { padding: 0; }
  .t th, .t td { padding: 7px 9px; }
  .card-head { flex-wrap: wrap; gap: 2px 10px; }
}

/* Points */
.stats dd.pts-big { color: var(--points); }
.t .neg { color: var(--danger); font-weight: 600; }
.bar { display: block; height: 6px; margin-top: 6px; border-radius: 3px; background: var(--border); overflow: hidden; max-width: 320px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.link-code { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.link-code code { font-size: 20px; font-weight: 700; letter-spacing: .06em; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-family: ui-monospace, monospace; font-size: 13px; }

/* Background saves (forms with data-ajax) */
.save-status { margin-left: 8px; font-size: 13px; color: var(--text-muted); white-space: normal; }
.save-status.ok { color: var(--complete); }
.save-status.err { color: var(--danger); }
form.dirty button[type=submit]:not(.danger) { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }


/* Custom emojis (emojis/ folder in the core root) */
img.emoji { width: 1.4em; height: 1.4em; object-fit: contain; vertical-align: -0.35em; margin: 0 1px; }
.emoji-field { position: relative; }
.emoji-field > input, .emoji-field > textarea { padding-right: 42px; }
.emoji-btn { position: absolute; right: 6px; top: 6px; width: 30px; height: 30px; padding: 3px; border: 0; border-radius: 6px; background: none; cursor: pointer; opacity: .75; filter: grayscale(.6); }
.emoji-btn:hover, .emoji-btn[aria-expanded="true"] { opacity: 1; filter: none; background: var(--surface-hover); }
.emoji-btn img { width: 100%; height: 100%; object-fit: contain; }
.emoji-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: min(320px, 92vw); padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.emoji-panel input { width: 100%; margin-bottom: 8px; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 4px; max-height: 220px; overflow-y: auto; }
.emoji-grid button { aspect-ratio: 1; padding: 5px; border: 0; border-radius: 6px; background: none; cursor: pointer; }
.emoji-grid button:hover, .emoji-grid button:focus-visible { background: var(--surface-hover); }
.emoji-grid img { width: 100%; height: 100%; object-fit: contain; }
.emoji-group { grid-column: 1 / -1; margin: 6px 2px 0; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.emoji-hint { margin: 6px 2px 0; font-size: 12px; color: var(--text-muted); }
.emoji-suggest { position: absolute; left: 0; top: calc(100% + 4px); z-index: 29; display: flex; flex-direction: column; min-width: 180px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.emoji-suggest button { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border: 0; border-radius: 6px; background: none; color: var(--text); cursor: pointer; text-align: left; font-size: 13px; }
.emoji-suggest button:first-child, .emoji-suggest button:hover { background: var(--surface-hover); }
.emoji-suggest img { width: 20px; height: 20px; object-fit: contain; }
.too-long { outline: 2px solid var(--danger); }
