body.designer-page { background: #0f1a14; }
body.designer-page .site-footer { margin-top: 0; }
body.designer-page .site-header { position: sticky; top: 0; z-index: 40; flex: none; }
.designer-app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-rows: auto minmax(0, 1fr);
  height: calc(100vh - var(--header-h) - 3px);
  max-height: calc(100vh - var(--header-h) - 3px);
  min-height: 0;
  background: #0f1a14;
}
.designer-toolbar {
  grid-column: 1 / -1;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.5rem;
  padding: 0.45rem 0.7rem;
  background: var(--pine-2);
  border-bottom: 1px solid #2a4636;
  color: var(--cream);
}
.designer-toolbar .group {
  display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center;
  padding-right: 0.55rem; margin-right: 0.25rem;
  border-right: 1px solid #3a5646;
}
.designer-toolbar .group:last-child { border-right: none; }
.tool-btn {
  min-width: 44px; min-height: 44px;
  padding: 0.3rem 0.65rem;
  border-radius: 9px;
  border: 1px solid #4a6a58;
  background: #1c3328;
  color: var(--cream);
  font: 650 0.85rem var(--font-sans);
  cursor: pointer;
  line-height: 1.15;
}
.tool-btn:hover, .tool-btn[aria-pressed="true"] {
  background: var(--clay); border-color: var(--clay); color: #fff;
}
.tool-btn.danger:hover { background: var(--danger); border-color: var(--danger); }
.mode-toggle { display: flex; border: 1px solid var(--gold); border-radius: 999px; overflow: hidden; }
.mode-toggle button {
  min-height: 44px; padding: 0 0.8rem; border: 0; background: transparent;
  color: var(--cream); font: 700 0.82rem var(--font-sans); cursor: pointer;
}
.mode-toggle button[aria-pressed="true"] { background: var(--gold); color: var(--pine); }

.designer-stage { position: relative; min-height: 0; height: 100%; background: #1a1a1a; overflow: hidden; }
#map { position: absolute; top: 0; left: 0; right: 0; bottom: var(--credit-h, 24px); }
.map-credit {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--credit-h, 24px);
  background: #101b15; color: #c9d3cc; border-top: 1px solid #2a4636;
  display: flex; align-items: center; justify-content: flex-end; padding: 0 0.5rem; overflow: hidden;
}
.map-credit .leaflet-control-attribution {
  background: transparent !important; color: #c9d3cc; font-size: 11px; line-height: 1.25;
  max-width: none; margin: 0; padding: 0; text-align: right;
}
.map-credit .leaflet-control-attribution a { color: #e8d9b0; }
.ex-label-wrap { pointer-events: none !important; }
.ex-label {
  display: inline-block; white-space: nowrap; transform: translateX(-50%); margin-left: 48px;
  font: 700 11px/1 var(--font-sans); letter-spacing: 0.04em; text-transform: uppercase;
  color: #f3efe6; text-shadow: 0 1px 2px rgba(0,0,0,0.85); opacity: 0.9;
}
.address-bar {
  position: absolute; top: 12px; left: 54px; right: 12px; z-index: 500;
  display: flex; gap: 0.4rem; max-width: 640px;
}
.address-bar input {
  flex: 1; min-height: 48px; border: 0; box-shadow: var(--shadow);
  font-size: 1rem;
}
.address-bar button { box-shadow: var(--shadow); }

.guide {
  position: absolute; left: 12px; bottom: calc(var(--credit-h, 24px) + 12px); z-index: 500;
  background: rgba(250,248,243,0.95);
  border-radius: 12px; padding: 0.7rem 0.85rem; max-width: 320px;
  box-shadow: var(--shadow); color: var(--ink);
}
.guide ol { margin: 0.3rem 0 0; padding-left: 1.2rem; }
.guide li { margin: 0.15rem 0; }
.guide li.done { color: var(--ok); }
.guide-hide { float: right; background: none; border: 0; cursor: pointer; font-weight: 700; min-width: 44px; min-height: 44px; margin: -0.5rem -0.6rem 0 0; font-size: 1.1rem; }
.guide-show { display: none; }
.guide.collapsed { padding: 0; background: transparent; box-shadow: none; }
.guide.collapsed > :not(.guide-show) { display: none; }
.guide.collapsed .guide-show {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 1rem;
  border-radius: 999px; border: 1px solid rgba(255,255,255,0.6); cursor: pointer;
  background: rgba(19,38,28,0.88); color: var(--cream); font: 700 0.85rem var(--font-sans); box-shadow: var(--shadow);
}

.status-chip {
  position: absolute; left: 12px; top: 68px; z-index: 500;
  background: rgba(19,38,28,0.9); color: var(--cream);
  border-radius: 999px; padding: 0.35rem 0.75rem; font-size: 0.88rem;
  max-width: calc(100% - 24px);
}

.designer-panel {
  background: var(--paper);
  color: var(--ink);
  border-left: 1px solid var(--line);
  overflow: auto;
  min-height: 0;
  padding: 0.85rem 0.9rem 1.4rem;
  display: flex; flex-direction: column; gap: 0.85rem;
}
.designer-panel h2 {
  font-family: var(--font-display);
  font-size: 1.15rem; margin: 0 0 0.4rem; font-weight: 650;
}
.cost-banner {
  background: #fff7e8; border: 1px solid #e6c888; color: #5a3f12;
  border-radius: 8px; padding: 0.55rem 0.7rem; font-size: 0.82rem; margin: 0;
}
.zone-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.zone-row {
  border: 1px solid var(--line); border-radius: 10px; padding: 0.5rem 0.55rem;
  background: #fff; display: grid; gap: 0.25rem;
}
.zone-row header { display: flex; align-items: center; gap: 0.4rem; }
.swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; border: 1px solid rgba(0,0,0,0.2); }
.zone-row input[type="text"] { min-height: 36px; font-weight: 700; }
.zone-meta { font-size: 0.82rem; color: var(--muted); }
.totals { background: var(--pine); color: var(--cream); border-radius: 10px; padding: 0.7rem 0.8rem; }
.totals .figure { font-family: var(--font-display); font-size: 1.6rem; font-weight: 650; }
.totals .sub { font-size: 0.82rem; opacity: 0.85; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.panel-actions .btn, .panel-actions button {
  min-height: 44px; font-size: 0.88rem; padding: 0.4rem 0.7rem;
}
.selected-box { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem; }
.selected-box label { font-size: 0.82rem; }
.range-row { display: flex; align-items: center; gap: 0.4rem; }
.range-row input[type="range"] { flex: 1; min-height: 32px; }
.settings-panel, .catalog-box { font-size: 0.92rem; }
.settings-panel .field { margin-bottom: 0.55rem; }
.settings-panel h3 { margin: 0.6rem 0 0.3rem; font-size: 0.95rem; }

.item-tooltip {
  position: absolute; z-index: 700; pointer-events: none;
  background: #fff; color: var(--ink);
  border-radius: 8px; padding: 0.45rem 0.6rem;
  box-shadow: var(--shadow); font-size: 0.85rem; max-width: 240px;
  display: none; border: 1px solid var(--line);
}
.item-tooltip.show { display: block; }
.item-tooltip strong { display: block; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,16,12,0.55);
  z-index: 80; display: none; align-items: center; justify-content: center; padding: 1rem;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--paper); color: var(--ink);
  border-radius: 14px; padding: 1.2rem; width: min(520px, 100%);
  max-height: 90vh; overflow: auto; box-shadow: var(--shadow);
}
.modal h2 { margin-top: 0; }

