/* DexArcana Map hall — battle editor chrome restored from the live MapLibre editor.
   Tokens from theme.css. Editor controls scoped so the shared site header stays house chrome.
   Headings use Cinzel/Limelight deco display serif. No ray/sunburst backgrounds, no bg images. */

/* Map chrome tokens for light / dark / nightforge / legacy arcana */
html[data-theme="arcana"],
html[data-theme="dark"],
html[data-theme="nightforge"],
html[data-theme="light"],
body.map-hall {
  --bg: var(--da-bg);
  --panel: var(--da-bg-elevated);
  --chrome: var(--da-surface);
  --chrome-top: var(--da-metal-blue-lo);
  --border: var(--da-metal-blue);
  --border-bright: var(--da-metal-blue-hi);
  --text: var(--da-ink);
  --muted: var(--da-mute);
  --accent: var(--da-metal-orange);
  --accent-dim: var(--da-metal-orange-lo);
  --accent-glow: color-mix(in srgb, var(--da-metal-orange) 35%, transparent);
  --steel: var(--da-metal-blue);
  --steel-bright: var(--da-metal-blue-hi);
  --danger: var(--da-danger);
  --ok: var(--da-ok);
  /* Distinct flat fills — never same as page bg, never pure black */
  --btn: color-mix(in srgb, var(--da-bg-elevated) 55%, var(--da-metal-blue-lo));
  --btn-hover: color-mix(in srgb, var(--da-metal-blue-lo) 65%, var(--da-bg-elevated));
  --btn-active: color-mix(in srgb, var(--da-metal-blue) 38%, var(--da-bg-elevated));
  --active: var(--btn-active);
  --metal: var(--btn);
  --metal-bar: var(--da-surface);
  --ink-soft: var(--da-ink-soft);
  --focus: var(--da-focus-ring);
  --deco-gold: #c9a15a;
  --deco-bronze: #8a6a32;
  --deco-line: color-mix(in srgb, #d4b56a 62%, transparent);
  --steel-glow: color-mix(in srgb, var(--da-metal-blue) 42%, transparent);
  --btn-label: var(--da-ink);
  --primary-label: #1a0d04;
}

/* Per-theme chip fills — contrast vs page bg */
html[data-theme="arcana"],
html[data-theme="dark"] {
  --btn: #243554;
  --btn-hover: #2f446c;
  --btn-active: #3a557f;
  --active: #3a557f;
  --border: #5a8fd4;
  --btn-label: #e8eef8;
}
html[data-theme="nightforge"] {
  --btn: #1a2740;
  --btn-hover: #243552;
  --btn-active: #2e4560;
  --active: #2e4560;
  --border: #5b7fa8;
  --btn-label: #e8e4dc;
}
html[data-theme="light"] {
  --btn: #d4dde8;
  --btn-hover: #c0ccd9;
  --btn-active: #aebccb;
  --active: #aebccb;
  --border: #3d5f86;
  --text: #12141a;
  --btn-label: #12141a;
  --primary-label: #1a0d04;
}

html {
  height: 100%;
}

body.map-hall {
  --deco-gold: #c9a15a;
  --deco-bronze: #8a6a32;
  /* Do NOT override --da-font-display here — that reflows the shared site header */
  margin: 0;
  width: 100%;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--da-bg);
}

body.map-hall > .site-header {
  /* layout only — visual chrome comes from theme.css .site-header */
  flex: 0 0 var(--da-header-h);
  flex-shrink: 0;
  height: var(--da-header-h);
  min-height: var(--da-header-h);
  max-height: var(--da-header-h);
  width: 100%;
  max-width: none;
  margin: 0;
  isolation: isolate;
  z-index: 50;
  box-sizing: border-box;
}

#editor-view h1,
#editor-view h2,
#editor-view h3 {
  font-family: "Cinzel", "Limelight", "Palatino Linotype", Palatino, serif;
}

#editor-view[hidden] {
  display: none !important;
}

#editor-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(240px, 1fr) auto;
  position: relative;
  flex: 1 1 0;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  z-index: 1;
}

#editor-view button,
#editor-view input,
#editor-view select {
  font: 13px/1.4 "Segoe UI", var(--da-font-body), system-ui, sans-serif;
  color: inherit;
}

#editor-view button:focus-visible,
#editor-view input:focus-visible,
#editor-view select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

#editor-view button {
  background: var(--btn);
  background-image: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.7rem;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: none;
  font-weight: 600;
}

#editor-view button:hover:not(:disabled) {
  background: var(--btn-hover);
  background-image: none;
  border-color: var(--steel-bright);
  color: var(--text);
  box-shadow: none;
}

#editor-view button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  /* keep outline readable when disabled */
  border-color: var(--border);
}

#editor-view button.tool.active,
#editor-view button.layer-active-btn.active,
#editor-view button.toggle[aria-pressed="true"],
#editor-view button.chip.active {
  background: var(--btn-active);
  background-image: none;
  border-color: var(--accent);
  color: var(--text);
  box-shadow: none;
}

