.maps-panel { min-width: 0; }
.maps-panel button { letter-spacing: 0; }
.map-library-bar, .map-settings-row, .map-tools-row, .map-view-tools, .map-editor-actions, .map-footer, .map-inspector-head { display: flex; align-items: center; gap: 12px; }
.map-library-bar { align-items: flex-end; flex-wrap: wrap; }
.map-library-bar > label { flex: 1 1 220px; max-width: 480px; }
.maps-panel label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.maps-panel :is(input:not([type="checkbox"]), select, textarea) { width: 100%; min-width: 0; margin: 0; font: inherit; color: var(--ink); }
.maps-panel :is(input:not([type="checkbox"]), select) { height: 42px; }
.maps-panel textarea { resize: vertical; padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: #191b1e; }
.maps-panel .small { width: auto; flex: 0 0 auto; min-height: 40px; margin: 0; padding: 8px 14px; }
.maps-panel .icon-button { width: 38px; height: 38px; flex: 0 0 38px; padding: 0; margin: 0; }
.map-status { display: flex; align-items: center; gap: 8px; min-height: 34px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.map-settings-row { flex-wrap: wrap; align-items: flex-end; padding: 16px 0; border-top: 1px solid var(--line); }
.map-settings { border-top: 1px solid var(--line); }
.map-settings > summary { display: flex; align-items: center; gap: 10px; padding: 12px 0; cursor: pointer; font-size: 13px; }
.map-settings > summary > span:last-child { margin-left: auto; color: var(--muted); font-size: 12px; }
.map-settings > summary:focus-visible { outline: 2px solid var(--red); outline-offset: -2px; }
.map-settings-row form { display: flex; align-items: flex-end; gap: 8px; flex: 1 1 180px; max-width: 340px; }
.map-settings-row form label { flex: 1; min-width: 0; }
.map-settings-row > label:not(.map-toggle) { flex: 0 1 200px; }
.map-grid-colours { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; margin: 0; min-width: 0; }
.map-grid-colours legend { color: var(--muted); font-size: 13px; padding: 0 0 6px; }
.map-grid-colours label { display: block; position: relative; width: 34px; height: 42px; cursor: pointer; }
.map-grid-swatch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.map-grid-swatch > span:not(.visually-hidden) { display: block; width: 34px; height: 34px; margin-top: 4px; background: var(--swatch-colour); border: 4px solid var(--paper); outline: 1px solid var(--line); border-radius: 4px; }
.map-grid-colours input:checked + span { outline: 2px solid var(--red); }
.map-grid-colours input:focus-visible + span { outline: 2px solid white; }
.maps-panel .map-grid-custom input[type="color"] { width: 34px; height: 34px; min-height: 0; margin: 4px 0; padding: 3px; border: 1px dashed var(--muted); border-radius: 4px; background: var(--paper); cursor: pointer; }
.map-grid-custom input::-webkit-color-swatch-wrapper { padding: 0; }
.map-grid-custom input::-webkit-color-swatch { border: 0; border-radius: 1px; }
.map-grid-custom input::-moz-color-swatch { border: 0; border-radius: 1px; }
.map-settings-row > .map-grid-opacity { flex: 0 1 190px; }
.map-grid-opacity > span { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.map-grid-opacity output { min-width: 4ch; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.maps-panel .map-grid-opacity input[type="range"] { width: 100%; height: 42px; padding: 0; margin: 0; border: 0; background: transparent; accent-color: var(--red); cursor: pointer; }
.maps-panel .map-toggle { display: flex; align-items: center; gap: 8px; min-height: 42px; white-space: nowrap; }
.map-toggle input { width: 16px; height: 16px; margin: 0; accent-color: var(--red); }
.map-tools-row { justify-content: space-between; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.map-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.map-view-tools { justify-content: flex-end; flex-wrap: wrap; margin-left: auto; }
.map-control-group { display: flex; align-items: center; flex: 0 0 auto; gap: 6px; }
.map-tools button[aria-pressed="true"] { color: var(--red); background: var(--red-deep); border-color: var(--red); }
.map-view-tools output { width: 44px; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; }
.map-view-tools [data-map-action="inspector"] { display: none; }
.map-workbench { display: grid; grid-template-columns: minmax(0, 1fr) 250px; min-height: 400px; }
.map-viewport { height: clamp(360px, calc(100dvh - 390px), 850px); overflow: auto; overscroll-behavior: contain; background: #101213; position: relative; min-width: 0; }
.map-canvas-space { min-width: 100%; min-height: 100%; width: max-content; display: grid; place-items: center; padding: 12px; }
.map-board { position: relative; flex: 0 0 auto; background: #202225; isolation: isolate; }
.map-board[data-map-board] { touch-action: none; user-select: none; }
.map-board[data-tool="pan"] { cursor: grab; }
.map-board[data-tool]:not([data-tool="select"]):not([data-tool="pan"]) { cursor: crosshair; }
.map-viewport[data-pan="true"], .map-viewport[data-pan="true"] :is(.map-board, .map-marker, .map-zone-resize) { cursor: grab; }
.map-viewport[data-dragging="true"], .map-viewport[data-dragging="true"] :is(.map-board, .map-marker, .map-zone-resize) { cursor: grabbing; }
.map-viewport[data-pan="true"] { touch-action: none; user-select: none; }
.map-board > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.map-grid { position: absolute; inset: 0; background-image: linear-gradient(to right, var(--map-grid-color) 1px, transparent 1px), linear-gradient(to bottom, var(--map-grid-color) 1px, transparent 1px); background-size: var(--map-cell) calc(var(--map-cell) * var(--map-ratio)); pointer-events: none; }
.map-marker-layer { position: absolute; inset: 0; pointer-events: none; }
.map-marker { position: absolute; display: grid; place-items: center; margin: 0; padding: 0; color: var(--marker-color); border: 2px solid var(--marker-color); background: #16191df2; pointer-events: auto; cursor: move; touch-action: none; }
.map-pin { width: 32px; height: 32px; min-height: 0; border-radius: 50%; transform: translate(-50%, -50%); }
.map-pin .ui-icon { width: 18px; height: 18px; }
.map-marker.is-selected { outline: 2px solid white; outline-offset: 3px; z-index: 2; }
.map-zone { border-radius: 0; min-height: 0; background: repeating-linear-gradient(135deg, #f17b8625 0 7px, #f17b8640 7px 14px); border-style: dashed; }
.map-zone-label { padding: 4px; font-size: 12px; font-weight: 600; color: #fff; text-shadow: 0 1px 3px #000; overflow-wrap: anywhere; max-width: 100%; max-height: 100%; overflow: hidden; }
.map-zone-resize { display: none; position: absolute; right: -6px; bottom: -6px; width: 16px; height: 16px; background: var(--marker-color); border: 2px solid #fff; cursor: nwse-resize; }
.map-zone.is-selected .map-zone-resize { display: block; }
.map-inspector { min-width: 0; max-height: clamp(360px, calc(100dvh - 390px), 850px); overflow: auto; border-left: 1px solid var(--line); padding: 14px; }
.map-inspector-head { justify-content: space-between; }
.map-inspector h3 { font-size: 14px; margin: 0; }
.map-inspector-head > span, .map-muted { color: var(--muted); font-size: 12px; }
.map-marker-editor { margin: 14px 0; }
.map-marker-editor fieldset, #mapUploadForm fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 12px; }
.map-coordinates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.map-editor-actions { justify-content: space-between; }
.map-marker-list { list-style: none; padding: 0; margin: 14px 0 0; border-top: 1px solid var(--line); }
.map-marker-list li { border-bottom: 1px solid var(--line); }
.map-marker-list button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 12px 8px; border: 0; border-radius: 0; background: transparent; color: var(--ink); }
.map-marker-list button > span:last-child { overflow-wrap: anywhere; min-width: 0; }
.map-marker-list button[aria-pressed="true"] { background: var(--red-deep); border-left: 3px solid var(--red); }
.map-footer { justify-content: space-between; flex-wrap: wrap; padding-top: 10px; font-size: 12px; color: var(--muted); }
.map-empty { display: grid; align-content: center; justify-items: center; min-height: 220px; gap: 12px; color: var(--muted); }
.map-empty > .ui-icon { width: 36px; height: 36px; }
.map-empty p { margin: 0; }
.dashboard-maps-widget { min-width: 0; }
.dashboard-maps-widget .maps-panel { display: flex; flex-direction: column; gap: 8px; min-height: 0; flex: 1; }
.map-preview { display: grid; place-items: center; container-type: size; width: 100%; flex: 1; min-height: 140px; margin: 0; padding: 4px; background: #101213; border: 0; border-radius: 0; overflow: hidden; }
.map-board-preview { width: min(100cqw, calc(100cqh * var(--map-ratio))); aspect-ratio: var(--map-ratio); }
.map-board-preview .map-marker { pointer-events: none; }
.map-board-preview .map-pin { width: 22px; height: 22px; }
.map-board-preview .map-pin .ui-icon { width: 13px; height: 13px; }
.map-board-preview .map-zone-label { font-size: 10px; }
.map-image-error { position: absolute; inset: 0; display: grid; place-content: center; padding: 24px; text-align: center; background: var(--paper); z-index: 4; }
#mapUploadForm input[type="file"] { height: auto; padding: 10px; }
#mapUploadForm input::file-selector-button { border: 1px solid var(--line); border-radius: 4px; background: var(--soft); color: var(--ink); padding: 6px 10px; margin-right: 10px; font: inherit; cursor: pointer; }
#mapUploadForm p { margin: 0; }
.map-clear-dialog { width: min(480px, calc(100% - 32px)); padding: 28px; }
.map-clear-dialog h2 { margin: 0 0 12px; }
.map-clear-dialog p { margin: 0; color: var(--muted); line-height: 1.6; overflow-wrap: anywhere; }
.map-clear-dialog form { margin-top: 24px; }
.map-clear-dialog .campaign-dialog-actions { gap: 12px; padding-top: 20px; border-top: 1px solid var(--line); }
@media (max-width: 1200px) { .map-workbench { grid-template-columns: minmax(0, 1fr) 220px; } }
@media (max-width: 700px) {
  .map-workbench { grid-template-columns: minmax(0, 1fr); }
  .map-viewport { height: 320px; }
  .map-inspector { border-left: 0; border-top: 1px solid var(--line); max-height: none; padding: 16px 0; }
  .map-marker-list { max-height: 240px; overflow: auto; }
  .map-settings-row > label:not(.map-toggle) { flex-grow: 1; }
  .map-settings-row form { max-width: none; flex-basis: 100%; }
  .map-tools-row { gap: 12px; }
  .map-tools { flex-wrap: nowrap; width: 100%; overflow-x: auto; padding: 4px 0; }
  .map-view-tools { width: 100%; gap: 8px 16px; }
  .map-zoom-controls { margin-right: auto; }
  .map-clear-dialog { padding: 20px; }
  .map-library-bar > label { max-width: none; flex-basis: 100%; }
  .maps-panel .icon-button { width: 40px; height: 40px; flex-basis: 40px; }
}

body.is-map-fullscreen-open { overflow: hidden; }
.maps-panel.is-map-fullscreen {
  position: fixed; inset: 0; z-index: 10001; box-sizing: border-box;
  width: 100%; height: 100dvh; max-width: none; max-height: none; margin: 0;
  display: flex; flex-direction: column; overflow: hidden; background: var(--paper);
  padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.is-map-fullscreen > :is(.map-library-bar, .map-settings, .map-footer) { display: none; }
.is-map-fullscreen > .map-status { order: 3; flex: 0 0 auto; min-height: 24px; }
.is-map-fullscreen .map-tools-row { flex: 0 0 auto; padding: 4px 0 8px; border-top: 0; }
.is-map-fullscreen .map-view-tools [data-map-action="inspector"] { display: grid; }
.is-map-fullscreen [data-map-action="inspector"][aria-expanded="true"] { color: var(--red); background: var(--red-deep); }
.is-map-fullscreen .map-workbench { flex: 1; min-height: 0; grid-template-columns: minmax(0, 1fr); position: relative; }
.is-map-fullscreen .map-viewport { height: 100%; min-height: 0; }
.is-map-fullscreen .map-inspector { display: none; height: 100%; max-height: none; min-height: 0; }
.is-map-fullscreen.map-inspector-open .map-workbench { grid-template-columns: minmax(0, 1fr) 250px; }
.is-map-fullscreen.map-inspector-open .map-inspector { display: block; }
@media (max-width: 700px) {
  .is-map-fullscreen .map-tools-row { gap: 4px; }
  .is-map-fullscreen .map-tools { padding: 0; }
  .is-map-fullscreen .map-view-tools { flex: 1 1 100%; gap: 8px 16px; }
  .is-map-fullscreen .map-view-tools .icon-button { width: 36px; height: 40px; flex-basis: 36px; }
  .is-map-fullscreen .map-view-tools output { width: 40px; flex: 0 0 40px; }
  .is-map-fullscreen.map-inspector-open .map-workbench { grid-template-columns: minmax(0, 1fr); }
  .is-map-fullscreen .map-inspector { position: absolute; inset: 0 0 0 auto; z-index: 5; width: min(280px, 100%); padding: 12px; border: 1px solid var(--line); background: var(--paper); }
  .is-map-fullscreen .map-marker-list { max-height: none; }
}
@media (max-width: 380px) {
  .map-grid-colours { gap: 6px; }
  .is-map-fullscreen .map-view-tools .icon-button { width: 34px; flex-basis: 34px; }
}
