/* ============================================================================
   2D KART-EDITOR (TORN, MARKPASS, ENSTAKA TRÄD, VÄGAR/STIGAR, TRÄDOMRÅDEN & DELOMRÅDEN)
   ============================================================================ */
.map-editor-shell {
  width: 98vw;
  max-width: 1920px;
  height: 96vh;
}

.map-editor-header {
  padding: 8px 16px;
}

.map-editor-header h1 {
  font-size: 15.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.medit-header-sub {
  font-size: 12px;
  font-weight: 500;
  color: #a7f3d0;
}

.map-editor-workspace {
  grid-template-columns: 1fr 318px;
}

.map-editor-workspace.sidebar-collapsed {
  grid-template-columns: 1fr;
}

.map-editor-workspace.sidebar-collapsed .map-editor-side {
  display: none;
}

#map-editor-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#map-editor-canvas:active {
  cursor: grabbing;
}

.map-editor-top-hint {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 6;
  background: rgba(10, 18, 14, 0.92);
  border: 1px solid rgba(110, 231, 135, 0.55);
  color: #e2fbe8;
  font-size: 11.5px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 99px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  max-width: calc(100% - 140px);
}

/* Floating Center-Place Bar at Bottom Center of Map Canvas */
.map-editor-center-bar {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}

.btn-medit-place-center {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #10b981 0%, #059669 60%, #047857 100%);
  border: 2px solid #fde047;
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 800;
  padding: 10px 20px;
  border-radius: 99px;
  cursor: pointer;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.78), 0 0 18px rgba(16, 185, 129, 0.45);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  white-space: nowrap;
}

.btn-medit-place-center:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.85), 0 0 24px rgba(250, 204, 21, 0.55);
}

.btn-medit-place-center:active {
  transform: translateY(1px);
}

.map-editor-draw-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(15, 25, 19, 0.96);
  border: 1.5px solid #facc15;
  padding: 6px 11px;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.75);
}

#map-editor-draw-status {
  font-size: 11.5px;
  font-weight: 800;
  color: #fde047;
  margin-right: 4px;
}

/* Floating Layer Manager Popover */
.map-editor-layers-popover {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 12;
  width: 265px;
  background: rgba(11, 19, 15, 0.97);
  backdrop-filter: blur(12px);
  border: 1.5px solid #38bdf8;
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.82);
}

.medit-layers-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 800;
  color: #e0f2fe;
  padding-bottom: 5px;
  margin-bottom: 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.medit-layers-close {
  appearance: none;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  padding: 2px 6px;
}

.medit-layer-chk {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: #e2e8f0;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
}

.medit-layer-chk:hover {
  background: rgba(255, 255, 255, 0.07);
}

.medit-layer-chk input[type="checkbox"] {
  accent-color: #10b981;
  width: 15px;
  height: 15px;
  margin: 0;
  cursor: pointer;
}

.layer-color-dot {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  border: 1.5px solid rgba(255, 255, 255, 0.75);
  flex-shrink: 0;
}

/* Grouped Sidebar Tabs */
.medit-group-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: rgba(0, 0, 0, 0.35);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.medit-group-tab {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 800;
  padding: 6px 4px;
  border-radius: 7px;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.12s ease;
}

.medit-group-tab:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
}

.medit-group-tab.active {
  background: rgba(16, 185, 129, 0.28);
  border-color: #34d399;
  color: #ecfdf5;
}

.medit-group-pane {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.map-editor-tools-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.map-editor-tools-grid.cols-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.medit-tool-btn {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #e2e8f0;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all 0.12s ease;
}

.medit-tool-btn:hover {
  background: rgba(52, 211, 153, 0.14);
  border-color: rgba(110, 231, 135, 0.5);
  color: #fff;
}

.medit-tool-btn.active {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.34) 0%, rgba(34, 197, 94, 0.22) 100%);
  border-color: #4ade80;
  color: #ffffff;
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.45), 0 4px 12px rgba(0, 0, 0, 0.4);
}

.medit-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.medit-options-panel {
  background: rgba(12, 22, 16, 0.85);
  border: 1px solid rgba(110, 231, 135, 0.28);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-medit-side-place {
  appearance: none;
  width: 100%;
  background: rgba(16, 185, 129, 0.24);
  border: 1.5px solid #34d399;
  color: #ecfdf5;
  font-size: 12px;
  font-weight: 800;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 2px;
  transition: all 0.12s ease;
}

.btn-medit-side-place:hover {
  background: rgba(16, 185, 129, 0.42);
  border-color: #fde047;
  color: #ffffff;
}

.medit-opt-title {
  font-size: 11.5px;
  font-weight: 800;
  color: #86efac;
  letter-spacing: 0.02em;
}

.medit-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11.5px;
  color: #cbd5e1;
}