#editor-view button.primary {
  border: 1px solid var(--da-metal-orange-hi);
  background: var(--da-metal-orange);
  background-image: none;
  color: var(--primary-label, #1a0d04);
  font-weight: 650;
  box-shadow: none;
}

#editor-view button.primary:hover:not(:disabled) {
  background: var(--da-metal-orange-hi);
  background-image: none;
  border-color: var(--da-metal-orange);
  color: var(--primary-label, #1a0d04);
  box-shadow: none;
}

#editor-view button.quiet {
  background: var(--btn);
  background-image: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.5rem;
  box-shadow: none;
}

#editor-view button.quiet:hover:not(:disabled) {
  background: var(--btn-hover);
  background-image: none;
  border-color: var(--steel-bright);
  color: var(--text);
}

#editor-view .chrome-bar {
  grid-column: 1 / -1;
  position: relative;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0.85rem;
  background: var(--metal-bar);
  border-bottom: 1px solid color-mix(in srgb, var(--da-metal-blue) 40%, transparent);
  box-shadow: none;
}

#editor-view .chrome-bar::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(var(--deco-gold), var(--deco-gold)) left 10px top 6px / 16px 1px no-repeat,
    linear-gradient(var(--deco-gold), var(--deco-gold)) left 10px top 6px / 1px 9px no-repeat,
    linear-gradient(var(--deco-gold), var(--deco-gold)) right 10px top 6px / 16px 1px no-repeat,
    linear-gradient(var(--deco-gold), var(--deco-gold)) right 10px top 6px / 1px 9px no-repeat,
    linear-gradient(var(--deco-bronze), var(--deco-bronze)) left 10px bottom 6px / 16px 1px no-repeat,
    linear-gradient(var(--deco-bronze), var(--deco-bronze)) left 10px bottom 6px / 1px 9px no-repeat,
    linear-gradient(var(--deco-bronze), var(--deco-bronze)) right 10px bottom 6px / 16px 1px no-repeat,
    linear-gradient(var(--deco-bronze), var(--deco-bronze)) right 10px bottom 6px / 1px 9px no-repeat,
    linear-gradient(90deg, transparent, var(--deco-gold) 14%, var(--steel-bright) 50%, var(--deco-gold) 86%, transparent) left bottom / 100% 1px no-repeat;
  opacity: 0.85;
}

#editor-view .brand {
  font-weight: 650;
  letter-spacing: 0;
  color: var(--accent);
  text-transform: none;
  font-size: 0.82rem;
  white-space: nowrap;
  text-shadow: 0 0 12px var(--accent-glow);
  display: inline-flex;
  align-items: baseline;
  gap: 0.25rem;
}

#editor-view .brand .wm-cap {
  font-size: 1.42em;
  font-weight: 700;
}

#editor-view .brand .wm-rest {
  font-size: 0.76em;
  font-weight: 600;
  letter-spacing: 0.03em;
}

#editor-view .mode-switch {
  display: inline-flex;
  flex: 0 0 auto;
  border: 1px solid var(--border-bright);
  border-radius: 6px;
  overflow: hidden;
  background: var(--chrome);
  box-shadow: none;
}

#editor-view .mode-btn {
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 0.38rem 0.85rem;
  background: var(--btn);
  background-image: none;
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.72rem;
  box-shadow: none;
}

#editor-view .mode-btn + .mode-btn {
  border-left: 1px solid var(--border);
}

#editor-view .mode-btn:hover:not(:disabled) {
  background: var(--btn-hover);
  background-image: none;
  color: var(--text);
  box-shadow: none;
}

#editor-view .mode-btn.active,
#editor-view .mode-btn[aria-pressed="true"] {
  background: var(--btn-active);
  background-image: none;
  border-color: var(--accent);
  color: var(--text);
  box-shadow: none;
}

#editor-view .toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  flex: 1;
}

#editor-view button.tool.tool-icon {
  width: 2.05rem;
  min-width: 2.05rem;
  padding: 0.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#editor-view button.tool.tool-icon svg {
  display: block;
}

#editor-view .sep {
  width: 1px;
  height: 1.4rem;
  background: var(--border);
  margin: 0 0.25rem;
}

#editor-view .zoom-readout {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 4.5rem;
  text-align: right;
}

#editor-view.tool-options-hidden {
  grid-template-columns: minmax(0, 1fr) auto;
}

body.tool-stamp #editor-view .side-panel {
  width: min(340px, 92vw);
}

#editor-view .side-panel {
  position: absolute;
  left: 0;
  top: var(--map-chrome-h, 52px);
  bottom: var(--map-status-h, 28px);
  width: min(270px, 86vw);
  z-index: 6;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--deco-gold) 7%, var(--da-surface)), var(--panel));
  border-right: 1px solid color-mix(in srgb, var(--deco-bronze) 45%, var(--da-metal-blue-lo));
  box-shadow:
    8px 0 24px rgba(0, 0, 0, 0.28),
    inset -1px 0 0 color-mix(in srgb, var(--deco-gold) 38%, transparent);
  overflow: auto;
  padding: 0.5rem 0.65rem 1rem;
  min-height: 0;
  transform: translateX(0);
  transition: transform 0.22s ease;
  pointer-events: auto;
}

