* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Noto Sans KR", "Malgun Gothic", Arial, sans-serif;
  background: #111;
  color: #fff;
}

body {
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
}

#panorama {
  width: 100%;
  height: 100%;
  background: #000;
}

/* 상단 바 */
.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.72), rgba(0,0,0,0.18));
}

.topbar-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

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

.title-wrap h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
  font-weight: 700;
}

.title-wrap p {
  margin: 4px 0 0;
  font-size: 13px;
  color: rgba(255,255,255,0.82);
  line-height: 1.4;
}

.topbar-right {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* 버튼 */
.ui-btn {
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(20,20,20,0.72);
  color: #fff;
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
  min-height: 40px;
}

.ui-btn:hover {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.36);
}

.ui-btn:active {
  transform: translateY(1px);
}

.ui-btn.danger {
  background: rgba(120, 18, 18, 0.78);
}

.icon-btn {
  min-width: 42px;
  padding-left: 10px;
  padding-right: 10px;
}

.rotate-btn {
  min-width: 72px;
  font-weight: 600;
}

/* 좌측 패널 */
.side-panel {
  position: absolute;
  top: 84px;
  left: 16px;
  bottom: 62px;
  z-index: 18;
  width: 300px;
  max-width: calc(100vw - 32px);
  background: rgba(15,15,15,0.78);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  padding: 14px;
  overflow-y: auto;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.side-panel.closed {
  transform: translateX(-115%);
  opacity: 0;
  pointer-events: none;
}

.panel-section + .panel-section {
  margin-top: 18px;
}

.panel-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 10px;
  color: rgba(255,255,255,0.95);
}

.scene-list,
.video-list,
.video-chooser {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scene-item,
.video-item {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.08);
  color: #fff;
  border-radius: 12px;
  padding: 11px 12px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  font-size: 14px;
  line-height: 1.35;
}

.scene-item:hover,
.video-item:hover {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.24);
}

.scene-item.active {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.42);
  font-weight: 700;
}

/* 우측 지도 패널 */
.map-panel {
  position: absolute;
  top: 84px;
  right: 16px;
  bottom: 62px;
  z-index: 18;
  width: 340px;
  max-width: calc(100vw - 32px);
  background: rgba(15,15,15,0.78);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  padding: 14px;
  overflow: hidden;
  transition: transform 0.25s ease, opacity 0.25s ease;
  display: flex;
  flex-direction: column;
}

.map-panel.closed {
  transform: translateX(115%);
  opacity: 0;
  pointer-events: none;
}

.map-panel-title {
  margin-bottom: 6px;
}

.map-info {
  font-size: 12px;
  color: rgba(255,255,255,0.76);
  margin-bottom: 10px;
  line-height: 1.4;
}

#sceneMap {
  width: 100%;
  height: 100%;
  min-height: 260px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
}

/* Leaflet */
.leaflet-container {
  background: #d8e3ea;
  color: #111;
  font-family: Arial, sans-serif;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  color: #111;
}

/* 하단 상태 */
.statusbar {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 14px;
  z-index: 18;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(0,0,0,0.56);
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 14px;
  backdrop-filter: blur(8px);
}

/* 모바일 도크 */
.mobile-dock {
  display: none;
}

.mobile-hint {
  display: none;
}

/* 모달 */
.modal {
  position: absolute;
  inset: 0;
  z-index: 50;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.72);
}

.modal-dialog {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: min(1000px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  background: #111;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.45);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  padding: 14px;
}

#videoPlayer {
  width: 100%;
  max-height: 60vh;
  background: #000;
  border-radius: 12px;
  display: block;
}

/* Pannellum 일부 숨김 */
.pnlm-about-msg,
.pnlm-title-box,
.pnlm-author-box {
  display: none !important;
}

/* 태블릿 */
@media (max-width: 1024px) {
  .map-panel {
    width: 300px;
  }
}

