:root {
  color-scheme: dark;
  --editor-bg: #101419;
  --editor-bg-soft: #141a20;
  --editor-surface: #182029;
  --editor-surface-strong: #202a34;
  --editor-surface-raised: #24313d;
  --editor-border: #344452;
  --editor-border-soft: rgba(157, 174, 189, 0.2);
  --editor-text: #edf3f7;
  --editor-text-soft: #bac7d1;
  --editor-muted: #8fa1af;
  --editor-accent: #7e170a;
  --editor-accent-strong: #d91c03;
  --editor-accent-soft: rgba(224, 82, 63, 0.16);
  --editor-link: #7dd3fc;
  --editor-success: #42d392;
  --editor-warning: #f3b84f;
  --editor-danger: #ec270d;
  --editor-radius: 8px;
  --editor-shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
  --bg: var(--editor-bg);
  --bg0: var(--editor-bg);
  --bg1: var(--editor-bg-soft);
  --ui-bg: rgba(24, 32, 41, 0.9);
  --ui-bg-2: rgba(17, 24, 32, 0.78);
  --panel: var(--editor-surface);
  --panel2: var(--editor-surface-strong);
  --panel-2: var(--editor-surface-strong);
  --surface: var(--editor-surface);
  --surface-soft: var(--editor-surface);
  --surface-strong: var(--editor-surface-strong);
  --card: var(--editor-surface);
  --card2: var(--editor-surface-strong);
  --border: var(--editor-border);
  --line: var(--editor-border);
  --line2: var(--editor-border-soft);
  --line-soft: var(--editor-border-soft);
  --text: var(--editor-text);
  --txt: var(--editor-text);
  --text2: var(--editor-text-soft);
  --muted: var(--editor-muted);
  --field: #111820;
  --field-border: var(--editor-border);
  --field-text: var(--editor-text);
  --tab: var(--editor-surface);
  --tab-active: var(--editor-surface-raised);
  --tab-border: var(--editor-border);
  --accent: var(--editor-accent);
  --accent2: var(--editor-accent-strong);
  --accent-2: var(--editor-accent-strong);
  --red: var(--editor-accent);
  --red-weak: var(--editor-accent-soft);
  --cyan: var(--editor-link);
  --info: var(--editor-link);
  --green: var(--editor-success);
  --good: var(--editor-success);
  --ok: var(--editor-success);
  --success: var(--editor-success);
  --amber: var(--editor-warning);
  --warn: var(--editor-warning);
  --warning: var(--editor-warning);
  --bad: var(--editor-danger);
  --danger: var(--editor-danger);
  --focus: rgba(125, 211, 252, 0.22);
}

html {
  min-height: 100%;
  background: var(--editor-bg);
}

body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(125, 211, 252, 0.08), transparent 32rem),
    linear-gradient(180deg, var(--editor-bg-soft), var(--editor-bg) 28rem);
  color: var(--editor-text);
}

body.browser-shop-body,
body.shop-only-body,
body.items-editor-body,
body.image-admin-body,
body.im-body,
body.missing-items-body,
body.min-h-screen {
  background:
    radial-gradient(circle at top left, rgba(125, 211, 252, 0.08), transparent 32rem),
    linear-gradient(180deg, var(--editor-bg-soft), var(--editor-bg) 28rem) !important;
  color: var(--editor-text) !important;
}

a {
  color: var(--editor-link);
}

.editor-global-shell {
  position: sticky;
  top: 0;
  z-index: 10000;
  width: min(1500px, calc(100% - 24px));
  margin: 12px auto 18px;
  padding: 10px;
  border: 1px solid var(--editor-border);
  border-radius: var(--editor-radius);
  background: rgba(24, 32, 41, 0.94);
  box-shadow: var(--editor-shadow);
  backdrop-filter: blur(14px);
}

.editor-global-menu,
.editor-section-menu {
  display: flex;
  align-items: center;
  gap: 8px;
}

.editor-global-menu {
  justify-content: space-between;
}

.editor-global-brand {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  background: var(--editor-accent);
  color: #fff;
  font: 800 0.86rem/1.1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  text-decoration: none;
  white-space: nowrap;
}

.editor-global-links,
.editor-section-menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.editor-global-link,
.editor-section-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--editor-text-soft);
  font: 700 0.78rem/1.1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.editor-global-link:hover,
.editor-section-link:hover,
.editor-global-link:focus-visible,
.editor-section-link:focus-visible {
  border-color: var(--editor-border);
  background: var(--editor-surface-raised);
  color: var(--editor-text);
  outline: none;
}

.editor-global-link.is-active,
.editor-section-link.is-active {
  border-color: rgba(224, 82, 63, 0.5);
  background: var(--editor-accent-soft);
  color: #fff;
}

