:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  --text: rgba(248, 246, 240, 0.96);
  --muted: rgba(248, 246, 240, 0.66);
  --faint: rgba(248, 246, 240, 0.34);
  --focus: #f8e7c6;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: #101820;
}

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

button,
select,
textarea,
input {
  font: inherit;
}

button,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
select:focus-visible,
textarea:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
}

.app {
  position: relative;
  isolation: isolate;
  display: grid;
  min-height: 100svh;
  overflow: hidden;
  color: var(--text);
  background: #687174;
}

.scene,
.weather,
.shade,
.loading-veil {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.scene {
  z-index: -4;
  opacity: 0;
  background-position: center;
  background-size: cover;
  filter: blur(22px) saturate(0.55);
  transform: scale(1.015);
  transition: background-image 900ms ease, filter 3000ms ease, opacity 2600ms ease;
  animation: breathe 18s ease-in-out infinite alternate;
}

.app[data-scene="night-rain"] .scene {
  background-image: url("/assets/night-rain.webp");
}

.app[data-scene="night-clear"] .scene {
  background-image: url("/assets/night-clear.webp");
}

.app[data-scene="day-clear"] .scene {
  background-image: url("/assets/day-clear.webp");
}

.app[data-scene="day-overcast"] .scene {
  background-image: url("/assets/day-overcast.webp");
}

.weather {
  z-index: -3;
  opacity: 0;
  pointer-events: none;
  transition: opacity 2200ms ease 600ms;
}

.shade {
  z-index: -2;
  opacity: 0;
  pointer-events: none;
  background: rgba(5, 9, 12, 0.12);
  transition: opacity 2200ms ease;
}

.loading-veil {
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 42%, rgba(196, 202, 201, 0.3), transparent 48%),
    linear-gradient(135deg, #747d7f, #505b5f);
  opacity: 1;
  transition: opacity 2600ms ease;
}

.app.context-ready .scene,
.app.context-ready .weather,
.app.context-ready .shade {
  opacity: 1;
}

.app.context-ready .scene {
  filter: blur(0) saturate(1);
}

.app.context-ready .loading-veil {
  opacity: 0;
}

.topbar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  align-self: start;
  width: 100%;
  padding: max(30px, env(safe-area-inset-top)) max(42px, env(safe-area-inset-right)) 0 max(42px, env(safe-area-inset-left));
}

.wordmark {
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  letter-spacing: 0.01em;
  text-decoration: none;
  text-shadow: 0 1px 16px rgba(0, 0, 0, 0.42);
}

.controls {
  display: flex;
  align-items: center;
  gap: 20px;
}

.language-control select,
.text-button,
.location-button,
.dialog-close {
  min-height: 44px;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.language-control select {
  max-width: 112px;
  padding: 0 4px;
  border-radius: 0;
  appearance: auto;
}

.text-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0;
}

.motion-state {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 0 9px rgba(248, 246, 240, 0.5);
}

.motion-toggle[aria-pressed="false"] .motion-state {
  background: var(--faint);
  box-shadow: none;
}

.greeting {
  position: absolute;
  top: 47%;
  left: 50%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(900px, calc(100% - 48px));
  text-align: center;
  transform: translate(-50%, -50%);
  transition: top 700ms cubic-bezier(0.22, 1, 0.36, 1);
}

.app.has-interaction .greeting {
  top: 42%;
}

.message-wrap {
  display: grid;
  min-height: 92px;
  place-items: center;
}

.message-wrap,
.context-line,
.progress {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 1600ms ease 900ms, transform 1800ms cubic-bezier(0.22, 1, 0.36, 1) 900ms;
}