#editor-view .side-panel[hidden] {
  display: none !important;
}

#editor-view .side-panel.is-collapsed {
  transform: translateX(-110%);
  pointer-events: none;
  box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
  #editor-view .side-panel {
    transition: none;
  }
}

#editor-view .panel-block {
  margin-bottom: 1.1rem;
}

#editor-view .panel-block h2,
.stamp-popup-head h2 {
  margin: 0 0 0.5rem;
  font-family: "Cinzel", "Limelight", "Palatino Linotype", Palatino, serif;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--steel-bright);
  font-weight: 700;
}

#editor-view .panel-block h2::after {
  content: "";
  display: block;
  margin-top: 0.32rem;
  height: 1px;
  background: linear-gradient(90deg, var(--deco-gold), transparent 78%);
  opacity: 0.7;
}

#editor-view .layer-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

#editor-view .layer-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

#editor-view .layer-active-btn {
  flex: 1;
  text-align: left;
}

#editor-view .vis {
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: 0;
  margin: 0;
}

#editor-view .vis input {
  width: auto;
}

#editor-view .field-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.55rem;
}

#editor-view .field-row[hidden] {
  display: none !important;
}

#editor-view .field-row label {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: 0;
  margin: 0;
}

#editor-view .field-row input[type="number"],
#editor-view .field-row input[type="text"],
#editor-view .field-row input[type="range"],
#editor-view .field-row select,
#editor-view .field-row input[type="color"],
#editor-view .field-row input[type="file"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.4rem;
}

#editor-view .field-row input[type="color"] {
  height: 2rem;
  padding: 0.15rem;
}

#editor-view #land-edge-smooth-row .stamp-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: 0;
}

#editor-view #land-edge-smooth-row .stamp-check input {
  width: auto;
  margin: 0;
}

#editor-view .map-layers-rail {
  grid-column: 2;
  grid-row: 2;
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: 280px;
  min-width: 280px;
  min-height: 0;
  background: color-mix(in srgb, var(--da-bg-elevated) 88%, transparent);
  border-left: 1px solid color-mix(in srgb, var(--da-metal-blue) 34%, transparent);
  z-index: 4;
}

#editor-view .map-layers-rail.is-collapsed {
  width: 32px;
  min-width: 32px;
}

#editor-view .map-layers-rail .hall-rail-tab {
  height: 100%;
  top: 0;
  position: relative;
  align-self: stretch;
  border-left: 0;
  border-right: 1px solid color-mix(in srgb, var(--deco-bronze) 50%, var(--da-metal-blue));
  box-shadow: inset -1px 0 0 color-mix(in srgb, var(--da-metal-blue-hi) 18%, transparent);
}

#editor-view .map-layers-body {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.7rem 0.75rem 1rem;
  min-height: 0;
  flex: 1;
  overflow: auto;
}

#editor-view .map-layers-rail.is-collapsed .map-layers-body {
  display: none;
}

#editor-view .dm-notes-list {
  list-style: none;
  margin: 0.45rem 0 0;
  padding: 0;
}

#editor-view .dm-notes-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.3rem;
}

#editor-view .dm-notes-list button {
  flex: 1;
  text-align: left;
}

#editor-view .dm-note-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

#editor-view #dm-note-body {
  width: 100%;
  resize: vertical;
  min-height: 5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem 0.4rem;
  color: inherit;
  font: inherit;
}

#editor-view .dm-note-marker {
  width: 22px;
  height: 28px;
  cursor: pointer;
}

#editor-view .dm-note-pin {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: linear-gradient(180deg, var(--da-metal-orange-hi), var(--da-metal-orange));
  border: 1px solid var(--accent-dim);
  box-shadow: 0 0 8px var(--accent-glow);
  color: #1a0e06;
  font: 700 11px/22px "Segoe UI", sans-serif;
  text-align: center;
}

#editor-view .dm-note-pin::after {
  content: "N";
  display: block;
  transform: rotate(45deg);
}

#editor-view .dm-note-marker.selected .dm-note-pin {
  box-shadow: 0 0 0 2px #fff4ec, 0 0 10px var(--accent-glow);
}

#editor-view #map-wrap {
  grid-column: 1;
  grid-row: 2;
  position: relative;
  min-width: 0;
  min-height: 240px;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

#editor-view #map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 240px;
  background: #080c12;
}

#editor-view #map .maplibregl-map,
#editor-view #map .maplibregl-canvas-container,
#editor-view #map canvas.maplibregl-canvas {
  width: 100% !important;
  height: 100% !important;
}

#editor-view #map img {
  max-width: none;
}

#editor-view .stamp-tray {
  display: none;
}

#editor-view .selected-stamp-chip {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  margin-top: 0;
  padding: 0.5rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  text-align: left;
  cursor: pointer;
  min-height: 3.4rem;
}

#editor-view .selected-stamp-chip:hover {
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

