.admin-page {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(62, 198, 216, 0.08), transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(232, 93, 4, 0.07), transparent 45%),
    var(--bg);
  overflow: auto;
}

.admin-card {
  width: min(420px, 100%);
  background: linear-gradient(#1a2028, #12161c);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px 24px 20px;
  box-shadow: 0 18px 48px var(--shadow);
}

.admin-kicker {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  color: var(--gold);
}

.admin-card h1 {
  margin: 0 0 10px;
  font-size: 1.45rem;
  font-weight: 600;
}

.admin-card .muted { color: var(--muted); margin: 0 0 18px; line-height: 1.45; }
.admin-card .dim { color: var(--dim); font-size: 12px; line-height: 1.45; }
.admin-card code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--cyan);
}

.admin-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}

#admin-pass {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0c0e11;
  color: var(--ink);
  font-size: 15px;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.admin-back { font-size: 13px; }

.admin-msg {
  min-height: 1.2em;
  margin: 10px 0 0;
  font-size: 13px;
}
.admin-msg.err { color: var(--danger); }
.admin-msg.ok { color: var(--green); }

.admin-foot { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); }

#district-deck a.admin-link {
  display: none; /* site_admin only — toggled .show in JS */
  margin-left: auto;
  font-size: 11px;
  opacity: 0.72;
  text-transform: none;
  letter-spacing: 0;
  padding: 4px 8px;
}
#district-deck a.admin-link:hover { opacity: 1; }

/* Design bar: docked above #stage in edit-mode (never overlays map). */
#edit-bar {
  display: none;
  align-items: center;
  gap: 4px 6px;
  flex-wrap: wrap;
  padding: 4px 8px;
  background: rgba(22, 26, 32, 0.98);
  border: 1px solid var(--line);
  border-radius: 0;
  position: relative;
  left: auto;
  top: auto;
  z-index: 12;
  width: 100%;
  max-width: none;
  flex: 0 0 auto;
  order: -1;
  box-sizing: border-box;
}
#edit-bar.show { display: flex; }
#world.edit-mode {
  display: flex;
  flex-direction: column;
}
#world.edit-mode #stage {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  /* height from flex remaining space — camera/resize uses getBoundingClientRect */
  height: auto;
}
#edit-bar .tag {
  font-size: 11px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 4px;
}
#edit-bar .hud-btn {
  font-size: 11px;
  padding: 3px 8px;
  min-height: 30px;
  min-width: 0;
}
#edit-bar .hud-btn.active {
  background: rgba(232, 93, 4, 0.25);
  border-color: var(--orange);
  color: var(--orange-2);
}
#edit-bar input[type="file"] {
  font-size: 11px;
  color: var(--muted);
  max-width: 140px;
}
#world.edit-mode { cursor: crosshair; }
/* Rich: hide OS cursor during Design RMB pan; 



#world.edit-mode #prompt { display: none; }
#btn-edit { display: none; }
#btn-edit.show { display: inline-flex; }


#inv-panel {
  position: absolute;
  right: 12px;
  /* Below docked Design bar (JS sets --edit-bar-h); desktop-draggable via .inv-head */
  top: calc(var(--edit-bar-h, 0px) + 8px);
  z-index: 13;
  width: min(320px, calc(100% - 24px));
  max-height: min(70vh, 560px);
  display: flex;
  flex-direction: column;
  background: rgba(18, 22, 28, 0.96);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 36px var(--shadow);
  overflow: hidden;
}
#inv-panel.inv-moved {
  /* After user drag, top/left come from inline style */
  right: auto;
}
#inv-panel .inv-head {
  cursor: grab;
  user-select: none;
  touch-action: none;
}
#inv-panel .inv-head:active { cursor: grabbing; }
#inv-panel.hidden { display: none; }
#world.edit-mode #inv-panel:not(.hidden) { display: flex; }

.inv-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--gold);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.inv-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}
.inv-cat {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #0c0e11;
  color: var(--muted);
  cursor: pointer;
}
.inv-cat.active {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(62, 198, 216, 0.12);
}
.inv-body {
  overflow: auto;
  padding: 8px 10px 12px;
  flex: 1;
}
.inv-sub {
  margin: 10px 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--dim);
}
.inv-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.inv-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c0e11;
  cursor: pointer;
  color: var(--ink);
  font-size: 10px;
  text-align: center;
  line-height: 1.25;
}
.inv-item:hover, .inv-item.active {
  border-color: var(--orange);
  background: rgba(232, 93, 4, 0.12);
}
.inv-thumb {
  width: 56px;
  height: 56px;
  object-fit: contain;
  image-rendering: auto;
  background:
    linear-gradient(45deg, #1a2028 25%, transparent 25%),
    linear-gradient(-45deg, #1a2028 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1a2028 75%),
    linear-gradient(-45deg, transparent 75%, #1a2028 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  border-radius: 4px;
}
.inv-thumb.ph {
  display: grid;
  place-items: center;
  color: var(--dim);
  font-size: 9px;
  text-transform: uppercase;
}
.inv-hint {
  margin: 0;
  padding: 6px 10px 10px;
  font-size: 11px;
  border-top: 1px solid var(--line);
}
#world.place-mode { cursor: cell; }
#btn-edit-del.warn {
  border-color: var(--danger);
  color: var(--danger);
}
#btn-edit-undo:disabled,
#btn-edit-undo.dim {
  opacity: 0.45;
  cursor: default;
}
#world.edit-mode.place-mode { cursor: cell; }

#district-deck a.admin-link.show { display: inline-flex !important; }


/* Design Structure | Decor */
.design-seg {
  display: inline-flex;
  border: 1px solid rgba(232, 93, 4, 0.45);
  border-radius: 999px;
  overflow: hidden;
  margin-right: 4px;
  background: #080a0d;
  box-shadow: 0 0 0 1px rgba(232, 93, 4, 0.18), inset 0 0 0 1px rgba(255,255,255,0.03);
}
.design-seg-btn {
  font-size: 11px;
  padding: 5px 11px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  opacity: 0.78;
  letter-spacing: 0.02em;
  transition: background 0.12s ease, color 0.12s ease, opacity 0.12s ease;
}
.design-seg-btn:hover {
  color: #d8dde4;
  opacity: 1;
}
.design-seg-btn.active {
  background: linear-gradient(180deg, rgba(232, 93, 4, 0.48), rgba(232, 93, 4, 0.28));
  color: #ffe0c2;
  font-weight: 700;
  opacity: 1;
  box-shadow: inset 0 -2px 0 #e85d04;
}
.design-tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.design-tool-row .hud-btn.active {
  border-color: var(--orange);
  color: var(--orange-2);
  background: rgba(232, 93, 4, 0.18);
}
.design-swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.design-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid var(--line);
  cursor: pointer;
  padding: 0;
}
.design-swatch.active {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px rgba(62, 198, 216, 0.45);
}

