/* Overrides to match schedule-blueprint + interactive-blueprint; PDF layer; room labels visible */
.map-viewport {
  position: absolute;
  inset: 0;
  cursor: grab;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  perspective: 2000px;
}

.map-viewport.panning {
  cursor: grabbing;
}

/* Blueprint background: solid by default; grid optional via .show-grid */
.canvas-wrap {
  background-color: #0d0d0d;
}

.canvas-wrap.show-grid {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 28px 28px;
}

.camera-rig {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform-origin: 50% 50%;
  will-change: transform;
}

.blueprint-stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
  transform-style: preserve-3d;
  will-change: transform;
}

.overlay-layer,
#pdfLayer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#pdfLayer {
  z-index: 0;
  pointer-events: none;
  background: transparent;
  mix-blend-mode: multiply;
  transform: translateZ(0px);
}

#pdfLayer canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
}

.overlay-layer {
  z-index: 1;
  transition: opacity 0.12s ease-out;
  transform-style: preserve-3d;
}

.overlay-layer.floor-changing {
  opacity: 0;
  pointer-events: none;
}

.overlay-layer svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.overlay-layer #hallwaysLayer,
.overlay-layer #stairwaysLayer {
  pointer-events: none;
}

.overlay-layer .shape-group,
.overlay-layer .map-shape {
  pointer-events: all;
  cursor: pointer;
}

#hallwaysLayer {
  z-index: 2;
  transform: translateZ(2px);
}

#stairwaysLayer {
  z-index: 4;
  transform: translateZ(4px);
}

.rooms-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  transform: translateZ(6px);
}

.rooms-layer .map-box {
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.4);
}

.rooms-layer .map-box.has-class-now {
  border-color: #2d8a4e;
  background: rgba(45, 138, 78, 0.25);
}

.rooms-layer .map-box.no-class-now {
  border-color: #b54a4a;
  background: rgba(181, 74, 74, 0.2);
}

.rooms-layer .map-box.search-highlight {
  border-color: #f9d65c;
  box-shadow: 0 0 0 2px #f9d65c;
}

#hallwaysLayer {
  --box-border-color: rgba(77, 179, 255, 0.9);
  --box-fill-color: rgba(77, 179, 255, 0.18);
}

.map-shape.hallway-box {
  fill: var(--box-fill-color);
  stroke: var(--box-border-color);
  stroke-width: 0.4;
  stroke-linejoin: miter;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  filter: drop-shadow(0px 5px 5px rgba(0, 0, 0, 0.3));
}

.map-shape.stairway-box {
  fill: rgba(122, 156, 173, 0.22);
  stroke: #7a9cad;
  stroke-width: 0.4;
  stroke-linejoin: miter;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
}

.map-shape.selected {
  stroke: #f9d65c;
  stroke-width: 0.6;
}

.map-shape-label {
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  font-weight: 700;
  letter-spacing: 0.05px;
  text-transform: uppercase;
  fill: #ffffff;
  paint-order: stroke fill;
  stroke: rgba(0, 0, 0, 0.9);
  stroke-width: 0.35;
  stroke-linejoin: round;
  stroke-linecap: round;
  pointer-events: none;
  user-select: none;
}

.room-popup {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}

.room-popup.open {
  display: flex;
}

