/* KlinikHarita — Clinical Cartography Design System (Map-First 100dvh PWA) */

:root {
  --kh-bg: #eef2f6;
  --kh-surface: rgba(255, 255, 255, 0.94);
  --kh-surface-solid: #ffffff;
  --kh-surface-muted: #f8fafc;
  --kh-border: rgba(15, 23, 42, 0.1);
  --kh-border-strong: rgba(15, 23, 42, 0.18);
  --kh-ink: #0f172a;
  --kh-ink-muted: #475569;
  --kh-ink-subtle: #64748b;
  --kh-teal: #0d9488;
  --kh-teal-dark: #0f766e;
  --kh-teal-soft: #ccfbf1;
  --kh-indigo: #4f46e5;
  --kh-emerald: #059669;
  --kh-amber: #d97706;
  --kh-crimson: #dc2626;
  --kh-cyan: #0891b2;
  --kh-shadow-sm: 0 2px 10px rgba(15, 23, 42, 0.08);
  --kh-shadow-md: 0 10px 28px rgba(15, 23, 42, 0.14);
  --kh-shadow-lg: 0 18px 48px rgba(15, 23, 42, 0.2);
  --kh-radius-pill: 999px;
  --kh-radius-md: 14px;
  --kh-radius-lg: 20px;
  --kh-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html,
body.kh-body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--kh-bg);
  color: var(--kh-ink);
  font-family: var(--kh-font);
  -webkit-font-smoothing: antialiased;
  touch-action: none;
  user-select: none;
}

.kh-app {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

/* --- Fullscreen SVG Map Stage --- */

.kh-canvas-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 45%, #f5f8fb 0%, #e5ecf4 100%);
  cursor: grab;
  touch-action: none;
}

.kh-canvas-stage:active {
  cursor: grabbing;
}

.kh-map-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Architectural Blueprint SVG Styles */
.bp-outer-footprint {
  fill: #e8eef5;
  stroke: #94a3b8;
  stroke-width: 2.4;
  filter: drop-shadow(0 10px 24px rgba(15, 23, 42, 0.08));
}

.bp-wing-hull {
  fill: #e8eef5;
  stroke: #94a3b8;
  stroke-width: 2.2;
}

.bp-wing-connector {
  fill: #eef3f8;
  stroke: #cbd5e1;
  stroke-width: 1.5;
}

.bp-hallway {
  fill: #ffffff;
  stroke: #dbe3ec;
  stroke-width: 1.1;
}

.bp-courtyard {
  fill: #e6f7ee;
  stroke: #86efac;
  stroke-width: 1.4;
  stroke-dasharray: 4 3;
}

.bp-arc-outer {
  fill: none;
  stroke: #94a3b8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bp-arc-inner {
  fill: none;
  stroke: #ffffff;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bp-arc-inner--building {
  stroke: #e8eef5;
}

.bp-arc-inner--courtyard {
  stroke: #e6f7ee;
}

.bp-wall {
  stroke: #475569;
  stroke-linecap: round;
}

.bp-tree {
  fill: #bbf7d0;
  stroke: #4ade80;
  stroke-width: 1.2;
  opacity: 0.78;
}

.bp-entrance-arrow {
  fill: none;
  stroke: #0d9488;
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bp-entrance-caption {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  fill: #0f766e;
}

.bp-courtyard-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.09em;
  fill: #047857;
  opacity: 0.75;
}

.bp-corridor-hint {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  fill: #94a3b8;
}

.bp-preparing-outline {
  fill: rgba(255, 255, 255, 0.72);
  stroke: #94a3b8;
  stroke-width: 2.5;
  stroke-dasharray: 10 8;
}

.bp-preparing-grid {
  stroke: #cbd5e1;
  stroke-width: 1.4;
  stroke-dasharray: 6 6;
}

/* Clickable Architectural Room Polygons (Apple Maps Indoor Style) */
.kh-room-group {
  cursor: pointer;
}

.kh-room-shape {
  stroke-width: 1.5;
  transition: fill 0.15s ease, stroke 0.15s ease, stroke-width 0.15s ease;
}

.kh-room-group:hover .kh-room-shape {
  stroke-width: 2.5;
  filter: brightness(0.96);
}

.kh-room-group.is-selected .kh-room-shape {
  fill: #0d9488 !important;
  stroke: #0f172a !important;
  stroke-width: 2.8 !important;
}

.kh-room-group.is-selected .kh-room-title,
.kh-room-group.is-selected .kh-room-sub {
  fill: #ffffff !important;
}

.kh-room-title {
  font-size: 9.5px;
  font-weight: 800;
  fill: #0f172a;
  pointer-events: none;
}

.kh-room-title--narrow {
  font-size: 8.2px;
}

.kh-room-title--compact {
  font-size: 7.4px;
}

.kh-room-sub {
  font-size: 7.5px;
  font-weight: 700;
  fill: #475569;
  pointer-events: none;
}

.kh-room-group.is-detail-tier .kh-room-sub {
  opacity: 0;
  transition: opacity 0.18s ease;
}

.kh-app.is-zoomed .kh-room-group.is-detail-tier .kh-room-sub {
  opacity: 1;
}