#inv-panel .inv-head strong {
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  font-size: 12px;
}

/* Decor catalog search + Structure section heads (keep2) */
.inv-filter-row {
  padding: 6px 8px 2px;
}
.inv-filter {
  width: 100%;
  box-sizing: border-box;
  background: #0c1014;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #d8dde4;
  font-size: 12px;
  padding: 6px 8px;
  outline: none;
}
.inv-filter:focus {
  border-color: rgba(62, 198, 216, 0.55);
  box-shadow: 0 0 0 1px rgba(62, 198, 216, 0.25);
}
.inv-filter::placeholder { color: var(--muted); opacity: 0.85; }
.inv-sub-section {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.06);
  color: var(--gold);
  letter-spacing: 0.04em;
  font-size: 11px;
  text-transform: uppercase;
}


/* Design bar groups: Mode | Tools | Save */
.design-bar-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px 2px 6px;
  border-right: 1px solid rgba(255,255,255,0.08);
  flex-wrap: wrap;
}
.design-bar-group:last-of-type { border-right: 0; }
.design-bar-lab {
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.75;
  margin-right: 2px;
  user-select: none;
}
#edit-bar .hud-btn-accent {
  border-color: rgba(232, 93, 4, 0.65);
  color: #ffe0c2;
  background: rgba(232, 93, 4, 0.22);
  font-weight: 600;
}
#edit-bar .hud-btn-accent:hover {
  background: rgba(232, 93, 4, 0.35);
}
#design-bar-dev:not(.show-dev) { display: none; }


/* —— Design bar dock + popup sheets (designbar2) —— */
#edit-bar .tag { margin-right: 2px; }
#edit-bar .design-bar-group {
  padding: 1px 6px 1px 4px;
  gap: 4px;
}
#edit-bar .design-seg-btn {
  padding: 4px 9px;
  font-size: 11px;
}
#edit-bar .dim {
  font-size: 10px !important;
  opacity: 0.8;
}

/* Desktop: toast sits in map area below docked bar */
#world.edit-mode #toast {
  top: calc(var(--edit-bar-h, 0px) + 12px);
}

/* Mobile / coarse: catalog + windows as full-screen sheets (no drag-resize) */
html.popup-sheet #inv-panel:not(.hidden),
html.popup-sheet #world.edit-mode #inv-panel:not(.hidden) {
  position: fixed !important;
  inset: 0 !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  max-width: none !important;
  max-height: none !important;
  height: 100% !important;
  border-radius: 0;
  z-index: 30;
  box-shadow: none;
}
html.popup-sheet #inv-panel .inv-head {
  cursor: default;
  min-height: 48px;
  padding: 10px 12px;
}
html.popup-sheet #inv-panel .inv-body {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
html.popup-sheet .window:not(.hidden) {
  position: fixed !important;
  inset: 0 !important;
  left: 0 !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  min-width: 0 !important;
  min-height: 0 !important;
  border-radius: 0;
  z-index: 30 !important;
  box-shadow: none;
}
html.popup-sheet .win-title {
  cursor: default;
  min-height: 48px;
}
html.popup-sheet .window.dock-left,
html.popup-sheet .window.dock-right,
html.popup-sheet .window.dock-full {
  inset: 0 !important;
  width: auto !important;
  height: auto !important;
}

/* pan grab: native OS hand only */
html.design-panning, html.design-panning body, html.design-panning #world, html.design-panning #stage, html.design-panning canvas.panning { cursor: grabbing !important; }


/* World Builder Hotkeys panel (wbhud1) */
#design-bar-hotkeys { border-right: 0; }
.design-hotkeys-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 80;
  min-width: 200px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(14, 18, 24, 0.96);
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  color: var(--text, #e8eef5);
  font: 12px/1.35 Segoe UI, system-ui, sans-serif;
}
.design-hotkeys-panel.hidden { display: none; }
.design-hotkeys-title {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted, #8b97a8);
  margin-bottom: 6px;
}
.design-hotkeys-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}
.design-hotkeys-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #d7e0ea;
}
.design-hotkeys-list kbd {
  display: inline-block;
  min-width: 64px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  font: 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #9ed9e4;
  text-align: center;
}