.room-popup-content {
  background: rgba(9, 9, 11, 0.85);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  max-width: 900px;
  width: min(94vw, 900px);
  padding: 24px;
  display: grid;
  gap: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

.room-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.room-popup-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.room-popup-meta {
  font-size: 13px;
  color: #a1a1aa;
  margin-top: 4px;
}

.room-popup-close {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fafafa;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.room-popup-close:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.room-popup-close:active {
  transform: scale(0.97);
}

/* Mobile: popup slightly smaller, easier to close and scroll (includes landscape phone) */
@media (max-width: 768px),
((orientation: landscape) and (max-height: 600px)) {
  .room-popup {
    padding: 10px;
    padding-top: max(10px, env(safe-area-inset-top));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    align-items: flex-start;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .room-popup-content {
    width: 100%;
    max-width: none;
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 14px;
    border-radius: 10px;
    gap: 10px;
  }

  .room-popup-header h2 {
    font-size: 17px;
  }

  .room-popup-close {
    min-height: 44px;
    min-width: 44px;
    padding: 10px 14px;
    font-size: 14px;
    -webkit-tap-highlight-color: transparent;
  }
}

@media (max-width: 480px) {
  .room-popup-content {
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    padding: 11px 12px;
  }

  .room-popup-header h2 {
    font-size: 16px;
  }
}

.room-popup-image-wrap {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  overflow: hidden;
}

.room-popup-image-wrap img {
  width: 100%;
  max-height: 440px;
  object-fit: cover;
  display: block;
}

@media (max-width: 768px),
((orientation: landscape) and (max-height: 600px)) {
  .room-popup-image-wrap img {
    max-height: 220px;
  }
}

@media (max-width: 480px) {
  .room-popup-image-wrap img {
    max-height: 180px;
  }
}

.room-popup-schedule {
  font-size: 14px;
  color: #e4e4e7;
  line-height: 1.5;
}

.room-popup-fullday-details {
  margin-top: 4px;
}

.room-popup-fullday-details summary {
  font-size: 13px;
  font-weight: 500;
  color: #fafafa;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  cursor: pointer;
  list-style: none;
  padding: 10px 14px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  margin-top: 8px;
  margin-bottom: 8px;
}

.room-popup-fullday-details summary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.room-popup-fullday-details summary:active {
  transform: scale(0.97);
}

.room-popup-fullday-details summary::-webkit-details-marker {
  display: none;
}

.room-popup-fullday-details summary::before {
  content: "▶";
  font-size: 10px;
  margin-right: 8px;
  color: #a1a1aa;
}

.room-popup-fullday-details[open] summary::before {
  content: "▼";
}

.room-popup-fullday {
  max-height: 240px;
  overflow-y: auto;
  font-size: 13px;
  color: #d4d4d8;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(24, 24, 27, 0.6);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-top: 4px;
}

.room-popup-fullday::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.room-popup-fullday::-webkit-scrollbar-track {
  background: transparent;
}

.room-popup-fullday::-webkit-scrollbar-thumb {
  background: #27272a;
  border-radius: 10px;
}

.room-popup-fullday::-webkit-scrollbar-thumb:hover {
  background: #3f3f46;
}

@media (max-width: 768px),
((orientation: landscape) and (max-height: 600px)) {
  .room-popup-fullday {
    max-height: 180px;
    -webkit-overflow-scrolling: touch;
  }

  .room-popup-fullday-details summary {
    padding: 10px 0;
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

.room-popup-fullday-row {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.room-popup-fullday-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.room-popup-fullday-row:last-child {
  border-bottom: none;
}

.room-popup-fullday-row.current-hour {
  background: rgba(255, 255, 255, 0.06);
  border-left: 3px solid #5ba3e8;
  padding-left: 11px;
}

.room-popup-next {
  font-size: 13px;
  color: #a1a1aa;
}

.room-popup-next:not(:empty) {
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Projector / TV / touch: lock scroll when modal open */
body.modal-open {
  overflow: hidden;
}

/* --- UI/UX REWRITE: MODERN PANEL --- */
.panel button,
.panel select,
.panel input[type="text"],
.panel input[type="range"],
.panel input[type="checkbox"]+label,
.panel .btn-tool {
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.panel {
  position: absolute !important;
  right: 16px;
  top: 16px;
  width: min(340px, calc(100vw - 32px)) !important;
  background: rgba(9, 9, 11, 0.75) !important;
  backdrop-filter: blur(16px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(16px) saturate(180%) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 16px !important;
  padding: 20px !important;
  gap: 20px !important;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.05) !important;
  max-height: calc(100vh - 32px) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  z-index: 20;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-20px);
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.app.panel-open .panel {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.panel::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.panel::-webkit-scrollbar-track {
  background: transparent;
}

.panel::-webkit-scrollbar-thumb {
  background: #27272a;
  border-radius: 10px;
}

.panel::-webkit-scrollbar-thumb:hover {
  background: #3f3f46;
}

.panel h1 {
  font-size: 20px !important;
  font-weight: 600 !important;
  letter-spacing: -0.02em;
  color: #ffffff;
  margin: 0 !important;
}

.panel .panel-home-link {
  margin: 0 !important;
  font-size: 13px;
}

.panel .panel-home-link a {
  color: #a1a1aa;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s;
}

.panel .panel-home-link a:hover {
  color: #fafafa;
}

.panel h2 {
  font-size: 12px !important;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #71717a !important;
  margin: 0 0 4px 0 !important;
}

.panel section {
  border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
  padding-top: 18px !important;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel section:first-of-type {
  border-top: none !important;
  padding-top: 0 !important;
}

.panel label {
  font-size: 13px !important;
  color: #a1a1aa !important;
  font-weight: 500;
}

.panel input[type="text"],
.panel select {
  background: rgba(24, 24, 27, 0.6) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 10px !important;
  color: #fafafa !important;
  font-family: inherit !important;
  font-size: 13px !important;
  transition: all 0.2s ease !important;
  padding: 10px 14px !important;
  width: 100%;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.panel input[type="text"]:focus,
.panel select:focus {
  outline: none !important;
  background: rgba(24, 24, 27, 0.9) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1) !important;
}

/* Custom Range Slider */
.panel input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  background: transparent !important;
  padding: 0 !important;
  margin: 6px 0;
}

.panel input[type="range"]:focus {
  outline: none;
}

.panel input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.panel input[type="range"]::-webkit-slider-thumb {
  height: 14px;
  width: 14px;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  margin-top: -4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  transition: transform 0.1s ease, background 0.1s ease;
}

.panel input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  background: #f4f4f5;
}

.panel input[type="range"]::-moz-range-track {
  width: 100%;
  height: 6px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.panel input[type="range"]::-moz-range-thumb {
  height: 14px;
  width: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: none;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  transition: transform 0.1s ease, background 0.1s ease;
}

.panel input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.1);
  background: #f4f4f5;
}

.panel .btn-tool,
.panel button:not(.panel-collapse-btn):not(.panel-toggle) {
  background: rgba(255, 255, 255, 0.04) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 8px !important;
  color: #fafafa !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  padding: 10px 14px !important;
  transition: all 0.2s ease !important;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.panel .btn-tool:hover,
.panel button:not(.panel-collapse-btn):not(.panel-toggle):hover {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
  transform: translateY(-1px);
}

.panel .btn-tool:active,
.panel button:not(.panel-collapse-btn):not(.panel-toggle):active {
  transform: scale(0.97);
}

.panel-shortcuts {
  margin: 4px 0 0;
  font-size: 12px;
  color: #71717a;
  line-height: 1.5;
}

/* Custom Checkbox */
.panel .checkbox-row {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  font-size: 14px !important;
  cursor: pointer;
}

.panel input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  min-width: 20px;
  width: 20px;
  height: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.3);
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  margin: 0;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.panel input[type="checkbox"]:hover {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.4);
}

.panel input[type="checkbox"]:checked {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}

.panel input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 7px;
  width: 4px;
  height: 8px;
  border: solid #09090b;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.panel input[type="checkbox"]+label {
  cursor: pointer;
  color: #d4d4d8 !important;
  font-size: 14px !important;
}

/* Search results */
.search-results {
  background: rgba(24, 24, 27, 0.8) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 12px !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5) !important;
  margin-top: 8px !important;
  max-height: 200px !important;
  overflow-y: auto !important;
}

.search-results-item {
  color: #e4e4e7 !important;
  font-size: 13px !important;
  padding: 12px 14px !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
  transition: all 0.2s ease !important;
  min-height: auto !important;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.search-results-item:last-child {
  border-bottom: none !important;
}

.search-results-item:hover {
  background: rgba(255, 255, 255, 0.06) !important;
  color: #ffffff !important;
  padding-left: 18px !important;
}

.search-results-item.search-highlight {
  border-left: 3px solid #5ba3e8 !important;
  padding-left: 15px !important;
  background: rgba(91, 163, 232, 0.1) !important;
}

/* Status line */
.workspace .status,
#status {
  padding: 10px 14px;
  background: #18181b;
  border: 1px solid #27272a;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #d4d4d8;
  min-height: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.error-block {
  margin-top: 8px;
  padding: 12px 14px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  font-size: 13px;
  color: #fca5a5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.btn-retry {
  background: rgba(239, 68, 68, 0.2) !important;
  border: 1px solid rgba(239, 68, 68, 0.4) !important;
  color: #fca5a5 !important;
  padding: 8px 14px !important;
  border-radius: 6px !important;
  font-weight: 500 !important;
  transition: background 0.2s !important;
}

.btn-retry:hover {
  background: rgba(239, 68, 68, 0.3) !important;
}

/* Responsive Panel adjustments */
.panel-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: 16px;
  top: 16px;
  z-index: 12;
  padding: 12px;
  background: rgba(9, 9, 11, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fafafa;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transition: all 0.3s ease;
}

.panel-toggle:hover {
  background: rgba(24, 24, 27, 0.85);
  transform: translateY(-1px);
}

.panel-toggle:active {
  transform: scale(0.97);
}

.panel-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 11;
  transition: opacity 0.3s;
}

@media (max-width: 768px),
((orientation: landscape) and (max-height: 600px)) {
  .app .panel {
    transform: translateY(-30px) scale(0.95);
  }

  .app.panel-open .panel {
    transform: translateY(0) scale(1);
  }

  .app.panel-open .panel-backdrop {
    display: block;
  }
}

@media (max-width: 480px) {
  .app .panel {
    width: min(100%, 100vw - 16px);
    padding: 10px;
  }

  .app .panel h1 {
    font-size: 15px;
  }

  .app .panel section:nth-of-type(3) .btn-tool {
    font-size: 12px;
  }
}

/* Fullscreen: map fills screen */
.canvas-wrap.fullscreen {
  position: fixed;
  inset: 0;
  max-width: none;
  aspect-ratio: auto;
  z-index: 15;
  border-radius: 0;
  border: none;
}

.canvas-wrap.fullscreen .map-viewport {
  border-radius: 0;
}

/* In fullscreen, popup must be absolute so it fills the fullscreen element (fixed can escape in some browsers) */
.canvas-wrap.fullscreen .room-popup {
  position: absolute;
}