/* Animated Active Route Line */
.kh-route-halo {
  fill: none;
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 11;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.kh-route-line {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.kh-route-dash {
  fill: none;
  stroke: #ffffff;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-dasharray: 8 12;
  animation: kh-route-flow 0.95s linear infinite;
}

@keyframes kh-route-flow {
  from {
    stroke-dashoffset: 20;
  }
  to {
    stroke-dashoffset: 0;
  }
}

/* Interactive Node Pins */
.kh-node-group {
  cursor: pointer;
}

.kh-node-hit {
  fill: transparent;
}

.kh-node-ring {
  fill: #ffffff;
  stroke-width: 2.5;
  filter: url(#kh-pin-shadow);
  transition: transform 0.16s ease;
}

.kh-node-group:hover .kh-node-ring,
.kh-node-group.is-selected .kh-node-ring {
  stroke-width: 3.4;
}

.kh-node-group.is-selected .kh-node-halo {
  fill: rgba(13, 148, 136, 0.22);
  animation: kh-pulse 1.8s ease-out infinite;
}

.kh-node-label-bg {
  fill: rgba(255, 255, 255, 0.92);
  stroke: rgba(15, 23, 42, 0.1);
  stroke-width: 0.9;
}

.kh-node-label {
  font-size: 8.5px;
  font-weight: 700;
  fill: #0f172a;
  pointer-events: none;
}

.kh-node-room {
  font-size: 8px;
  font-weight: 600;
  fill: #475569;
  pointer-events: none;
}

.kh-node-wait-dot {
  stroke: #ffffff;
  stroke-width: 1.6;
}

/* Pulsing Start Radar & Destination Marker */
.kh-start-radar {
  fill: rgba(37, 99, 235, 0.24);
  animation: kh-pulse 2s ease-out infinite;
}

.kh-start-dot {
  fill: #2563eb;
  stroke: #ffffff;
  stroke-width: 3;
}

.kh-transfer-badge {
  cursor: pointer;
}

.kh-transfer-pill-bg {
  fill: #0f172a;
  stroke: #ffffff;
  stroke-width: 2;
  filter: url(#kh-pin-shadow);
}

.kh-transfer-pill-text {
  font-size: 10px;
  font-weight: 800;
  fill: #ffffff;
}

.kh-journey-badge-circle {
  fill: #0f172a;
  stroke: #ffffff;
  stroke-width: 2;
}

.kh-journey-badge-circle.is-done {
  fill: #059669;
}

.kh-journey-badge-num {
  font-size: 9.5px;
  font-weight: 800;
  fill: #ffffff;
}

@keyframes kh-pulse {
  0% {
    opacity: 0.9;
    r: 16;
  }
  100% {
    opacity: 0;
    r: 34;
  }
}

/* --- Preparing Floor Overlay --- */

.kh-preparing-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(238, 242, 246, 0.56);
  backdrop-filter: blur(4px);
  z-index: 12;
  pointer-events: auto;
}

.kh-preparing-overlay[hidden] {
  display: none;
}

.kh-preparing-card {
  width: 100%;
  max-width: 340px;
  background: var(--kh-surface-solid);
  border: 1px solid var(--kh-border);
  border-radius: var(--kh-radius-lg);
  box-shadow: var(--kh-shadow-lg);
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.kh-preparing-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--kh-radius-pill);
  background: #fef3c7;
  color: #92400e;
  font-size: 12px;
  font-weight: 700;
}

.kh-preparing-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.kh-preparing-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.kh-preparing-chip {
  padding: 5px 10px;
  border-radius: var(--kh-radius-pill);
  background: var(--kh-surface-muted);
  border: 1px solid var(--kh-border);
  font-size: 12px;
  font-weight: 600;
  color: var(--kh-ink-muted);
}

/* --- Floating Top Search Dock --- */

.kh-top-dock {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  max-width: 560px;
  margin: 0 auto;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.kh-route-dock-card {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--kh-surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--kh-border);
  border-radius: 20px;
  padding: 8px 10px 10px;
  box-shadow: var(--kh-shadow-md);
}

.kh-dock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kh-dock-tools {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kh-brand-pill {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 11px 0 6px;
  border: none;
  border-radius: var(--kh-radius-pill);
  background: #f0fdfa;
  color: var(--kh-teal-dark);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.kh-brand-pill:hover {
  background: var(--kh-teal-soft);
}

.kh-brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--kh-teal);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.kh-brand-name {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kh-route-inputs {
  display: flex;
  flex-direction: column;
  background: #f8fafc;
  border: 1px solid var(--kh-border);
  border-radius: 14px;
  padding: 2px 6px;
}

.kh-route-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.kh-field-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-left: 6px;
}

.kh-field-dot--start {
  background: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.kh-field-dot--end {
  background: var(--kh-teal);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.18);
}

.kh-route-divider {
  height: 1px;
  background: var(--kh-border);
  margin: 0 6px 0 24px;
}

.kh-route-input {
  width: 100%;
  min-height: 36px;
  border: none;
  background: transparent;
  padding: 6px 28px 6px 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--kh-ink);
  outline: none;
}

.kh-route-input::placeholder {
  color: var(--kh-ink-subtle);
  font-weight: 500;
}

.kh-field-clear {
  position: absolute;
  right: 2px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: #e2e8f0;
  color: var(--kh-ink);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.kh-icon-toggle {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--kh-border);
  background: var(--kh-surface-solid);
  color: var(--kh-ink-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.kh-icon-toggle[hidden] {
  display: none;
}

.kh-icon-toggle--install {
  color: var(--kh-teal-dark);
  border-color: rgba(13, 148, 136, 0.35);
  background: #f0fdfa;
}

.kh-icon-toggle:hover {
  border-color: var(--kh-teal);
  color: var(--kh-teal-dark);
}

.kh-icon-toggle[aria-pressed="true"] {
  background: var(--kh-teal);
  border-color: var(--kh-teal);
  color: #ffffff;
}

.kh-search-mode-label {
  padding: 6px 10px 4px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--kh-teal-dark);
}

/* Quick Filter Chips */
.kh-quick-chips {
  pointer-events: auto;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 2px 4px;
}

.kh-quick-chips::-webkit-scrollbar {
  display: none;
}

.kh-chip {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--kh-radius-pill);
  border: 1px solid var(--kh-border);
  background: var(--kh-surface);
  backdrop-filter: blur(10px);
  color: var(--kh-ink);
  font-size: 12.5px;
  font-weight: 700;
  box-shadow: var(--kh-shadow-sm);
  cursor: pointer;
  white-space: nowrap;
}

.kh-chip:hover {
  border-color: var(--kh-teal);
  color: var(--kh-teal-dark);
}

.kh-chip--emergency {
  background: #fef2f2;
  border-color: rgba(220, 38, 38, 0.25);
  color: #b91c1c;
}

/* Search Dropdown & Hospital Picker */
.kh-search-results,
.kh-hospital-picker {
  pointer-events: auto;
  background: var(--kh-surface-solid);
  border: 1px solid var(--kh-border);
  border-radius: var(--kh-radius-md);
  box-shadow: var(--kh-shadow-lg);
  max-height: min(52dvh, 360px);
  overflow-y: auto;
  padding: 6px;
}

.kh-search-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--kh-ink);
}

.kh-search-item:hover {
  background: #f1f5f9;
}

.kh-search-item-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kh-search-item-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--kh-ink);
}

.kh-search-item-meta {
  font-size: 11.5px;
  color: var(--kh-ink-subtle);
}

.kh-search-floor-tag {
  flex: 0 0 auto;
  padding: 4px 9px;
  border-radius: var(--kh-radius-pill);
  background: #f0fdfa;
  color: var(--kh-teal-dark);
  font-size: 11px;
  font-weight: 800;
}

.kh-search-floor-tag.is-preparing {
  background: #fef3c7;
  color: #92400e;
}

.kh-picker-header {
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--kh-ink-subtle);
}

.kh-picker-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--kh-ink);
}

.kh-picker-item.is-current {
  background: #f0fdfa;
  color: var(--kh-teal-dark);
}

