:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --accent: #10b981;
  --gold: #f59e0b;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --bg-sidebar: rgba(255, 255, 255, 0.96);
  --border-color: #e2e8f0;
  --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --header-height: 60px;
  --sidebar-width: 380px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Microsoft JhengHei", sans-serif;
  color: var(--text-main);
  background-color: #0b0f19;
}

#app {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* --- Top Header Bar --- */
#top-bar {
  height: var(--header-height);
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

#toggle-sidebar-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: background 0.2s;
}

#toggle-sidebar-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.title-group h1 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.title-group .subtitle {
  font-size: 0.72rem;
  color: #94a3b8;
  display: block;
}

/* Spot Selector Dropdown */
.spot-selector-wrapper {
  display: flex;
  align-items: center;
}

.spot-dropdown-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 6px 14px;
  border-radius: 24px;
  color: #e2e8f0;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.spot-dropdown-box:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3);
}

.spot-select {
  background: transparent;
  border: none;
  color: white;
  font-size: 0.85rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.spot-select option {
  background: #1e293b;
  color: white;
}

/* Header Action Buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.action-pill-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(37, 99, 235, 0.25);
  border: 1px solid rgba(59, 130, 246, 0.5);
  color: #93c5fd;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.action-pill-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.brand-catalog-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: white;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 500;
  transition: all 0.2s;
}

.brand-catalog-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.38);
}

.catalog-pill-btn {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.45);
  color: #7dd3fc;
}

.catalog-pill-btn:hover {
  background: #0284c7;
  border-color: #0284c7;
  color: #fff;
}

.admin-pill-btn {
  display: none;
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.45);
  color: #6ee7b7;
}

.admin-pill-btn:hover {
  background: #059669;
  border-color: #059669;
  color: #fff;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #e2e8f0;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

/* --- Main Panorama Viewport --- */
#panorama-container {
  flex: 1;
  width: 100%;
  height: calc(100vh - var(--header-height));
  position: relative;
  overflow: hidden;
  cursor: grab;
}

#panorama-container:active {
  cursor: grabbing;
}

#canvas-container {
  width: 100%;
  height: 100%;
}

#hotspots-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Hotspot Markers */
.hotspot {
  position: absolute;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  z-index: 10;
  cursor: pointer;
  user-select: none;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.hotspot:hover {
  transform: translate(-50%, -50%) scale(1.12);
  z-index: 25;
}

.art-marker {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}

.art-marker .pin-icon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 10px #38bdf8;
}

/* 360 Semi-Transparent Artwork Bounding Box Hotspots */
.art-frame-hotspot {
  position: absolute;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  z-index: 20;
  cursor: pointer;
  user-select: none;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.art-frame-box {
  min-width: 28px;
  min-height: 20px;
  box-sizing: border-box;
  border: 1.5px dashed rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 3px 5px;
  transition: border-color 0.22s ease, background 0.22s ease, box-shadow 0.22s ease;
}

.art-frame-id {
  font-family: monospace;
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.65);
  transition: color 0.2s, text-shadow 0.2s;
}

.art-frame-hotspot:hover {
  transform: translate(-50%, -50%) scale(1.15);
  z-index: 60;
}

.art-frame-hotspot:hover .art-frame-box {
  border: 2px solid #38bdf8;
  background: rgba(56, 189, 248, 0.22);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.6), inset 0 0 10px rgba(56, 189, 248, 0.3);
}

.art-frame-hotspot:hover .art-frame-id {
  color: #fff;
  text-shadow: 0 0 6px #38bdf8;
}

.art-frame-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(56, 189, 248, 0.6);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  gap: 10px;
  width: 220px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.art-frame-hotspot:hover .art-frame-tooltip {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.art-tooltip img,
.art-frame-tooltip img {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,0.2);
}

.art-tooltip-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.art-tooltip-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.art-tooltip-sub {
  font-size: 0.74rem;
  color: #94a3b8;
  margin-top: 2px;
}

.art-tooltip-hint {
  font-size: 0.68rem;
  color: #38bdf8;
  margin-top: 4px;
  font-weight: 500;
}

/* Navigation Arrow Markers on Floor */
.nav-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.nav-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.9) 0%, rgba(30, 58, 138, 0.7) 100%);
  border: 2px solid rgba(255, 255, 255, 0.9);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(37, 99, 235, 0.7), 0 4px 12px rgba(0, 0, 0, 0.5);
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.96); box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.7); }
  70% { transform: scale(1.04); box-shadow: 0 0 0 16px rgba(37, 99, 235, 0); }
  100% { transform: scale(0.96); box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

.nav-label {
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  color: white;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 12px;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Pan Hint */
#pan-hint {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  color: #e2e8f0;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transition: opacity 1s ease;
  z-index: 20;
}

#pan-hint.fade-out {
  opacity: 0.85;
}