#editor-view .selected-stamp-chip img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  background: #0a1018;
  border-radius: 3px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

#editor-view .selected-stamp-chip.is-empty img {
  visibility: hidden;
}

#editor-view .selected-stamp-chip #selected-stamp-name {
  font-size: 0.82rem;
  color: var(--ink-soft);
}

#editor-view .text-style-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

#editor-view .text-style-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.45rem 0.55rem;
  min-height: 3.4rem;
}

#editor-view .text-style-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

#editor-view .text-style-sample {
  font-size: 1.15rem;
  line-height: 1.1;
  color: #f4e6c8;
}

#editor-view .text-style-name {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

#editor-view .font-serif,
.map-text-label.font-serif {
  font-family: "Cinzel", "Palatino Linotype", Palatino, "Times New Roman", serif;
  font-weight: 700;
  letter-spacing: 0.04em;
}

#editor-view .font-deco,
.map-text-label.font-deco {
  font-family: "Limelight", "Copperplate Gothic Light", "Copperplate", "Times New Roman", serif;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#editor-view .font-nouveau,
.map-text-label.font-nouveau {
  font-family: "Cormorant Garamond", "Palatino Linotype", Palatino, Georgia, serif;
  font-weight: 600;
  font-style: italic;
  letter-spacing: 0.03em;
}

#editor-view .font-hand,
.map-text-label.font-hand {
  font-family: "Caveat", "Segoe Script", "Bradley Hand", cursive;
  font-weight: 700;
  letter-spacing: 0.01em;
}

#editor-view .texture-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.4rem;
}

#editor-view .texture-cats button {
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
  text-transform: capitalize;
}

#editor-view .empty-hint {
  margin: 0.4rem 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

#editor-view .stamp-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  margin-bottom: 0.35rem;
  text-align: left;
  padding: 0.3rem 0.45rem;
}

#editor-view .stamp-item.selected {
  outline: 1px solid var(--accent);
  background: var(--active);
  box-shadow: 0 0 6px var(--accent-glow);
}

#editor-view .stamp-item img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  background: #0a1018;
  border-radius: 3px;
  border: 1px solid var(--border);
}

#editor-view .stamp-item .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#editor-view .stamp-item .kind {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: auto;
  flex-shrink: 0;
}

#editor-view .status-bar {
  grid-column: 1 / -1;
  grid-row: 3;
  position: relative;
  z-index: 8;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.3rem 0.75rem;
  background: var(--chrome);
  border-top: 1px solid color-mix(in srgb, var(--da-metal-blue) 38%, transparent);
  color: var(--muted);
  font-size: 0.8rem;
}

#editor-view .status-bar::before {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  top: 0;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--deco-gold) 22%, var(--steel-bright) 50%, var(--deco-gold) 78%, transparent);
  opacity: 0.7;
}

#editor-view .status-bar #status.error {
  color: var(--danger);
}

#editor-view .maplibregl-ctrl-group {
  background: var(--panel) !important;
  border: 1px solid var(--border) !important;
}

#editor-view .maplibregl-ctrl-group button {
  background-color: var(--btn) !important;
}

#editor-view .stamp-marker {
  width: 48px;
  height: 48px;
  cursor: grab;
  user-select: none;
  position: absolute;
  top: 0;
  left: 0;
  box-sizing: border-box;
  overflow: visible;
}

#editor-view .stamp-art {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  height: 100%;
  transform: translate(-50%, -50%);
  transform-origin: center center;
  pointer-events: none;
}

#editor-view .stamp-art img.stamp-src {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

#editor-view .stamp-blend-canvas {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#editor-view .stamp-marker img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  display: block;
}

#editor-view .stamp-kind-wall img,
#editor-view .stamp-table img {
  object-fit: fill;
}

/* Path walls are a textured canvas stroke. Click-placed wall stamps stay
   as markers for hit-testing; their plank art is drawn on the wall canvas
   so path-aligned grain and stamp art cannot fight. */
#editor-view .stamp-kind-wall .stamp-art {
  opacity: 0;
}

#editor-view .stamp-marker.selected {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
  box-shadow: 0 0 10px var(--accent-glow);
}

#editor-view .stamp-marker.dragging {
  cursor: grabbing;
  opacity: 0.9;
}

#editor-view .stamp-handle {
  position: absolute;
  width: 9px;
  height: 9px;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  background: var(--da-metal-orange-hi);
  border: 1px solid var(--accent-dim);
  border-radius: 1px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
  z-index: 2;
  pointer-events: auto;
}

#editor-view .stamp-handle-nw {
  left: -5px;
  top: -5px;
  cursor: nwse-resize;
}

#editor-view .stamp-handle-ne {
  right: -5px;
  top: -5px;
  cursor: nesw-resize;
}

#editor-view .stamp-handle-sw {
  left: -5px;
  bottom: -5px;
  cursor: nesw-resize;
}

#editor-view .stamp-handle-se {
  right: -5px;
  bottom: -5px;
  cursor: nwse-resize;
}

#editor-view .stamp-marker:not(.selected) .stamp-handle {
  display: none;
}