.kh-picker-item span {
  font-size: 12px;
  color: var(--kh-ink-subtle);
}

/* --- Toast Pill & Shared Loading Spinners --- */

@keyframes kh-spin {
  to {
    transform: rotate(360deg);
  }
}

.kh-spinner {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(13, 148, 136, 0.2);
  border-top-color: var(--kh-teal);
  animation: kh-spin 0.72s linear infinite;
}

.kh-spinner--lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

.kh-loading-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 12px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--kh-ink-muted);
}

.kh-loading-row--inline {
  justify-content: flex-start;
  padding: 7px 10px;
  border-bottom: 1px solid var(--kh-border);
}

.kh-loading-pill {
  position: fixed;
  top: calc(max(12px, env(safe-area-inset-top)) + 166px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 55;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--kh-radius-pill);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--kh-border);
  color: var(--kh-ink);
  font-size: 12.5px;
  font-weight: 700;
  box-shadow: var(--kh-shadow-md);
  max-width: calc(100vw - 32px);
  white-space: nowrap;
  pointer-events: none;
}

.kh-loading-pill[hidden] {
  display: none;
}

.kh-toast {
  position: fixed;
  top: calc(max(12px, env(safe-area-inset-top)) + 166px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  padding: 8px 14px;
  border-radius: var(--kh-radius-pill);
  background: #0f172a;
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 700;
  box-shadow: var(--kh-shadow-md);
  max-width: calc(100vw - 32px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Right-Edge Vertical Floor Rail & Zoom Controls --- */

.kh-right-rail {
  position: fixed;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.kh-floor-rail {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 5px;
  border-radius: 18px;
  background: var(--kh-surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--kh-border);
  box-shadow: var(--kh-shadow-md);
}

.kh-floor-btn {
  position: relative;
  width: 48px;
  min-height: 44px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--kh-ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.kh-floor-btn:hover {
  background: #f1f5f9;
}

.kh-floor-btn.is-active {
  background: var(--kh-teal);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(13, 148, 136, 0.35);
}

.kh-floor-btn.is-preparing {
  opacity: 0.68;
  border: 1px dashed #94a3b8;
}

.kh-floor-btn.is-preparing.is-active {
  opacity: 1;
  background: #475569;
  border-style: solid;
  border-color: #475569;
  color: #ffffff;
}

.kh-floor-short {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.1;
}

.kh-floor-name {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.1;
  white-space: nowrap;
  opacity: 0.85;
}

.kh-floor-route-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 2px #ffffff;
}

.kh-zoom-stack {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 14px;
  background: var(--kh-surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--kh-border);
  box-shadow: var(--kh-shadow-md);
}

.kh-zoom-btn {
  width: 44px;
  height: 40px;
  border: none;
  border-bottom: 1px solid var(--kh-border);
  background: transparent;
  color: var(--kh-ink);
  font-size: 18px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.kh-zoom-btn:last-child {
  border-bottom: none;
}

.kh-zoom-btn:hover {
  background: #f1f5f9;
}

/* --- Destination Marker & Route Step List --- */

.kh-target-halo {
  fill: rgba(13, 148, 136, 0.24);
}

.kh-target-dot {
  fill: var(--kh-teal);
  stroke: #ffffff;
  stroke-width: 2.5;
}

.kh-mini-link {
  border: none;
  background: #f1f5f9;
  color: var(--kh-ink);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.kh-mini-link:hover {
  background: #e2e8f0;
}

.kh-route-top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.kh-route-all-steps {
  margin: 2px 0 0;
  padding: 8px 0 0;
  border-top: 1px solid var(--kh-border);
  list-style: none;
  max-height: min(34dvh, 240px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kh-route-all-steps[hidden] {
  display: none;
}

.kh-all-step-btn {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 8px;
  border: none;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--kh-ink);
}

.kh-all-step-btn:hover {
  background: #f8fafc;
}

.kh-all-step-item.is-current .kh-all-step-btn {
  background: #f0fdfa;
}

.kh-all-step-num {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e2e8f0;
  color: var(--kh-ink);
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.kh-all-step-item.is-current .kh-all-step-num {
  background: var(--kh-teal);
  color: #ffffff;
}

.kh-all-step-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
}

.kh-all-step-floor {
  font-size: 10.5px;
  font-weight: 800;
  color: var(--kh-teal-dark);
}

/* --- Minimal Swipeable Route Step-Pill --- */

.kh-route-pill {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(14px, env(safe-area-inset-bottom));
  max-width: 480px;
  margin: 0 auto;
  z-index: 28;
  background: var(--kh-surface-solid);
  border: 1px solid var(--kh-border);
  border-radius: var(--kh-radius-lg);
  box-shadow: var(--kh-shadow-lg);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kh-route-pill[hidden] {
  display: none;
}

.kh-route-pill-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kh-route-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.kh-route-eta {
  font-size: 14px;
  font-weight: 800;
  color: var(--kh-teal-dark);
}

.kh-route-dist {
  font-size: 12px;
  font-weight: 700;
  color: var(--kh-ink-subtle);
}

.kh-route-line-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: var(--kh-radius-pill);
  font-size: 11px;
  font-weight: 800;
  color: #ffffff;
}

.kh-route-step-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.kh-step-nav {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--kh-border);
  background: var(--kh-surface-muted);
  color: var(--kh-ink);
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
}

.kh-route-step-body {
  flex: 1 1 auto;
  min-width: 0;
}

.kh-route-step-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--kh-ink-subtle);
  margin-bottom: 2px;
}

.kh-route-step-floor {
  padding: 1px 7px;
  border-radius: var(--kh-radius-pill);
  background: #f0fdfa;
  color: var(--kh-teal-dark);
}

.kh-route-instruction {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--kh-ink);
}

/* --- Compact Node Detail Bottom-Sheet --- */

.kh-sheet {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  max-width: 480px;
  margin: 0 auto;
  z-index: 32;
  background: var(--kh-surface-solid);
  border: 1px solid var(--kh-border);
  border-radius: 22px;
  box-shadow: var(--kh-shadow-lg);
  padding: 10px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kh-sheet[hidden] {
  display: none;
}

.kh-sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 4px;
  background: #cbd5e1;
  margin: 0 auto 2px;
}

.kh-sheet-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.kh-sheet-icon {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 18px;
  font-weight: 800;
}

.kh-sheet-titles {
  flex: 1 1 auto;
  min-width: 0;
}

.kh-sheet-title {
  margin: 0 0 4px;
  font-size: 15.5px;
  font-weight: 800;
  line-height: 1.25;
}

.kh-sheet-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.kh-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--kh-radius-pill);
  background: #f1f5f9;
  color: var(--kh-ink-muted);
  font-size: 11px;
  font-weight: 700;
}

.kh-badge--teal {
  background: #f0fdfa;
  color: var(--kh-teal-dark);
}

.kh-sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 8px;
}

