:root {
  --ink: #1c2a33;
  --ink-soft: #4a5d6a;
  --cream: #f6f1e8;
  --glass: rgba(246, 241, 232, 0.84);
  --glass-border: rgba(255, 255, 255, 0.55);
  --accent: #2f6f7e;
  --accent-deep: #1e4d58;
  --shadow: 0 18px 50px rgba(28, 42, 51, 0.18);
  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-ui: "DM Sans", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #8ec4d4;
  font-family: var(--font-ui);
  color: var(--ink);
}

#c {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
}

/* —— Top bar —— */
.topbar {
  position: absolute;
  top: 18px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
  background: var(--glass);
  backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 8px 16px 8px 8px;
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(145deg, #3d8a9a, #1e4d58);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: grid;
  place-items: center;
  letter-spacing: 0.04em;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 14px;
  font-weight: 600;
}

.brand-text span {
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  font-weight: 500;
}

.daylight-pill {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s;
}

.daylight-pill:hover {
  transform: translateY(-1px);
}

.daylight-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f0c15a;
  box-shadow: 0 0 10px #f0c15a;
}

.daylight-pill.night .dot {
  background: #9bb7ff;
  box-shadow: 0 0 10px #9bb7ff;
}

/* —— Intro card —— */
.intro-card {
  position: absolute;
  top: 88px;
  left: 24px;
  width: min(380px, calc(100vw - 48px));
  background: var(--glass);
  backdrop-filter: blur(18px);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  padding: 28px 28px 24px;
  box-shadow: var(--shadow);
  z-index: 12;
  animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.intro-card.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.98);
  transition: 0.35s ease;
}

.icon-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(28, 42, 51, 0.12);
  background: rgba(255, 255, 255, 0.5);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-soft);
}

.eyebrow {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 10px;
}

.intro-card h1 {
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}

.intro-card h1 em {
  font-style: italic;
  color: var(--accent-deep);
}

.lede {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-soft);
  margin-bottom: 16px;
}

.district-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 18px;
}

.chip {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(28, 42, 51, 0.12);
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink-soft);
}

