:root {
  --ink: #e8e3d5;
  --accent: #c9c9d1;
  --panel: rgba(18, 22, 34, 0.72);
  --panel-border: rgba(200, 200, 210, 0.30);
  --gutter: clamp(12px, 2.5vw, 22px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #04060c;
}

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  cursor: grab;
  touch-action: none;
}

#sky:active { cursor: grabbing; }


/* ---- 右侧缩放滑块（iOS 透明毛玻璃） ---- */
#zoom-slider {
  position: fixed;
  right: var(--gutter);
  bottom: calc(var(--gutter) + 340px);
  width: 28px;
  height: 36vh;
  cursor: pointer;
  touch-action: none;
  z-index: 20;
}

.zs-track {
  position: absolute;
  left: 50%;
  top: 8px;
  bottom: 8px;
  transform: translateX(-50%);
  width: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
}

.zs-thumb {
  position: absolute;
  left: 50%;
  top: 0;
  width: 20px;
  height: 20px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
}

/* ---- 右下角控制区（位于滑块下方） ---- */
#controls {
  position: fixed;
  right: var(--gutter);
  bottom: calc(var(--gutter) + env(safe-area-inset-bottom, 0px));
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

/* 统一右下角所有开关的字体大小与毛玻璃质感 */
.grid-toggle,
#term-toggle {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--ink);
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 2px 10px rgba(0,0,0,0.35);
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease, background .2s ease, color .2s ease;
}

.grid-toggle {
  padding: 7px 11px;
  border-radius: 999px;
  opacity: 0.82;
}

.grid-toggle.on {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(200, 200, 210, 0.14);
  opacity: 1;
}

.grid-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 0 14px rgba(200, 200, 210, 0.25);
}

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

#term-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: clamp(32px, 5vh, 38px);
  padding: 0 clamp(12px, 1.6vw, 16px);
  border-radius: 999px;
}

#term-toggle:hover {
  border-color: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 0 16px rgba(200, 200, 210, 0.25);
}

#term-toggle:active { transform: scale(0.97); }

.term-toggle-label { line-height: 1; }

.term-toggle-switch {
  position: relative;
  width: 26px;
  height: 14px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(255,255,255,0.16);
}

.term-toggle-switch i {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  transition: left .2s ease;
}

#term-toggle.ancient .term-toggle-switch i { left: 14px; }
#term-toggle.ancient .term-toggle-label { color: var(--accent); }

/* ---- 星座搜索（替换式输入栏） ---- */
#search-bar {
  position: fixed;
  right: var(--gutter);
  bottom: calc(var(--gutter) + 300px);
  z-index: 21;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

#toggle-search {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 1px solid var(--panel-border);
  border-radius: 50%;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
}

#toggle-search .icon {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  display: block;
}

#search-input {
  width: 0;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px 0 0 999px;
  background: var(--panel);
  color: var(--ink);
  font-size: 12px;
  outline: none;
  opacity: 0;
  transition: width .25s ease, opacity .2s ease, padding .25s ease, border-color .2s ease;
}

#search-input::placeholder { color: rgba(232, 227, 213, 0.5); }

#search-go {
  width: 0;
  height: 30px;
  padding: 0;
  border: none;
  background: var(--accent);
  color: #0a0c12;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  overflow: hidden;
  border-radius: 0 999px 999px 0;
  opacity: 0;
  transition: width .25s ease, opacity .2s ease;
}

#search-bar.open #search-input {
  width: 150px;
  padding: 0 12px;
  border-color: var(--panel-border);
  opacity: 1;
}

#search-bar.open #search-go {
  width: 28px;
  opacity: 1;
}

#search-bar.open #toggle-search {
  display: none;
}

#search-input.err { animation: search-shake .3s ease; }

@keyframes search-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* ---- 顶部菜单栏（液体玻璃特效） ---- */
#menu {
  position: fixed;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px;
  border-radius: 999px;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: 2px solid rgba(215, 220, 232, 0.45);
  box-shadow: 0 0 12px rgba(205, 212, 228, 0.35), 0 0 28px rgba(205, 212, 228, 0.18), 0 0 48px rgba(205, 212, 228, 0.10);
  overflow: hidden;
  transition: opacity .8s ease, transform .8s ease;
}

#menu.hide {
  opacity: 0;
  transform: translate(-50%, -14px) scale(0.85);
  pointer-events: none;
}

#menu::before {
  display: none;
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: 0.05;
  pointer-events: none;
}

#menu::after {
  display: none;
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(115deg, transparent 20%, rgba(255,255,255,0.18) 42%, rgba(255,255,255,0.04) 52%, transparent 64%);
  background-size: 260% 100%;
  animation: liquid-sheen 5.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes liquid-sheen {
  0% { background-position: 220% 0; }
  100% { background-position: -80% 0; }
}

.menu-item {
  position: relative;
  padding: 7px 48px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.06em;
  transition: background .2s ease, color .2s ease;
}

.menu-item:hover { background: rgba(255,255,255,0.14); }
.menu-item.active { background: rgba(255,255,255,0.18); color: var(--accent); }

/* ---- 首页文案 ---- */
#home-intro {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 15;
  width: min(840px, 92vw);
  text-align: center;
  pointer-events: none;
}

#home-intro p {
  margin: 0;
  font-size: clamp(18px, 2.1vw, 23px);
  line-height: 2.1;
  letter-spacing: 0.1em;
  color: rgba(232, 227, 213, 0.94);
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.75), 0 0 10px rgba(0, 0, 0, 0.6);
}

#home-intro .sign {
  margin-top: 18px;
  text-align: right;
  padding-right: 4em;
  font-size: clamp(18px, 2.1vw, 23px);
  font-weight: 400;
  letter-spacing: 0.1em;
  color: rgba(232, 227, 213, 0.94);
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.75), 0 0 10px rgba(0, 0, 0, 0.6);
}

.hidden { display: none !important; }

/* ---- 返回按钮（右上角） ---- */
#back-btn {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 30;
  padding: 9px 18px;
  border-radius: 999px;
  border: none;
  background: rgba(235, 238, 244, 0.92);
  color: #10131c;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.35), 0 0 20px rgba(205, 212, 228, 0.5);
  opacity: 0;
  transform: translateX(24px);
  pointer-events: none;
  transition: opacity .8s ease, transform .8s ease;
}

#back-btn.show {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

#back-btn:hover { background: #ffffff; }

/* 右侧控件仅在观星页显示 */
#zoom-slider,
#controls,
#search-bar {
  opacity: 0;
  pointer-events: none;
  transition: opacity .5s ease;
}
body.observe #zoom-slider,
body.observe #controls,
body.observe #search-bar {
  opacity: 1;
  pointer-events: auto;
}

/* ---- 时间选择器 ---- */
#time-picker {
  position: fixed;
  right: var(--gutter);
  bottom: calc(var(--gutter) + 52px);
  z-index: 22;
  opacity: 0;
  pointer-events: none;
  transform: translateX(20px);
  transition: opacity .25s ease, transform .25s ease;
}
#time-picker.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}
.tp-row {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  box-shadow: 0 2px 14px rgba(0,0,0,0.4);
}
#time-picker select {
  width: 52px;
  height: 24px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: rgba(10,12,18,0.7);
  color: var(--ink);
  font-size: 11px;
  text-align: center;
  outline: none;
  cursor: pointer;
}
#time-picker select:focus { border-color: var(--accent); }
.tp-label {
  font-size: 10px;
  color: var(--ink);
  opacity: 0.8;
}
#tp-go {
  margin-left: 4px;
  padding: 4px 12px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #0a0c12;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
#tp-go:hover { background: #fff; }