.app.context-ready .message-wrap,
.app.context-ready .context-line,
.app.context-ready .progress {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.message {
  margin: 0;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
  font-size: clamp(38px, 4vw, 62px);
  font-weight: 400;
  line-height: 1.34;
  letter-spacing: 0.015em;
  text-wrap: balance;
  text-shadow: 0 2px 28px rgba(0, 0, 0, 0.68);
  transition: opacity 560ms ease, transform 560ms ease;
}

.message.changing {
  opacity: 0;
  transform: translateY(7px);
}

.message.acknowledgement-leaving {
  opacity: 0;
  transform: translateY(7px);
  transition-duration: 1050ms;
}

.message.acknowledgement-entering {
  animation: acknowledgement-in 1500ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.context-line {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 14px;
  min-height: 44px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 15px;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.72);
}

.location-button {
  padding: 0;
  text-decoration: underline;
  text-decoration-color: rgba(248, 246, 240, 0.32);
  text-underline-offset: 4px;
}

.progress {
  position: fixed;
  bottom: max(70px, env(safe-area-inset-bottom));
  left: 50%;
  display: flex;
  gap: 14px;
  margin-top: 0;
  transform: translate(-50%, 8px);
}

.app.context-ready .progress {
  transform: translate(-50%, 0);
}

.progress button {
  position: relative;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.progress button::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(248, 246, 240, 0.3);
  content: "";
  transform: translate(-50%, -50%);
  transition: width 250ms ease, background 250ms ease;
}

.progress button.active::after {
  width: 18px;
  border-radius: 999px;
  background: rgba(248, 246, 240, 0.92);
}

.reveal-panel[hidden] {
  display: none;
}

.reveal-panel {
  width: min(580px, 100%);
  max-height: 0;
  margin: 0 auto;
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px);
  transition: max-height 700ms cubic-bezier(0.22, 1, 0.36, 1),
    margin-top 700ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 480ms ease,
    transform 700ms cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal-panel.open {
  max-height: 430px;
  margin-top: 22px;
  opacity: 1;
  transform: translateY(0);
}

.choice-panel {
  position: absolute;
  top: calc(100% + 18px);
  left: 50%;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  width: max-content;
  max-width: 100%;
  margin: 0;
  transform: translate(-50%, 10px);
  transition: opacity 1400ms ease, transform 1400ms cubic-bezier(0.22, 1, 0.36, 1);
}

.choice-panel.open {
  max-height: 60px;
  margin: 0;
  transform: translate(-50%, 0);
}

.experience-button {
  min-height: 46px;
  padding: 0 22px;
  border-radius: 999px;
  cursor: pointer;
}

.experience-button-primary {
  border: 1px solid rgba(244, 234, 217, 0.92);
  color: #172027;
  background: #f4ead9;
}

.experience-button-secondary {
  border: 1px solid rgba(248, 246, 240, 0.34);
  color: var(--text);
  background: rgba(10, 17, 22, 0.2);
  backdrop-filter: blur(10px);
}

.note-form {
  display: grid;
  gap: 12px;
  text-align: left;
}

.panel-prompt,
.voice-kicker {
  margin: 0;
  color: rgba(248, 246, 240, 0.72);
  font-size: 14px;
  letter-spacing: 0.04em;
}

.note-form textarea {
  display: block;
  width: 100%;
  min-height: 98px;
  padding: 16px 18px;
  resize: none;
  border: 1px solid rgba(248, 246, 240, 0.3);
  border-radius: 14px;
  color: var(--text);
  background: rgba(10, 17, 22, 0.38);
  box-shadow: 0 12px 50px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(10px);
}

.note-form textarea::placeholder {
  color: rgba(248, 246, 240, 0.48);
}

.audience-choice {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 0;
  border: 0;
}

.audience-choice legend {
  width: 100%;
  margin-bottom: 8px;
  color: rgba(248, 246, 240, 0.68);
  font-size: 13px;
}

.audience-choice label {
  cursor: pointer;
}

.audience-choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.audience-choice span {
  display: grid;
  min-height: 42px;
  padding: 0 14px;
  place-items: center;
  border: 1px solid rgba(248, 246, 240, 0.2);
  border-radius: 11px;
  color: rgba(248, 246, 240, 0.66);
  background: rgba(10, 17, 22, 0.2);
  font-size: 13px;
  transition: border-color 240ms ease, color 240ms ease, background 240ms ease;
}

.audience-choice input:checked + span {
  border-color: rgba(248, 246, 240, 0.58);
  color: var(--text);
  background: rgba(248, 246, 240, 0.12);
}

.audience-choice input:focus-visible + span {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

.audience-hint {
  min-height: 18px;
  margin: -4px 0 0;
  color: rgba(248, 246, 240, 0.5);
  font-size: 12px;
}

.note-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 10px;
}

.privacy-hint {
  color: rgba(248, 246, 240, 0.5);
  font-size: 12px;
}

.voice-panel {
  padding: 20px 24px;
  border: 1px solid rgba(248, 246, 240, 0.2);
  border-radius: 18px;
  text-align: left;
  background: rgba(10, 17, 22, 0.26);
  backdrop-filter: blur(12px);
  transition: max-height 700ms cubic-bezier(0.22, 1, 0.36, 1),
    margin-top 700ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 280ms ease,
    transform 700ms cubic-bezier(0.22, 1, 0.36, 1);
}

.voice-panel blockquote {
  margin: 18px 0 12px;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
  font-size: clamp(19px, 2.2vw, 25px);
  line-height: 1.75;
}

.voice-context {
  margin: 0;
  color: rgba(248, 246, 240, 0.5);
  font-size: 12px;
}

.voice-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.voice-panel.changing blockquote,
.voice-panel.changing .voice-context {
  opacity: 0;
  transform: translateY(5px);
}

.voice-panel blockquote,
.voice-panel .voice-context {
  transition: opacity 280ms ease, transform 280ms ease;
}

.send-button,
.primary-button {
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  color: #172027;
  background: #f4ead9;
  cursor: pointer;
}

.send-button:disabled,
.primary-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.status {
  position: absolute;
  right: 24px;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 24px;
  z-index: 4;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  pointer-events: none;
}

.location-dialog {
  width: min(480px, calc(100% - 32px));
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  color: #f6f2e9;
  background: rgba(17, 25, 31, 0.96);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.48);
}