.editor-section-menu {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--editor-border-soft);
  justify-content: flex-start;
}

.editor-section-link {
  min-height: 30px;
  font-weight: 650;
}

.topbar,
.shop-topbar,
.items-editor-topbar,
.ia-topbar,
.im-topbar,
header.topbar,
header[class*="topbar"] {
  border-color: var(--editor-border) !important;
  background: rgba(24, 32, 41, 0.94) !important;
  color: var(--editor-text) !important;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
}

.panel,
.card,
.ia-panel,
.im-panel,
.scum-slot,
.admin-table,
.category-admin-panel,
.simple-card,
.bp-panel,
.encountercalc,
.encounter-card,
.encounter-pill,
.field,
.container,
.section,
.box,
.content,
main,
table,
form {
  border-color: var(--editor-border-soft);
}

.panel,
.card,
.ia-panel,
.im-panel,
.scum-slot,
.admin-table,
.simple-card,
.bp-panel,
.encountercalc,
.encounter-card,
.encounter-pill {
  background: rgba(24, 32, 41, 0.88) !important;
  border-color: var(--editor-border-soft) !important;
  color: var(--editor-text);
}

button,
.btn,
.button,
input[type="button"],
input[type="submit"],
input[type="file"]::file-selector-button {
  border-color: rgba(224, 82, 63, 0.46) !important;
  background: var(--editor-accent) !important;
  color: #fff !important;
}

button:hover,
.btn:hover,
.button:hover,
input[type="button"]:hover,
input[type="submit"]:hover {
  background: var(--editor-accent-strong) !important;
}

button.secondary,
.btn.secondary,
.button.secondary,
a.secondary {
  border-color: var(--editor-border) !important;
  background: var(--editor-surface-raised) !important;
  color: var(--editor-text) !important;
}

input,
select,
textarea {
  border-color: var(--editor-border) !important;
  background: #111820 !important;
  color: var(--editor-text) !important;
}

input::placeholder,
textarea::placeholder {
  color: var(--editor-muted);
}

table {
  background-color: rgba(24, 32, 41, 0.78);
  color: var(--editor-text);
}

th {
  background-color: var(--editor-surface-strong);
  color: var(--editor-text);
}

td {
  border-color: var(--editor-border-soft);
}

@media (max-width: 860px) {
  .editor-global-shell {
    position: static;
    width: min(100% - 16px, 1500px);
    margin-top: 8px;
    padding: 8px;
  }

  .editor-global-menu {
    align-items: stretch;
    flex-direction: column;
  }

  .editor-global-brand {
    justify-content: center;
    width: 100%;
  }

  .editor-global-links,
  .editor-section-menu {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }
}
/* Collapsible editor navigation */
.editor-menu-launcher {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 11980;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: calc(100vw - 28px);
  padding: 6px;
  border: 1px solid var(--editor-border);
  border-radius: 14px;
  background: rgba(16, 20, 25, .94);
  box-shadow: 0 14px 38px rgba(0, 0, 0, .34);
  backdrop-filter: blur(14px);
}

.editor-menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid rgba(224, 82, 63, .48);
  border-radius: 10px;
  background: var(--editor-accent-soft);
  color: var(--editor-text);
  font: 800 .82rem/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
}

.editor-menu-toggle:hover,
.editor-menu-toggle:focus-visible {
  border-color: var(--editor-accent-strong);
  background: rgba(224, 82, 63, .24);
  outline: none;
}

.editor-menu-toggle-icon {
  display: grid;
  gap: 3px;
  width: 17px;
}

.editor-menu-toggle-icon i {
  display: block;
  height: 2px;
  border-radius: 99px;
  background: currentColor;
}

.editor-menu-current {
  min-width: 0;
  overflow: hidden;
  padding-right: 8px;
  color: var(--editor-muted);
  font: 750 .76rem/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-menu-spacer {
  height: 72px;
}

.editor-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 11990;
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(3px);
}

.editor-menu-backdrop[hidden] {
  display: none;
}

body .editor-global-shell.editor-menu-drawer {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 12000;
  display: block;
  width: min(360px, calc(100vw - 28px));
  height: 100dvh;
  margin: 0;
  padding: 18px;
  overflow-x: hidden;
  overflow-y: auto;
  border: 0;
  border-right: 1px solid var(--editor-border);
  border-radius: 0 22px 22px 0;
  background: rgba(16, 20, 25, .985);
  box-shadow: 30px 0 80px rgba(0, 0, 0, .48);
  backdrop-filter: blur(18px);
  transform: translateX(-105%);
  visibility: hidden;
  transition: transform .22s ease, visibility .22s;
}

body .editor-global-shell.editor-menu-drawer.is-open {
  transform: translateX(0);
  visibility: visible;
}