/* --- Interactive Floor Plan Mini-Map Widget --- */
.minimap-card {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 250px;
  background: rgba(15, 23, 42, 0.90);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  z-index: 35;
  overflow: hidden;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s ease;
  user-select: none;
}

.minimap-card.expanded {
  width: 380px;
}

.minimap-card.hidden {
  transform: translateY(120%);
  pointer-events: none;
}

.minimap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 0.78rem;
  font-weight: 600;
}

.minimap-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #93c5fd;
}

.minimap-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.minimap-controls button {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  transition: color 0.2s, background 0.2s;
}

.minimap-controls button:hover {
  color: white;
  background: rgba(255, 255, 255, 0.15);
}

.minimap-body {
  position: relative;
  width: 100%;
  aspect-ratio: 1085 / 1100;
  background: #111827;
  overflow: hidden;
}

#minimap-bg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

#minimap-pins-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

/* Pins on Mini-Map */
.map-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #334155;
  border: 1.5px solid #ffffff;
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  transition: all 0.2s ease;
  z-index: 10;
}

.map-pin:hover {
  transform: translate(-50%, -50%) scale(1.3);
  background: #2563eb;
  z-index: 20;
}

.map-pin.active {
  background: #2563eb;
  border-color: #60a5fa;
  box-shadow: 0 0 12px #3b82f6;
  z-index: 25;
  transform: translate(-50%, -50%) scale(1.25);
}

/* Radar direction fan attached to active pin */
.radar-cone {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60px;
  height: 60px;
  margin-top: -30px;
  margin-left: -30px;
  pointer-events: none;
  z-index: -1;
  transform-origin: center center;
}

/* --- Right Sidebar Drawer --- */
#sidebar {
  position: absolute;
  top: var(--header-height);
  right: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  background: var(--bg-sidebar);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid var(--border-color);
  box-shadow: -6px 0 24px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  z-index: 90;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#sidebar.collapsed {
  transform: translateX(100%);
}

.sidebar-header {
  padding: 16px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
}

.sidebar-header-titles {
  display: flex;
  align-items: center;
  gap: 10px;
}

.close-sidebar-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.close-sidebar-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateX(2px);
}

/* Search Box */
.search-box {
  margin: 12px 16px 8px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  padding: 9px 34px 9px 36px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.85rem;
  background: #f8fafc;
  outline: none;
  transition: all 0.2s;
}

.search-box input:focus {
  background: white;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

#clear-search-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--text-muted);
  cursor: pointer;
}

/* Category Filter Tabs */
.category-filter-wrapper {
  padding: 4px 16px 8px;
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  white-space: nowrap;
}

.category-filter-wrapper::-webkit-scrollbar {
  height: 4px;
}
.category-filter-wrapper::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.category-tabs {
  display: flex;
  gap: 6px;
}

.cat-tab-btn {
  background: #f1f5f9;
  border: 1px solid transparent;
  color: #475569;
  font-size: 0.76rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.cat-tab-btn:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.cat-tab-btn.active {
  background: #1e293b;
  color: white;
}

/* Class Filter Chips */
.class-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-color);
  max-height: 110px;
  overflow-y: auto;
}

.class-filter-bar::-webkit-scrollbar {
  width: 4px;
}
.class-filter-bar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.filter-chip {
  background: white;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-chip:hover {
  border-color: #94a3b8;
  color: var(--text-main);
}

.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Artwork List Scrollable Area */
.artwork-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.artwork-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: white;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.artwork-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-shadow);
  border-color: #93c5fd;
}

.card-thumb {
  width: 68px;
  height: 68px;
  border-radius: 8px;
  object-fit: cover;
  background: #f1f5f9;
  flex-shrink: 0;
}

.card-info {
  flex: 1;
  min-width: 0;
}

.card-meta-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.card-id-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 6px;
  border-radius: 6px;
}

.card-cat-badge {
  font-size: 0.68rem;
  color: #64748b;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 6px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.card-author {
  font-size: 0.76rem;
  color: var(--text-muted);
}

/* --- Fullscreen Artwork Lightbox Showcase --- */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 15, 29, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 1;
  transition: opacity 0.25s ease;
  user-select: none;
  -webkit-user-select: none;
}

.modal-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.fullscreen-showcase {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: transparent;
  color: white;
}

/* Showcase Header */
.showcase-header {
  height: 56px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.75);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 10;
}