.location-dialog::backdrop {
  background: rgba(3, 8, 11, 0.68);
  backdrop-filter: blur(8px);
}

.dialog-close-row {
  display: flex;
  justify-content: flex-end;
  padding: 10px 16px 0;
}

.dialog-close {
  padding: 0;
}

.location-form {
  display: grid;
  gap: 12px;
  padding: 0 34px 34px;
}

.dialog-kicker {
  margin: 0;
  color: rgba(246, 242, 233, 0.52);
  font-family: Georgia, serif;
}

.location-form h2 {
  margin: 4px 0 0;
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: 30px;
  font-weight: 400;
}

.location-form > p:not(.dialog-kicker) {
  margin: 0 0 8px;
  color: rgba(246, 242, 233, 0.68);
  line-height: 1.7;
}

.location-form label {
  margin-top: 4px;
  color: rgba(246, 242, 233, 0.78);
  font-size: 14px;
}

.location-form input {
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
}

.location-form .primary-button {
  margin-top: 8px;
}

.location-form .precise-location-button {
  width: 100%;
  margin: 0;
}

.location-form .location-permission-status {
  min-height: 0;
  margin: -4px 0 0;
  color: rgba(246, 242, 233, 0.68);
  font-size: 12px;
}

.location-permission-status:empty {
  display: none;
}

.location-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(246, 242, 233, 0.48);
  font-size: 12px;
}

.location-divider::before,
.location-divider::after {
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
  content: "";
  flex: 1;
}

.location-form .dialog-privacy {
  margin-top: 8px;
  font-size: 12px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

noscript {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  padding: 24px;
  place-items: center;
  color: #f6f2e9;
  background: #101820;
}

@keyframes breathe {
  from { transform: scale(1.015); }
  to { transform: scale(1.045); }
}

@keyframes acknowledgement-in {
  from {
    opacity: 0;
    transform: translateY(9px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 700px) {
  .topbar {
    padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left));
  }

  .wordmark {
    font-size: 19px;
  }

  .controls {
    gap: 8px;
  }

  .language-control select {
    width: 76px;
    font-size: 14px;
  }

  .text-button {
    font-size: 14px;
  }

  .motion-state {
    display: none;
  }

  .greeting {
    width: calc(100% - 36px);
    top: 45%;
  }

  .app.has-interaction .greeting {
    top: 39%;
  }

  .message-wrap {
    min-height: 118px;
  }

  .message {
    font-size: clamp(32px, 9.4vw, 44px);
    line-height: 1.45;
  }

  .context-line {
    margin-top: 6px;
    font-size: 14px;
  }

  .progress {
    bottom: max(20px, env(safe-area-inset-bottom));
  }

  .reveal-panel.open {
    margin-top: 18px;
  }

  .choice-panel {
    flex-wrap: nowrap;
  }

  .choice-panel .experience-button {
    padding: 0 16px;
    font-size: 13px;
  }

  .voice-panel {
    padding: 18px;
  }

  .note-actions {
    align-items: flex-end;
  }

  .privacy-hint {
    max-width: 180px;
  }

  .location-form {
    padding: 0 24px 28px;
  }

  .scene {
    background-position: 54% center;
  }
}

@media (max-height: 650px) {
  .greeting {
    top: 46%;
  }

  .message-wrap {
    min-height: 72px;
  }

  .note-form textarea {
    min-height: 78px;
  }

  .app.has-interaction .greeting {
    top: 38%;
  }
}

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

.motion-off .scene {
  animation: none;
  transform: scale(1.015);
}