.medit-row input[type="range"] {
  width: 100%;
  accent-color: #22c55e;
}

.medit-help {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.35;
  margin: 2px 0 0 0;
}

.medit-selected-badge {
  display: inline-block;
  background: rgba(250, 204, 21, 0.18);
  border: 1px solid rgba(250, 204, 21, 0.55);
  color: #fef08a;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  margin-bottom: 4px;
}

.medit-items-details {
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.medit-items-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 800;
  color: #94a3b8;
  cursor: pointer;
  user-select: none;
  margin-bottom: 5px;
}

.medit-compact-list {
  max-height: 185px;
  overflow-y: auto;
}

.medit-item-del-btn {
  appearance: none;
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fca5a5;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}

.medit-item-del-btn:hover {
  background: rgba(239, 68, 68, 0.35);
  color: #fff;
}

/* GPS Recording & Best-Fit Action Dialog in 2D Map Editor */
.medit-center-btn-row {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-medit-gps-rec {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(15, 23, 42, 0.92);
  border: 2px solid #f43f5e;
  color: #ffe4e6;
  font-size: 13px;
  font-weight: 800;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.6);
  transition: all 0.14s ease;
}

.btn-medit-gps-rec:hover {
  background: rgba(225, 29, 72, 0.32);
  border-color: #fda4af;
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-medit-gps-rec.recording,
.btn-gps-rec.recording {
  background: linear-gradient(135deg, #e11d48 0%, #be123c 100%) !important;
  border-color: #fde047 !important;
  color: #ffffff !important;
  box-shadow: 0 0 18px rgba(244, 63, 94, 0.75), 0 6px 20px rgba(0, 0, 0, 0.65);
  animation: gpsRecPulse 1.2s infinite ease-in-out;
}

.gps-rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f43f5e;
  box-shadow: 0 0 8px #f43f5e;
  display: inline-block;
}

.btn-medit-gps-rec.recording .gps-rec-dot {
  background: #fde047;
  box-shadow: 0 0 10px #fde047;
  border-radius: 2px;
}

@keyframes gpsRecPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}

.map-editor-gps-finish-card {
  position: absolute;
  bottom: 74px;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 24px));
  background: rgba(8, 16, 22, 0.96);
  border: 1.5px solid #00f0ff;
  border-radius: 14px;
  padding: 12px 14px;
  z-index: 32;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(12px);
  color: #f1f5f9;
}

.medit-gps-finish-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 4px;
}

.medit-gps-fit-badge {
  background: rgba(0, 240, 255, 0.16);
  border: 1px solid rgba(0, 240, 255, 0.55);
  color: #67e8f9;
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}

.medit-gps-finish-sub {
  font-size: 11.5px;
  color: #cbd5e1;
  margin: 0 0 10px 0;
}

.medit-gps-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}

.medit-gps-choice-btn {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 9px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 8px 10px;
  color: #f8fafc;
  text-align: left;
  cursor: pointer;
  transition: all 0.12s ease;
}

.medit-gps-choice-btn > span {
  font-size: 18px;
  flex-shrink: 0;
}

.medit-gps-choice-btn strong {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: #ffffff;
}

.medit-gps-choice-btn small {
  display: block;
  font-size: 10.5px;
  color: #94a3b8;
  margin-top: 1px;
}

.medit-gps-choice-btn:hover {
  background: rgba(16, 185, 129, 0.24);
  border-color: #4ade80;
  transform: translateY(-1px);
}

.medit-gps-choice-btn.highlight-cyan {
  background: rgba(0, 240, 255, 0.12);
  border-color: rgba(0, 240, 255, 0.55);
}

.medit-gps-choice-btn.highlight-cyan:hover {
  background: rgba(0, 240, 255, 0.26);
  border-color: #fde047;
}

.medit-gps-choice-btn.danger-choice {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(248, 113, 113, 0.45);
}

.medit-gps-choice-btn.danger-choice:hover {
  background: rgba(239, 68, 68, 0.32);
  border-color: #fca5a5;
}

.btn-medit-undo-pill {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(15, 23, 42, 0.92);
  border: 2px solid #38bdf8;
  color: #e0f2fe;
  font-size: 13px;
  font-weight: 800;
  padding: 10px 15px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.6);
  transition: all 0.14s ease;
}