.kh-btn {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.kh-btn--sm {
  min-height: 36px;
  padding: 0 14px;
}

.kh-btn--full {
  width: 100%;
}

.kh-btn--primary {
  background: var(--kh-teal);
  color: #ffffff;
}

.kh-btn--primary:hover {
  background: var(--kh-teal-dark);
}

.kh-btn--accent {
  background: #0f172a;
  color: #ffffff;
}

.kh-btn--soft {
  background: #f1f5f9;
  color: var(--kh-ink);
}

.kh-btn--outline {
  background: #ffffff;
  border-color: var(--kh-border-strong);
  color: var(--kh-ink);
}

.kh-btn--outline.is-pinned {
  background: #0f172a;
  border-color: #0f172a;
  color: #ffffff;
}

.kh-sheet-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 2px;
}

.kh-sheet-foot-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.kh-qr-link-btn {
  border: none;
  background: transparent;
  padding: 4px 0;
  color: var(--kh-teal-dark);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.kh-qr-link-btn--pill {
  padding: 4px 10px;
  border-radius: var(--kh-radius-pill);
  background: #f0fdfa;
  border: 1px solid rgba(13, 148, 136, 0.28);
}

.kh-qr-link-btn--pill:hover {
  background: var(--kh-teal-soft);
}

/* --- Accessible Share & QR Code Modal --- */

.kh-share-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.kh-share-modal[hidden] {
  display: none;
}

.kh-share-card {
  width: min(380px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--kh-surface-solid);
  border: 1px solid var(--kh-border);
  border-radius: 22px;
  box-shadow: var(--kh-shadow-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kh-share-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kh-share-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--kh-ink);
}

.kh-share-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 3px;
  border-radius: 14px;
  background: #f1f5f9;
  border: 1px solid var(--kh-border);
}

.kh-share-tab {
  flex: 1 1 auto;
  min-height: 32px;
  padding: 0 8px;
  border: none;
  border-radius: var(--kh-radius-pill);
  background: transparent;
  color: var(--kh-ink-muted);
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.kh-share-tab[hidden] {
  display: none;
}

.kh-share-tab.is-active {
  background: var(--kh-ink);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
}

.kh-share-qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 12px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid var(--kh-border);
  text-align: center;
}

.kh-share-qr-frame {
  position: relative;
  width: 216px;
  height: 216px;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--kh-border);
  box-shadow: var(--kh-shadow-sm);
}

.kh-qr-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--kh-ink-muted);
  font-size: 12px;
  font-weight: 700;
  z-index: 2;
}

.kh-qr-loading[hidden] {
  display: none;
}

.kh-share-qr-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: opacity 0.18s ease;
}

.kh-share-qr-img.is-loading {
  opacity: 0;
}

.kh-share-caption {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--kh-ink);
  line-height: 1.3;
}

.kh-share-url {
  display: block;
  width: 100%;
  padding: 6px 10px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid var(--kh-border);
  color: var(--kh-ink-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: text;
}

.kh-share-qr-box[hidden],
.kh-share-actions[hidden],
.kh-qr-scanner-box[hidden] {
  display: none;
}

.kh-qr-scanner-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid var(--kh-border);
  text-align: center;
}

.kh-qr-video-frame {
  position: relative;
  width: min(240px, 100%);
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  overflow: hidden;
  background: #0f172a;
  border: 2px solid var(--kh-teal);
  box-shadow: var(--kh-shadow-sm);
}

.kh-qr-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.kh-qr-reticle {
  position: absolute;
  inset: 22px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 14px;
  box-shadow: 0 0 0 999px rgba(15, 23, 42, 0.25);
  pointer-events: none;
  overflow: hidden;
}

.kh-qr-reticle-beam {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 8px;
  height: 2.5px;
  border-radius: 999px;
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
  animation: kh-qr-reticle-sweep 2.2s ease-in-out infinite;
}

@keyframes kh-qr-reticle-sweep {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(165px);
  }
}

.kh-qr-scan-status {
  margin: 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--kh-ink-muted);
  line-height: 1.35;
}

.kh-qr-scanner-actions {
  width: 100%;
  display: flex;
  gap: 8px;
}

.kh-qr-scanner-actions > * {
  flex: 1 1 0;
  min-height: 40px;
}

.kh-qr-file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .kh-qr-reticle-beam {
    animation: none;
  }
}

.kh-share-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.kh-share-actions .kh-btn {
  min-height: 40px;
  padding: 0 8px;
  font-size: 12px;
  text-decoration: none;
}

.kh-node-code-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--kh-ink-subtle);
}

