/* Admin console — layered on top of style.css. Everything here is scoped to admin.html (via
   html / body.admin / #console / .admin-* selectors) so none of it leaks into the main game's UI,
   which shares style.css's base tokens (--bg2, --panel, --line, --accent, etc.) but not this file. */
html {
  /* The admin header is sticky (position: sticky; top: 0) and its height varies a lot with the
     grouped nav (up to ~460px at some in-between tablet widths where groups wrap but the mobile
     compact layout hasn't kicked in yet). Without scroll-padding-top, scrollIntoView()/focus/anchor
     navigation would scroll a below-the-fold element to y:0 — right where the sticky header sits —
     hiding it behind the header instead of revealing it. This reserves that headroom everywhere.
     It belongs on <html>, not body.admin: document.scrollingElement is <html> in standards mode
     regardless of which element's `overflow` rule is doing the actual scrolling. */
  scroll-padding-top: 470px;
}
body.admin {
  overflow: auto;
  padding: 0 0 24px;
  background: radial-gradient(ellipse at top, #221f42 0%, var(--bg) 55%);
}
.admin-login { max-width: 420px; margin: 10vh auto; }
/* A <select> sizes itself to fit its longest <option> text by default, ignoring its container's
   width entirely — unlike text/number inputs, which don't have this problem. A handful of admin
   selects (e.g. the Playground's module picker, listing full module names + ids) have long enough
   option text to push the whole page wider on a narrow phone. This caps every select at its
   container's width; anything already narrower (deliberately width:Npx selects elsewhere) is
   unaffected, since max-width only ever constrains, never expands. */
#console select { max-width: 100%; min-width: 0; }
/* label is `display:flex; flex-direction:column` (style.css base rule) — without min-width:0 here
   too, the label itself resists shrinking below the select's long-option content width, so the
   select's own min-width:0 above has nothing narrower to shrink into. */
#console label { min-width: 0; }

/* ---------------------------------------------------------------- header & grouped navigation */
.admin-head {
  position: sticky; top: 0; z-index: 40;
  max-width: 1400px; margin: 0 auto; padding: 14px 20px 10px;
  background: linear-gradient(180deg, rgba(14, 13, 28, 0.97) 0%, rgba(14, 13, 28, 0.94) 80%, rgba(14, 13, 28, 0.85) 100%);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.admin-head-top { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; }
.admin-head h1 { margin: 0; font-size: 22px; letter-spacing: 0.2px; }
.admin-head-meta { align-items: center; gap: 8px; margin: 0; }
.admin-tab-search {
  background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; font-size: 12.5px; width: 190px; transition: width .18s ease, border-color .15s ease;
}
.admin-tab-search:focus { width: 240px; border-color: var(--accent); }

#admin-nav-toggle { font-size: 12px; padding: 3px 9px; transition: transform .15s ease; }
/* Manual show/hide for the section nav (not just mobile — anyone can reclaim the vertical space);
   state persists across reloads via localStorage, see admin.js. */
.admin-head.nav-collapsed .admin-nav { display: none; }
.admin-head.nav-collapsed { padding-bottom: 10px; }
.admin-head.nav-collapsed #admin-nav-toggle { transform: rotate(-90deg); }

.admin-nav { display: flex; flex-wrap: wrap; gap: 14px 22px; margin-top: 12px; }
.admin-nav-group { display: flex; flex-direction: column; gap: 5px; transition: opacity .15s ease; }
.admin-nav-group.nav-group-empty { display: none; }
.admin-nav-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.9px; text-transform: uppercase; color: var(--muted); padding-left: 2px; }
.admin-nav-row { display: flex; flex-wrap: wrap; gap: 5px; }
.admin-nav .tab {
  border: 1px solid transparent; border-radius: 999px; background: rgba(255, 255, 255, 0.03);
  color: var(--muted); padding: 6px 13px; font-size: 13px; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .1s ease;
}
.admin-nav .tab:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.admin-nav .tab:active { transform: translateY(1px); }
.admin-nav .tab.active { background: var(--accent); color: #1a1400; font-weight: 700; border-color: var(--accent); box-shadow: 0 2px 10px rgba(255, 215, 0, 0.3); }
.admin-nav .tab.nav-tab-hidden { display: none; }

.admin main, #console .tab-panel { max-width: 1400px; margin: 0 auto; padding: 18px 20px 0; }

/* ---------------------------------------------------------------- cards, sections, stats, tables */
#console .card { margin-bottom: 14px; border-radius: 14px; }
#console .card > h3:first-child, #console .card > .row:first-child > h3 { margin-top: 0; }
#console section.tab-panel > .card:first-of-type h3:first-child { display: flex; align-items: center; gap: 8px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat {
  background: linear-gradient(160deg, var(--panel) 0%, rgba(20, 20, 40, 0.65) 100%);
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 12px;
  transition: transform .15s ease, border-color .15s ease;
}
.stat:hover { transform: translateY(-2px); border-color: rgba(255, 215, 0, 0.35); }
.stat b { display: block; font-size: 26px; color: var(--accent); }
.stat span { color: var(--muted); font-size: 13px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }

#console .table thead th { background: rgba(255, 255, 255, 0.03); }
#console .table tbody tr:hover td { background: rgba(255, 255, 255, 0.025); }
#console table.table { border-radius: 8px; }
#console .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; }
#console .table-scroll > table.table { min-width: max-content; }
.flag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
textarea { background: #10101f; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-family: var(--mono); width: 100%; }
#bounds-table input[type=number] { width: 90px; }
#bounds-table td { vertical-align: middle; }
#bounds-table .schema { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.preset-edit { border: 1px solid var(--line); background: rgba(255,255,255,0.02); border-radius: 10px; padding: 12px; margin-bottom: 12px; display: grid; gap: 8px; transition: border-color 0.2s; }
.preset-edit:hover { border-color: rgba(255,255,255,0.2); }
.preset-edit .preset-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.preset-edit .preset-title-row { display: flex; gap: 8px; flex: 1; min-width: 280px; }
.preset-edit .preset-title-row input { flex: 1; }
.preset-edit .preset-actions { display: flex; gap: 4px; align-items: center; }
.preset-edit .json-status { font-size: 11px; font-family: var(--mono); padding: 2px 6px; border-radius: 4px; }
.preset-edit .json-status.valid { color: #51cf66; background: rgba(81, 207, 102, 0.1); }
.preset-edit .json-status.invalid { color: #ff6b6b; background: rgba(255, 107, 107, 0.1); }
.preset-edit.filtered-out { display: none !important; }
.actions { display: flex; gap: 4px; flex-wrap: wrap; }
code { font-family: var(--mono); color: var(--accent); }

/* ---------------------------------------------------------------- level editor */
body.editor { padding: 0; overflow: hidden; height: 100vh; }
#editor { display: flex; flex-direction: column; height: 100vh; max-width: none; }
#editor.hidden { display: none; }
.ed-head, .ed-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 6px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.ed-head h1 { margin: 0; font-size: 18px; }
.ed-head input, .ed-bar input, .ed-bar select { background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }
.ed-bar label { font-size: 12px; color: var(--muted); display: flex; flex-direction: row; gap: 4px; align-items: center; margin: 0; }
.ed-bar .sep { width: 1px; height: 22px; background: var(--line); }
.ed-body { flex: 1; display: grid; grid-template-columns: 150px 1fr 280px; min-height: 0; }
.ed-tools { overflow-y: auto; padding: 6px; border-right: 1px solid var(--line); display: grid; gap: 4px; align-content: start; }
.ed-tool { display: flex; gap: 6px; align-items: center; background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 5px 6px; cursor: pointer; text-align: left; }
.ed-tool span { font-size: 18px; width: 22px; text-align: center; }
.ed-tool small { font-size: 11px; line-height: 1.2; }
.ed-tool.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.ed-canvas-wrap { position: relative; min-width: 0; min-height: 0; }
#ed-canvas { display: block; width: 100%; height: 100%; cursor: crosshair; outline: none; }
.ed-hint { position: absolute; left: 8px; bottom: 6px; font-size: 11px; color: var(--muted); background: rgba(0,0,0,0.5); padding: 2px 6px; border-radius: 6px; pointer-events: none; }
.ed-side { overflow-y: auto; padding: 8px; border-left: 1px solid var(--line); }
.ed-side .card { margin-bottom: 8px; padding: 10px; }
.ed-side h3 { margin: 0 0 6px; font-size: 14px; }
.ed-side .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 6px 0; }
.ed-side label { font-size: 12px; color: var(--muted); display: grid; gap: 2px; }
.ed-side input, .ed-side select { background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px 5px; width: 100%; }
.ed-errors { margin: 6px 0 0; padding-left: 18px; font-size: 12px; color: #ff8a8a; max-height: 260px; overflow-y: auto; }
.ed-counts { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; font-size: 12px; }
.ed-counts .bad { color: #ff8a8a; }

/* ---------------------------------------------------------------- admin: players / levels */
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form input, .inline-form select { background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
.chip { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; border: 1px solid var(--line); }
.chip.bad { color: #ff8a8a; border-color: #ff8a8a; }
.chip.warn { color: #ffd27f; border-color: #ffd27f; }
.chat-log { max-height: 220px; overflow-y: auto; font-size: 13px; background: #10101f; border-radius: 8px; padding: 6px 10px; }
.map-thumb { width: 160px; height: 70px; background: #0b0a14; border-radius: 6px; display: block; }

/* ---------------------------------------------------------------- admin: content / textures */
.content-table input, .content-table select, #pack-editor input, #pack-editor select, #skin-levels select, #skin-active, #pack-pick { background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px 5px; }
.content-table input.w-id { width: 90px; font-family: var(--mono); }
.content-table input.w-name { width: 130px; }
.content-table input.w-icon { width: 46px; text-align: center; }
.content-table input.w-blurb { width: 220px; }
.content-table input.w-num { width: 70px; }
.content-table tr.off { opacity: 0.45; }
.content-table td { vertical-align: middle; }
.look { width: 34px; height: 34px; display: grid; place-items: center; font-size: 22px; background: #10101f; border-radius: 6px; }
.look img { max-width: 32px; max-height: 32px; object-fit: contain; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin-top: 10px; }
.media-card { background: #10101f; border: 1px solid var(--line); border-radius: 8px; padding: 6px; display: grid; gap: 4px; font-size: 11px; }
.media-card img { width: 100%; height: 90px; object-fit: contain; background: repeating-conic-gradient(#222 0 25%, #2c2c2c 0 50%) 0 0 / 16px 16px; border-radius: 4px; }
.media-card .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pack-meta { display: grid; grid-template-columns: 140px 1fr 2fr; gap: 8px; margin-bottom: 10px; }
.slot-table td { vertical-align: middle; }
#sprite-studio-card { width: min(560px, 96vw); }
.ss-canvas-wrap { display: flex; justify-content: center; margin: 10px 0; background: #0a0a12; border: 1px solid var(--line); border-radius: 8px; padding: 8px; overflow: auto; max-height: 60vh; }
#ss-canvas { image-rendering: pixelated; cursor: crosshair; touch-action: none; }
.ss-tool.active { border-color: var(--accent); color: var(--accent); }
.ss-palette { display: flex; flex-wrap: wrap; gap: 4px; }
.ss-swatch { width: 22px; height: 22px; border-radius: 4px; border: 1px solid var(--line); cursor: pointer; padding: 0; }
.ss-swatch:hover { transform: scale(1.1); }
.slot-table .slot-kind { width: 130px; font-family: var(--mono); }
.slot-table .w-num { width: 64px; }
.slot-prev { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; background: #10101f; }
.slot-quick { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
@media (max-width: 800px) { .pack-meta { grid-template-columns: 1fr; } .two-col { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  html { scroll-padding-top: 420px; } /* the compact mobile nav tops out around 388px */
  .admin-head { padding: 8px 10px 6px; }
  .admin-head h1 { font-size: 17px; }
  .admin-tab-search { width: 100%; }
  .admin-tab-search:focus { width: 100%; }
  .admin-head-meta { width: 100%; font-size: 12px; }
  .admin main, #console .tab-panel { padding: 10px 10px 0; }

  /* Compact nav: each group becomes one horizontally-scrollable row (label beside it, not above
     it) instead of wrapping across many lines — the difference between a nav that eats the whole
     screen on a phone and one that leaves room for content. Nothing is removed, every tab is still
     one swipe/tap away; touch targets grow to a comfortable 40px instead of desktop's compact 31px. */
  .admin-nav { gap: 6px; margin-top: 8px; }
  /* width:100% gives the row a definite (not auto/intrinsic) containing width to shrink against —
     without it, nested flex-shrink negotiation leaves the row free to overflow instead of scroll. */
  .admin-nav-group { flex-direction: row; align-items: center; gap: 8px; width: 100%; }
  .admin-nav-label { flex: 0 0 62px; font-size: 9px; line-height: 1.25; white-space: normal; }
  .admin-nav-row {
    flex: 1 1 0; min-width: 0; /* without min-width:0 a nowrap flex row refuses to shrink below its
    unwrapped content width, so it silently overflows its container instead of scrolling internally */
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding-bottom: 3px; scrollbar-width: thin;
  }
  .admin-nav-row::-webkit-scrollbar { height: 3px; }
  .admin-nav-row::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
  .admin-nav .tab { min-height: 40px; display: inline-flex; align-items: center; padding: 8px 14px; }
}

/* ---------------------------------------------------------------- admin: modes & features */
.toggle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.toggle { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; background: #10101f; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .switch { flex: none; width: 38px; height: 22px; border-radius: 11px; background: #3a3550; position: relative; transition: background 0.15s; margin-top: 1px; }
.toggle .switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #cfcfe0; transition: transform 0.15s; }
.toggle input:checked + .switch { background: #2ecc71; }
.toggle input:checked + .switch::after { transform: translateX(16px); background: #fff; }
.toggle input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle:has(input:not(:checked)) .tlabel { color: var(--muted); }
.toggle .tlabel { display: grid; gap: 2px; font-size: 14px; }
.toggle .tlabel small { color: var(--muted); font-size: 11px; line-height: 1.3; }
#console label.toggle { flex-direction: row; align-items: center; margin: 0; }

/* ---------------------------------------------------------------- admin: modules & plugins */
/* minmax(0, 1fr), not bare 1fr: a plain `1fr` track expands to `minmax(auto, 1fr)`, so it refuses
   to shrink below its content's intrinsic width (e.g. an unwrapped module name + version string) —
   the exact same class of bug as the nav row fix above, just via CSS Grid instead of Flexbox. */
.admin-modules-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-bottom: 24px; }
.botlab-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; margin-bottom: 24px; }
@media (max-width: 900px) {
  .admin-modules-grid, .botlab-grid { grid-template-columns: minmax(0, 1fr) !important; }
}

/* ---------------------------------------------------------------- admin: file manager */
.fm-stats-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.fm-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.fm-stat-box { background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.fm-stat-box b { display: block; font-size: 22px; color: var(--accent); }
.fm-stat-box span { font-size: 12px; color: var(--muted); }
.fm-storage-bar { width: 100%; height: 10px; background: rgba(255, 255, 255, 0.08); border-radius: 5px; overflow: hidden; margin: 8px 0 14px; }
.fm-storage-bar-fill { height: 100%; background: linear-gradient(90deg, #38ef7d, #11998e); width: 0%; transition: width 0.3s ease; }
.fm-storage-bar-fill.warn { background: linear-gradient(90deg, #f2994a, #f2c94c); }
.fm-storage-bar-fill.danger { background: linear-gradient(90deg, #eb3349, #f45c43); }

.fm-dropzone { border: 2px dashed rgba(255, 255, 255, 0.2); border-radius: 12px; padding: 24px; text-align: center; background: rgba(255, 255, 255, 0.015); transition: all 0.2s ease; cursor: pointer; margin-bottom: 16px; }
.fm-dropzone:hover, .fm-dropzone.dragover { border-color: var(--accent); background: rgba(255, 215, 0, 0.04); transform: scale(1.002); }
.fm-dropzone-icon { font-size: 32px; display: block; margin-bottom: 6px; }
.fm-dropzone h4 { margin: 0 0 4px; font-size: 15px; color: var(--text); }
.fm-dropzone p { margin: 0; font-size: 12px; color: var(--muted); }

.fm-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 16px; background: rgba(0,0,0,0.2); padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line); }
.fm-controls-left { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 1; min-width: 280px; }
.fm-controls-right { display: flex; gap: 6px; align-items: center; }

.fm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.fm-card { background: #121222; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease; position: relative; }
.fm-card:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, 0.25); box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.fm-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.fm-card-thumb-wrap { width: 100%; height: 130px; background: repeating-conic-gradient(#181828 0 25%, #222238 0 50%) 0 0 / 16px 16px; display: flex; align-items: center; justify-content: center; position: relative; cursor: pointer; }
.fm-card-thumb-wrap img { max-width: 100%; max-height: 100%; object-fit: contain; }
.fm-card-checkbox { position: absolute; top: 8px; left: 8px; z-index: 2; cursor: pointer; width: 18px; height: 18px; accent-color: var(--accent); }
.fm-card-badges { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; z-index: 2; }
.fm-badge { font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.fm-badge.format { background: rgba(0, 0, 0, 0.7); color: #fff; border: 1px solid rgba(255,255,255,0.2); }
.fm-badge.in-use { background: #2ecc71; color: #000; font-weight: 700; }
.fm-badge.unused { background: rgba(255, 255, 255, 0.15); color: #ccc; }

.fm-card-body { padding: 10px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.fm-card-name { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-card-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.fm-card-actions { display: flex; gap: 4px; margin-top: auto; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.06); }
.fm-card-actions button { flex: 1; padding: 4px 6px; font-size: 11px; }

.fm-table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.fm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fm-table th, .fm-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.fm-table th { background: rgba(0,0,0,0.3); color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; }
.fm-table tr:hover td { background: rgba(255, 255, 255, 0.02); }
.fm-table-thumb { width: 36px; height: 36px; object-fit: contain; border-radius: 4px; background: repeating-conic-gradient(#181828 0 25%, #222238 0 50%) 0 0 / 12px 12px; }

.fm-detail-wrap { display: grid; grid-template-columns: 280px 1fr; gap: 20px; }
@media (max-width: 700px) { .fm-detail-wrap { grid-template-columns: 1fr; } }
.fm-detail-preview { background: repeating-conic-gradient(#181828 0 25%, #222238 0 50%) 0 0 / 20px 20px; border-radius: 8px; border: 1px solid var(--line); padding: 16px; display: flex; align-items: center; justify-content: center; min-height: 220px; }
.fm-detail-preview img { max-width: 100%; max-height: 280px; object-fit: contain; }
.fm-detail-fields { display: grid; gap: 10px; font-size: 13px; }
.fm-detail-row { display: grid; grid-template-columns: 90px 1fr; gap: 8px; align-items: center; }
.fm-detail-label { color: var(--muted); font-size: 12px; }
.fm-ref-tag { display: inline-block; padding: 2px 8px; background: rgba(46, 204, 113, 0.15); border: 1px solid rgba(46, 204, 113, 0.3); color: #2ecc71; border-radius: 99px; font-size: 11px; margin: 2px 4px 2px 0; }



/* Character Creator — full-viewport editor (public/js/admin-characters.js), styled like the level
   editor (editor.html): a top toolbar, a sidebar of collapsible tool sections, and a big live
   preview, instead of a small centred popup. */
.cc-fullscreen.overlay { padding: 0; place-items: stretch; }
.cc-editor-card {
  width: 100%; height: 100%; max-width: none; max-height: none;
  border-radius: 0; display: flex; flex-direction: column; overflow: hidden; padding: 0;
}

.cc-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: rgba(0,0,0,0.18); flex-shrink: 0; }
.cc-toolbar h3 { margin: 0 6px 0 0; flex-shrink: 0; align-self: center; }
.cc-tb-field { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--muted); min-width: 0; }
.cc-tb-field input { font-size: 13px; min-width: 0; }
.cc-tb-name { flex: 1 1 180px; }
.cc-tb-icon { flex: 0 1 70px; }
.cc-tb-desc { flex: 2 1 220px; }
.cc-toolbar-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; align-self: center; }
#char-creator-modal #cc-status { margin: 0; padding: 0 18px; flex-shrink: 0; }
#char-creator-modal #cc-status:empty { display: none; }

.cc-editor-body { display: flex; flex: 1; min-height: 0; }
.cc-sidebar { width: 400px; flex-shrink: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; border-right: 1px solid var(--line); }
.cc-main { flex: 1; min-width: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; padding: 28px 20px; }

#cc-preview-canvas {
  background: radial-gradient(circle at 50% 40%, rgba(255,255,255,0.06), rgba(0,0,0,0.35));
  border: 1px solid var(--line); border-radius: 18px;
  width: min(360px, 60vh, 80vw); height: min(360px, 60vh, 80vw);
}
#cc-preview-canvas.bg-light { background: radial-gradient(circle at 50% 40%, rgba(255,255,255,0.95), rgba(200,205,220,0.65)); }
#cc-preview-bg-btn { padding: 3px 8px; font-size: 11px; }
.cc-preview-caption { font-size: 11px; text-align: center; margin: 0; }
.cc-summary { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin-top: 10px; max-width: 420px; }
.cc-summary .cc-chip { font-size: 11px; padding: 2px 9px; border-radius: 99px; background: rgba(255, 215, 0, 0.1); border: 1px solid rgba(255, 215, 0, 0.28); color: var(--accent); white-space: nowrap; }

/* Collapsible sections: <details>/<summary>, one open section (or several) at a time instead of a
   long uninterrupted scroll — "Body Sculptor", "Eye Designer" etc. from the reference screenshot. */
.cc-section { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: rgba(255, 255, 255, 0.015); flex-shrink: 0; }
.cc-section:not([open]) { padding-bottom: 12px; }
.cc-section-title {
  font-size: 12.5px; font-weight: 700; letter-spacing: 0.3px; color: var(--accent);
  display: flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; user-select: none;
}
.cc-section[open] > .cc-section-title { margin-bottom: 8px; }
.cc-section-title::-webkit-details-marker { display: none; }
.cc-section-title::before { content: '▸'; display: inline-block; font-size: 10px; color: var(--muted); transition: transform .15s ease; flex-shrink: 0; }
.cc-section[open] > .cc-section-title::before { transform: rotate(90deg); }
.cc-section .field-label:first-child { margin-top: 0; }

.cc-picker { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.cc-picker button { border: 1px solid var(--line); background: var(--bg2); color: var(--text); border-radius: 8px; padding: 6px 10px; font-size: 12px; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.cc-picker button:hover { border-color: var(--accent); }
.cc-picker button[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 8px rgba(255, 215, 0, 0.3); background: rgba(255, 215, 0, 0.08); }
.cc-picker button.cc-filtered-out { display: none; }
.cc-feature-filter { background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 11px; width: 130px; min-width: 0; }
.cc-sliders { display: flex; flex-direction: column; gap: 6px; }
.cc-sliders label { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.cc-sliders input[type="range"] { flex: 1; }
.cc-sliders span { min-width: 32px; text-align: right; font-family: var(--mono); font-size: 11px; }
.cc-sub-section { border: 1px solid rgba(255,255,255,0.08); border-radius: 8px; padding: 10px 12px; margin-top: 8px; margin-bottom: 6px; background: rgba(0,0,0,0.18); }
.cc-sub-title { font-size: 11px; font-weight: 700; color: var(--accent); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; display: flex; align-items: center; justify-content: space-between; }
.cc-grid-sliders { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px 14px; }
.cc-grid-sliders label { display: flex; align-items: center; gap: 8px; font-size: 11.5px; }
.cc-grid-sliders input[type="range"] { flex: 1; }
.cc-grid-sliders span { min-width: 32px; text-align: right; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.cc-advanced textarea { width: 100%; box-sizing: border-box; font-family: var(--mono); font-size: 11px; background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; margin-top: 6px; resize: vertical; }

@media (max-width: 900px) {
  .cc-editor-body { flex-direction: column; overflow-y: auto; }
  .cc-sidebar { width: auto; max-height: 55vh; border-right: none; border-bottom: 1px solid var(--line); }
  .cc-main { padding: 16px; }
}
@media (max-width: 640px) {
  .cc-toolbar { flex-direction: column; align-items: stretch; }
  .cc-toolbar h3 { margin-bottom: 2px; }
  /* flex:1 1 180px etc. is meant for the row layout; in a column stack flex-grow would stretch each
     field to fill the toolbar's leftover height instead of just sitting at its natural size, leaving
     big empty gaps between Name/Icon/Description. */
  .cc-tb-field { flex: none; }
  .cc-toolbar-actions { margin-left: 0; justify-content: flex-start; }
  #cc-preview-canvas { width: min(260px, 70vw); height: min(260px, 70vw); }
}
