/* Map Studio toolbar — visual match to Toolbar/Toolbar.html */
.map-studio-root {
  --ms-bg: #f3f4f7;
  --ms-surface: #ffffff;
  --ms-surface-2: #f8f9fb;
  --ms-surface-3: #eef1f6;
  --ms-ink: #1a1d23;
  --ms-ink-2: #4a5260;
  --ms-ink-3: #8a93a3;
  --ms-line: #e4e7ee;
  --ms-line-2: #edf0f5;
  --ms-accent: oklch(0.55 0.16 255);
  --ms-accent-soft: oklch(0.95 0.04 255);
  --ms-accent-ink: oklch(0.40 0.18 255);
  --ms-shadow-2: 0 4px 14px -4px rgba(20, 24, 32, 0.12), 0 2px 6px rgba(20, 24, 32, 0.06);
  --ms-shadow: 0 10px 28px rgba(20, 24, 32, 0.14);
  --ms-radius: 10px;
  --ms-radius-btn: 8px;
}

.map-studio-root.is-dark-scheme {
  color-scheme: dark;
  --ms-bg: #040a12;
  --ms-surface: #171d26;
  --ms-surface-2: #111720;
  --ms-surface-3: #202936;
  --ms-ink: #f2f5f8;
  --ms-ink-2: #c5ced9;
  --ms-ink-3: #8793a2;
  --ms-line: #2a3442;
  --ms-line-2: #222b38;
  --ms-accent: oklch(0.70 0.16 248);
  --ms-accent-soft: color-mix(in oklab, var(--ms-accent) 18%, #172132);
  --ms-accent-ink: #d7e7ff;
  --ms-shadow-2: 0 14px 34px rgba(0, 0, 0, 0.34), 0 2px 10px rgba(0, 0, 0, 0.28);
  --ms-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
}

.map-studio-root .toolbar {
  display: inline-flex;
  align-items: stretch;
  background: var(--ms-surface);
  border: 1px solid var(--ms-line);
  border-radius: var(--ms-radius);
  box-shadow: var(--ms-shadow-2);
  padding: 6px;
  gap: 4px;
  user-select: none;
  flex-wrap: wrap;
}

.map-studio-toolbar-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  min-width: 0;
}

.map-studio-main-toolbar {
  width: 100%;
  flex-wrap: wrap;
  align-items: center;
}

.map-studio-route-tools-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  box-sizing: border-box;
  background: var(--ms-surface);
  border: 1px solid var(--ms-line);
  border-radius: var(--ms-radius);
  box-shadow: var(--ms-shadow-2);
}

.map-studio-route-tools-row-label {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ms-ink-3);
  white-space: nowrap;
}

.map-studio-route-tools-row .map-studio-route-tools {
  flex: 1;
  min-width: 0;
}

.map-studio-canvas-route-tools,
.map-studio-canvas-shape-tools {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 11;
  display: flex;
  padding: 8px;
  pointer-events: auto;
  background: var(--ms-surface);
  border: 2px solid var(--ms-accent);
  border-radius: 10px;
  box-shadow: var(--ms-shadow);
}

.map-studio-canvas-shape-tools {
  top: auto;
  bottom: 56px;
  left: 10px;
}