.btn-medit-undo-pill:hover:not(:disabled),
.btn-medit-undo:hover:not(:disabled) {
  background: rgba(14, 165, 233, 0.32);
  border-color: #fde047;
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-medit-undo-pill:disabled,
.btn-medit-undo:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.18);
  color: #94a3b8;
}

.medit-vertex-help-box {
  background: rgba(0, 240, 255, 0.09);
  border: 1px solid rgba(0, 240, 255, 0.42);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 11px;
  line-height: 1.42;
  color: #e2e8f0;
  margin-bottom: 6px;
}

.medit-bg-control-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
}

.medit-ortofoto-dropdown-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

#btn-medit-bg-ortofoto.active {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
  border: 1px solid #86efac !important;
  color: #ffffff !important;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.55);
}

.medit-ortofoto-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 255px;
  background: rgba(10, 20, 15, 0.98);
  backdrop-filter: blur(14px);
  border: 1.5px solid #34d399;
  border-radius: 10px;
  padding: 5px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 3px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.85);
}

.medit-ortofoto-opt {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 7px 10px;
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s ease;
}

.medit-ortofoto-opt:hover {
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(52, 211, 153, 0.45);
  color: #ffffff;
}

.medit-ortofoto-opt.selected {
  background: rgba(16, 185, 129, 0.30);
  border-color: #34d399;
  color: #ecfdf5;
  font-weight: 800;
}

.btn-medit-save-close {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
  border: 1.5px solid #fde047 !important;
  color: #ffffff !important;
  font-weight: 800 !important;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.btn-medit-save-close:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

/* Unified Område (Tom / Träd / Fast färg) Controls */
.medit-sub-heading-lbl {
  font-size: 11px;
  font-weight: 800;
  color: #a7f3d0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.medit-omrade-sub-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-top: 2px;
}

.medit-omrade-sub-grid.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.medit-omrade-sub-btn {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #cbd5e1;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s ease;
}

.medit-omrade-sub-btn:hover {
  background: rgba(52, 211, 153, 0.14);
  border-color: rgba(110, 231, 135, 0.5);
  color: #ffffff;
}

.medit-omrade-sub-btn.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.36) 0%, rgba(5, 150, 105, 0.28) 100%);
  border-color: #34d399;
  color: #ecfdf5;
  box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.45);
}

.medit-omrade-subpane {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.medit-snap-toggle-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  border-radius: 7px;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(34, 211, 238, 0.35);
  color: #cffafe;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.medit-snap-toggle-row input[type="checkbox"] {
  accent-color: #06b6d4;
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
}

.medit-color-swatch-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.medit-color-swatch {
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.medit-color-swatch:hover {
  transform: scale(1.1);
  border-color: #ffffff;
}

.medit-color-swatch.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px #10b981, 0 2px 8px rgba(0, 0, 0, 0.6);
  transform: scale(1.1);
}

.medit-color-picker-input {
  width: 28px;
  height: 26px;
  padding: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}





/* ============================================================================
   MAP EDITOR COMPONENT RULES (EXTRACTED FROM INLINE HTML)
   ============================================================================ */
.map-editor-header .selector-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.medit-bg-control-wrap {
  width: auto;
}

.medit-layer-chk input[data-medit-layer="granser"] + .layer-color-dot {
  background: #ff2a6d;
  border-color: #fde047;
}
.medit-layer-chk input[data-medit-layer="delomradenLines"] + .layer-color-dot {
  background: #00f0ff;
}
.medit-layer-chk input[data-medit-layer="delomradenLabels"] + .layer-color-dot {
  background: #38bdf8;
}
.medit-layer-chk input[data-medit-layer="jaktpass"] + .layer-color-dot {
  background: #ea580c;
}
.medit-layer-chk input[data-medit-layer="ways"] + .layer-color-dot {
  background: #f59e0b;
}
.medit-layer-chk input[data-medit-layer="zones"] + .layer-color-dot {
  background: #22c55e;
}
.medit-layer-chk input[data-medit-layer="singleTrees"] + .layer-color-dot {
  background: #10b981;
}
.medit-layer-chk input[data-medit-layer="buildings"] + .layer-color-dot {
  background: #f43f5e;
}
.medit-layer-chk input[data-medit-layer="baseTrees"] + .layer-color-dot {
  background: #15803d;
}