.chip[data-d="jung"] { border-color: #6a9bb0; color: #2a5a6a; }
.chip[data-d="nam"] { border-color: #c48a6a; color: #8a4a2a; }
.chip[data-d="dong"] { border-color: #5a8a9a; color: #1e4d58; }
.chip[data-d="buk"] { border-color: #7a9a6a; color: #3a5a2a; }
.chip[data-d="ulju"] { border-color: #9a8a5a; color: #5a4a2a; }

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  border: none;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: 999px;
  padding: 12px 18px;
  transition: transform 0.15s, box-shadow 0.15s;
}

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

.btn.primary {
  background: var(--accent-deep);
  color: #fff;
  box-shadow: 0 8px 20px rgba(30, 77, 88, 0.28);
}

.btn.primary span {
  margin-left: 4px;
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(28, 42, 51, 0.18);
}

/* —— Toolbar —— */
.toolbar {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

.tool {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 15px;
  color: var(--ink);
  transition: transform 0.15s, background 0.2s;
}

.tool:hover {
  transform: scale(1.06);
  background: #fff;
}

.tool.active {
  background: var(--accent-deep);
  color: #fff;
  border-color: transparent;
}

/* —— District filter bar —— */
.district-bar {
  position: absolute;
  left: 50%;
  bottom: 118px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 6px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 10;
  max-width: calc(100vw - 40px);
  overflow-x: auto;
}

.d-btn {
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 8px 14px;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}

.d-btn:hover {
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
}

.d-btn.active {
  background: var(--accent-deep);
  color: #fff;
}

/* —— Bottom rail —— */
.rail-wrap {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(1100px, calc(100vw - 32px));
  z-index: 10;
}

.rail {
  display: flex;
  gap: 4px;
  padding: 8px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow-x: auto;
  scrollbar-width: thin;
}

.rail-item {
  flex: 0 0 auto;
  min-width: 108px;
  border: none;
  background: transparent;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-ui);
  color: var(--ink);
  transition: background 0.2s, opacity 0.25s;
}

.rail-item:hover,
.rail-item.active {
  background: rgba(255, 255, 255, 0.75);
}

.rail-item.dim {
  opacity: 0.32;
}

.rail-item .num {
  display: block;
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 2px;
}

.rail-item .name {
  display: block;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

.rail-item .sub {
  display: block;
  font-size: 9px;
  color: var(--ink-soft);
  margin-top: 2px;
  letter-spacing: 0.03em;
}

/* —— Tour bar —— */
.tour-bar {
  position: absolute;
  left: 50%;
  bottom: 168px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 20px;
  background: rgba(30, 77, 88, 0.92);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  z-index: 11;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.tour-meta {
  display: flex;
  flex-direction: column;
  min-width: 140px;
}

.tour-meta span {
  font-size: 10px;
  letter-spacing: 0.14em;
  opacity: 0.75;
}

.tour-meta strong {
  font-size: 15px;
}

.tour-actions {
  display: flex;
  gap: 8px;
}

.tour-actions button {
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: transparent;
  color: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font-ui);
}

.tour-actions button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.tooltip {
  position: absolute;
  z-index: 15;
  min-width: 180px;
  max-width: 240px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--glass-border);
  pointer-events: none;
  transform: translate(-50%, -120%);
}

.hint {
  position: absolute;
  left: 50%;
  bottom: 175px;
  transform: translateX(-50%);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  z-index: 5;
  opacity: 0.85;
  transition: opacity 0.5s;
}

.hint.fade {
  opacity: 0;
}

/* —— Runtime log panel —— */
.log-panel {
  position: absolute;
  left: 16px;
  bottom: 170px;
  width: min(360px, calc(100vw - 32px));
  max-height: 280px;
  display: flex;
  flex-direction: column;
  background: rgba(18, 28, 36, 0.9);
  color: #d8e4ea;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
}

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

.log-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  letter-spacing: 0.08em;
}

.log-head strong {
  font-size: 10px;
  color: #8ec4d4;
}

.log-head #logCount {
  font-size: 10px;
  color: rgba(216, 228, 234, 0.5);
}

.log-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.log-actions button {
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: transparent;
  color: #d8e4ea;
  border-radius: 6px;
  width: 26px;
  height: 24px;
  cursor: pointer;
  font-size: 12px;
}

.log-actions button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.log-list {
  overflow-y: auto;
  padding: 6px 8px 10px;
  flex: 1;
  min-height: 120px;
}

.log-row {
  display: grid;
  grid-template-columns: 72px 40px 1fr;
  gap: 6px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  line-height: 1.35;
  word-break: break-all;
}

.log-t {
  color: rgba(216, 228, 234, 0.4);
  font-size: 10px;
}

.log-lv {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.log-info .log-lv { color: #8ec4d4; }
.log-event .log-lv { color: #f0c15a; }
.log-warn .log-lv { color: #e8a070; }
.log-error .log-lv { color: #e07070; }
.log-debug .log-lv { color: #8a9aaa; }

.log-m {
  color: rgba(246, 241, 232, 0.88);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .intro-card h1 {
    font-size: 36px;
  }

  .district-bar {
    bottom: 108px;
  }

  .tour-bar {
    bottom: 155px;
  }

  .hint {
    display: none;
  }

  .toolbar {
    right: 10px;
  }

  .rail-item {
    min-width: 96px;
  }
}

/* —— v1 통합 수정 —— */
/* hidden 속성이 display:flex에 눌리던 v0 버그 수정 */
.tour-bar[hidden] {
  display: none;
}
/* 투어 랜드마크 설명 */
#tourDesc {
  display: block;
  font-size: 12px;
  font-style: normal;
  opacity: 0.75;
  max-width: 340px;
  line-height: 1.4;
  margin-top: 2px;
}

/* 모바일: 캔버스 제스처를 OrbitControls가 전유 */
#c {
  touch-action: none;
}
