:root {
  --bg-0: #000000;
  --bg-1: #000000;
  --text: #f0f2f7;
  --muted: #b5bccd;
  --line: rgba(240, 242, 247, 0.28);
  --line-strong: rgba(240, 242, 247, 0.64);
  --accent: #ffd98d;
  --ui-surface: rgba(0, 0, 0, 0.76);
  --ui-surface-strong: rgba(0, 0, 0, 0.9);
  --ui-surface-hover: rgba(20, 20, 20, 0.86);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  background-color: var(--bg-0);
  background: #000;
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  overscroll-behavior: none;
}

#starfield {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.options-toggle {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 6;
  width: 2.15rem;
  height: 2.15rem;
  border: 1px solid rgba(240, 242, 247, 0.28);
  border-radius: 0.5rem;
  background: var(--ui-surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
}

.options-toggle:hover {
  border-color: rgba(240, 242, 247, 0.52);
  background: var(--ui-surface-hover);
}

.options-panel {
  position: fixed;
  top: 3.2rem;
  left: 0.75rem;
  z-index: 6;
  min-width: 11rem;
  border: 1px solid rgba(240, 242, 247, 0.22);
  border-radius: 0.6rem;
  background: var(--ui-surface-strong);
  padding: 0.55rem 0.65rem;
  backdrop-filter: blur(6px);
}

.options-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.84rem;
  color: var(--text);
}

.options-item + .options-item {
  margin-top: 0.4rem;
}

.shortcut-hint {
  color: rgba(240, 242, 247, 0.56);
}

.options-item--sub {
  justify-content: space-between;
  gap: 0.75rem;
}

.options-item--sub select {
  min-width: 6.9rem;
  border: 1px solid rgba(240, 242, 247, 0.24);
  border-radius: 0.4rem;
  background: var(--ui-surface);
  color: var(--text);
  font: inherit;
  font-size: 0.79rem;
  padding: 0.22rem 0.38rem;
}

.options-item--sub select:disabled {
  opacity: 0.5;
}

.options-info {
  margin-top: 0.58rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(240, 242, 247, 0.16);
  display: grid;
  gap: 0.24rem;
  font-size: 0.73rem;
  line-height: 1.35;
}

.options-info__line {
  margin: 0 0 0.1rem;
  color: rgba(240, 242, 247, 0.76);
}

.options-info a {
  color: rgba(189, 210, 238, 0.88);
  text-decoration: none;
}

.options-info a:hover {
  color: rgba(215, 233, 255, 0.96);
  text-decoration: underline;
}

.app {
  position: relative;
  z-index: 1;
  width: 100vw;
  margin: 0;
  padding: 1rem 0.75rem;
  height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 0.8rem;
}

body.controls-right .app {
  grid-template-rows: 1fr auto;
}

.app__header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  letter-spacing: 0.04em;
  font-weight: 600;
}

.app__header p {
  margin: 0.4rem 0;
  color: var(--muted);
}

.timestamp {
  margin: 0.1rem 0 0;
  font-size: 0.92rem;
  text-align: center;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.chart {
  position: relative;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  touch-action: none;
}

.chart-wave {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.86;
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0, 0, 0, 0.85) 18%,
    rgba(0, 0, 0, 0.85) 82%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0, 0, 0, 0.85) 18%,
    rgba(0, 0, 0, 0.85) 82%,
    transparent 100%
  );
}

body.flip-mode .chart-wave {
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0%,
    rgba(0, 0, 0, 0.85) 18%,
    rgba(0, 0, 0, 0.85) 82%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to right,
    transparent 0%,
    rgba(0, 0, 0, 0.85) 18%,
    rgba(0, 0, 0, 0.85) 82%,
    transparent 100%
  );
}

.axis {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 2px;
  z-index: 3;
}

.axis-line {
  height: 2px;
  width: 100%;
  background: linear-gradient(90deg, transparent, var(--line-strong), transparent);
}

body.flip-mode .axis {
  top: 0;
  bottom: 0;
  left: 50%;
  right: auto;
  width: 2px;
  height: auto;
  transform: translateX(-50%);
}

body.flip-mode .axis-line {
  width: 2px;
  height: 100%;
  background: linear-gradient(180deg, transparent, var(--line-strong), transparent);
}

.zodiac-band {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 2;
}

.zodiac-tick {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 1.8rem;
  background: var(--line);
}

.zodiac-tick--h {
  left: 50%;
  top: 0;
  transform: translate(-50%, -50%);
  width: 1.8rem;
  height: 1px;
}

.zodiac-label {
  position: absolute;
  top: calc(50% - 44px);
  transform: translateX(-50%);
  font-size: clamp(1.45rem, 2.6vw, 2rem);
  color: rgba(240, 242, 247, 0.9);
  font-family: "Noto Sans Symbols 2", "Segoe UI Symbol", "Apple Symbols", serif;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}

.zodiac-label--v {
  left: calc(50% - 42px);
  top: 0;
  transform: translate(-100%, -50%);
  text-align: right;
}

.planet-layer {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 4;
  pointer-events: none;
}