#editor-view #selection-info {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

#editor-view .stamp-rotate-btn {
  font-size: 0.78rem;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--border);
  background: var(--btn);
  color: var(--text);
}

#editor-view .coming-soon-banner {
  margin: 0.5rem 0;
  padding: 0.5rem 0.65rem;
  background: color-mix(in srgb, var(--da-metal-orange) 15%, transparent);
  border: 1px solid var(--da-metal-orange-lo);
  border-radius: 6px;
  color: var(--da-metal-orange-hi);
  font-size: 0.82rem;
}

#editor-view button.chip {
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  background: var(--da-surface);
  border-color: var(--border);
  color: var(--ink-soft);
  text-transform: capitalize;
}

#editor-view .tool-hint {
  margin: 0 0 0.65rem;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--muted);
}

#editor-view .context-panel[hidden] {
  display: none !important;
}

body.tool-path #paint-panel:not([hidden]),
body.tool-paint #paint-panel:not([hidden]),
body.tool-erase #paint-panel:not([hidden]),
body.tool-stamp #stamp-panel:not([hidden]),
body.tool-wall #wall-panel:not([hidden]),
body.tool-text #text-panel:not([hidden]),
body.tool-select #select-panel:not([hidden]),
body.tool-template #template-panel:not([hidden]) {
  box-shadow: none;
}

body.tool-text #map {
  cursor: text;
}

body.tool-erase .map-text-label,
body.tool-path .map-text-label,
body.tool-paint .map-text-label,
body.tool-wall .map-text-label,
body.tool-stamp .map-text-label {
  pointer-events: none;
}

.map-text-marker {
  pointer-events: auto;
  user-select: none;
}

.map-text-label {
  display: inline-block;
  min-width: 1.2em;
  padding: 0.05em 0.2em;
  color: #f4e6c8;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85), 0 0 8px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  line-height: 1.05;
  cursor: grab;
  outline: none;
}

.map-text-label[contenteditable="true"] {
  cursor: text;
  user-select: text;
}

.map-text-marker.selected .map-text-label {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
  box-shadow: 0 0 10px var(--accent-glow);
}

.stamp-popup {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.stamp-popup[hidden] {
  display: none;
}

.stamp-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 8, 12, 0.62);
}

.stamp-popup-sheet {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: min(78vh, 720px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--da-surface), var(--panel));
  border: 1px solid var(--border-bright);
  border-radius: 10px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45), 0 0 0 1px var(--accent-glow);
  padding: 0.85rem 1rem 1rem;
}

.push-world-sheet {
  width: min(420px, 100%);
  max-height: none;
}

.push-world-sheet .field-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0.7rem 0 0.85rem;
}

.push-world-sheet .field-row[hidden] {
  display: none !important;
}

.push-world-sheet .field-row label {
  color: var(--muted);
  font-size: 0.85rem;
}

.push-world-sheet select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem 0.45rem;
  color: inherit;
}

.push-world-sheet .empty-hint {
  margin: 0.7rem 0;
  color: var(--muted);
}

.push-world-sheet .toolbar {
  display: flex;
  gap: 0.4rem;
}

.push-world-sheet .toolbar[hidden] {
  display: none !important;
}

.stamp-popup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.stamp-popup-head h2 {
  margin: 0;
}

.stamp-popup-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.45rem 0 0.7rem;
}

.stamp-selected-box {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0.65rem 0 0;
  padding: 0.5rem 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.22);
}

.stamp-selected-box[hidden] {
  display: none !important;
}

.stamp-selected-preview {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.stamp-selected-preview img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  background: #0a1018;
  border: 1px solid var(--border);
  border-radius: 4px;
  transform-origin: center center;
}

.stamp-selected-preview span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.72rem;
}

.stamp-selected-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.22rem;
  align-items: stretch;
}

.stamp-selected-controls label {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--steel-bright);
  white-space: nowrap;
}

.stamp-selected-controls input[type="range"] {
  width: 100%;
}

.stamp-selected-controls select {
  width: 100%;
  min-height: 1.7rem;
  font-size: 0.78rem;
}

.stamp-ctrl-label {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--steel-bright);
  white-space: nowrap;
}

.stamp-layer-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.28rem;
}

.stamp-layer-btns button {
  margin: 0;
  padding: 0.28rem 0.4rem;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
}

.stamp-selected-controls > .stamp-check {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  text-transform: none;
  letter-spacing: 0;
  white-space: normal;
}

.stamp-selected-controls .stamp-check input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.stamp-shadow-fields {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
  min-width: 0;
  margin-top: 0.1rem;
  padding: 0.35rem 0.1rem 0.2rem;
  border-top: 1px dashed var(--border);
  isolation: isolate;
  position: relative;
  z-index: 3;
}

.stamp-shadow-fields[hidden] {
  display: none !important;
}

.stamp-shadow-row {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  width: 100%;
  min-width: 0;
}

.stamp-shadow-row label {
  white-space: nowrap;
}