.showcase-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.info-badge {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
}

.id-badge {
  background: rgba(37, 99, 235, 0.3);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.cat-badge {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.spot-badge {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.showcase-student {
  font-size: 0.95rem;
  font-weight: 600;
  color: #f8fafc;
}

.showcase-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Floating Zoom Toolbar */
.zoom-toolbar {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 2px 6px;
  gap: 4px;
}

.zoom-tool-btn {
  background: none;
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.zoom-tool-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.zoom-level-btn {
  width: auto;
  padding: 0 6px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 10px;
}

.header-locate-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #2563eb;
  color: white;
  border: none;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.header-locate-btn:hover {
  background: #1d4ed8;
}

.close-modal-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}

.close-modal-btn:hover {
  color: white;
}

/* Stage Area (Image Viewport & Prev/Next Arrows) */
.showcase-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-arrow-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s;
}

.nav-arrow-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  transform: translateY(-50%) scale(1.1);
}

.prev-btn { left: 24px; }
.next-btn { right: 24px; }

.modal-img-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: zoom-in;
}

.modal-img-viewport.grabbing {
  cursor: grabbing;
}

#modal-img {
  max-width: 90%;
  max-height: 85%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  transform-origin: center center;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

#modal-img.dragging {
  transition: none;
}

/* Caption Footer */
.showcase-caption {
  padding: 12px 24px;
  background: rgba(15, 23, 42, 0.85);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.caption-title-line {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.caption-title-line h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.caption-details {
  font-size: 0.85rem;
  color: #94a3b8;
}

.zoom-tip {
  font-size: 0.78rem;
  color: #64748b;
}

/* Quick Help Modal */
.help-card {
  background: white;
  color: var(--text-main);
  padding: 24px;
  border-radius: 14px;
  max-width: 480px;
  width: 90%;
  position: relative;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.help-card h3 {
  font-size: 1.2rem;
  margin-bottom: 16px;
  color: var(--primary);
}

.help-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 20px;
}

.help-card li strong {
  color: #0f172a;
}

.primary-btn {
  background: var(--primary);
  color: white;
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

/* --- Mobile & Tablet Responsive Layout Engine --- */

/* Canvas Touch Optimization */
#panorama-container, #canvas-container, canvas {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Touch feedback for hotspots */
.art-frame-hotspot {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.art-frame-hotspot:active .art-frame-box {
  border: 2px solid #38bdf8 !important;
  background: rgba(56, 189, 248, 0.35) !important;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.8) !important;
}
.ground-arrow {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.ground-arrow:active {
  transform: translate(-50%, -50%) scale(0.92);
}

/* 1. Medium Tablet Screens (<= 1024px) */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 360px;
  }
  .title-group h1 {
    font-size: 0.98rem;
  }
  .minimap-card {
    width: 160px;
  }
}

/* 2. Tablet & Mobile Screens (<= 768px) */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 100vw;
    --header-height: 52px;
  }

  /* Top Bar Adaptation */
  #top-bar {
    padding: 0 10px;
    gap: 8px;
  }

  .brand {
    gap: 8px;
    min-width: 0;
    flex-shrink: 1;
  }

  .brand-catalog-btn {
    padding: 6px 8px;
    gap: 4px;
  }

  .brand-catalog-btn .brand-btn-text {
    display: none;
  }

  .title-group {
    min-width: 0;
  }

  .title-group h1 {
    font-size: 0.92rem;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .title-group .subtitle {
    display: none !important;
  }

  /* Spot Selector */
  .spot-selector-wrapper {
    flex-shrink: 1;
    min-width: 0;
  }

  .spot-dropdown-box {
    padding: 4px 10px;
    font-size: 0.8rem;
    gap: 6px;
    border-radius: 20px;
  }

  .spot-dropdown-box svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
  }

  .spot-select {
    font-size: 0.8rem;
    max-width: 125px;
  }

  /* Header Actions */
  .header-actions {
    gap: 6px;
    flex-shrink: 0;
  }

  /* Hide duplicate catalog button in header on mobile */
  #top-catalog-btn {
    display: none !important;
  }

  /* Compact Map Button */
  #toggle-map-btn {
    padding: 6px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    justify-content: center;
  }

  #toggle-map-btn span {
    display: none;
  }

  #help-btn {
    width: 34px;
    height: 34px;
    padding: 0;
  }

  /* 360 Wall Frames subtle glowing border for touch recognition */
  .art-frame-box {
    border: 1.5px solid rgba(56, 189, 248, 0.65);
    background: rgba(56, 189, 248, 0.12);
  }

  /* Mini-map on Mobile */
  .minimap-card {
    width: 140px;
    bottom: 12px;
    right: 12px;
  }

  .minimap-header {
    padding: 6px 8px;
    font-size: 0.72rem;
  }

  .minimap-card.expanded {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
    width: min(88vw, 350px) !important;
    z-index: 220 !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9) !important;
  }

  #pan-hint {
    font-size: 0.72rem;
    padding: 6px 12px;
    max-width: 90vw;
    bottom: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Sidebar Drawer on Mobile */
  #sidebar {
    width: 100vw;
    max-width: 100%;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
  }

  .sidebar-header {
    padding: 12px 16px;
  }

  .sidebar-header h2 {
    font-size: 1rem;
  }

  .category-filter-wrapper {
    padding: 8px 12px;
    -webkit-overflow-scrolling: touch;
  }

  .category-tab-btn {
    padding: 5px 12px;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  .class-filter-bar {
    padding: 6px 12px;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
  }

  .class-filter-chip {
    padding: 4px 10px;
    font-size: 0.75rem;
    min-height: 28px;
  }

  .artwork-list-container {
    padding: 10px 12px;
    gap: 8px;
  }

  .artwork-card {
    padding: 8px 10px;
    gap: 10px;
  }

  .card-thumb {
    width: 60px;
    height: 60px;
  }

  .card-title {
    font-size: 0.88rem;
  }

  .card-author {
    font-size: 0.74rem;
  }

  /* Artwork Fullscreen Lightbox on Mobile */
  .showcase-header {
    min-height: 48px;
    padding: 6px 10px;
    gap: 6px;
    background: rgba(15, 23, 42, 0.92);
  }

  .showcase-meta {
    gap: 6px;
    max-width: calc(100% - 90px);
    overflow: hidden;
  }

  .showcase-meta .cat-badge,
  .showcase-meta .spot-badge {
    display: none !important;
  }

  .showcase-student {
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
  }

  .showcase-actions {
    gap: 6px;
  }

  .zoom-toolbar {
    display: none !important;
  }

  #modal-locate-btn {
    padding: 5px 8px;
    font-size: 0.75rem;
  }

  #modal-locate-btn .btn-text {
    display: none;
  }

  .close-modal-btn {
    width: 36px;
    height: 36px;
    font-size: 26px;
    line-height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Nav Arrows on Mobile */
  .nav-arrow-btn {
    width: 38px;
    height: 38px;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
  }

  .prev-btn { left: 6px; }
  .next-btn { right: 6px; }

  /* Showcase Stage & Image */
  #modal-img {
    max-width: 96%;
    max-height: calc(100vh - 145px);
  }

  /* Showcase Caption */
  .showcase-caption {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 8px 12px;
    background: rgba(15, 23, 42, 0.95);
  }

  .caption-title-line h2 {
    font-size: 0.95rem;
  }

  .caption-details {
    font-size: 0.74rem;
    color: #94a3b8;
  }

  .zoom-tip-desktop {
    display: none !important;
  }

  .zoom-tip-mobile {
    display: block !important;
    font-size: 0.72rem;
    color: #38bdf8;
    margin-top: 2px;
  }

  /* Help Card */
  .help-card {
    padding: 20px 16px;
    max-width: 92vw;
  }
}

/* 3. Small Mobile Phones (<= 480px) */
@media (max-width: 480px) {
  :root {
    --header-height: 48px;
  }

  #top-bar {
    padding: 0 6px;
    gap: 4px;
  }

  .title-group h1 {
    font-size: 0.82rem;
    max-width: 110px;
  }

  .spot-dropdown-box {
    padding: 3px 6px;
    gap: 4px;
  }

  .spot-select {
    font-size: 0.74rem;
    max-width: 95px;
  }

  #toggle-map-btn {
    width: 32px;
    height: 32px;
  }

  #help-btn {
    width: 32px;
    height: 32px;
  }

  .card-thumb {
    width: 52px;
    height: 52px;
  }
}

/* 4. Mobile Landscape Orientation (Phone turned sideways) */
@media (max-height: 500px) and (orientation: landscape) {
  :root {
    --header-height: 42px;
  }

  #top-bar {
    height: 42px;
    padding: 0 8px;
  }

  .showcase-header {
    min-height: 38px;
    height: 38px;
    padding: 0 8px;
  }

  #modal-img {
    max-height: calc(100vh - 85px);
  }

  .showcase-caption {
    padding: 4px 10px;
  }

  .showcase-caption .zoom-tip-mobile {
    display: none !important;
  }
}