.kh-close-x {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: none;
  border-radius: 50%;
  background: #f1f5f9;
  color: var(--kh-ink);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* --- 2D / 3D Segmented Toggle --- */

.kh-view-switch {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border-radius: var(--kh-radius-pill);
  background: #eef2f6;
  border: 1px solid var(--kh-border);
}

.kh-view-btn {
  min-width: 38px;
  height: 28px;
  padding: 0 10px;
  border: none;
  border-radius: var(--kh-radius-pill);
  background: transparent;
  color: var(--kh-ink-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.kh-view-btn.is-active {
  background: var(--kh-ink);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.22);
}

/* --- Interactive Stacked 3D Multi-Floor Building Stage --- */

.kh-3d-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  isolation: isolate;
  contain: layout paint;
  overflow: hidden;
  background: radial-gradient(circle at 50% 42%, #f0f7fa 0%, #dce6f2 62%, #cfdbe9 100%);
  cursor: grab;
  touch-action: none;
}

.kh-3d-stage[hidden] {
  display: none;
}

.kh-3d-stage:active {
  cursor: grabbing;
}

.kh-3d-camera {
  position: absolute;
  inset: 0;
  perspective: 1850px;
  perspective-origin: 50% 50%;
  overflow: hidden;
}

.kh-3d-world {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1200px;
  height: 860px;
  margin-left: -600px;
  margin-top: -430px;
  transform-style: preserve-3d;
}

.kh-3d-floors,
.kh-3d-routes,
.kh-3d-shafts {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.kh-3d-routes,
.kh-3d-shafts {
  pointer-events: none;
}

.kh-3d-floor {
  position: absolute;
  inset: 0;
  width: 1200px;
  height: 860px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.1);
  border: 1.5px solid rgba(100, 116, 139, 0.34);
  box-shadow: 0 3px 0 rgba(148, 163, 184, 0.32);
  transform-style: preserve-3d;
  backface-visibility: visible;
  transition: transform 300ms cubic-bezier(0.22, 1, 0.36, 1), opacity 220ms ease, border-color 200ms ease, box-shadow 200ms ease;
}

.kh-3d-floor.is-focused {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(13, 148, 136, 0.78);
  box-shadow: 0 4px 0 rgba(13, 148, 136, 0.52);
}

.kh-3d-floor.is-route-floor {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(37, 99, 235, 0.82);
  box-shadow: 0 4px 0 rgba(37, 99, 235, 0.5);
}

.kh-3d-floor.is-passthrough {
  opacity: 0.4;
}

.kh-3d-floor.is-passthrough:hover {
  opacity: 0.68;
}

.kh-3d-floor.is-dimmed {
  opacity: 0.2;
}

.kh-3d-floor.is-dimmed:hover {
  opacity: 0.58;
}

.kh-3d-floor-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: hidden;
}

/* Transparent Glass Architectural Building & Flicker-Free 3D Rendering */

.kh-3d-floor .bp-outer-footprint,
.kh-3d-floor .bp-wing-hull,
.kh-3d-floor .bp-wing-connector {
  fill: rgba(226, 236, 248, 0.2);
  stroke: rgba(71, 85, 105, 0.64);
  stroke-width: 2.2;
  filter: none;
}

.kh-3d-floor .bp-hallway {
  fill: rgba(255, 255, 255, 0.26);
  stroke: rgba(148, 163, 184, 0.36);
}

.kh-3d-floor .kh-3d-route,
.kh-3d-floor .kh-3d-markers {
  display: none;
}

/* Hardware-Accelerated 3D Route Ribbons & Elevated Pins (Immune to Chromium 3D SVG Slicing) */
.kh-3d-route-seg {
  position: absolute;
  left: 0;
  top: 0;
  height: 10px;
  border-radius: 5px;
  border: 2px solid rgba(255, 255, 255, 0.94);
  box-shadow: 0 0 8px rgba(15, 23, 42, 0.24);
  transform-origin: 0 50%;
  backface-visibility: visible;
  pointer-events: none;
}

.kh-3d-route-joint {
  position: absolute;
  left: 0;
  top: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.94);
  backface-visibility: visible;
  pointer-events: none;
}

.kh-3d-pin {
  position: absolute;
  left: 0;
  top: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  backface-visibility: visible;
  pointer-events: none;
}

.kh-3d-pin--start {
  background: #2563eb;
  box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.28), 0 4px 10px rgba(15, 23, 42, 0.28);
}

.kh-3d-pin--target {
  background: var(--kh-teal);
  box-shadow: 0 0 0 6px rgba(13, 148, 136, 0.28), 0 4px 10px rgba(15, 23, 42, 0.28);
}

.kh-3d-floor .bp-courtyard {
  fill: rgba(187, 247, 208, 0.24);
  stroke: rgba(34, 197, 94, 0.52);
}

.kh-3d-floor .bp-tree {
  opacity: 0.48;
}

.kh-3d-floor .kh-room-shape {
  fill-opacity: 0.46;
  stroke-opacity: 0.88;
}

.kh-3d-floor .kh-room-group:hover .kh-room-shape {
  fill-opacity: 0.72;
  filter: none;
}

.kh-3d-floor .kh-room-group.is-selected .kh-room-shape {
  fill-opacity: 0.9;
}

.kh-3d-floor .kh-node-ring,
.kh-3d-floor .kh-transfer-pill-bg {
  filter: none;
}

/* Disable continuous SVG keyframe repaints inside 3D slabs to prevent GPU flicker */
.kh-3d-floor .kh-route-halo {
  stroke: rgba(255, 255, 255, 0.9);
  stroke-width: 12;
}

.kh-3d-floor .kh-route-line {
  stroke-width: 7;
}

.kh-3d-floor .kh-route-dash {
  animation: none;
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 2.5;
  stroke-dasharray: 8 10;
}

.kh-3d-floor .kh-start-radar,
.kh-3d-floor .kh-node-group.is-selected .kh-node-halo {
  animation: none;
}

.kh-3d-floor-tag {
  position: absolute;
  left: -14px;
  top: 50%;
  transform: translate(-100%, -50%) translateZ(4px);
  padding: 10px 18px;
  border-radius: 14px;
  border: 2px solid #cbd5e1;
  background: rgba(255, 255, 255, 0.92);
  color: var(--kh-ink);
  font-size: 20px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.14);
  cursor: pointer;
}

.kh-3d-floor.is-focused .kh-3d-floor-tag {
  background: var(--kh-teal);
  border-color: var(--kh-teal-dark);
  color: #ffffff;
}

.kh-3d-floor.is-route-floor:not(.is-focused) .kh-3d-floor-tag {
  background: #eff6ff;
  border-color: #2563eb;
  color: #1d4ed8;
}

/* Solid, Flicker-Free 3D Vertical Elevator / Stair Route Shafts */

.kh-3d-shaft {
  position: absolute;
  width: 14px;
  transform-origin: 50% 0%;
  transform-style: preserve-3d;
}

.kh-3d-shaft-plane {
  position: absolute;
  left: 0;
  top: 0;
  width: 14px;
  height: 100%;
  border-radius: 7px;
  transform-origin: 50% 0%;
  background: linear-gradient(
    to bottom,
    rgba(37, 99, 235, 0.92) 0%,
    rgba(59, 130, 246, 0.85) 50%,
    rgba(37, 99, 235, 0.92) 100%
  );
  border-left: 2px solid rgba(255, 255, 255, 0.72);
  border-right: 2px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 0 14px rgba(37, 99, 235, 0.55);
  backface-visibility: visible;
}

.kh-3d-shaft.is-stairs .kh-3d-shaft-plane {
  background: linear-gradient(
    to bottom,
    rgba(217, 119, 6, 0.92) 0%,
    rgba(245, 158, 11, 0.85) 50%,
    rgba(217, 119, 6, 0.92) 100%
  );
  box-shadow: 0 0 14px rgba(217, 119, 6, 0.55);
}

.kh-3d-shaft-plane--a {
  transform: rotateX(90deg);
}

.kh-3d-shaft-plane--b {
  transform: rotateZ(90deg) rotateX(90deg);
}

.kh-3d-shaft-ring {
  position: absolute;
  left: 50%;
  top: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3.5px solid #2563eb;
  background: rgba(37, 99, 235, 0.18);
}

.kh-3d-shaft.is-stairs .kh-3d-shaft-ring {
  border-color: #d97706;
  background: rgba(217, 119, 6, 0.18);
}