/* 모바일 */
@media (max-width: 768px) {
  .topbar {
    padding: calc(8px + env(safe-area-inset-top)) 8px 8px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .topbar-left,
  .topbar-right {
    width: 100%;
  }

  .topbar-right {
    justify-content: flex-start;
    gap: 5px;
  }

  .title-wrap h1 {
    font-size: 15px;
  }

  .title-wrap p {
    font-size: 10px;
    margin-top: 2px;
    line-height: 1.3;
  }

  .topbar-right .ui-btn,
  .topbar-left .ui-btn {
    min-height: 34px;
    padding: 7px 9px;
    font-size: 11px;
    border-radius: 8px;
  }

  .icon-btn {
    min-width: 34px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .rotate-btn {
    min-width: 56px;
  }

  .side-panel,
  .map-panel {
    top: 96px;
    bottom: 96px;
    width: min(280px, calc(100vw - 16px));
    max-width: calc(100vw - 16px);
    padding: 10px;
    border-radius: 12px;
  }

  .side-panel {
    left: 8px;
  }

  .map-panel {
    right: 8px;
  }

  .panel-title {
    font-size: 13px;
    margin-bottom: 8px;
  }

  .map-info {
    font-size: 11px;
    margin-bottom: 8px;
  }

  .scene-item,
  .video-item {
    padding: 9px 10px;
    font-size: 12px;
    border-radius: 10px;
  }

  .statusbar {
    left: 8px;
    right: 8px;
    bottom: 54px;
    font-size: 11px;
    padding: 7px 10px;
    border-radius: 10px;
  }

  .mobile-dock {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    z-index: 22;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .dock-btn {
    border: 1px solid rgba(255,255,255,0.16);
    background: rgba(12,12,12,0.82);
    color: #fff;
    border-radius: 10px;
    min-height: 38px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(10px);
    padding: 6px 4px;
  }

  .mobile-hint {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 98px;
    z-index: 19;
    display: block;
    padding: 8px 10px;
    font-size: 11px;
    line-height: 1.35;
    color: #fff;
    background: rgba(0,0,0,0.55);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    backdrop-filter: blur(8px);
  }

  .mobile-hint.hidden {
    display: none;
  }

  .modal-dialog {
    width: calc(100vw - 10px);
    max-height: calc(100vh - 10px);
    border-radius: 12px;
  }

  .modal-header {
    padding: 10px;
  }

  .modal-header h2 {
    font-size: 15px;
  }

  .modal-body {
    padding: 10px;
  }

  #videoPlayer {
    max-height: 40vh;
  }
}

/* 모바일 가로 모드 전용 보정 */
@media (max-width: 900px) and (orientation: landscape) {
  .topbar {
    padding: 6px 8px;
    gap: 6px;
  }

  .title-wrap h1 {
    font-size: 13px;
  }

  .title-wrap p {
    font-size: 9px;
    margin-top: 1px;
    line-height: 1.2;
  }

  .topbar-right .ui-btn,
  .topbar-left .ui-btn {
    min-height: 30px;
    padding: 5px 8px;
    font-size: 10px;
    border-radius: 7px;
  }

  .icon-btn {
    min-width: 30px;
    padding-left: 6px;
    padding-right: 6px;
  }

  .rotate-btn {
    min-width: 52px;
  }

  .side-panel,
  .map-panel {
    top: 68px;
    bottom: 52px;
    width: min(250px, calc(100vw - 16px));
    max-width: calc(100vw - 16px);
    padding: 8px;
    border-radius: 10px;
  }

  .panel-title {
    font-size: 12px;
    margin-bottom: 6px;
  }

  .map-info {
    font-size: 10px;
    margin-bottom: 6px;
  }

  .scene-item,
  .video-item {
    padding: 7px 8px;
    font-size: 11px;
    border-radius: 8px;
  }

  .statusbar {
    left: 8px;
    right: 8px;
    bottom: 40px;
    font-size: 10px;
    padding: 5px 8px;
    border-radius: 8px;
  }

  .mobile-dock {
    left: 8px;
    right: 8px;
    bottom: 6px;
    gap: 5px;
  }

  .dock-btn {
    min-height: 30px;
    font-size: 10px;
    padding: 4px 3px;
    border-radius: 8px;
  }

  .mobile-hint {
    display: none !important;
  }

  #sceneMap {
    min-height: 180px;
  }
}