.planet {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  display: block;
  pointer-events: none;
}

.planet__node {
  width: 31px;
  height: 31px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--planet-color, #f0f2f7) 28%, #060912 72%);
  color: #f4f8ff;
  display: grid;
  place-items: center;
  font-size: 1.69rem;
  line-height: 1;
  font-weight: 600;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--planet-color, #f0f2f7) 62%, rgba(255, 255, 255, 0.18) 38%),
    0 0 18px color-mix(in srgb, var(--planet-color, #f0f2f7) 30%, transparent);
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.72),
    0 0 8px rgba(255, 255, 255, 0.18);
  font-family: "Noto Sans Symbols 2", "Segoe UI Symbol", "Apple Symbols", serif;
}

.planet__glyph {
  display: block;
  line-height: 1;
  transform: translate(0.03em, 0.04em);
}

.planet--sun .planet__node {
  width: 55px;
  height: 55px;
  font-size: 1.82rem;
  background: radial-gradient(circle at 36% 34%, #fff8d9, var(--accent));
  color: #382300;
  box-shadow:
    0 0 0 2px rgba(255, 217, 141, 0.3),
    0 0 30px 0 rgba(255, 206, 117, 0.75);
}

/* Eclipse awareness: visual cues when Moon is in solar or lunar eclipse */
.planet--solar-eclipse .planet__node {
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--planet-color, #d6deff) 62%, rgba(255, 255, 255, 0.18) 38%),
    0 0 18px color-mix(in srgb, var(--planet-color, #d6deff) 30%, transparent),
    0 0 0 2px rgba(255, 200, 100, 0.5),
    0 0 12px rgba(255, 180, 80, 0.4);
}

.planet--lunar-eclipse .planet__node {
  background: color-mix(in srgb, #a04020 24%, #060912 76%);
  box-shadow:
    0 0 0 1px rgba(140, 60, 40, 0.5),
    0 0 18px rgba(120, 50, 30, 0.4);
}

.planet__label {
  position: absolute;
  top: 46px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  color: var(--muted);
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1;
  padding: 0.1rem 0.25rem;
  border-radius: 0.25rem;
  background: rgba(4, 6, 10, 0.72);
}

#trend-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.time-controls {
  margin-top: 0;
  display: grid;
  grid-template-columns: repeat(13, minmax(0, 1fr));
  gap: 0.55rem;
}

body.controls-right .time-controls {
  position: fixed;
  right: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  margin: 0;
  width: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.time-btn {
  position: relative;
  border: 1px solid rgba(240, 242, 247, 0.2);
  border-radius: 0.5rem;
  padding: 0.52rem 0.6rem;
  color: var(--text);
  background: var(--ui-surface);
  font: inherit;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  cursor: pointer;
}

body.controls-right .time-btn {
  min-width: 5.55rem;
  padding: 0.42rem 0.55rem;
  font-size: 0.82rem;
  text-align: left;
}

.time-btn:hover {
  border-color: rgba(240, 242, 247, 0.52);
  background: var(--ui-surface-hover);
}

.time-btn--step-active {
}

.time-btn--step-active::after {
  content: "";
  position: absolute;
  right: 0.48rem;
  top: 50%;
  width: 0.34rem;
  height: 0.34rem;
  border-radius: 50%;
  background: rgba(240, 242, 247, 0.58);
  transform: translateY(-50%);
  pointer-events: none;
}

.time-btn--now {
  border-color: rgba(255, 219, 149, 0.5);
  background: rgba(22, 16, 6, 0.72);
}

body.is-time-dragging {
  cursor: grabbing;
}

@media (max-width: 640px) {
  html,
  body {
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
  }

  .app {
    height: 100dvh;
    min-height: 100dvh;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto auto;
    margin: 0;
    padding: 0.8rem;
    gap: 0.8rem;
    overflow: hidden;
  }

  .chart {
    margin-top: 0;
    min-height: 0;
    padding: 4.6rem 0 5.4rem;
  }

  .zodiac-label {
    top: calc(50% - 38px);
  }

  .time-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body.controls-right .time-controls {
    position: static;
    right: auto;
    top: auto;
    transform: none;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.55rem;
    margin-top: 0;
  }

  body.controls-right .time-btn {
    min-width: 0;
    text-align: center;
    padding: 0.52rem 0.6rem;
    font-size: 0.92rem;
  }

  .planet__node {
    width: 29px;
    height: 29px;
    font-size: 1.61rem;
  }

  .planet--sun .planet__node {
    width: 49px;
    height: 49px;
    font-size: 1.56rem;
  }

  body.mobile-immersive .time-controls {
    display: none !important;
  }

  body.mobile-immersive .app {
    grid-template-rows: minmax(0, 1fr) auto;
    padding: max(0.45rem, env(safe-area-inset-top)) 0.6rem max(0.45rem, env(safe-area-inset-bottom));
    gap: 0.32rem;
  }

  body.mobile-immersive .chart {
    padding: 3.2rem 0 1.1rem;
  }

  body.mobile-immersive .timestamp {
    margin: 0;
  }
}