.stamp-slider-hit {
  display: block;
  width: 100%;
  min-width: 200px;
  box-sizing: border-box;
  padding: 0.2rem 0.1rem;
  position: relative;
  z-index: 2;
  touch-action: none;
}

.stamp-selected-controls .stamp-slider-hit input[type="range"],
.stamp-selected-controls .stamp-shadow-fields input[type="range"],
.stamp-shadow-row input[type="range"] {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 200px;
  box-sizing: border-box;
  height: 2rem;
  margin: 0;
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
  accent-color: var(--steel-bright);
  touch-action: none;
}

.stamp-popup-sheet.is-region-catalog .stamp-popup-cats {
  opacity: 0.55;
}

.stamp-popup-tray {
  min-height: 8rem;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 0.45rem;
  padding: 0.45rem;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
}

.stamp-popup-tray .empty-hint {
  grid-column: 1 / -1;
}

.stamp-popup-tray .stamp-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  padding: 0.45rem 0.4rem;
  text-align: center;
}

.stamp-popup-tray .stamp-item img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: #0a1018;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.stamp-popup-tray .stamp-item .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  font-size: 0.72rem;
}

.stamp-popup-tray .stamp-item .kind {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stamp-popup-tray .stamp-item.selected {
  outline: 1px solid var(--accent);
  background: var(--active);
  box-shadow: 0 0 6px var(--accent-glow);
}

.template-popup-tray .stamp-item img,
.template-popup-tray .template-item img {
  width: 100%;
  height: 72px;
  object-fit: cover;
}

#editor-view #btn-template.active,
body.template-popup-open #btn-template {
  background: var(--btn-active);
  background-image: none;
  border-color: var(--steel-bright);
  color: #eef4ff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 0 10px var(--steel-glow);
}

body.tool-erase .stamp-marker,
body.tool-path .stamp-marker,
body.tool-paint .stamp-marker,
body.tool-wall .stamp-marker {
  pointer-events: none;
  cursor: inherit;
}

body.tool-paint #map,
body.tool-erase #map {
  cursor: crosshair;
}

body.tool-stamp #map {
  cursor: copy;
}

body.tool-wall #map,
body.tool-path #map {
  cursor: crosshair;
}

body.tool-select #map {
  cursor: grab;
}

@media (max-width: 820px) {
  #editor-view,
  #editor-view.tool-options-hidden {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(240px, 1fr) auto;
  }

  #editor-view #map-wrap,
  #editor-view.tool-options-hidden #map-wrap {
    grid-column: 1;
    grid-row: 2;
  }

  #editor-view .map-layers-rail,
  #editor-view.tool-options-hidden .map-layers-rail {
    grid-column: 2;
    grid-row: 2;
  }

  #editor-view .status-bar,
  #editor-view.tool-options-hidden .status-bar {
    grid-row: 3;
    grid-column: 1 / -1;
  }

  #editor-view .side-panel {
    width: min(300px, 88vw);
  }
}

.stamp-popup-sheet {
  box-shadow:
    0 18px 48px rgba(0, 0, 0, 0.45),
    0 0 0 1px color-mix(in srgb, var(--deco-bronze) 45%, var(--da-metal-blue-lo)),
    inset 0 1px 0 color-mix(in srgb, var(--deco-gold) 22%, transparent);
}

.stamp-popup-head {
  position: relative;
}

.stamp-popup-head::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.2rem;
  height: 1px;
  background: linear-gradient(90deg, var(--deco-gold), transparent 82%);
  opacity: 0.55;
}

/* ——— MapLibre / header isolation (t157u) ———
   Vendor maplibre-gl.css is already .maplibregl-* scoped.
   Keep any control/button rules under #editor-view / #map only.
   Never let map page restyle global .site-header / .wordmark / .site-nav. */
body.map-hall > .site-header::after {
  content: none !important;
  display: none !important;
}

#editor-view .maplibregl-map,
#editor-view #map,
#map.maplibregl-map {
  isolation: isolate;
  contain: layout style;
}

#editor-view .maplibregl-ctrl-group button,
#editor-view .maplibregl-ctrl button,
#editor-view a.maplibregl-ctrl-logo {
  /* reinstate maplibre control sizing only inside the editor */
  box-sizing: border-box;
}

/* Guard: MapLibre / map-hall must not cascade into site chrome.
   Wordmark/nav keep Cinzel. Auth + theme-switch buttons use theme.css ONLY —
   Map must not restyle Sign In / Register / Guest Vault (exact parity with Home/Forge). */
body.map-hall > .site-header,
body.map-hall > .site-header .wordmark,
body.map-hall > .site-header .site-nav a {
  box-sizing: border-box;
  font-family: "Cinzel", "Palatino Linotype", Palatino, serif;
}

/* Undo Cinzel on header controls only — size comes from theme.css (Map-large).
   Do NOT shrink Sign In/Register (James 2026-09-20 / MAP-HEADER-CHROME-PATCH). */
body.map-hall > .site-header .theme-switch button,
body.map-hall > .site-header .auth-slot button,
body.map-hall > .site-header .auth-slot .guest-chip,
body.map-hall > .site-header .auth-slot .user-chip {
  font-family: var(--da-font-body), "Source Sans 3", "Segoe UI", system-ui, sans-serif !important;
  font-synthesis: none;
  transform: none !important;
  text-shadow: none !important;
}