.kh-3d-shaft-badge {
  position: absolute;
  left: 50%;
  top: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.94);
  color: #ffffff;
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.3);
}

/* Floating 3D Camera Controls Pill */

.kh-3d-controls {
  position: fixed;
  left: 12px;
  top: calc(max(12px, env(safe-area-inset-top)) + 154px);
  z-index: 26;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 5px;
  border-radius: var(--kh-radius-pill);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--kh-border);
  box-shadow: var(--kh-shadow-md);
  transform: translate3d(0, 0, 0);
}

.kh-3d-controls[hidden] {
  display: none;
}

/* In 3D view, replace quick-chips row with the 3D camera controls bar so mobile/portrait never overlaps */
.kh-app.is-3d .kh-quick-chips {
  display: none;
}

/* Prevent Android/Tablet Chromium backdrop-filter + preserve-3d white-box compositor bug */
.kh-app.is-3d .kh-top-dock,
.kh-app.is-3d .kh-right-rail,
.kh-app.is-3d .kh-route-pill,
.kh-app.is-3d .kh-sheet,
.kh-app.is-3d .kh-share-modal,
.kh-app.is-3d .kh-guide-layer,
.kh-app.is-3d .kh-loading-pill,
.kh-app.is-3d .kh-toast {
  transform: translate3d(0, 0, 0);
}

.kh-app.is-3d .kh-share-modal {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.kh-app.is-3d .kh-right-rail {
  transform: translate3d(0, -50%, 0);
}

.kh-app.is-3d .kh-loading-pill,
.kh-app.is-3d .kh-toast {
  top: calc(max(12px, env(safe-area-inset-top)) + 204px);
  transform: translate3d(-50%, 0, 0);
}

.kh-app.is-3d .kh-route-dock-card,
.kh-app.is-3d .kh-chip,
.kh-app.is-3d .kh-floor-rail,
.kh-app.is-3d .kh-zoom-stack {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: rgba(255, 255, 255, 0.97);
}

.kh-app.is-3d .kh-chip--emergency {
  background: #fef2f2;
}

@media (min-width: 1024px) {
  .kh-3d-controls {
    top: auto;
    bottom: 20px;
    left: 20px;
    padding: 5px;
    gap: 5px;
  }
}

.kh-3d-ctrl-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 9px;
  border: none;
  border-radius: var(--kh-radius-pill);
  background: transparent;
  color: var(--kh-ink);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.kh-3d-ctrl-btn:hover {
  background: #f1f5f9;
}

.kh-3d-ctrl-btn--text {
  font-size: 11.5px;
  padding: 0 10px;
}

.kh-3d-ctrl-btn[aria-pressed="true"] {
  background: var(--kh-teal);
  color: #ffffff;
}

/* --- Third-Person 3D AR Corridor Walkthrough Stage --- */

.kh-ar-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  overflow: hidden;
  background: #e5edf5;
}

.kh-ar-stage[hidden] {
  display: none;
}

.kh-ar-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: ew-resize;
  touch-action: none;
}

.kh-ar-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(241, 245, 249, 0.72);
  z-index: 4;
}

.kh-ar-empty[hidden] {
  display: none;
}

.kh-ar-empty-text {
  margin: 0;
  font-size: 13px;
  color: var(--kh-ink-muted);
  line-height: 1.45;
}

.kh-ar-empty-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kh-mini-link--ar {
  background: #0d9488;
  color: #ffffff;
}

.kh-mini-link--ar:hover {
  background: #0f766e;
}

.kh-ar-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid var(--kh-border);
}

.kh-ar-bar[hidden] {
  display: none;
}

.kh-ar-btn {
  flex: 0 0 auto;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--kh-border);
  background: #ffffff;
  color: var(--kh-ink);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.kh-ar-btn--play {
  background: var(--kh-teal);
  border-color: var(--kh-teal);
  color: #ffffff;
}

.kh-ar-btn--speed {
  font-size: 11.5px;
  min-width: 36px;
}

.kh-ar-scrubber {
  flex: 1 1 auto;
  min-width: 0;
  accent-color: var(--kh-teal);
  cursor: pointer;
}

.kh-app.is-ar .kh-zoom-stack,
.kh-app.is-ar .kh-route-transfer-bar {
  display: none;
}

/* Desktop & Tablet Right Rail Width (prevents floor badge label clipping) */
@media (min-width: 768px) {
  .kh-floor-btn {
    width: 54px;
  }
}

/* Tablet & Desktop Landscape: Side-Docked Left Column (Maximizes Live Map Viewport; Portrait Stays Unchanged) */
@media (min-width: 768px) and (orientation: landscape) {
  :root {
    --kh-dock-w: clamp(300px, 31vw, 355px);
  }

  .kh-top-dock {
    top: max(12px, env(safe-area-inset-top));
    left: 12px;
    right: auto;
    margin: 0;
    width: var(--kh-dock-w);
    max-width: none;
    gap: 5px;
  }

  .kh-route-dock-card {
    padding: 6px 8px;
    gap: 4px;
    border-radius: 16px;
  }

  .kh-dock-header {
    gap: 6px;
  }

  .kh-dock-tools {
    flex: 0 0 auto;
    gap: 3px;
  }

  .kh-brand-pill {
    min-height: 30px;
    padding: 0 8px 0 4px;
    overflow: hidden;
  }

  .kh-brand-name {
    max-width: 82px;
  }

  .kh-view-btn {
    min-width: 28px;
    height: 24px;
    padding: 0 6px;
    font-size: 11px;
  }

  .kh-icon-toggle {
    width: 26px;
    height: 26px;
  }

  .kh-route-inputs {
    flex-direction: column;
    align-items: stretch;
    padding: 1px 6px;
    border-radius: 12px;
  }

  .kh-route-field {
    flex: none;
    width: 100%;
    gap: 6px;
  }

  .kh-field-dot {
    margin-left: 5px;
  }

  .kh-route-divider {
    width: auto;
    height: 1px;
    margin: 0 6px 0 22px;
  }

  .kh-route-input {
    min-height: 30px;
    padding: 4px 24px 4px 0;
    font-size: 13px;
  }

  .kh-field-clear {
    width: 20px;
    height: 20px;
    font-size: 13px;
  }

  .kh-quick-chips {
    flex-wrap: wrap;
    overflow-x: visible;
    padding: 0 2px;
    gap: 5px;
  }

  .kh-chip {
    min-height: 24px;
    padding: 0 9px;
    font-size: 11px;
  }

  .kh-app.has-route .kh-quick-chips,
  .kh-app.is-ar .kh-quick-chips {
    display: none;
  }

  .kh-search-results,
  .kh-hospital-picker {
    max-height: min(48dvh, 320px);
  }

  .kh-route-pill {
    left: 12px;
    right: auto;
    bottom: max(12px, env(safe-area-inset-bottom));
    margin: 0;
    width: var(--kh-dock-w);
    max-width: none;
    padding: 10px 12px;
    gap: 6px;
  }

  .kh-route-pill-top {
    flex-wrap: wrap;
    gap: 6px;
  }

  .kh-mini-link {
    padding: 4px 8px;
    font-size: 11px;
  }

  .kh-sheet {
    left: 12px;
    right: auto;
    bottom: max(12px, env(safe-area-inset-bottom));
    margin: 0;
    width: var(--kh-dock-w);
    max-width: none;
    padding: 10px 12px 12px;
  }

  .kh-loading-pill,
  .kh-app.is-3d .kh-loading-pill,
  .kh-toast,
  .kh-app.is-3d .kh-toast {
    top: max(12px, env(safe-area-inset-top));
    left: calc(50% + var(--kh-dock-w) / 2);
  }

  .kh-3d-controls {
    top: auto;
    bottom: max(14px, env(safe-area-inset-bottom));
    left: calc(var(--kh-dock-w) + 24px);
    padding: 5px;
    gap: 5px;
  }
}

