:root {
  --text: #ffffff;
  --text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  background: #0b1020;
}

/* 三层结构：背景 → 效果 → 内容 */
#bg-layer,
#bg-layer-2,
#fx-layer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#bg-layer,
#bg-layer-2 {
  z-index: 0;
  background-size: cover;
  background-position: center;
  transition: opacity 0.8s ease, filter 0.6s ease;
}

#bg-layer-2 {
  opacity: 0;
}

#fx-layer {
  z-index: 1;
  pointer-events: none;
}

#daynight-overlay {
  position: absolute;
  inset: 0;
  z-index: 0;
  transition: background 2s ease;
}

/* 日月天空层：overlay 之上（日月不被夜色压暗）、天气粒子之下（雨雪落在日月之前） */
#sky {
  position: absolute;
  inset: 0;
  z-index: 1;
}

#sun,
#moon {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
  opacity: 0;
  will-change: transform;
  /* 位置由 rAF 每帧实时驱动，不再依赖 CSS 长过渡补间 */
  transition:
    opacity 1.4s ease,
    box-shadow 2s ease;
}

#sun {
  width: 84px;
  height: 84px;
  background: radial-gradient(circle,
      #fffdf0 0%,
      #fff3c0 30%,
      #ffd76a 55%,
      rgba(255, 190, 100, 0.55) 70%,
      rgba(255, 170, 80, 0) 78%);
}

#moon {
  width: 58px;
  height: 58px;
  overflow: hidden;
  background: radial-gradient(circle at 38% 36%,
      #fffef7 0%,
      #f0ebda 45%,
      #d8d2bd 78%,
      #c6c0aa 100%);
}

/* 月相：与月面同大的暗盘横向平移，被裁出的亮区即当前相位（明暗交界为圆弧） */
#moon-shadow {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, #0a0f28 0%, #070b1e 100%);
  opacity: 0.96;
  /* 月相由 rAF 每帧连续更新，无需长过渡 */
}

.stars {
  position: absolute;
  left: 0;
  top: 0;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 2s ease;
}

#stars-a {
  animation: twinkle 3.4s ease-in-out infinite;
}

#stars-b {
  animation: twinkle 4.9s ease-in-out infinite 1.2s;
}

@keyframes twinkle {
  50% {
    filter: brightness(0.5);
  }
}

/* 首次定位不播过渡，避免从 (0,0) 飞入 */
.sky-noanim {
  transition: none !important;
}

#weather-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
}

#content {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  gap: 28px;
  padding: 24px;
  text-shadow: var(--text-shadow);
}

/* 时钟 */
#clock {
  text-align: center;
  user-select: none;
}

#clock-time {
  font-size: clamp(48px, 9vw, 104px);
  font-weight: 300;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

#clock-date {
  margin-top: 8px;
  font-size: clamp(14px, 2vw, 20px);
  opacity: 0.85;
}

/* 左上角：农历 + 干支三柱徽标 */
#lunar-badge {
  position: fixed;
  left: 20px;
  top: 16px;
  z-index: 30;
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--text);
  opacity: 0.75;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  user-select: none;
  white-space: nowrap;
}

/* 徽标右侧：天气中文（含温度），点击跳 MSN 天气。
   竖线分隔仅在农历文本非空时出现：农历开关关闭时 span 为空，
   天气贴左显示，不留孤立间距与竖线（两者显隐已解耦） */
#lunar-weather {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  opacity: 0.95;
}

#lunar-text:not(:empty) + #lunar-weather {
  margin-left: 8px;
  padding-left: 10px;
  border-left: 1px solid currentColor;
}

#lunar-weather:hover {
  opacity: 1;
  text-decoration: underline;
}

/* 搜索 */
#search-form {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(620px, 90vw);
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  padding: 6px 8px 6px 16px;
}

#search-engine {
  font-size: 13px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  white-space: nowrap;
  cursor: pointer;
}

#search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 17px;
  padding: 10px 8px;
}

#search-input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

#search-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 360px;
  overflow-y: auto;
  margin: 0;
  padding: 8px 0;
  list-style: none;
  /* 随昼夜相位联动（--phase-panel 由 effects.js 的 applyDayNight 写入） */
  background-color: var(--phase-panel, rgba(20, 23, 34, 0.92));
  transition: background-color 2s ease;
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(24px);
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  z-index: 20;
}

#search-suggestions::-webkit-scrollbar {
  width: 6px;
}

#search-suggestions::-webkit-scrollbar-track {
  background: transparent;
}

#search-suggestions::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 3px;
}

#search-suggestions li {
  padding: 10px 18px 10px 38px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.1s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E");
  background-position: 14px center;
  background-repeat: no-repeat;
}

/* 高亮只由 JS 维护的 .active 决定（鼠标悬停也写入同一状态），避免出现两行高亮 */
#search-suggestions li.active {
  background-color: rgba(255, 255, 255, 0.12);
}

#search-suggestions[hidden] {
  display: none;
}

/* 天气 */
#weather {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 15px;
}

#weather-temp {
  font-size: 26px;
  font-weight: 500;
}

#weather-city {
  opacity: 0.8;
}

#poetry {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  font-size: initial;
  flex-direction: column;
  transition: opacity 0.6s ease;
}

#poetry.poetry-fade {
  opacity: 0;
}

#poetry .poetry-subtitle {
  font-size: small;
}

/* 快捷链接 */
#quicklinks {
  display: grid;
  grid-template-columns: repeat(auto-fill, 84px);
  gap: 18px;
  justify-content: center;
  max-width: min(620px, 92vw);
}

.ql-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 12px;
  padding: 8px 4px;
  border-radius: 12px;
  transition: background 0.15s ease, transform 0.15s ease;
}

.ql-item:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: translateY(-2px);
}

.ql-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background-color: rgba(255, 255, 255, 0.14);
  background-position: center;
  background-size: 60%;
  background-repeat: no-repeat;
  border: 1px solid rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.ql-name {
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: var(--text-shadow);
}

/* 右下角设置图标：仅图标，默认半透明，悬停清晰 */
#settings-btn {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  width: 40px;
  height: 40px;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text);
  opacity: 0.4;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#settings-btn:hover {
  opacity: 1;
  transform: scale(1.1);
}

#settings-btn svg {
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45));
}

#bg-toast {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  transition: opacity 0.2s;
}

#bg-toast.show {
  opacity: 1;
}

#bg-toast .spin {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: bg-spin 0.7s linear infinite;
}

@keyframes bg-spin {
  to {
    transform: rotate(360deg);
  }
}

#bottom-xianchuang {
  position: fixed;
  bottom: 0;
  width: 100%;
  height: 20px;
  z-index: 1;
  text-align: center;
  pointer-events: none;
  background-image: url(../images/xianchuang.svg);
  background-repeat: no-repeat;
  background-position: center;
}