.medit-color-swatch[data-omrade-color="#eab308"] { background: #eab308; }
.medit-color-swatch[data-omrade-color="#22c55e"] { background: #22c55e; }
.medit-color-swatch[data-omrade-color="#ef4444"] { background: #ef4444; }
.medit-color-swatch[data-omrade-color="#3b82f6"] { background: #3b82f6; }
.medit-color-swatch[data-omrade-color="#a855f7"] { background: #a855f7; }
.medit-color-swatch[data-omrade-color="#f97316"] { background: #f97316; }
.medit-color-swatch[data-omrade-color="#14b8a6"] { background: #14b8a6; }

#medit-chain-badge,
#medit-way-conn-badge {
  font-size: 11px;
  color: #67e8f9;
  background: rgba(8, 47, 73, 0.65);
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: 5px;
  padding: 4px 7px;
  margin-bottom: 6px;
}

.medit-tiny-action-btn {
  flex: 0 0 auto;
  padding: 2px 8px;
  font-size: 11px;
}

.medit-age-controls-row {
  display: flex;
  gap: 5px;
  align-items: center;
}

.medit-age-step-btn {
  flex: 0 0 auto;
  padding: 4px 8px;
}

#medit-comp-age-num {
  width: 58px;
  padding: 4px 6px;
  text-align: center;
}

#btn-medit-delete-way {
  flex: 0 0 auto;
  padding: 4px 10px;
}

.medit-local-io-bar {
  display: flex;
  gap: 6px;
  padding: 6px 10px 2px 10px;
}

.medit-local-io-btn {
  flex: 1;
  font-size: 11px;
  padding: 5px 8px;
}

#btn-medit-clear-custom {
  padding: 1px 7px;
  font-size: 10px;
}

/* ============================================================================
   3-MODE SWITCHER (VÄLJ/MODIFIERA vs RITA GRÄNSLINJE vs RITA OMRÅDE) & RITLÄGE-BANNER
   ============================================================================ */
.medit-omrade-mode-bar {
  background: rgba(8, 16, 12, 0.92);
  border: 1.5px solid rgba(52, 211, 153, 0.42);
  border-radius: 10px;
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.medit-omrade-mode-lbl {
  font-size: 10.5px;
  font-weight: 800;
  color: #a7f3d0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.medit-omrade-mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.medit-mode-btn {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 7px 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  color: #cbd5e1;
  cursor: pointer;
  text-align: center;
  transition: all 0.12s ease;
}

.medit-mode-btn:hover {
  background: rgba(52, 211, 153, 0.16);
  border-color: rgba(110, 231, 135, 0.6);
  color: #ffffff;
}

.medit-mode-btn.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.38) 0%, rgba(5, 150, 105, 0.32) 100%);
  border-color: #4ade80;
  color: #ffffff;
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.55), 0 4px 12px rgba(0, 0, 0, 0.45);
}

#btn-medit-mode-polyline.active,
#btn-medit-mode-polygon.active,
#btn-medit-way-mode-road.active,
#btn-medit-way-mode-path.active {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.34) 0%, rgba(202, 138, 4, 0.28) 100%);
  border-color: #fde047;
  color: #fef9c3;
  box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.6), 0 4px 12px rgba(0, 0, 0, 0.5);
}

.medit-mode-icon {
  font-size: 16px;
  line-height: 1;
}

.medit-mode-txt {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.medit-mode-txt strong {
  font-size: 11px;
  font-weight: 800;
  color: inherit;
  line-height: 1.15;
}

.medit-mode-txt small {
  font-size: 9.5px;
  color: #94a3b8;
  line-height: 1.1;
}

.medit-mode-btn.active .medit-mode-txt small {
  color: #e2fbe8;
}

.medit-active-draw-banner {
  background: linear-gradient(135deg, rgba(66, 32, 6, 0.95) 0%, rgba(45, 18, 10, 0.95) 100%);
  border: 2px solid #facc15;
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.65), 0 0 14px rgba(250, 204, 21, 0.25);
}

.medit-active-draw-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 800;
  color: #fef08a;
}

.medit-active-draw-badge {
  background: rgba(250, 204, 21, 0.22);
  border: 1px solid #fde047;
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.medit-active-draw-sub {
  font-size: 11px;
  color: #fde68a;
  line-height: 1.35;
  margin: 0;
}

.btn-medit-exit-draw {
  appearance: none;
  width: 100%;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border: 1.5px solid #fecaca;
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 800;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: all 0.12s ease;
}

.btn-medit-exit-draw:hover {
  background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
  border-color: #ffffff;
  transform: translateY(-1px);
}

.map-editor-top-hint.is-drawing-mode {
  background: rgba(66, 32, 6, 0.95);
  border: 1.5px solid #facc15;
  color: #fef08a;
}

/* ============================================================================
   SEPARAT MAGNETISK SNÄPPNING (LINJER vs KNUTPUNKTER vs BÅDA vs AV)
   ============================================================================ */
.medit-boundary-snap-card {
  background: rgba(6, 22, 26, 0.92);
  border: 1.5px solid rgba(34, 211, 238, 0.45);
}

.medit-snap-mode-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.medit-snap-mode-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 5px 4px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  color: #cbd5e1;
  font-size: 10.5px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s ease;
}