.map-studio-shape-tools-inner {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.map-studio-tools-divider {
  width: 1px;
  align-self: stretch;
  min-height: 28px;
  margin: 0 4px;
  background: var(--ms-border, rgba(255, 255, 255, 0.2));
}

.map-studio-pathfinder-tools-inner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.map-studio-pathfinder-count {
  min-width: 1.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  color: var(--ms-text-muted, #94a3b8);
}

.map-studio-pathfinder-btn {
  width: 32px;
  height: 32px;
  padding: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ms-text, #e2e8f0);
  background: var(--ms-surface-elevated, rgba(30, 27, 75, 0.6));
  border: 1px solid var(--ms-border, rgba(255, 255, 255, 0.15));
  border-radius: 6px;
  cursor: pointer;
}

.map-studio-pathfinder-btn svg {
  width: 18px;
  height: 18px;
}

.map-studio-pathfinder-btn:hover:not(:disabled) {
  border-color: var(--ms-accent, #6366f1);
  color: var(--ms-accent, #818cf8);
}

.map-studio-pathfinder-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.map-studio-main-toolbar .toolbar-spacer {
  flex: 1;
  min-width: 8px;
}

.map-studio-main-toolbar .toolbar-group-sections {
  gap: 6px;
}

.map-studio-root .toolbar-section-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: var(--ms-radius-btn);
  background: transparent;
  color: var(--ms-ink-2);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.map-studio-root .toolbar-section-btn:hover:not(:disabled) {
  background: var(--ms-surface-2);
  color: var(--ms-ink);
  border-color: var(--ms-line);
}

.map-studio-root .toolbar-section-btn.is-active {
  background: var(--ms-accent-soft);
  color: var(--ms-accent-ink);
  border-color: color-mix(in oklab, var(--ms-accent) 35%, transparent);
}

.map-studio-root .toolbar-section-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.map-studio-root .toolbar-section-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
}

.map-studio-root .toolbar-section-icon svg {
  width: 18px;
  height: 18px;
}

.map-studio-root .toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 4px;
  position: relative;
}

.map-studio-root .toolbar-group + .toolbar-group::before {
  content: "";
  position: absolute;
  left: -2px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--ms-line);
}

.map-studio-root .group-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ms-ink-3);
  text-transform: uppercase;
  padding: 0 6px;
  align-self: center;
  pointer-events: none;
  white-space: nowrap;
}

.map-studio-root .tool-btn {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ms-ink-2);
  width: 36px;
  height: 36px;
  border-radius: var(--ms-radius-btn);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 80ms ease;
}

.map-studio-root .tool-btn:hover:not(:disabled) {
  background: var(--ms-surface-2);
  color: var(--ms-ink);
  border-color: var(--ms-line);
}

.map-studio-root .tool-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.map-studio-root .tool-btn[aria-pressed="true"],
.map-studio-root .tool-btn.is-active {
  background: var(--ms-accent-soft);
  color: var(--ms-accent-ink);
  border-color: color-mix(in oklab, var(--ms-accent) 25%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--ms-accent) 20%, transparent);
}

.map-studio-root .tool-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.map-studio-root .tool-btn svg {
  width: 22px;
  height: 22px;
  display: block;
  overflow: visible;
}

.map-studio-root .tt {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background: #1a1d23;
  color: #f5f6f8;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(10, 12, 16, 0.22), 0 2px 6px rgba(10, 12, 16, 0.14);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
  z-index: 30;
  text-align: left;
}

.map-studio-root .tool-btn:hover:not(:disabled) .tt,
.map-studio-root .tool-btn:focus-visible .tt {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  transition-delay: 220ms;
}

.map-studio-root .tt::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 8px;
  height: 8px;
  background: #1a1d23;
  border-radius: 1px;
}

.map-studio-root .tt-title {
  font-size: 12.5px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.005em;
}

.map-studio-workspace {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
}

.map-studio-chrome {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.map-studio-canvas-wrap {
  position: relative;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  background: var(--ms-surface-2);
}

.map-studio-location-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  pointer-events: none;
  user-select: none;
  z-index: 0;
}

.map-studio-location-bg.is-drag-enabled {
  pointer-events: auto;
  cursor: grab;
}

.map-studio-location-bg.is-dragging {
  cursor: grabbing;
}

.map-studio-canvas-wrap.is-bg-drag-mode canvas {
  pointer-events: none;
}

.map-studio-canvas-wrap canvas {
  position: relative;
  z-index: 1;
  display: block;
  touch-action: none;
}

.map-studio-canvas-popup-backdrop {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.4);
  pointer-events: auto;
}

.map-studio-canvas-popup-inner {
  position: relative;
  max-width: min(420px, 100%);
  max-height: 100%;
  overflow: auto;
}

.map-studio-canvas-popup-close {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--ms-radius-btn);
  background: var(--ms-surface);
  color: var(--ms-ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--ms-shadow);
}