/* theme-switch metrics only (prior lock) — not auth */
body.map-hall > .site-header .theme-switch {
  height: 32px !important;
}
body.map-hall > .site-header .theme-switch button {
  height: 30px !important;
  margin: 0 !important;
  padding: 0 0.55rem !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  font-size: 0.72rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.02em !important;
  line-height: 1 !important;
  background-image: none !important;
}

#editor-view .maplibregl-canvas-container,
#editor-view .maplibregl-control-container {
  /* keep MapLibre layout contained to the map pane */
  contain: layout;
}


/* map-scale-footer-20260919 — keep scale visible in status bar, never under tool panel */
#editor-view .status-bar .map-scale-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 1.25rem;
  pointer-events: none;
}
#editor-view .status-bar .map-scale-slot .maplibregl-ctrl {
  position: static !important;
  margin: 0 !important;
  float: none !important;
}
#editor-view .status-bar .map-scale-slot .maplibregl-ctrl-scale {
  position: static !important;
  background: color-mix(in srgb, var(--panel, #121820) 80%, transparent);
  border: 1px solid color-mix(in srgb, var(--da-metal-blue, #5b7fa8) 55%, transparent);
  border-top: none;
  color: var(--muted, #a8b4c4);
  font-size: 0.75rem;
  line-height: 1.1;
  padding: 0.15rem 0.45rem 0.1rem;
  box-sizing: border-box;
  height: auto !important;
}
#editor-view .maplibregl-ctrl-bottom-left:empty,
#editor-view .maplibregl-ctrl-bottom-left:not(:has(*)) {
  display: none;
}
#editor-view .maplibregl-ctrl-bottom-left {
  /* leftover empty corner after scale moves to footer */
  pointer-events: none;
}


/* map-toolbar-visibility-20260919 — theme-proof flat toolbar (light/dark/nightforge) */
#editor-view .chrome-bar .toolbar > button:not(.primary),
#editor-view .chrome-bar .mode-switch .mode-btn {
  background: var(--btn) !important;
  background-image: none !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  box-shadow: none !important;
}
#editor-view .chrome-bar .mode-switch {
  background: var(--chrome);
  border: 1px solid var(--border);
  box-shadow: none !important;
}
#editor-view .chrome-bar .mode-switch .mode-btn + .mode-btn {
  border-left: 1px solid var(--border) !important;
}
#editor-view .chrome-bar .toolbar > button:not(.primary):hover:not(:disabled),
#editor-view .chrome-bar .mode-switch .mode-btn:hover:not(:disabled) {
  background: var(--btn-hover) !important;
  background-image: none !important;
  border-color: var(--steel-bright) !important;
  color: var(--text) !important;
  box-shadow: none !important;
}
#editor-view .chrome-bar .toolbar > button.tool.active,
#editor-view .chrome-bar .toolbar > button.toggle[aria-pressed="true"],
#editor-view .chrome-bar .toolbar > #btn-template.active,
#editor-view .chrome-bar .mode-switch .mode-btn.active,
#editor-view .chrome-bar .mode-switch .mode-btn[aria-pressed="true"],
body.template-popup-open #editor-view .chrome-bar #btn-template {
  background: var(--btn-active) !important;
  background-image: none !important;
  border-color: var(--accent) !important;
  color: var(--text) !important;
  box-shadow: none !important;
}
/* Select / Grid / Snap: flat only (no gradient lighting) */
#editor-view .chrome-bar .toolbar > button.tool.tool-icon,
#editor-view .chrome-bar .toolbar > button.tool.tool-icon.active,
#editor-view .chrome-bar .toolbar > button.toggle,
#editor-view .chrome-bar .toolbar > button.toggle[aria-pressed="true"] {
  background-image: none !important;
  box-shadow: none !important;
}
#editor-view .chrome-bar .toolbar > button.primary,
#editor-view .chrome-bar .toolbar > button.primary:hover:not(:disabled),
#editor-view .chrome-bar .toolbar > button.primary:focus-visible:not(:disabled) {
  background: var(--da-metal-orange) !important;
  background-image: none !important;
  border: 1px solid var(--da-metal-orange-hi) !important;
  color: var(--da-on-primary) !important;
  box-shadow: none !important;
}
#editor-view .chrome-bar .toolbar > button.primary:hover:not(:disabled) {
  background: var(--da-metal-orange-hi) !important;
  background-image: none !important;
  border-color: var(--da-metal-orange) !important;
  color: var(--da-on-primary) !important;
}
#editor-view .chrome-bar .toolbar > button:not(.primary):disabled {
  opacity: 0.45;
  border-color: var(--border) !important;
  color: var(--text) !important;
  background: var(--btn) !important;
  background-image: none !important;
}
#editor-view .chrome-bar .toolbar > button.primary:disabled {
  opacity: 0.45;
  background: var(--da-metal-orange) !important;
  background-image: none !important;
  border: 1px solid var(--da-metal-orange-hi) !important;
  color: var(--da-on-primary) !important;
}