/* Leaflet attribution must stay visible (it lives in .map-credit under the map). */
.leaflet-container { font-family: var(--font-sans); }

.head-marker, .equip-marker {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.35);
}
.equip-marker { border-radius: 4px; }
.manifold-marker { box-shadow: 0 0 0 2px rgba(19,38,28,0.25); }
.manifold-badge {
  position: absolute; top: -8px; right: -8px;
  background: var(--clay, #c45c32); color: #fff;
  border-radius: 999px; min-width: 20px; height: 20px; padding: 0 5px;
  font: 700 11px/20px "Source Sans 3", sans-serif;
  text-align: center; border: 2px solid #fff;
}


@media (max-width: 860px) {
  /* Phones and small tablets: a normal scrolling page — toolbar, a tall map, then the panel. */
  .designer-app {
    display: block; height: auto; max-height: none;
  }
  .designer-toolbar {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; padding: 0.45rem 0.6rem;
  }
  .designer-toolbar::-webkit-scrollbar { display: none; }
  /* fade on the right edge hints that the tool row scrolls sideways */
  .designer-toolbar { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); padding-right: 2.5rem; }
  .designer-toolbar .group { flex-wrap: nowrap; flex: none; }
  .designer-toolbar .mode-toggle { flex: none; }
  .designer-stage { --credit-h: 40px; height: 68vh; min-height: 420px; max-height: 640px; }
  .map-credit { justify-content: flex-start; }
  .map-credit .leaflet-control-attribution { text-align: left; font-size: 10.5px; }
  .address-bar { left: 10px; right: 10px; top: 10px; }
  .address-bar input { min-width: 0; font-size: 16px; }
  .address-bar .btn { padding-left: 0.9rem; padding-right: 0.9rem; white-space: nowrap; }
  .status-chip { left: 10px; right: 10px; top: 66px; max-width: none; border-radius: 12px; font-size: 0.82rem; }
  .guide { left: 10px; right: auto; max-width: calc(100% - 80px); font-size: 0.9rem; }
  .designer-panel { border-left: 0; border-top: 1px solid var(--line); max-height: none; overflow: visible; }
}
@media (max-width: 600px) {
  .leaflet-marker-icon .equip-marker { transform: scale(0.72); transform-origin: center; }
}
@media print {
  .site-header, .designer-toolbar, .address-bar, .guide, .status-chip, .panel-actions, .site-footer { display: none !important; }
  .designer-app { display: block; min-height: 0; }
  .designer-stage { height: 420px; position: relative; }
  #map { position: absolute; top: 0; left: 0; right: 0; bottom: var(--credit-h, 24px); }
  .designer-panel { max-height: none; overflow: visible; }
}
