@font-face {
  font-family: "Jinxuan Latte";
  src: url("./assets/fonts/jinxuan-latte-book.otf") format("opentype");
  font-display: swap;
}

:root {
  color-scheme: dark;
  font-family: "Jinxuan Latte", "Noto Serif TC", serif;
  --pearl: 238, 236, 247;
  --lavender: 181, 177, 224;
  --line: rgba(222, 223, 244, 0.14);
}

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

button {
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100svh;
  overflow: hidden;
  background: #071126;
}

.night-app {
  position: fixed;
  inset: 0;
  isolation: isolate;
  overflow: hidden;
  color: rgba(var(--pearl), 0.72);
}

.scene,
.scene-image,
.deep-shade,
.breath-glow,
.particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scene {
  z-index: -2;
  overflow: hidden;
  background: #071126;
}

.scene-image {
  inset: -5%;
  background: url("./assets/whale-dream.png") center 58% / cover no-repeat;
  filter: saturate(0.74) brightness(0.58) contrast(0.94);
  transform: scale(1.075);
  animation: water-drift 64s ease-in-out infinite alternate;
}

.deep-shade {
  background:
    radial-gradient(circle at 50% 43%, rgba(22, 30, 68, 0.04) 0 15%, rgba(4, 11, 28, 0.38) 62%, rgba(3, 8, 21, 0.72) 100%),
    linear-gradient(180deg, rgba(4, 9, 24, 0.18), rgba(4, 9, 24, 0.28) 54%, rgba(2, 8, 21, 0.66));
}

.surface-light {
  position: absolute;
  width: 18vw;
  height: 80vh;
  top: -33vh;
  left: 31%;
  background: linear-gradient(180deg, rgba(222, 214, 255, 0.14), rgba(162, 171, 236, 0.025) 65%, transparent);
  filter: blur(18px);
  transform: rotate(15deg);
  transform-origin: top;
  animation: light-sway 14s ease-in-out infinite alternate;
}

.surface-light-b {
  width: 11vw;
  left: 58%;
  opacity: 0.5;
  animation-delay: -8s;
}

.breath-glow {
  inset: 30% 20%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(149, 150, 217, 0.1), transparent 67%);
  animation: scene-breathe 8s ease-in-out infinite;
}

.particle {
  position: absolute;
  bottom: -4vh;
  border-radius: 50%;
  background: rgba(216, 211, 249, 0.58);
  box-shadow: 0 0 9px rgba(184, 182, 240, 0.4);
  animation: float-up linear infinite;
}

.screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(28px, env(safe-area-inset-top)) 28px max(28px, env(safe-area-inset-bottom));
  visibility: hidden;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 1.2s ease, transform 1.2s ease, visibility 1.2s;
}