/* Wide PC Desktop Landscape: Comfortable Dock Width & Crisp Controls */
@media (min-width: 1200px) and (orientation: landscape) {
  :root {
    --kh-dock-w: clamp(458px, 31vw, 476px);
  }

  .kh-route-dock-card {
    padding: 8px 10px;
    gap: 6px;
  }

  .kh-dock-tools {
    gap: 4px;
  }

  .kh-brand-pill {
    min-height: 32px;
    padding: 0 9px 0 5px;
  }

  .kh-brand-name {
    max-width: 185px;
  }

  .kh-view-btn {
    min-width: 32px;
    height: 26px;
    padding: 0 8px;
    font-size: 11.5px;
  }

  .kh-icon-toggle {
    width: 30px;
    height: 30px;
  }

  .kh-route-input {
    min-height: 32px;
    font-size: 13.5px;
  }

  .kh-chip {
    min-height: 26px;
    padding: 0 10px;
    font-size: 11.5px;
  }
}

/* Mobile & Compact Viewport Fit */
@media (max-width: 640px) {
  .kh-dock-header {
    gap: 5px;
  }

  .kh-dock-tools {
    gap: 3px;
  }

  .kh-brand-pill {
    padding: 0 7px 0 4px;
  }

  .kh-brand-name {
    max-width: 68px;
  }

  .kh-view-btn {
    min-width: 28px;
    padding: 0 5px;
    font-size: 11px;
  }

  .kh-icon-toggle {
    width: 28px;
    height: 28px;
  }

  .kh-right-rail {
    top: 58%;
  }

  .kh-floor-btn {
    width: 44px;
    min-height: 36px;
  }

  .kh-zoom-btn {
    width: 42px;
    height: 36px;
  }

  .kh-sheet-actions {
    grid-template-columns: 1fr 1fr;
  }
}

/* --- Interactive 3-Step Spoken Visitor Guide (Selin) --- */

.kh-icon-toggle--guide {
  color: var(--kh-teal-dark);
  border-color: rgba(13, 148, 136, 0.35);
  background: #f0fdfa;
}

@keyframes kh-guide-btn-pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(13, 148, 136, 0.65), 0 0 12px rgba(20, 184, 166, 0.45);
  }
  50% {
    transform: scale(1.09);
    box-shadow: 0 0 0 6px rgba(13, 148, 136, 0), 0 0 18px rgba(245, 158, 11, 0.6);
  }
}

.kh-icon-toggle--guide.is-first-visit-highlight {
  background: var(--kh-teal-dark);
  border-color: var(--kh-teal);
  color: #ffffff;
  animation: kh-guide-btn-pulse 1.6s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .kh-icon-toggle--guide.is-first-visit-highlight {
    animation: none;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.4);
  }
}

@keyframes kh-guide-pulse-glow {
  0%, 100% {
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.88), 0 0 20px rgba(20, 184, 166, 0.5);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(225, 29, 72, 0.9), 0 0 26px rgba(244, 63, 94, 0.62);
  }
}

.kh-guide-spotlight-active {
  position: relative;
  z-index: 45 !important;
  border-radius: 12px;
  animation: kh-guide-pulse-glow 1.35s infinite ease-in-out !important;
}

.kh-guide-layer {
  position: fixed;
  inset: 0;
  z-index: 48;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 12px 12px max(12px, env(safe-area-inset-bottom));
}

.kh-guide-layer[hidden] {
  display: none;
}

.kh-guide-card {
  pointer-events: auto;
  width: 100%;
  max-width: 410px;
  background: rgba(255, 255, 255, 0.98);
  border: 2px solid var(--kh-teal-dark);
  border-radius: 18px;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.22);
  padding: 12px 14px;
}

.kh-guide-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.kh-guide-avatar {
  position: relative;
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kh-guide-svg {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  position: relative;
  z-index: 2;
}

.kh-guide-ring-pulse {
  position: absolute;
  inset: -3px;
  border-radius: 999px;
  border: 2px solid rgba(13, 148, 136, 0.4);
  opacity: 0;
  z-index: 1;
}

.kh-guide-avatar.is-speaking .kh-guide-ring-pulse {
  opacity: 1;
  border-color: #10b981;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.55);
  animation: kh-guide-ring-pulse 1.1s infinite ease-in-out;
}

.kh-guide-mouth {
  transform-origin: 40px 43px;
  transition: transform 0.12s ease;
}

.kh-guide-avatar.is-speaking .kh-guide-mouth {
  animation: kh-guide-mouth-talk 0.26s infinite alternate ease-in-out;
}

.kh-guide-wave-bars {
  position: absolute;
  bottom: -2px;
  right: -2px;
  z-index: 3;
  background: #064e3b;
  border: 1px solid #34d399;
  border-radius: 999px;
  padding: 2px 5px;
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
}

.kh-guide-avatar.is-speaking .kh-guide-wave-bars {
  display: inline-flex;
}

.kh-guide-wave-bars span {
  width: 2px;
  height: 4px;
  background: #6ee7b7;
  border-radius: 1px;
  animation: kh-guide-wave-bar 0.45s infinite alternate ease-in-out;
}

.kh-guide-wave-bars span:nth-child(2) { animation-delay: 0.12s; }
.kh-guide-wave-bars span:nth-child(3) { animation-delay: 0.24s; }
.kh-guide-wave-bars span:nth-child(4) { animation-delay: 0.08s; }

@keyframes kh-guide-mouth-talk {
  0% { transform: scaleY(0.75) scaleX(0.95); }
  50% { transform: scaleY(2.15) scaleX(1.08); }
  100% { transform: scaleY(1.2) scaleX(0.9); }
}

@keyframes kh-guide-ring-pulse {
  0% { transform: scale(0.98); opacity: 0.85; }
  50% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(0.98); opacity: 0.85; }
}

