:root {
  --bg: #04060f;
  --panel: rgba(17, 24, 46, 0.9);
  --panel-line: rgba(150, 170, 230, 0.26);
  --text: #f1f4ff;
  --text-dim: #b4bfe0;
  --accent: #4d6ff0;
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  --edge: 12px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

#app {
  position: fixed;
  inset: 0;
}

#gl {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#sky {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#sky.dragging { cursor: grabbing; }

button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible {
  outline: 2px solid #a9baff;
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* 왼쪽 위: 장소, 날짜와 시각, 하늘 상태 한 줄. */
.top {
  position: absolute;
  top: calc(var(--edge) + env(safe-area-inset-top));
  left: calc(var(--edge) + env(safe-area-inset-left));
  right: calc(var(--edge) + 64px + env(safe-area-inset-right));
  pointer-events: none;
}
.where-when {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
#place-button {
  pointer-events: auto;
  min-height: 40px;
  padding: 0 14px 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--panel-line);
  border-radius: 20px;
  background: var(--panel);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
#place-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}
#place-button:hover { border-color: rgba(170, 188, 255, 0.6); }
#place-button[aria-expanded="true"] {
  background: var(--accent);
  border-color: var(--accent);
}
#clock {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 6px var(--bg), 0 0 12px var(--bg);
}
#condition {
  margin: 8px 0 0 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  text-shadow: 0 0 6px var(--bg), 0 0 12px var(--bg);
}

/* 오른쪽: 조작 버튼 */
.tools {
  position: absolute;
  top: calc(var(--edge) + env(safe-area-inset-top));
  right: calc(var(--edge) + env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tools button {
  width: 52px;
  height: 52px;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  background: var(--panel);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.tools svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tools button:hover { border-color: rgba(170, 188, 255, 0.6); }
.tools button:active { background: rgba(40, 54, 100, 0.95); }
.tools button[aria-expanded="true"] {
  background: var(--accent);
  border-color: var(--accent);
}

/* 펼침 패널. 표시 설정은 "표시" 버튼 옆에, 장소는 장소 버튼 아래에 펼쳐진다. */
.panel {
  position: absolute;
  padding: 6px;
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  background: var(--panel);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.panel[hidden] { display: none; }
#layers-panel {
  top: calc(var(--edge) + env(safe-area-inset-top));
  right: calc(var(--edge) + 60px + env(safe-area-inset-right));
  width: min(260px, calc(100vw - 2 * var(--edge) - 60px));
}
#place-panel {
  top: calc(var(--edge) + 48px + env(safe-area-inset-top));
  left: calc(var(--edge) + env(safe-area-inset-left));
  width: min(320px, calc(100vw - 2 * var(--edge)));
  max-height: calc(100% - 2 * var(--edge) - 60px - env(safe-area-inset-top));
  overflow-y: auto;
}
.panel h2 {
  margin: 8px 10px 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
}
.panel button[role="switch"], .panel button.wide {
  width: 100%;
  min-height: 46px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.panel button:hover { background: rgba(255, 255, 255, 0.07); }
.panel button.wide {
  border: 1px solid var(--panel-line);
  justify-content: center;
}
.panel button.wide svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
.panel button:disabled { opacity: 0.45; cursor: default; }
#locate-message {
  margin: 0;
  padding: 0 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
}
#locate-message:not(:empty) { padding: 8px 10px 2px; }
.cities {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 8px;
}
.cities button {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.panel .name { flex: 1; }
.panel .credit {
  margin: 6px 10px 8px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-dim);
}
.panel kbd {
  padding: 1px 6px;
  border: 1px solid var(--panel-line);
  border-radius: 5px;
  font: 600 11px/1.5 var(--font);
  color: var(--text-dim);
}
/* 키보드가 없는 기기에서는 단축키 표시를 숨긴다. */
@media (hover: none) {
  .panel kbd { display: none; }
}
.switch {
  flex: none;
  position: relative;
  width: 40px;
  height: 24px;
  border-radius: 12px;
  background: rgba(150, 165, 210, 0.3);
  transition: background 0.15s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
[aria-checked="true"] .switch { background: var(--accent); }
[aria-checked="true"] .switch::after { transform: translateX(16px); }
@media (prefers-reduced-motion: reduce) {
  .switch, .switch::after { transition: none; }
}

#message {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--panel);
  color: var(--text-dim);
  font-size: 15px;
  text-align: center;
  max-width: 80%;
}
#message.error { color: #ffb4a8; }

#debug {
  position: absolute;
  left: 12px;
  top: 96px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #cfe3ff;
  font: 12px/1.5 Consolas, "D2Coding", monospace;
  pointer-events: none;
  white-space: pre;
}

/* 아래: 시간 막대. 낮 12시부터 다음 날 낮 12시까지를 끌어서 본다. */
.timebar {
  position: absolute;
  left: 50%;
  bottom: calc(var(--edge) + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(680px, calc(100% - 2 * var(--edge)));
  padding: 10px 14px 8px;
  border: 1px solid var(--panel-line);
  border-radius: 18px;
  background: var(--panel);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.time-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.timebar button {
  min-height: 40px;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.timebar button:hover { border-color: rgba(170, 188, 255, 0.6); }
.timebar button.icon {
  width: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.timebar button.icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* 날짜: 글자 위에 투명한 날짜 입력란을 겹쳐, 누르면 달력이 열리게 한다. */
.night {
  position: relative;
  min-height: 40px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.night input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.night:focus-within {
  outline: 2px solid #a9baff;
  outline-offset: 2px;
  border-radius: 8px;
}
#time-readout {
  margin-left: auto;
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
#now-button {
  margin-left: 8px;
  padding: 0 14px;
}
/* "지금"을 따라가는 중이면 채워서 표시한다. */
#now-button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
}

.slider-wrap {
  position: relative;
  margin-top: 8px;
  padding-bottom: 20px;
}
#time-slider {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 28px;
  margin: 0;
  background: none;
  cursor: pointer;
  --track: #141a36;
}
#time-slider::-webkit-slider-runnable-track {
  height: 12px;
  border-radius: 6px;
  background: var(--track);
}
#time-slider::-moz-range-track {
  height: 12px;
  border-radius: 6px;
  background: var(--track);
}
#time-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  margin-top: -6px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}
#time-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}
.ticks {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 18px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
}
.ticks span {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}
.ticks span:first-child { transform: none; margin-left: -12px; }
.ticks span:last-child { transform: translateX(-100%); margin-left: 12px; }
@media (max-width: 420px) {
  .ticks span:first-child, .ticks span:last-child { display: none; }
  #time-readout { font-size: 20px; }
  #now-button { margin-left: 4px; padding: 0 10px; }
}