.screen.is-visible {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

.corner-button {
  position: absolute;
  top: max(18px, calc(env(safe-area-inset-top) + 10px));
  z-index: 3;
  min-width: 34px;
  min-height: 34px;
  padding: 7px;
  border: 0;
  background: transparent;
  color: rgba(var(--pearl), 0.22);
  font-size: 11px;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: color 0.5s ease;
}

.corner-button:hover {
  color: rgba(var(--pearl), 0.48);
}

.corner-left {
  left: max(15px, env(safe-area-inset-left));
}

.corner-right {
  right: max(15px, env(safe-area-inset-right));
  font-family: system-ui, sans-serif;
  font-size: 17px;
  font-weight: 200;
}

.landing-copy,
.calm-panel,
.page-panel {
  width: min(100%, 420px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.landing-copy {
  margin-top: -4vh;
}

.eyebrow {
  color: rgba(var(--pearl), 0.38);
  font-size: 13px;
  letter-spacing: 0.14em;
}

.wake-button {
  position: relative;
  width: 148px;
  height: 148px;
  margin-top: 34px;
  border: 1px solid rgba(224, 223, 246, 0.21);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(187, 184, 227, 0.12), rgba(118, 126, 185, 0.035) 62%, transparent 72%);
  box-shadow: inset 0 0 30px rgba(201, 197, 236, 0.03), 0 0 48px rgba(109, 122, 194, 0.06);
  cursor: pointer;
  transition: border-color 0.6s ease, background 0.6s ease, transform 0.6s ease;
}

.wake-button:active {
  transform: scale(0.98);
}

.wake-button:hover {
  border-color: rgba(224, 223, 246, 0.34);
  background: radial-gradient(circle, rgba(187, 184, 227, 0.17), rgba(118, 126, 185, 0.04) 62%, transparent 72%);
}

.wake-ring {
  position: absolute;
  inset: -1px;
  border: 1px solid rgba(221, 219, 245, 0.15);
  border-radius: 50%;
  animation: wake-ripple 6s ease-out infinite;
}

.wake-ring-b {
  animation-delay: 3s;
}

.wake-label {
  position: relative;
  color: rgba(var(--pearl), 0.82);
  font-size: 20px;
  letter-spacing: 0.24em;
  padding-left: 0.24em;
}

.whisper {
  margin-top: 26px;
  color: rgba(var(--pearl), 0.34);
  font-size: 13px;
  letter-spacing: 0.12em;
}

.landing-nav {
  position: absolute;
  bottom: max(30px, calc(env(safe-area-inset-bottom) + 18px));
  display: flex;
  align-items: center;
  gap: 15px;
}

.text-button,
.quiet-button,
.return-button,
.back-button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.text-button {
  padding: 10px 5px;
  color: rgba(var(--pearl), 0.34);
  font-size: 12px;
  letter-spacing: 0.13em;
}

.text-button.faint {
  color: rgba(var(--pearl), 0.21);
}

.nav-divider {
  width: 1px;
  height: 12px;
  background: var(--line);
}

.calm-panel {
  margin-top: -5vh;
}

.main-line {
  color: rgba(var(--pearl), 0.76);
  font-size: 20px;
  letter-spacing: 0.24em;
  padding-left: 0.24em;
  line-height: 1.8;
  text-align: center;
  text-shadow: 0 2px 18px rgba(2, 6, 18, 0.7);
}

.breathing-orb {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  margin-top: 30px;
  border: 1px solid rgba(211, 208, 241, 0.12);
  border-radius: 50%;
  animation: orb-breathe 7s ease-in-out infinite;
}

.breathing-orb span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(222, 219, 246, 0.56);
  box-shadow: 0 0 20px 5px rgba(170, 169, 225, 0.14);
}

.soft-line {
  margin-top: 28px;
  color: rgba(var(--pearl), 0.38);
  font-size: 13px;
  letter-spacing: 0.14em;
  line-height: 2.1;
  text-align: center;
}

.delayed {
  animation: gentle-appear 2.4s 1.4s both;
}

.now-playing {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 34px;
  color: rgba(var(--pearl), 0.34);
  font-size: 12px;
  letter-spacing: 0.13em;
}

.playing-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(210, 204, 239, 0.6);
  box-shadow: 0 0 10px rgba(195, 190, 240, 0.45);
  animation: dot-pulse 3s ease-in-out infinite;
}

.playing-dot.blue {
  background: rgba(155, 188, 231, 0.7);
}

.quiet-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 35px;
  color: rgba(var(--pearl), 0.16);
}

.quiet-button {
  padding: 9px;
  color: rgba(var(--pearl), 0.32);
  font-size: 12px;
  letter-spacing: 0.12em;
}

.ambient-pause {
  margin-top: 20px;
  color: rgba(var(--pearl), 0.22);
}

.sound-picker {
  display: flex;
  gap: 8px;
  margin-top: 34px;
  padding: 4px;
  border: 1px solid rgba(222, 221, 245, 0.09);
  border-radius: 99px;
  background: rgba(9, 15, 37, 0.22);
  backdrop-filter: blur(12px);
}

.sound-button {
  min-width: 66px;
  padding: 8px 14px;
  border: 0;
  border-radius: 99px;
  background: transparent;
  color: rgba(var(--pearl), 0.28);
  font-size: 12px;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: background 0.5s ease, color 0.5s ease;
}

.sound-button.is-active {
  background: rgba(221, 220, 246, 0.09);
  color: rgba(var(--pearl), 0.65);
}

.return-button {
  margin-top: 38px;
  padding: 9px;
  color: rgba(var(--pearl), 0.19);
  font-size: 11px;
  letter-spacing: 0.12em;
}