.medit-snap-mode-btn:hover {
  background: rgba(6, 182, 212, 0.18);
  border-color: rgba(103, 232, 249, 0.65);
  color: #ffffff;
}

.medit-snap-mode-btn.active {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.38) 0%, rgba(16, 185, 129, 0.32) 100%);
  border-color: #22d3ee;
  color: #ecfeff;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.55), 0 3px 10px rgba(0, 0, 0, 0.45);
}

.medit-snap-mode-btn[data-boundary-snap-mode="none"].active {
  background: rgba(239, 68, 68, 0.25);
  border-color: #f87171;
  color: #fee2e2;
  box-shadow: none;
}

.medit-snap-separate-checks {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
}

.medit-drawbar-snap-group {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.medit-drawbar-snap-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  border: 1.5px solid rgba(148, 163, 184, 0.45);
  color: #94a3b8;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.12s ease;
}

.medit-drawbar-snap-btn:hover {
  border-color: #67e8f9;
  color: #e0f2fe;
}

.medit-drawbar-snap-btn.active {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.34) 0%, rgba(16, 185, 129, 0.28) 100%);
  border-color: #22d3ee;
  color: #ecfeff;
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.35);
}

#btn-medit-bg-irfoto.active,
#btn-medit-bg-tradhojd.active {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
  border: 1px solid #86efac !important;
  color: #ffffff !important;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.55);
}

/* ============================================================================
   MOBILE & TABLET RESPONSIVE LAYOUT FOR 2D KART-EDIT (BOTTOM SHEET + FULL MAP)
   ============================================================================ */
@media (max-width: 900px) {
  .map-editor-shell {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
  }

  .map-editor-header {
    padding: max(6px, env(safe-area-inset-top)) 10px 6px;
    gap: 6px;
    flex-wrap: wrap;
  }

  .map-editor-header .selector-brand {
    flex: 0 1 auto;
  }

  .map-editor-header h1 {
    font-size: 13.5px;
    gap: 6px;
  }

  .medit-header-sub {
    display: none;
  }

  .map-editor-header .selector-header-actions {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 5px;
    flex-wrap: wrap;
  }

  .map-editor-header .btn-modal-secondary,
  .map-editor-header .btn-modal-primary {
    padding: 6px 9px;
    font-size: 11.5px;
    min-height: 34px;
  }

  .medit-bg-control-wrap {
    max-width: 100%;
    flex-wrap: wrap;
    gap: 3px;
  }

  .medit-bg-control-wrap .seg-btn {
    padding: 5px 7px;
    font-size: 11px;
  }

  .map-editor-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(0, 40dvh);
  }

  .map-editor-workspace.sidebar-collapsed {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
  }

  .map-editor-side {
    border-left: none;
    border-top: 1.5px solid rgba(52, 211, 153, 0.35);
    max-height: 40dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
    gap: 8px;
  }

  #medit-group-tabs {
    position: sticky;
    top: -8px;
    z-index: 6;
    background: rgba(9, 16, 12, 0.98);
    padding-top: 2px;
    padding-bottom: 4px;
  }

  .medit-group-tab {
    min-height: 36px;
    font-size: 11.5px;
    padding: 6px 4px;
  }

  .map-editor-top-hint {
    top: 8px;
    left: 8px;
    font-size: 10.5px;
    padding: 4px 9px;
    max-width: calc(100% - 62px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .map-editor-center-bar {
    bottom: 8px;
    max-width: calc(100% - 14px);
    width: max-content;
  }

  .medit-center-btn-row {
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
  }

  .btn-medit-place-center {
    font-size: 12px;
    padding: 8px 13px;
  }

  .btn-medit-gps-rec {
    font-size: 11.5px;
    padding: 8px 11px;
  }

  .map-editor-gps-finish-card {
    width: calc(100% - 16px);
    max-width: 420px;
    max-height: calc(100% - 16px);
    overflow-y: auto;
    padding: 12px;
  }
}

@media (max-width: 440px) {
  .medit-omrade-mode-grid {
    gap: 4px;
  }

  .medit-mode-btn {
    padding: 6px 4px;
  }

  .medit-mode-txt strong {
    font-size: 11px;
  }

  .medit-mode-txt small {
    display: none;
  }
}