.map-studio-root.is-fullscreen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1400;
  background: var(--ms-bg);
  padding: 12px 16px;
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.map-studio-root.is-fullscreen .map-studio-alerts {
  flex-shrink: 0;
  max-height: 28vh;
  overflow-y: auto;
}

.map-studio-root.is-fullscreen .map-studio-workspace {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.map-studio-root.is-fullscreen .map-studio-main-row {
  flex: 1;
  min-height: 0;
}

.map-studio-root.is-visitor .map-studio-canvas-wrap {
  cursor: default;
}

body:has(.map-studio-root.is-fullscreen) {
  overflow: hidden;
}

/* Map Studio section chrome and floor overview */
.map-studio-main-toolbar {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.map-studio-publish-btn {
  min-width: max-content;
  height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid color-mix(in oklab, var(--ms-accent) 55%, var(--ms-line));
  border-radius: 4px;
  background: var(--ms-accent-soft);
  color: var(--ms-accent-ink);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.map-studio-publish-btn:disabled {
  opacity: 0.45;
  cursor: wait;
}

.map-studio-publish-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.map-studio-map-column {
  position: relative;
}

.map-studio-floor-overview {
  position: absolute;
  inset: 0;
  z-index: 20;
  overflow: auto;
  padding: 14px;
  background: var(--ms-bg);
  border: 1px solid var(--ms-line);
}

.map-studio-floor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 200px));
  align-content: start;
  gap: 12px;
}

.map-studio-floor-tile {
  position: relative;
  appearance: none;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--ms-line);
  border-radius: 4px;
  background: var(--ms-surface);
  color: var(--ms-ink-2);
  text-align: left;
  cursor: pointer;
}

.map-studio-floor-tile-open {
  appearance: none;
  flex: 1;
  min-height: 0;
  width: 100%;
  padding: 0;
  display: flex;
  flex-direction: column;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: inherit;
  cursor: pointer;
}

.map-studio-floor-order-actions {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 2;
  display: flex;
  gap: 3px;
}

.map-studio-floor-order-actions button {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--ms-line);
  border-radius: 3px;
  background: color-mix(in oklab, var(--ms-surface) 88%, transparent);
  color: var(--ms-ink);
  cursor: pointer;
}

.map-studio-floor-order-actions button:hover {
  border-color: var(--ms-accent);
  color: var(--ms-accent-ink);
}

.map-studio-floor-tile:hover,
.map-studio-floor-tile.is-active {
  border-color: var(--ms-accent);
  box-shadow: 0 0 0 1px var(--ms-accent);
}

.map-studio-floor-tile-image {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--ms-surface-2);
}

.map-studio-floor-tile-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.map-studio-floor-empty-plan {
  color: var(--ms-ink-3);
  font-size: 11px;
}

.map-studio-floor-tile-meta {
  flex: 0 0 auto;
  padding: 7px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border-top: 1px solid var(--ms-line);
}

.map-studio-floor-tile-meta strong {
  color: var(--ms-ink);
  font-size: 11px;
}

.map-studio-floor-tile-meta small {
  color: var(--ms-ink-3);
  font-size: 9px;
}

@media (max-width: 820px) {
  .map-studio-root.is-fullscreen {
    padding: 5px;
  }

  .map-studio-workspace {
    gap: 5px;
  }

  .map-studio-root .toolbar {
    padding: 3px;
    border-radius: 3px;
  }

  .map-studio-root .toolbar-section-btn {
    height: 44px;
    padding: 0 9px;
    flex: 0 0 auto;
  }

  .map-studio-root .toolbar-section-label {
    display: none;
  }

  .map-studio-root .toolbar-section-icon,
  .map-studio-root .toolbar-section-icon svg {
    width: 22px;
    height: 22px;
  }

  .map-studio-root .tool-btn {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
  }

  .map-studio-pathfinder-btn {
    width: 44px;
    height: 44px;
  }

  .map-studio-main-toolbar .toolbar-spacer {
    min-width: 0;
  }

  .map-studio-publish-btn {
    height: 40px;
  }

  .map-studio-floor-overview {
    padding: 8px;
  }

  .map-studio-floor-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 7px;
  }

  .map-studio-floor-order-actions button {
    width: 44px;
    height: 44px;
  }
}