.scroll-screen {
  align-items: start;
  overflow-y: auto;
}

.page-panel {
  align-items: stretch;
  padding-top: 9vh;
  padding-bottom: 36px;
}

.page-header h1 {
  margin-top: 10px;
  color: rgba(var(--pearl), 0.74);
  font-size: 23px;
  font-weight: 400;
  letter-spacing: 0.2em;
}

.story-list {
  display: grid;
  gap: 10px;
  margin-top: 34px;
}

.story-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 18px 18px;
  border: 1px solid rgba(225, 222, 246, 0.1);
  border-radius: 14px;
  background: linear-gradient(110deg, rgba(218, 214, 246, 0.075), rgba(117, 126, 181, 0.025));
  color: rgba(var(--pearl), 0.52);
  font-size: 14px;
  letter-spacing: 0.1em;
  text-align: left;
  cursor: pointer;
  backdrop-filter: blur(15px);
}

.story-card i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(223, 219, 248, 0.36);
}

.pill-button {
  align-self: center;
  margin-top: 28px;
  padding: 10px 22px;
  border: 1px solid rgba(225, 222, 246, 0.12);
  border-radius: 99px;
  background: rgba(218, 214, 246, 0.045);
  color: rgba(var(--pearl), 0.4);
  font-size: 12px;
  letter-spacing: 0.13em;
  cursor: pointer;
}

.back-button {
  align-self: center;
  margin-top: 30px;
  padding: 10px;
  color: rgba(var(--pearl), 0.29);
  font-size: 12px;
  letter-spacing: 0.14em;
}

.settings-panel fieldset {
  margin-top: 34px;
  border: 0;
}

.settings-panel legend {
  margin-bottom: 12px;
  color: rgba(var(--pearl), 0.37);
  font-size: 12px;
  letter-spacing: 0.13em;
}

.setting-note {
  margin: -4px 0 13px;
  color: rgba(var(--pearl), 0.23);
  font-size: 11px;
  letter-spacing: 0.1em;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segment {
  padding: 10px 14px;
  border: 1px solid rgba(225, 222, 246, 0.09);
  border-radius: 10px;
  background: rgba(218, 214, 246, 0.035);
  color: rgba(var(--pearl), 0.31);
  font-size: 12px;
  letter-spacing: 0.1em;
  cursor: pointer;
}

.segment.is-active {
  border-color: rgba(225, 222, 246, 0.24);
  background: rgba(218, 214, 246, 0.11);
  color: rgba(var(--pearl), 0.68);
}

.segment.is-previewing {
  box-shadow: 0 0 0 1px rgba(225, 222, 246, 0.12), 0 0 22px rgba(168, 169, 222, 0.12);
}

@keyframes water-drift {
  from { transform: scale(1.075) translate3d(-0.55%, 0, 0); }
  to { transform: scale(1.075) translate3d(0.55%, -0.12%, 0); }
}

@keyframes light-sway {
  from { transform: rotate(11deg) translateX(-12px); opacity: 0.44; }
  to { transform: rotate(19deg) translateX(12px); opacity: 0.76; }
}

@keyframes scene-breathe {
  0%, 100% { opacity: 0.35; transform: scale(0.92); }
  50% { opacity: 0.8; transform: scale(1.16); }
}

@keyframes float-up {
  0% { transform: translate3d(0, 0, 0); opacity: 0; }
  12% { opacity: 0.55; }
  88% { opacity: 0.35; }
  100% { transform: translate3d(10px, -108vh, 0); opacity: 0; }
}

@keyframes wake-ripple {
  0% { transform: scale(0.8); opacity: 0; }
  22% { opacity: 0.6; }
  100% { transform: scale(1.55); opacity: 0; }
}

@keyframes orb-breathe {
  0%, 100% { transform: scale(0.88); opacity: 0.52; }
  50% { transform: scale(1.13); opacity: 0.94; }
}

@keyframes dot-pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.85); }
  50% { opacity: 0.9; transform: scale(1.15); }
}

@keyframes gentle-appear {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 700px) {
  .scene-image {
    background-position: center 54%;
  }

  .landing-copy,
  .calm-panel {
    margin-top: -8vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