@keyframes kh-guide-wave-bar {
  0% { height: 3px; }
  100% { height: 9px; }
}

.kh-guide-meta {
  flex: 1 1 auto;
  min-width: 0;
}

.kh-guide-badge-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.kh-guide-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--kh-radius-pill);
  background: #ccfbf1;
  color: var(--kh-teal-dark);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.kh-guide-pointer {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--kh-radius-pill);
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
  font-size: 10.5px;
  font-weight: 700;
}

.kh-guide-pointer[hidden] {
  display: none;
}

.kh-guide-title {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 800;
  color: var(--kh-ink);
  line-height: 1.28;
}

.kh-guide-body {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--kh-ink-muted);
  line-height: 1.6;
  max-height: 98px;
  overflow-y: auto;
  scrollbar-width: none;
}

.kh-guide-body::-webkit-scrollbar {
  display: none;
}

.kh-speech-segment {
  display: inline;
  padding: 1px 4px;
  border-radius: 5px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.kh-speech-segment.is-active {
  background-color: rgba(245, 158, 11, 0.26);
  color: #0f172a;
  font-weight: 700;
}

.kh-speech-segment.is-spoken {
  opacity: 0.86;
}

.kh-guide-qr-demo {
  margin-top: 8px;
  padding: 6px 8px;
  border-radius: 12px;
  background: linear-gradient(135deg, #f0fdfa 0%, #eff6ff 100%);
  border: 1px solid rgba(13, 148, 136, 0.24);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.kh-guide-qr-demo[hidden] {
  display: none;
}

.kh-guide-qr-svg {
  width: 100%;
  height: 84px;
  display: block;
}

.kh-guide-qr-caption {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--kh-teal-dark);
  text-align: center;
  line-height: 1.25;
}

.kh-qr-scan-beam {
  animation: kh-qr-beam-sweep 3.4s ease-in-out infinite;
}

.kh-qr-phone-group {
  transform-box: fill-box;
  transform-origin: center;
  animation: kh-qr-phone-hover 3.4s ease-in-out infinite;
}

.kh-qr-scan-cone {
  animation: kh-qr-cone-pulse 3.4s ease-in-out infinite;
}

.kh-qr-phone-check,
.kh-qr-result-badge {
  transform-box: fill-box;
  transform-origin: center;
  animation: kh-qr-lock-pop 3.4s ease-in-out infinite;
}

.kh-qr-pin-radar {
  transform-box: fill-box;
  transform-origin: center;
  animation: kh-qr-radar-pulse 2s ease-out infinite;
}

@keyframes kh-qr-beam-sweep {
  0%, 10% {
    transform: translateY(0);
    opacity: 0.95;
  }
  45% {
    transform: translateY(34px);
    opacity: 1;
  }
  75%, 100% {
    transform: translateY(14px);
    opacity: 0.45;
  }
}

@keyframes kh-qr-phone-hover {
  0%, 100% {
    transform: translate(0, 0) rotate(0deg);
  }
  35% {
    transform: translate(-5px, -1px) rotate(-3deg);
  }
  65% {
    transform: translate(-3px, 1px) rotate(-1.5deg);
  }
}

@keyframes kh-qr-cone-pulse {
  0%, 100% {
    opacity: 0.14;
  }
  40% {
    opacity: 0.34;
  }
}

@keyframes kh-qr-lock-pop {
  0%, 42% {
    transform: scale(0.9);
    opacity: 0.55;
  }
  58%, 88% {
    transform: scale(1.06);
    opacity: 1;
  }
  100% {
    transform: scale(0.95);
    opacity: 0.7;
  }
}

@keyframes kh-qr-radar-pulse {
  0% {
    transform: scale(0.75);
    opacity: 0.5;
  }
  100% {
    transform: scale(1.65);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kh-qr-scan-beam,
  .kh-qr-phone-group,
  .kh-qr-scan-cone,
  .kh-qr-phone-check,
  .kh-qr-result-badge,
  .kh-qr-pin-radar {
    animation: none;
  }
}

.kh-guide-step-dots {
  margin-top: 9px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.kh-guide-step-dots[hidden] {
  display: none;
}

.kh-guide-dot {
  padding: 5px 6px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  background: #f1f5f9;
  color: var(--kh-ink-muted);
  border: 1px solid var(--kh-border);
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kh-guide-dot.is-active {
  background: var(--kh-teal-dark);
  color: #ffffff;
  border-color: var(--kh-teal);
}

.kh-guide-actions {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--kh-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kh-guide-primary-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.kh-guide-btn {
  padding: 7px 11px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.kh-guide-btn[hidden] {
  display: none;
}

.kh-guide-btn--secondary {
  background: #f1f5f9;
  color: var(--kh-ink-muted);
  border: 1px solid var(--kh-border);
}

.kh-guide-btn--secondary:hover {
  background: #e2e8f0;
  color: var(--kh-ink);
}

.kh-guide-btn--primary {
  background: var(--kh-teal-dark);
  color: #ffffff;
  border: 1px solid var(--kh-teal);
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.25);
}

.kh-guide-btn--primary:hover {
  background: var(--kh-teal);
}

@media (max-width: 767px), (orientation: portrait) {
  .kh-guide-layer[data-guide-step="2"] {
    padding-right: 68px;
    align-items: flex-start;
  }

  .kh-guide-avatar {
    width: 38px;
    height: 38px;
  }

  .kh-guide-title {
    font-size: 13px;
  }

  .kh-guide-body {
    font-size: 12px;
  }

  .kh-guide-qr-svg {
    height: 70px;
  }

  .kh-guide-qr-caption {
    font-size: 10px;
  }

  .kh-guide-btn {
    padding: 6px 9px;
    font-size: 11.5px;
  }
}

@media (min-width: 768px) and (orientation: landscape) {
  .kh-guide-layer {
    justify-content: flex-end;
    align-items: flex-end;
    padding: 20px 84px max(20px, env(safe-area-inset-bottom)) calc(var(--kh-dock-w) + 24px);
  }

  .kh-guide-card {
    max-width: 380px;
  }
}