/* map-btn-contrast-20260919b — James contrast lock */
#editor-view .chrome-bar .toolbar > button:not(.primary),
#editor-view .chrome-bar .mode-switch .mode-btn {
  background: var(--btn) !important;
  background-image: none !important;
  border: 1px solid var(--border) !important;
  color: var(--btn-label) !important;
  box-shadow: none !important;
}
#editor-view .chrome-bar .toolbar > button:not(.primary):hover:not(:disabled),
#editor-view .chrome-bar .mode-switch .mode-btn:hover:not(:disabled) {
  background: var(--btn-hover) !important;
  background-image: none !important;
  border-color: var(--border) !important;
  color: var(--btn-label) !important;
  box-shadow: none !important;
}
#editor-view .chrome-bar .toolbar > button.tool.active,
#editor-view .chrome-bar .toolbar > button.toggle[aria-pressed="true"],
#editor-view .chrome-bar .toolbar > #btn-template.active,
#editor-view .chrome-bar .mode-switch .mode-btn.active,
#editor-view .chrome-bar .mode-switch .mode-btn[aria-pressed="true"],
body.template-popup-open #editor-view .chrome-bar #btn-template {
  background: var(--btn-active) !important;
  background-image: none !important;
  border: 1px solid var(--accent) !important;
  color: var(--btn-label) !important;
  box-shadow: none !important;
}
#editor-view .chrome-bar .toolbar > button.tool.tool-icon,
#editor-view .chrome-bar .toolbar > button.tool.tool-icon.active,
#editor-view .chrome-bar .toolbar > button.toggle,
#editor-view .chrome-bar .toolbar > button.toggle[aria-pressed="true"] {
  background-image: none !important;
  box-shadow: none !important;
}
#editor-view .chrome-bar .toolbar > button.primary,
#editor-view .chrome-bar .toolbar > button.primary:hover:not(:disabled),
#editor-view .chrome-bar .toolbar > button.primary:focus-visible:not(:disabled),
#editor-view .chrome-bar .toolbar > button.primary:active:not(:disabled) {
  background: var(--da-metal-orange) !important;
  background-image: none !important;
  border: 1px solid var(--da-metal-orange-hi) !important;
  color: var(--primary-label, #1a0d04) !important;
  box-shadow: none !important;
}
#editor-view .chrome-bar .toolbar > button.primary:hover:not(:disabled) {
  background: var(--da-metal-orange-hi) !important;
  background-image: none !important;
  border: 1px solid var(--da-metal-orange) !important;
  color: var(--primary-label, #1a0d04) !important;
}
html[data-theme="light"] #editor-view .chrome-bar .mode-switch .mode-btn,
html[data-theme="light"] #editor-view .chrome-bar .mode-switch .mode-btn:hover:not(:disabled),
html[data-theme="light"] #editor-view .chrome-bar .mode-switch .mode-btn.active,
html[data-theme="light"] #editor-view .chrome-bar .mode-switch .mode-btn[aria-pressed="true"],
html[data-theme="light"] #editor-view .chrome-bar .toolbar > button:not(.primary),
html[data-theme="light"] #editor-view .chrome-bar .toolbar > button:not(.primary):hover:not(:disabled),
html[data-theme="light"] #editor-view .chrome-bar .toolbar > button.tool.active,
html[data-theme="light"] #editor-view .chrome-bar .toolbar > button.toggle[aria-pressed="true"] {
  color: #12141a !important;
}


/* map-mode-flat-20260919 — no top highlight strip on Region/Battle */
#editor-view .chrome-bar .mode-switch,
#editor-view .chrome-bar .mode-switch .mode-btn,
#editor-view .chrome-bar .mode-switch .mode-btn:hover:not(:disabled),
#editor-view .chrome-bar .mode-switch .mode-btn.active,
#editor-view .chrome-bar .mode-switch .mode-btn[aria-pressed="true"],
#editor-view .chrome-bar .mode-switch .mode-btn:focus-visible {
  box-shadow: none !important;
  background-image: none !important;
  text-shadow: none !important;
}
html[data-theme="light"] #editor-view .chrome-bar .mode-switch .mode-btn,
html[data-theme="light"] #editor-view .chrome-bar .mode-switch .mode-btn:hover:not(:disabled),
html[data-theme="light"] #editor-view .chrome-bar .mode-switch .mode-btn.active,
html[data-theme="light"] #editor-view .chrome-bar .mode-switch .mode-btn[aria-pressed="true"] {
  color: #12141a !important;
}




/* map-header-theme-only-20260920 — auth = theme.css; MapLibre never in .site-header */
body.map-hall > .site-header button.maplibregl-ctrl,
body.map-hall > .site-header .maplibregl-ctrl-group,
body.map-hall > .site-header .maplibregl-ctrl {
  display: none !important;
}
#editor-view button,
#map button,
.maplibregl-map button {
  /* map-stage button rules stay under map containers only */
}