.editor-menu-drawer-head {
  position: sticky;
  top: -18px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -2px -2px 18px;
  padding: 2px 2px 14px;
  border-bottom: 1px solid var(--editor-border-soft);
  background: rgba(16, 20, 25, .98);
}

body .editor-menu-drawer .editor-global-brand {
  justify-content: flex-start;
  width: auto;
  min-height: 42px;
  padding-inline: 14px;
}

.editor-menu-close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--editor-border);
  border-radius: 10px;
  background: var(--editor-surface);
  color: var(--editor-text);
  font: 400 1.45rem/1 system-ui, sans-serif;
  cursor: pointer;
}

.editor-menu-close:hover,
.editor-menu-close:focus-visible {
  border-color: var(--editor-accent-strong);
  background: var(--editor-accent-soft);
  outline: none;
}

body .editor-menu-drawer .editor-global-menu {
  display: block;
}

.editor-menu-list-title,
.editor-menu-section > strong {
  display: block;
  margin: 0 0 9px;
  color: var(--editor-muted);
  font: 800 .66rem/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: .12em;
  text-transform: uppercase;
}

body .editor-menu-drawer .editor-global-links,
body .editor-menu-drawer .editor-section-menu {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  padding: 0;
  overflow: visible;
}

body .editor-menu-drawer .editor-global-link,
body .editor-menu-drawer .editor-section-link {
  justify-content: flex-start;
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 10px;
  white-space: normal;
}

body .editor-menu-drawer .editor-global-link::after,
body .editor-menu-drawer .editor-section-link::after {
  content: "›";
  margin-left: auto;
  color: var(--editor-muted);
  font-size: 1rem;
}

body .editor-menu-drawer .editor-global-link.is-active,
body .editor-menu-drawer .editor-section-link.is-active {
  border-color: rgba(224, 82, 63, .55);
  background: var(--editor-accent-soft);
  color: #fff;
}

body .editor-menu-drawer .editor-section-menu {
  margin: 0;
  border: 0;
}

.editor-menu-section {
  margin-bottom: 20px;
  padding: 13px;
  border: 1px solid var(--editor-border-soft);
  border-radius: 13px;
  background: rgba(255, 255, 255, .025);
}

body.editor-menu-open {
  overflow: hidden;
}

@media (max-width: 620px) {

  .editor-menu-spacer {
    height: 62px;
  }
  .editor-menu-launcher {
    top: 9px;
    left: 9px;
    max-width: calc(100vw - 18px);
  }

  .editor-menu-current {
    display: none;
  }

  body .editor-global-shell.editor-menu-drawer {
    width: min(92vw, 350px);
    border-radius: 0 18px 18px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  body .editor-global-shell.editor-menu-drawer {
    transition: none;
  }
}
/* Keep the shared drawer stable against editor-specific button/link rules. */
body .editor-menu-launcher .editor-menu-toggle {
  min-height: 40px !important;
  padding: 8px 12px !important;
  border: 1px solid rgba(224, 82, 63, .48) !important;
  border-radius: 10px !important;
  background: var(--editor-accent-soft) !important;
  color: var(--editor-text) !important;
  transform: none !important;
}

body .editor-menu-drawer .editor-menu-close {
  width: 40px !important;
  height: 40px !important;
  min-height: 40px !important;
  padding: 0 !important;
  border: 1px solid var(--editor-border) !important;
  border-radius: 10px !important;
  background: var(--editor-surface) !important;
  color: var(--editor-text) !important;
  transform: none !important;
}

body .editor-menu-drawer .editor-global-brand {
  min-height: 42px !important;
  padding: 0 14px !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: var(--editor-accent) !important;
  color: #fff !important;
  text-decoration: none !important;
  transform: none !important;
}

body .editor-menu-drawer .editor-global-link,
body .editor-menu-drawer .editor-section-link {
  min-height: 42px !important;
  padding: 9px 12px !important;
  border: 1px solid transparent !important;
  border-radius: 10px !important;
  background: transparent !important;
  color: var(--editor-text-soft) !important;
  text-decoration: none !important;
  transform: none !important;
}

body .editor-menu-drawer .editor-global-link:hover,
body .editor-menu-drawer .editor-section-link:hover,
body .editor-menu-drawer .editor-global-link:focus-visible,
body .editor-menu-drawer .editor-section-link:focus-visible {
  border-color: var(--editor-border) !important;
  background: var(--editor-surface-raised) !important;
  color: var(--editor-text) !important;
}

body .editor-menu-drawer .editor-global-link.is-active,
body .editor-menu-drawer .editor-section-link.is-active {
  border-color: rgba(224, 82, 63, .55) !important;
  background: var(--editor-accent-soft) !important;
  color: #fff !important;
}
