/* ==========================================================================
   霞光预报样式表：按组件组织，每个组件内先写基础状态，再写媒体查询与交互状态。
   同一元素同一属性、同重要性同特异性的规则保持原有先后（调整时以计算样式快照验证）。
   ========================================================================== */

/* ---------- 令牌、主题与基础元素 ---------- */
/* Sky Letter tokens own paper, ink and type; these aliases serve retained dialogs. */
:root {
  color-scheme: light;
  --muted: var(--ink-muted, #625b4e);
  --faint: var(--ink-muted, #625b4e);
  --line-strong: #8c8372;
  --panel-solid: #131d28;
  --accent: #edb56f;
  --accent-hover: #f7c586;
  --status-success: #8fd687;
  --status-info: #9dcced;
  --status-warning: #ffcb99;
  --status-error: #ff9f98;
  --sky-top: var(--weather-clear-day-top, #9dbecb);
  --sky-mid: var(--weather-clear-day-mid, #c2d0cd);
  --sky-horizon: var(--weather-clear-day-bottom, #e5dcc0);
  --sky-glow: rgba(255, 220, 170, 0.16);
  --sky-cloud-opacity: 0;
  --sky-texture-opacity: 0.04;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --sun-x: 78%;
  --sun-y: 19%;
  --sun-elevation: 35;
  --precip-intensity: 0;
  --fx-density: 0;
  --twilight-warmth: 0;
  --clear-energy: 0.22;
  --precip-fog-boost: 0;
  --wind-strength: 0;
  --wind-direction: 0deg;
  --fog-density: 0;
  --wind-motion-add: 0vw;
  --wind-back-speed-cut: 0s;
  --wind-front-speed-cut: 0s;
  --wind-sweep-speed-cut: 0s;
  --fog-back-opacity: 0.28;
  --fog-front-opacity: 0.24;
  --fog-back-opacity-reduced: 0.1;
  --fog-front-opacity-reduced: 0.08;
  --strong-cloud-duration: 16s;
  --severe-cloud-duration: 11s;
  --atmosphere-intensity: 0.88;
  --atmosphere-motion-range: 7vw;
  --atmosphere-cloud-blur: 9px;
  --atmosphere-fog-blur: 18px;
  --atmosphere-fog-front-blur: 13px;
  --atmosphere-storm-travel: 0vw;
  --atmosphere-storm-speed-cut: 0s;
  --atmosphere-storm-sweep-opacity: 0;
  --atmosphere-storm-sweep-duration-cut: 0s;
  --atmosphere-sun-core: rgba(255, 226, 176, 0.22);
  --atmosphere-sun-ray: rgba(255, 218, 153, 0.11);
  --atmosphere-heat: rgba(255, 221, 170, 0.1);
  --atmosphere-night-glow: rgba(118, 158, 203, 0.13);
  --atmosphere-night-horizon: rgba(142, 168, 195, 0.07);
  --atmosphere-cloud-high: rgba(255, 255, 255, 0.46);
  --atmosphere-cloud-mid: rgba(225, 240, 250, 0.24);
  --atmosphere-cloud-low: rgba(90, 135, 170, 0.13);
  --sky-cloud-highlight: rgba(255, 255, 255, 0.55);
  --sky-cloud-body: rgba(225, 240, 250, 0.26);
  --sky-cloud-shade: rgba(75, 115, 150, 0.13);
  --atmosphere-fog-high: rgba(226, 234, 232, 0.23);
  --atmosphere-fog-mid: rgba(184, 198, 198, 0.17);
  --atmosphere-fog-low: rgba(85, 105, 111, 0.12);
  --atmosphere-rain-wash: rgba(7, 19, 29, 0.16);
  --atmosphere-snow-wash: rgba(222, 235, 240, 0.13);
  --atmosphere-hail-wash: rgba(92, 132, 158, 0.18);
  --atmosphere-lightning-core: rgba(224, 238, 255, 0.54);
  --atmosphere-lightning-wash: rgba(163, 191, 222, 0.2);
  --atmosphere-wind-sweep: rgba(218, 235, 240, 0.09);
  --radius-control: 12px;
  --radius-card: 18px;
  --radius-pill: 999px;
  --font-serif-title: var(--font-hand, "Xiaolai", sans-serif);
  --font-serif-num: var(--font-hand, "Xiaolai", sans-serif);
  --font-sans: var(--font-hand, "Xiaolai", sans-serif);
  --surface-metrics-bg: rgba(18, 36, 52, 0.42);
  --surface-card-bg: rgba(18, 36, 52, 0.52);
  --surface-border: rgba(255, 255, 255, 0.16);
  font-family: var(--font-sans);
  font-synthesis: none;
  --seal-cinnabar: #b53826;
  --seal-vermilion: #d2482e;
  --brass-gold: #c89c56;
  --brass-highlight: #f8dfa4;
  --brass-dark: #7c5c28;
  --paper-cream: #fbf7ee;
  --paper-card-bg: #fdfaf3;
  --paper-border: rgba(195, 175, 145, 0.45);
  --paper-shadow: 0 8px 28px rgba(60, 45, 30, 0.10), 0 2px 6px rgba(60, 45, 30, 0.05);
  --font-serif: var(--font-hand, "Xiaolai", sans-serif);
  --font-num: var(--font-hand, "Xiaolai", sans-serif);
  --font-mono: var(--font-hand, "Xiaolai", sans-serif);
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --ease-peel: cubic-bezier(0.25, 1, 0.5, 1);
  --ink-epic: #9a2814;
  --ink-great: #8f4006;
  --ink-good: #2d5f8a;
  --ink-fair: #4f6070;
  --ink-dull: #5c554d;
  --ink-unavailable: #5a5650;
}

/* Ambient copy follows the sky; paper contents retain their own dark ink. */
body { --sky-ink: var(--sky-ink-on-light); --sky-accent: var(--sky-accent-on-light); }
body[data-light="night"],
body:is([data-weather="rain"], [data-weather="thunder"], [data-weather="hail"]) { --sky-ink: var(--sky-ink-on-dark); --sky-accent: var(--sky-accent-on-dark); }
body :is(.brand, .brand-copy small, .top-actions, .home-city, .home-weather, .event-status, .hero-lunar-badge, .week-block > .section-head, .week-block > .section-head p) { color: var(--sky-ink); }
body .event-tabs button { color: var(--sky-ink); }
body :is(.event-tabs button[aria-pressed="true"], .week-best, .top-actions .favorite-button[aria-pressed="true"]) { color: var(--sky-accent); }
body .ready :is(.home-city, .event-tabs button, .hero-lunar-badge, .week-best):hover:not(:disabled),
body .brand:hover, body .top-actions .icon-button:hover { color: var(--sky-accent); }
body .ready :is(.home-city, .event-tabs button, .hero-lunar-badge, .week-best):focus-visible,
body .top-actions .icon-button:focus-visible { text-decoration-color: currentColor; outline-color: currentColor; }

body[data-light="day"] {
  --surface-metrics-bg: rgba(18, 36, 52, 0.38);
  --surface-card-bg: rgba(18, 36, 52, 0.38);
  --surface-border: rgba(255, 255, 255, 0.18);
}

body[data-light="night"] {
  --surface-metrics-bg: rgba(12, 22, 34, 0.65);
  --surface-card-bg: rgba(12, 22, 34, 0.65);
  --surface-border: rgba(255, 255, 255, 0.1);
  --sky-top: var(--weather-night-top, #142936);
  --sky-mid: var(--weather-night-mid, #2b414b);
  --sky-horizon: var(--weather-night-bottom, #56646a);
  --sky-glow: rgba(112, 153, 199, 0.16);
  --sky-cloud-opacity: 0.2;
  --sky-texture-opacity: 0.1;
  --sky-cloud-highlight: rgba(145, 170, 192, 0.22);
  --sky-cloud-body: rgba(90, 118, 140, 0.15);
  --sky-cloud-shade: rgba(12, 24, 36, 0.28);
  --atmosphere-cloud-high: rgba(151, 169, 181, 0.2);
  --atmosphere-cloud-mid: rgba(113, 134, 149, 0.16);
  --atmosphere-cloud-low: rgba(8, 18, 28, 0.36);
  --atmosphere-fog-high: rgba(174, 190, 194, 0.17);
  --atmosphere-fog-mid: rgba(121, 143, 149, 0.14);
  --atmosphere-fog-low: rgba(19, 34, 43, 0.2);
}

body[data-storm="strong"] {
  --atmosphere-storm-travel: 5vw;
  --atmosphere-storm-speed-cut: 8s;
  --atmosphere-storm-sweep-opacity: 0.14;
  --atmosphere-storm-sweep-duration-cut: 1.2s;
}

body[data-storm="severe"] {
  --atmosphere-storm-travel: 9vw;
  --atmosphere-storm-speed-cut: 15s;
  --atmosphere-storm-sweep-opacity: 0.23;
  --atmosphere-storm-sweep-duration-cut: 2.5s;
}

body[data-light="day"][data-weather="clear"] {
  --sky-top: var(--weather-clear-day-top, #9dbecb);
  --sky-mid: var(--weather-clear-day-mid, #c2d0cd);
  --sky-horizon: var(--weather-clear-day-bottom, #e5dcc0);
  --sky-glow: rgb(255 220 170 / calc(0.12 + var(--clear-energy) * 0.3));
  --sky-cloud-opacity: 0;
  --sky-texture-opacity: 0.04;
  --atmosphere-sun-core: rgb(255 244 220 / calc(0.26 + var(--clear-energy) * 0.16));
  --atmosphere-sun-ray: rgb(255 230 190 / calc(0.02 + var(--clear-energy) * 0.09));
  --atmosphere-heat: rgb(255 228 180 / calc(0.03 + var(--clear-energy) * 0.12));
}

body[data-light="day"][data-weather="partly"] {
  --sky-top: var(--weather-partly-top, #91a7b5);
  --sky-mid: var(--weather-partly-mid, #bdc8c7);
  --sky-horizon: var(--weather-partly-bottom, #d8d3bf);
  --sky-glow: rgba(255, 232, 195, 0.28);
  --sky-cloud-opacity: 0.55;
  --sky-texture-opacity: 0.05;
  --sky-cloud-highlight: rgba(255, 255, 255, 0.62);
  --sky-cloud-body: rgba(225, 242, 252, 0.28);
  --sky-cloud-shade: rgba(80, 120, 155, 0.12);
  --atmosphere-cloud-high: rgba(255, 255, 255, 0.46);
  --atmosphere-cloud-mid: rgba(220, 238, 250, 0.22);
  --atmosphere-cloud-low: rgba(90, 135, 170, 0.12);
}

body[data-light="day"][data-weather="overcast"] {
  --sky-top: var(--weather-overcast-top, #697a83);
  --sky-mid: var(--weather-overcast-mid, #9ba6a8);
  --sky-horizon: var(--weather-overcast-bottom, #bbc0b8);
  --sky-glow: rgba(215, 228, 238, 0.14);
  --sky-cloud-opacity: 0.85;
  --sky-texture-opacity: 0.2;
  --sky-cloud-highlight: rgba(220, 232, 240, 0.35);
  --sky-cloud-body: rgba(180, 195, 206, 0.22);
  --sky-cloud-shade: rgba(50, 68, 82, 0.22);
  --atmosphere-cloud-high: rgba(210, 222, 230, 0.35);
  --atmosphere-cloud-mid: rgba(165, 180, 192, 0.22);
  --atmosphere-cloud-low: rgba(65, 82, 96, 0.22);
}

body[data-light="day"][data-weather="rain"] {
  --sky-top: var(--weather-rain-top, #3a5263);
  --sky-mid: var(--weather-rain-mid, #6e8790);
  --sky-horizon: var(--weather-rain-bottom, #b7c3c1);
  --sky-glow: rgba(180, 205, 222, 0.1);
  --sky-cloud-opacity: 0.94;
  --sky-texture-opacity: 0.25;
  --sky-cloud-highlight: rgba(185, 202, 215, 0.26);
  --sky-cloud-body: rgba(130, 150, 166, 0.18);
  --sky-cloud-shade: rgba(22, 36, 48, 0.3);
  --atmosphere-cloud-high: rgba(170, 190, 205, 0.25);
  --atmosphere-cloud-mid: rgba(125, 145, 160, 0.2);
  --atmosphere-cloud-low: rgba(24, 38, 50, 0.26);
}

body[data-light="day"][data-weather="snow"] {
  --sky-top: var(--weather-snow-top, #8aa0ad);
  --sky-mid: var(--weather-snow-mid, #c3cfd2);
  --sky-horizon: var(--weather-snow-bottom, #e4e8e4);
  --sky-glow: rgba(235, 245, 252, 0.22);
  --sky-cloud-opacity: 0.74;
  --sky-texture-opacity: 0.16;
  --sky-cloud-highlight: rgba(250, 253, 255, 0.5);
  --sky-cloud-body: rgba(215, 232, 244, 0.25);
  --sky-cloud-shade: rgba(60, 88, 110, 0.14);
}

body[data-light="day"][data-weather="fog"] {
  --sky-top: var(--weather-fog-top, #a6b3b8);
  --sky-mid: var(--weather-fog-mid, #bec7c6);
  --sky-horizon: var(--weather-fog-bottom, #d0d2c7);
  --sky-glow: rgba(230, 235, 228, 0.16);
  --sky-cloud-opacity: 0.32;
  --sky-texture-opacity: 0.08;
}

body[data-light="day"][data-weather="thunder"] {
  --sky-top: var(--weather-thunder-top, #253643);
  --sky-mid: var(--weather-thunder-mid, #4b6270);
  --sky-horizon: var(--weather-thunder-bottom, #acb9bb);
  --sky-glow: rgba(160, 185, 205, 0.08);
  --sky-cloud-opacity: 1;
  --sky-texture-opacity: 0.32;
  --sky-cloud-highlight: rgba(170, 190, 208, 0.22);
  --sky-cloud-body: rgba(110, 130, 148, 0.18);
  --sky-cloud-shade: rgba(15, 26, 38, 0.35);
}

body[data-light="day"][data-weather="hail"] {
  --sky-top: var(--weather-hail-top, #304957);
  --sky-mid: var(--weather-hail-mid, #657f88);
  --sky-horizon: var(--weather-hail-bottom, #a0b2b0);
  --sky-glow: rgba(175, 220, 235, 0.15);
  --sky-cloud-opacity: 0.98;
  --sky-texture-opacity: 0.28;
  --atmosphere-hail-wash: rgba(72, 128, 158, 0.28);
  --sky-cloud-highlight: rgba(185, 215, 230, 0.24);
  --sky-cloud-body: rgba(120, 155, 175, 0.2);
  --sky-cloud-shade: rgba(18, 38, 52, 0.35);
}

body[data-light="night"][data-weather="partly"] {
  --sky-top: var(--weather-night-top, #142936);
  --sky-mid: var(--weather-night-mid, #2b414b);
  --sky-horizon: var(--weather-night-bottom, #56646a);
  --sky-glow: rgba(126, 154, 181, 0.1);
  --sky-cloud-opacity: 0.52;
}

body[data-light="night"][data-weather="overcast"] {
  --sky-top: var(--weather-night-heavy-top, #101e2a);
  --sky-mid: var(--weather-night-heavy-mid, #26353f);
  --sky-horizon: var(--weather-night-heavy-bottom, #46565e);
  --sky-glow: rgba(180, 190, 196, 0.04);
  --sky-cloud-opacity: 0.86;
  --sky-texture-opacity: 0.2;
}

body[data-light="night"][data-weather="rain"] {
  --sky-top: var(--weather-night-top, #142936);
  --sky-mid: var(--weather-night-mid, #2b414b);
  --sky-horizon: var(--weather-night-bottom, #56646a);
  --sky-glow: rgba(129, 158, 177, 0.04);
  --sky-cloud-opacity: 0.96;
  --sky-texture-opacity: 0.28;
}

body[data-light="night"][data-weather="snow"] {
  --sky-top: var(--weather-night-top, #142936);
  --sky-mid: var(--weather-night-mid, #2b414b);
  --sky-horizon: var(--weather-night-bottom, #56646a);
  --sky-glow: rgba(204, 222, 232, 0.13);
  --sky-cloud-opacity: 0.72;
  --sky-texture-opacity: 0.15;
}

body[data-light="night"][data-weather="fog"] {
  --sky-top: var(--weather-night-fog-top, #344853);
  --sky-mid: var(--weather-night-fog-mid, #52646a);
  --sky-horizon: var(--weather-night-fog-bottom, #778181);
  --sky-glow: rgba(162, 181, 187, 0.07);
  --sky-cloud-opacity: 0.34;
  --sky-texture-opacity: 0.07;
}

body[data-light="night"][data-weather="thunder"] {
  --sky-top: var(--weather-night-heavy-top, #101e2a);
  --sky-mid: var(--weather-night-heavy-mid, #26353f);
  --sky-horizon: var(--weather-night-heavy-bottom, #46565e);
  --sky-glow: rgba(118, 147, 169, 0.03);
  --sky-cloud-opacity: 1;
  --sky-texture-opacity: 0.34;
}

body[data-light="night"][data-weather="hail"] {
  --sky-top: var(--weather-night-heavy-top, #101e2a);
  --sky-mid: var(--weather-night-heavy-mid, #26353f);
  --sky-horizon: var(--weather-night-heavy-bottom, #46565e);
  --sky-glow: rgba(144, 181, 202, 0.05);
  --sky-cloud-opacity: 0.98;
  --sky-texture-opacity: 0.27;
}

body[data-theme="dawn"][data-weather="clear"] {
  --sky-ink: var(--sky-ink-on-light);
  --sky-accent: var(--sky-accent-on-light);
  --sky-top: var(--weather-clear-dawn-top, #8a9eaf);
  --sky-mid: var(--weather-clear-dawn-mid, #cbb4ae);
  --sky-horizon: var(--weather-clear-dawn-bottom, #eacaa5);
}

body[data-theme="dusk"][data-weather="clear"] {
  --sky-ink: var(--sky-ink-on-light);
  --sky-accent: var(--sky-accent-on-light);
  --sky-top: var(--weather-clear-dusk-top, #bdccd5);
  --sky-mid: var(--weather-clear-dusk-mid, #d5b29d);
  --sky-horizon: var(--weather-clear-dusk-bottom, #edcd9a);
}

body[data-light="day"][data-weather="wind"] {
  --sky-top: var(--weather-wind-top, #9aaeb8);
  --sky-mid: var(--weather-wind-mid, #c7c7b7);
  --sky-horizon: var(--weather-wind-bottom, #dac49a);
}

body[data-weather="thunder"] {
  --atmosphere-cloud-high: rgba(173, 190, 203, 0.23);
  --atmosphere-cloud-mid: rgba(93, 117, 134, 0.18);
  --atmosphere-cloud-low: rgba(5, 14, 23, 0.43);
}

body[data-weather="hail"] {
  --atmosphere-cloud-high: rgba(185, 211, 224, 0.3);
  --atmosphere-cloud-mid: rgba(105, 143, 163, 0.22);
  --atmosphere-cloud-low: rgba(10, 26, 38, 0.4);
  --atmosphere-lightning-core: rgba(210, 236, 255, 0.48);
  --atmosphere-lightning-wash: rgba(140, 188, 214, 0.22);
}

* {
  box-sizing: border-box;
  font-weight: 400;
}

html {
  min-height: 100%;
  background: var(--sky-top, #1c5b94);
}

/* Lock only the root scrollport while a native modal is open; retain its offset. */
html:has(dialog:modal) {
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--sky-top);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button,
a {
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

.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;
}

@media (min-width: 900px) {
  body[data-light="day"][data-weather="overcast"] {
    --sky-cloud-opacity: 0.7;
  }

  body[data-light="night"][data-weather="overcast"] {
    --sky-cloud-opacity: 0.72;
  }
}
.app-shell {
  position: relative;
  z-index: 1;
  width: min(calc(100% - 96px), 1100px);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 0 max(32px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.panel {
  flex: 1;
}




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

:focus-visible {
  outline: 1px dashed var(--ink, #36372f);
  outline-offset: 4px;
}

@media (max-width: 760px) {
  :root {
    --atmosphere-intensity: 0.74;
    --atmosphere-motion-range: 9vw;
    --atmosphere-cloud-blur: 7px;
    --atmosphere-fog-blur: 14px;
    --atmosphere-fog-front-blur: 10px;
  }

  .app-shell {
    width: calc(100% - 48px);
  }

}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto;
    animation: none !important;
    transition: none !important;
  }
}
body[data-input="keyboard"] dialog[open] { animation: none !important; }

/* ---------- 天幕、天气粒子与月亮 ---------- */
.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(ellipse 72% 15% at 76% 78%, var(--sky-glow), transparent 72%),
    radial-gradient(
      ellipse 90% 28% at 50% 100%,
      rgba(255, 168, 96, calc(var(--twilight-warmth) * 0.34)) 0%,
      transparent 70%
    ),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 58%, var(--sky-horizon) 100%);
  transition: none;
}
.sky-scene-wash { position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: 1; transition: opacity var(--duration-scene) linear; }
@starting-style { .sky-scene-wash { opacity: 0; } }

.sky::before {
  content: "";
  position: absolute;
  inset: -14% -18%;
  z-index: 0;
  opacity: var(--sky-cloud-opacity);
  background:
    radial-gradient(ellipse 34% 10% at 4% 27%, var(--sky-cloud-highlight) 0 20%, var(--sky-cloud-body) 48%, transparent 72%),
    radial-gradient(ellipse 42% 12% at 5% 34%, var(--sky-cloud-shade) 0 16%, transparent 60%),
    radial-gradient(ellipse 31% 9% at 49% 42%, var(--sky-cloud-highlight) 0 21%, var(--sky-cloud-body) 49%, transparent 72%),
    radial-gradient(ellipse 39% 11% at 50% 49%, var(--sky-cloud-shade) 0 16%, transparent 60%),
    radial-gradient(ellipse 37% 11% at 94% 28%, var(--sky-cloud-highlight) 0 22%, var(--sky-cloud-body) 49%, transparent 73%),
    radial-gradient(ellipse 45% 13% at 94% 35%, var(--sky-cloud-shade) 0 17%, transparent 62%),
    radial-gradient(ellipse 50% 12% at 28% 72%, var(--sky-cloud-body) 0 18%, transparent 72%),
    radial-gradient(ellipse 62% 15% at 31% 79%, var(--sky-cloud-shade) 0 16%, transparent 65%);
  filter: blur(6px);
  transition: opacity var(--duration-scene) linear;
}

.sky::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: var(--sky-texture-opacity);
  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.025) 0,
    rgba(255, 255, 255, 0.025) 1px,
    transparent 1px,
    transparent 4px
  );
  mix-blend-mode: soft-light;
  transition: opacity var(--duration-scene) linear;
}

/* Unconfirmed records keep astronomical light and moon, not observed weather. */
body[data-unconfirmed="true"] :is(.weather-atmosphere, .weather-canvas, .weather-contact-canvas, .weather-foreground-canvas),
body[data-unconfirmed="true"] .sky::before,
body[data-unconfirmed="true"] .sky::after { display: none; }
body[data-unconfirmed="true"] .sky-moon { filter: none; }
body[data-unconfirmed="true"] .sky-moon-halo { opacity: 0; }
.weather-atmosphere {
  --atmosphere-back-image: none;
  --atmosphere-front-image: none;
  --atmosphere-light-image: none;
  --atmosphere-back-opacity: 0;
  --atmosphere-front-opacity: 0;
  --atmosphere-light-opacity: 0;
  --atmosphere-back-animation: none;
  --atmosphere-front-animation: none;
  --atmosphere-light-animation: none;
  --atmosphere-back-base-duration: var(--duration-cloud);
  --atmosphere-front-base-duration: var(--duration-cloud);
  --atmosphere-back-blur: var(--atmosphere-cloud-blur);
  --atmosphere-front-blur: var(--atmosphere-cloud-blur);
  --atmosphere-back-blend: normal;
  --atmosphere-front-blend: normal;
  --atmosphere-light-blend: normal;
  --atmosphere-light-duration: 10s;
  --atmosphere-light-timing: ease-in-out;
  --atmosphere-light-mask: none;
  --atmosphere-travel: clamp(
    var(--atmosphere-motion-range),
    calc(var(--atmosphere-motion-range) + var(--wind-motion-add) + var(--atmosphere-storm-travel)),
    24vw
  );
  --atmosphere-travel-negative: calc(0vw - var(--atmosphere-travel));
  --atmosphere-cloud-back-texture:
    radial-gradient(ellipse 31% 12% at 8% 27%, var(--atmosphere-cloud-high) 0 28%, var(--atmosphere-cloud-mid) 52%, transparent 75%),
    radial-gradient(ellipse 38% 14% at 45% 35%, var(--atmosphere-cloud-high) 0 24%, var(--atmosphere-cloud-mid) 50%, transparent 76%),
    radial-gradient(ellipse 34% 13% at 83% 23%, var(--atmosphere-cloud-high) 0 27%, var(--atmosphere-cloud-mid) 54%, transparent 77%),
    radial-gradient(ellipse 59% 18% at 26% 64%, var(--atmosphere-cloud-low) 0 22%, transparent 72%),
    radial-gradient(ellipse 64% 19% at 82% 69%, var(--atmosphere-cloud-low) 0 20%, transparent 74%);
  --atmosphere-cloud-front-texture:
    radial-gradient(ellipse 45% 15% at 3% 48%, var(--atmosphere-cloud-high) 0 24%, var(--atmosphere-cloud-mid) 51%, transparent 74%),
    radial-gradient(ellipse 55% 17% at 56% 55%, var(--atmosphere-cloud-high) 0 22%, var(--atmosphere-cloud-mid) 48%, transparent 73%),
    radial-gradient(ellipse 47% 15% at 100% 43%, var(--atmosphere-cloud-high) 0 25%, var(--atmosphere-cloud-mid) 51%, transparent 75%),
    radial-gradient(ellipse 78% 21% at 23% 76%, var(--atmosphere-cloud-low) 0 18%, transparent 72%),
    radial-gradient(ellipse 72% 20% at 88% 78%, var(--atmosphere-cloud-low) 0 19%, transparent 73%);
  --atmosphere-fog-back-texture:
    linear-gradient(180deg, transparent 18%, var(--atmosphere-fog-high) 42%, var(--atmosphere-fog-mid) 61%, transparent 86%),
    radial-gradient(ellipse 78% 18% at 20% 48%, var(--atmosphere-fog-high) 0 31%, transparent 74%),
    radial-gradient(ellipse 86% 20% at 86% 62%, var(--atmosphere-fog-low) 0 27%, transparent 75%);
  --atmosphere-fog-front-texture:
    linear-gradient(180deg, transparent 34%, var(--atmosphere-fog-high) 56%, var(--atmosphere-fog-mid) 72%, transparent 94%),
    radial-gradient(ellipse 92% 17% at 4% 68%, var(--atmosphere-fog-high) 0 29%, transparent 73%),
    radial-gradient(ellipse 84% 18% at 92% 76%, var(--atmosphere-fog-low) 0 28%, transparent 75%);
  --atmosphere-heat-texture:
    radial-gradient(ellipse 16% 38% at calc(var(--sun-x) - 10%) 92%, var(--atmosphere-heat) 0 18%, transparent 78%),
    radial-gradient(ellipse 20% 44% at var(--sun-x) 95%, var(--atmosphere-heat) 0 16%, transparent 80%),
    radial-gradient(ellipse 14% 34% at calc(var(--sun-x) + 9%) 91%, var(--atmosphere-heat) 0 18%, transparent 78%);
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  isolation: isolate;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-scene) linear;
}

.weather-atmosphere,
.weather-atmosphere * {
  pointer-events: none;
}

.atmosphere-layer {
  position: absolute;
  inset: 0;
  display: block;
  pointer-events: none;
  transition: opacity var(--duration-scene) linear;
}

.atmosphere-layer--back,
.atmosphere-layer--front {
  inset: -18% -28%;
  background-repeat: no-repeat;
  transform: translate3d(0, 0, 0);
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-direction: alternate;
}

.atmosphere-layer--back {
  background-image: var(--atmosphere-back-image);
  opacity: var(--atmosphere-back-opacity);
  filter: blur(var(--atmosphere-back-blur));
  mix-blend-mode: var(--atmosphere-back-blend);
  animation-name: var(--atmosphere-back-animation);
  animation-duration: var(--atmosphere-back-base-duration);
}

.atmosphere-layer--front {
  background-image: var(--atmosphere-front-image);
  opacity: var(--atmosphere-front-opacity);
  filter: blur(var(--atmosphere-front-blur));
  mix-blend-mode: var(--atmosphere-front-blend);
  animation-name: var(--atmosphere-front-animation);
  animation-duration: var(--atmosphere-front-base-duration);
}

.atmosphere-layer--light {
  background-image: var(--atmosphere-light-image);
  opacity: var(--atmosphere-light-opacity);
  mix-blend-mode: var(--atmosphere-light-blend);
  -webkit-mask-image: var(--atmosphere-light-mask);
  mask-image: var(--atmosphere-light-mask);
  animation-name: var(--atmosphere-light-animation);
  animation-duration: var(--atmosphere-light-duration);
  animation-timing-function: var(--atmosphere-light-timing);
  animation-iteration-count: infinite;
  animation-direction: alternate;
}

.atmosphere-layer--wind {
  inset: -36vmax;
  opacity: 0;
  background-image: repeating-linear-gradient(
    90deg,
    transparent 0 12%,
    var(--atmosphere-wind-sweep) 15% 17%,
    transparent 20% 35%
  );
  background-size: 42% 100%;
  filter: blur(8px);
  mix-blend-mode: screen;
  transform-origin: center;
  animation: none;
}

body[data-state="ready"][data-wind-active="true"][data-storm="strong"] .atmosphere-layer--wind,
body[data-state="ready"][data-wind-active="true"][data-storm="severe"] .atmosphere-layer--wind {
  opacity: var(--atmosphere-storm-sweep-opacity);
  animation: atmosphere-gust-sweep clamp(
    2.8s,
    calc(8.5s - var(--wind-sweep-speed-cut) - var(--atmosphere-storm-sweep-duration-cut)),
    8.5s
  ) ease-in-out infinite alternate;
}

body[data-state="ready"][data-weather] .weather-atmosphere {
  opacity: var(--atmosphere-intensity);
}

body[data-state="ready"][data-light="day"][data-weather="clear"] .weather-atmosphere {
  --atmosphere-back-image: var(--atmosphere-heat-texture);
  --atmosphere-back-opacity: calc(0.16 + var(--clear-energy) * 0.42);
  --atmosphere-back-animation: atmosphere-heat-breathe;
  --atmosphere-back-base-duration: 14s;
  --atmosphere-back-blur: 22px;
  --atmosphere-back-blend: soft-light;
  --atmosphere-light-image:
    radial-gradient(
      circle at var(--sun-x) var(--sun-y),
      rgb(255 252 245 / 0.78) 0%,
      rgb(255 240 210 / 0.42) 7%,
      var(--atmosphere-sun-core) 16%,
      transparent 42%
    ),
    radial-gradient(
      ellipse 118% 96% at var(--sun-x) var(--sun-y),
      transparent 22%,
      var(--atmosphere-sun-ray) 48%,
      transparent 72%
    ),
    repeating-conic-gradient(
      from 210deg at var(--sun-x) var(--sun-y),
      transparent 0 26deg,
      var(--atmosphere-sun-ray) 27deg 28deg,
      transparent 29deg 55deg
    );
  --atmosphere-light-opacity: calc(0.38 + var(--clear-energy) * 0.3);
  --atmosphere-light-blend: screen;
  --atmosphere-light-mask: radial-gradient(
    ellipse 86% 74% at var(--sun-x) var(--sun-y),
    var(--ink) 0 24%,
    transparent 70%
  );
  --atmosphere-light-animation: atmosphere-sun-breathe;
  --atmosphere-light-duration: 11s;
}

body[data-state="ready"][data-light="night"][data-weather="clear"] .weather-atmosphere {
  --atmosphere-light-image:
    radial-gradient(ellipse 88% 48% at 50% -8%, var(--atmosphere-night-glow) 0, transparent 72%),
    radial-gradient(ellipse 76% 19% at 62% 88%, var(--atmosphere-night-horizon) 0, transparent 74%);
  --atmosphere-light-opacity: 0.7;
  --atmosphere-light-blend: screen;
}

body[data-state="ready"][data-weather="partly"] .weather-atmosphere {
  --atmosphere-back-image: var(--atmosphere-cloud-back-texture);
  --atmosphere-front-image: none;
  --atmosphere-back-opacity: 0.52;
  --atmosphere-front-opacity: 0;
  --atmosphere-back-blend: soft-light;
  --atmosphere-back-animation: atmosphere-cloud-back-drift;
  --atmosphere-front-animation: none;
}

body[data-state="ready"][data-weather="overcast"] .weather-atmosphere {
  --atmosphere-back-image: var(--atmosphere-cloud-back-texture);
  --atmosphere-front-image: var(--atmosphere-cloud-front-texture);
  --atmosphere-back-opacity: 0.78;
  --atmosphere-front-opacity: 0.68;
  --atmosphere-back-animation: atmosphere-cloud-back-drift;
  --atmosphere-front-animation: atmosphere-cloud-front-drift;
}

@media (min-width: 900px) {
  body[data-state="ready"][data-weather="overcast"] .weather-atmosphere {
    --atmosphere-back-opacity: 0.64;
    --atmosphere-front-opacity: 0.5;
  }

  body[data-state="ready"][data-weather="partly"] .sky::before {
    opacity: calc(var(--sky-cloud-opacity) * 0.72);
  }
}
body[data-state="ready"][data-weather="fog"] .weather-atmosphere {
  --atmosphere-back-image: var(--atmosphere-fog-back-texture);
  --atmosphere-front-image: var(--atmosphere-fog-front-texture);
  --atmosphere-back-opacity: var(--fog-back-opacity);
  --atmosphere-front-opacity: var(--fog-front-opacity);
  --atmosphere-back-animation: atmosphere-fog-back-drift;
  --atmosphere-front-animation: atmosphere-fog-front-drift;
  --atmosphere-back-base-duration: 30s;
  --atmosphere-front-base-duration: 30s;
  --atmosphere-back-blur: var(--atmosphere-fog-blur);
  --atmosphere-front-blur: var(--atmosphere-fog-front-blur);
  --atmosphere-back-blend: screen;
  --atmosphere-front-blend: screen;
  --atmosphere-light-image: linear-gradient(180deg, transparent 18%, var(--atmosphere-fog-mid) 58%, var(--atmosphere-fog-high) 82%, transparent 100%);
  --atmosphere-light-opacity: 0.34;
  --atmosphere-light-blend: screen;
}

body[data-state="ready"][data-weather="rain"] .weather-atmosphere {
  --atmosphere-back-image: var(--atmosphere-cloud-back-texture);
  --atmosphere-front-image: var(--atmosphere-cloud-front-texture), var(--atmosphere-fog-front-texture);
  --atmosphere-back-opacity: calc(0.62 + var(--precip-intensity) * 0.22);
  --atmosphere-front-opacity: calc(0.5 + var(--precip-intensity) * 0.2 + var(--precip-fog-boost) * 0.22);
  --atmosphere-back-animation: atmosphere-cloud-back-drift;
  --atmosphere-front-animation: atmosphere-cloud-front-drift;
  --atmosphere-light-image: linear-gradient(180deg, var(--atmosphere-rain-wash), transparent 68%);
  --atmosphere-light-opacity: calc(0.5 + var(--precip-intensity) * 0.32);
}

body[data-state="ready"][data-weather="snow"] .weather-atmosphere {
  --atmosphere-back-image: var(--atmosphere-cloud-back-texture);
  --atmosphere-front-image: var(--atmosphere-cloud-front-texture);
  --atmosphere-back-opacity: calc(0.46 + var(--precip-intensity) * 0.2);
  --atmosphere-front-opacity: calc(0.36 + var(--precip-intensity) * 0.18);
  --atmosphere-back-animation: atmosphere-cloud-back-drift;
  --atmosphere-front-animation: atmosphere-cloud-front-drift;
  --atmosphere-light-image: radial-gradient(ellipse 82% 27% at 50% 88%, var(--atmosphere-snow-wash), transparent 74%);
  --atmosphere-light-opacity: calc(0.52 + var(--precip-intensity) * 0.28);
  --atmosphere-light-blend: screen;
}

body[data-state="ready"][data-weather="thunder"] .weather-atmosphere {
  --atmosphere-back-image: var(--atmosphere-cloud-back-texture);
  --atmosphere-front-image: var(--atmosphere-cloud-front-texture);
  --atmosphere-back-opacity: calc(0.8 + var(--precip-intensity) * 0.16);
  --atmosphere-front-opacity: calc(0.68 + var(--precip-intensity) * 0.14);
  --atmosphere-back-animation: atmosphere-cloud-back-drift;
  --atmosphere-front-animation: atmosphere-cloud-front-drift;
  --atmosphere-light-image:
    radial-gradient(circle at 72% 10%, var(--atmosphere-lightning-core) 0, transparent 28%),
    radial-gradient(circle at 38% 18%, rgba(220, 236, 255, 0.35) 0, transparent 18%),
    linear-gradient(180deg, var(--atmosphere-lightning-wash), var(--atmosphere-rain-wash) 55%, transparent 82%);
  --atmosphere-light-animation: paper-thunder-glow;
  --atmosphere-light-duration: 8s;
  --atmosphere-light-timing: ease-in-out;
  --atmosphere-light-blend: screen;
  --atmosphere-light-mask: radial-gradient(ellipse 96% 82% at 60% 12%, var(--ink) 0 24%, transparent 80%);
  --atmosphere-light-opacity: .4;
}


body[data-state="ready"][data-weather="hail"] .weather-atmosphere {
  --atmosphere-back-image: var(--atmosphere-cloud-back-texture);
  --atmosphere-front-image: var(--atmosphere-cloud-front-texture);
  --atmosphere-back-opacity: calc(0.72 + var(--precip-intensity) * 0.16);
  --atmosphere-front-opacity: calc(0.6 + var(--precip-intensity) * 0.16);
  --atmosphere-back-animation: atmosphere-cloud-back-drift;
  --atmosphere-front-animation: atmosphere-cloud-front-drift;
  --atmosphere-light-image:
    radial-gradient(circle at 64% 14%, var(--atmosphere-lightning-core) 0, transparent 20%),
    linear-gradient(180deg, var(--atmosphere-hail-wash), var(--atmosphere-rain-wash));
  --atmosphere-light-opacity: .4;
  --atmosphere-light-animation: paper-thunder-glow;
  --atmosphere-light-duration: 8s;
  --atmosphere-light-timing: ease-in-out;
  --atmosphere-light-blend: screen;
}

.weather-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  mix-blend-mode: screen;
  transition: opacity var(--duration-scene) linear;
}

.weather-contact-canvas {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: screen;
  transition: opacity var(--duration-scene) linear;
}

body[data-state="ready"][data-contact-visible="true"] .weather-contact-canvas { opacity: .92; }
body[data-state="ready"][data-fx-visible="true"] .weather-canvas { opacity: .92; }

body[data-state="ready"][data-fx="wind"][data-wind-active="true"] .atmosphere-layer--wind {
  opacity: calc(var(--atmosphere-storm-sweep-opacity) * 0.55);
}


body[data-state="ready"][data-weather="clear"] .sky::before {
  animation: clear-air-drift 18s ease-in-out infinite alternate;
}

body[data-state="ready"][data-light="day"][data-weather="clear"] .sky {
  background:
    radial-gradient(ellipse 70% 14% at 74% 82%, var(--sky-glow), transparent 74%),
    radial-gradient(
      ellipse 92% 26% at 50% 100%,
      rgb(255 168 96 / calc(var(--twilight-warmth) * 0.26)) 0%,
      transparent 72%
    ),
    linear-gradient(
      180deg,
      var(--sky-top) 0%,
      var(--sky-mid) 46%,
      color-mix(in srgb, var(--sky-mid) 58%, var(--sky-horizon)) 76%,
      var(--sky-horizon) 100%
    );
  filter: brightness(0.97) saturate(0.98);
}

body[data-state="ready"][data-light="day"][data-weather="clear"] .sky::after {
  opacity: calc(0.16 + var(--clear-energy) * 0.14);
  background: radial-gradient(
    circle at var(--sun-x) var(--sun-y),
    rgb(255 246 224 / 0.46) 0%,
    rgb(255 232 196 / 0.2) 18%,
    transparent 40%
  );
  mix-blend-mode: soft-light;
}

body[data-state="ready"]:is([data-weather="partly"], [data-weather="overcast"], [data-weather="rain"], [data-weather="snow"], [data-weather="thunder"], [data-weather="hail"]) .sky::before {
  animation: scene-cloud-drift var(--duration-cloud) ease-in-out infinite alternate;
}

body[data-state="ready"] .sky,
body[data-state="loading"] .sky,
body[data-state="error"] .sky,
body[data-state="welcome"] .sky {
  filter: none;
}

.sky-moon {
  position: absolute;
  left: var(--moon-x, 78%);
  top: var(--moon-y, 16%);
  width: 76px;
  height: 76px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-scene) linear;
  z-index: 1;
}

@media (max-width: 640px) {
  /* 只缩小月体；实际月位仍由此刻的天文坐标决定。 */
  .sky-moon {
    width: 40px;
    height: 40px;
    transform: translate(-50%, -50%);
  }
}
body[data-light="night"] .sky-moon {
  opacity: 1;
}

/* 晴朗夜晚：皎洁明月与清澈月晕 */
body[data-light="night"][data-weather="clear"] .sky-moon {
  filter: drop-shadow(0 0 18px rgba(225, 240, 255, 0.76)) drop-shadow(0 0 38px rgba(180, 215, 255, 0.4));
}

body[data-light="night"][data-weather="clear"] .sky-moon-halo {
  opacity: calc(0.35 + var(--moon-illumination, 0.5) * 0.45);
}

/* 多云夜晚：轻纱微掩 */
body[data-light="night"][data-weather="partly"] .sky-moon {
  opacity: 0.88;
  filter: drop-shadow(0 0 14px rgba(200, 225, 250, 0.55)) blur(0.5px);
}

body[data-light="night"][data-weather="partly"] .sky-moon-halo {
  opacity: calc(0.28 + var(--moon-illumination, 0.5) * 0.35);
}

/* 阴天夜晚：云隙透月，朦胧清幽 */
body[data-light="night"][data-weather="overcast"] .sky-moon {
  opacity: 0.48;
  filter: blur(2.5px) drop-shadow(0 0 16px rgba(180, 205, 235, 0.4));
}

body[data-light="night"][data-weather="overcast"] .sky-moon-halo {
  opacity: 0.22;
}

/* 雨天/雷暴：水气漫射，月影朦胧 */
body[data-light="night"][data-weather="rain"] .sky-moon,
body[data-light="night"][data-weather="thunder"] .sky-moon {
  opacity: 0.42;
  filter: blur(2.5px) drop-shadow(0 0 14px rgba(180, 210, 240, 0.35));
}

/* 雾天夜晚：大光圈漫反射月晕 */
body[data-light="night"][data-weather="fog"] .sky-moon {
  opacity: 0.48;
  filter: blur(4.5px) drop-shadow(0 0 20px rgba(195, 220, 250, 0.4));
}

/* 降雪夜晚：清冷皎洁银霜月 */
body[data-light="night"][data-weather="snow"] .sky-moon {
  filter: drop-shadow(0 0 20px rgba(235, 248, 255, 0.85)) drop-shadow(0 0 45px rgba(200, 230, 255, 0.45));
}

/* 月晕漫射环 */
.sky-moon-halo {
  position: absolute;
  inset: -52px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(225, 242, 255, 0.30) 0%, rgba(185, 220, 255, 0.12) 42%, transparent 72%);
  pointer-events: none;
  opacity: 0.4;
  transform: scale(calc(0.7 + var(--moon-illumination, 0.5) * 0.6));
  transition: none;
  animation: sky-moon-breathe var(--duration-moon) ease-in-out infinite alternate;
}

.sky-moon-disk {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sky-moon-disk svg {
  width: 100%;
  height: 100%;
  display: block;
}

@keyframes clear-air-drift {
  from {
    transform: translate3d(-2%, -0.5%, 0) scale(1.02);
  }
  to {
    transform: translate3d(2.5%, 0.8%, 0) scale(1.06);
  }
}


@keyframes atmosphere-cloud-back-drift {
  from {
    transform: translate3d(var(--atmosphere-travel-negative), -1%, 0) scale(1.05);
  }
  to {
    transform: translate3d(var(--atmosphere-travel), 1.2%, 0) scale(1.1);
  }
}

@keyframes atmosphere-cloud-front-drift {
  from {
    transform: translate3d(var(--atmosphere-travel-negative), 1%, 0) scale(1.08);
  }
  to {
    transform: translate3d(var(--atmosphere-travel), -0.8%, 0) scale(1.14);
  }
}

@keyframes atmosphere-fog-back-drift {
  from {
    transform: translate3d(var(--atmosphere-travel-negative), -0.5%, 0) scale(1.04);
  }
  to {
    transform: translate3d(var(--atmosphere-travel), 0.6%, 0) scale(1.08);
  }
}

@keyframes atmosphere-fog-front-drift {
  from {
    transform: translate3d(var(--atmosphere-travel), 0.4%, 0) scale(1.07);
  }
  to {
    transform: translate3d(var(--atmosphere-travel-negative), -0.3%, 0) scale(1.12);
  }
}

@keyframes atmosphere-heat-breathe {
  from {
    transform: translate3d(-0.8%, 0.8%, 0) scale(0.99);
  }
  to {
    transform: translate3d(0.9%, -0.6%, 0) scale(1.04);
  }
}

@keyframes atmosphere-sun-breathe {
  from { transform: scale(.995); opacity: .55; }
  to { transform: scale(1.012); opacity: .85; }
}
@keyframes sky-moon-breathe { from { opacity: .55; } to { opacity: .85; } }
@keyframes scene-cloud-drift { from { transform: translateX(-12%); } to { transform: translateX(16%); } }
@keyframes paper-thunder-glow { from { opacity: .2; } to { opacity: .65; } }

@keyframes atmosphere-gust-sweep {
  from {
    transform: rotate(var(--wind-direction, 0deg)) translate3d(-18%, 0, 0);
  }
  to {
    transform: rotate(var(--wind-direction, 0deg)) translate3d(18%, 0, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sky::before,
  .sky::after {
    animation: none !important;
  }

  .weather-atmosphere,
  .atmosphere-layer {
    animation: none !important;
    will-change: auto;
  }

  /* Keep static wash / cloud / fog differentiation; only drop particle motion. */
  .weather-canvas,
  .weather-contact-canvas {
    opacity: 0 !important;
  }

  body[data-state="ready"][data-weather="thunder"] .weather-atmosphere {
    --atmosphere-light-opacity: 0.22;
    --atmosphere-light-animation: none;
  }

  body[data-state="ready"][data-weather="hail"] .weather-atmosphere {
    --atmosphere-light-opacity: 0.7;
    --atmosphere-light-animation: none;
  }

  body[data-state="ready"][data-weather="clear"] .weather-atmosphere,
  body[data-state="ready"][data-weather="fog"] .weather-atmosphere,
  body[data-state="ready"][data-weather="partly"] .weather-atmosphere,
  body[data-state="ready"][data-weather="overcast"] .weather-atmosphere,
  body[data-state="ready"][data-weather="rain"] .weather-atmosphere,
  body[data-state="ready"][data-weather="snow"] .weather-atmosphere,
  body[data-state="ready"][data-fx="fog"] .weather-atmosphere {
    --atmosphere-back-animation: none;
    --atmosphere-front-animation: none;
    --atmosphere-light-animation: none;
  }
}
@media (prefers-reduced-transparency: reduce) {
  body[data-state="ready"][data-weather="fog"] .weather-atmosphere {
    --atmosphere-back-opacity: var(--fog-back-opacity-reduced);
    --atmosphere-front-opacity: var(--fog-front-opacity-reduced);
    --atmosphere-light-opacity: 0.06;
  }
}
/* 前后双层气象 Canvas (穿透与背景融合) */
.weather-foreground-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 100;
  opacity: 1;
  transition: opacity var(--duration-scene) linear;
}

/* ---------- Header and shared controls ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 56px;
}

.brand {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 52px;
  padding: 7px 12px 7px 5px;
  border: 0;
  background: none;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}


.brand-mark { display: block; width: 43px; height: 43px; flex: 0 0 auto; }
.brand-mark-svg { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand-copy { min-width: 0; }
.brand-copy strong { display: block; font-size: 23px; line-height: 1.3; font-weight: 400; }
.brand-copy small { display: block; margin-top: 4px; font-size: 12px; line-height: 1.65; color: var(--ink-muted); }

.top-actions {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  color: var(--ink);
}

.top-actions:not(:has(button:not([hidden]))) { display: none; }
.top-actions .icon-button { border: 0; background: none; color: inherit; }
.top-actions .favorite-button[aria-pressed="true"] { color: var(--ink-accent); }
.top-actions .favorite-button[aria-pressed="true"] svg { fill: var(--ink-accent-wash); }

/* Retained dialogs and welcome actions share these primitives. */
.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(12, 21, 31, 0.2);
  color: var(--ink);
  cursor: pointer;
  transition: transform 100ms var(--ease-out);
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button:active { transform: scale(.97); }
.icon-button:disabled { cursor: default; opacity: .55; }
.favorite-button.is-active { color: var(--ink-accent); }
.favorite-button.is-active svg { fill: var(--ink-accent-wash); }

.primary,
.text-button {
  min-height: 50px;
  padding: 0 18px;
  border-radius: var(--radius-control);
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  transition: border-color 160ms var(--ease-out), background-color 160ms var(--ease-out), color 160ms var(--ease-out), transform 100ms var(--ease-out);
}

.primary {
  min-width: 168px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #17202a;
}

.text-button { border: 1px solid var(--line); background: rgba(12, 21, 31, .12); color: var(--ink); }
.top-actions .motion-toggle { width: auto; min-width: 44px; min-height: 44px; padding: 8px 4px; border: 0; border-radius: 0; background: none; box-shadow: none; color: var(--sky-ink); font-size: 12px; white-space: nowrap; }
.top-actions .motion-toggle:focus-visible { outline: none; text-decoration: underline dashed currentColor; text-decoration-thickness: 1.5px; text-underline-offset: 6px; }
.primary:active,
.text-button:active { transform: scale(.98); }
.primary:disabled,
.text-button:disabled { cursor: not-allowed; opacity: .55; }

.favorite-feedback {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 15px 22px;
  color: var(--ink);
  filter: drop-shadow(1px 6px 7px #43352b16);
}

.favorite-feedback::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--paper) url("../assets/paper/paper-grain-wide.png") center / cover no-repeat;
  background-blend-mode: multiply;
  mask: url("../assets/paper/supporting-paper-mask.svg") center / 100% 100% no-repeat;
}
@media (forced-colors: active) { .favorite-feedback::before { background: Canvas; mask: none; } }

.favorite-feedback[data-status="error"] { color: var(--ink-accent); }
.favorite-feedback p { flex: 1 1 120px; min-width: 0; margin: 0; font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.favorite-feedback .text-button { min-height: 44px; width: auto; padding: 8px 4px; border: 0; border-radius: 0; background: none; color: var(--ink-accent); }

#favorite-feedback {
  position: fixed;
  z-index: 40;
  inset: auto 16px max(20px, env(safe-area-inset-bottom));
  width: min(440px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  margin: 0 auto;
}

.search-spinner {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-top-color: var(--ink-accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.brand:focus-visible,
.favorite-feedback .text-button:focus-visible {
  outline: none;
  text-decoration: underline dashed var(--ink);
  text-underline-offset: 7px;
  text-decoration-thickness: 1px;
}

.top-actions .icon-button:focus-visible {
  outline: 1px dashed var(--ink);
  outline-offset: -4px;
}

@media (hover: hover) and (pointer: fine) {
  .brand:hover,
  .top-actions .icon-button:hover { color: var(--ink-accent); }
  .primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
}

@media (max-width: 760px) {
  .topbar { gap: 12px; }
  .brand { gap: 8px; padding-right: 5px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand-copy strong { font-size: 20px; }
  .brand-copy small { max-width: 150px; overflow-wrap: anywhere; }
  .top-actions { gap: 2px; padding-inline: 2px; }
  .primary,
  .text-button { width: 100%; }
}

@media (max-width: 370px) {
  .topbar { gap: 8px; flex-wrap: wrap; }
  .brand { flex: 1 1 168px; }
  .top-actions { margin-left: auto; }
}

/* ---------- 欢迎页：天空扉页、入门纸条与观测实录 ---------- */
.welcome {
  padding: 74px 0 34px;
  color: var(--sky-ink);
  font-family: var(--font-hand);
  font-weight: 400;
  font-synthesis: none;
}

.welcome-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 74px;
  align-items: center;
}

.welcome-copy,
.welcome-specimen { min-width: 0; }
.welcome-eyebrow { font-size: 13px; letter-spacing: 2px; }
.welcome h1 {
  margin: 16px 0 24px;
  font-size: 62px;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: 2px;
}
.welcome .intro { max-width: 350px; margin: 0; font-size: 18px; line-height: 1.75; }
.welcome-journal-folio,
.specimen-card { position: relative; isolation: isolate; color: var(--ink); }
.welcome-journal-folio::before,
.specimen-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--paper) url("../assets/paper/paper-grain-wide.png") center / cover no-repeat;
  background-blend-mode: multiply;
  mask: url("../assets/paper/supporting-paper-mask.svg") center / 100% 100% no-repeat;
  pointer-events: none;
}
.welcome-journal-folio {
  max-width: 400px;
  margin-top: 36px;
  padding: 27px 29px;
  --card-rot: 0deg;
  transform-origin: top center;
}
.welcome-journal-folio h2 { width: fit-content; margin: 0; padding-bottom: 9px; background: url("../assets/paper/supporting-pencil.png") left bottom / 100% 7px no-repeat; font-size: 19px; font-weight: 400; line-height: 1.5; }
.welcome-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 23px; margin-top: 9px; }
.welcome-actions .text-button,
.specimen-tab,
.loading-search,
.error :is(.primary, .text-button),
.welcome-bottom {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: auto;
  min-width: 44px;
  min-height: 44px;
  padding: 10px 4px;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  font: inherit;
  font-weight: 400;
  color: inherit;
  line-height: 1.5;
  text-decoration: none;
  cursor: pointer;
}
.welcome-actions .folio-btn-search { color: var(--ink-accent); font-size: 20px; }
.welcome-actions .folio-btn-locate { font-size: 16px; }
.welcome-actions .text-button:disabled { color: var(--ink-muted); cursor: default; }
.folio-btn-search::after,
.specimen-tab[aria-checked="true"]::after,
.error .primary::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 1px;
  height: 7px;
  background: url("../assets/paper/supporting-pencil.png") center / 100% 100%;
  pointer-events: none;
}
.welcome :is(button, a):focus-visible,
.loading-search:focus-visible,
.error :is(.primary, .text-button):focus-visible {
  outline: none;
  text-decoration: underline dashed var(--ink);
  text-underline-offset: 6px;
}
.privacy-note { margin: 18px 0 0; padding-left: 16px; background: url("../assets/paper/supporting-brace.png") left center / 8px 100% no-repeat; color: var(--ink-muted); font-size: 12px; line-height: 1.75; }
.notice { margin: 12px 0 0; color: var(--ink-accent); font-size: 14px; line-height: 1.7; }
.notice:empty { display: none; }
.welcome-bottom { margin-top: 55px; color: var(--sky-ink); font-size: 13px; }
.welcome .welcome-bottom:focus-visible { text-decoration-color: currentColor; }
.specimen-card {
  padding: 27px 28px 28px;
  margin-top: 54px;
  transform-origin: top center;
  scroll-margin-top: 35px;
}
.specimen-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 15px; }
.specimen-tag { margin: 0; font-size: 12px; line-height: 1.6; color: var(--ink-muted); }
.specimen-tabs { display: flex; gap: 14px; }
.specimen-tab { flex-shrink: 0; font-size: 14px; }
.specimen-tab[aria-checked="true"] { color: var(--ink-accent); }
.specimen-photo-frame { margin: 0; }
.specimen-photo { display: block; width: 100%; height: 265px; object-fit: cover; border-radius: 2px 6px 3px 5px; }
.specimen-caption { margin: 18px 0 15px; font-size: 18px; line-height: 1.5; }
.specimen-verdict-row {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding-top: 16px;
  font-size: 15px;
}
.specimen-verdict-row::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 5px; background: url("../assets/paper/supporting-rule.png") center / 100% 100%; }
.specimen-verdict-row strong { padding: 0 2px 9px; transform: rotate(-3deg); background: url("../assets/paper/supporting-pencil.png") left bottom / 100% 8px no-repeat; font-size: 21px; font-weight: 400; color: var(--ink-accent); }
.specimen-note,
.specimen-photo-credit { margin: 15px 0 0; font-size: 12px; line-height: 1.65; color: var(--ink-muted); }
.specimen-photo-credit { margin-top: 4px; }

.welcome-journal-folio, .specimen-card { filter: drop-shadow(1px 6px 7px #43352b16); }
/* ---------- Compact first read and unavailable forecast papers ---------- */
.loading, .error { flex: 0 1 auto; margin: 75px auto 70px; }
.loading .loading-caption { margin: 24px 0 0; padding: 0; color: var(--ink-muted); font-size: 12px; line-height: 1.6; }
.loading-search { margin-top: 14px; font-size: 14px; }
.loading-search:focus-visible { text-decoration-color: var(--ink); }
.loader-stage { display: grid; place-items: start; min-height: 105px; margin: 0 0 12px; }
.error-symbol { display: block; width: 100px; height: 52px; color: #8e7961; }
.error h1:focus { outline: none; }
.error h1:focus-visible { text-decoration: underline dashed var(--ink); text-decoration-thickness: 1.5px; text-underline-offset: 8px; }
.error-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; margin-top: 17px; }
.error .primary { color: var(--ink-accent); font-size: 16px; }
.error .text-button { font-size: 14px; }

@media (max-width: 760px) {
  .welcome { padding-top: 42px; padding-bottom: 28px; }
  .welcome-layout { grid-template-columns: minmax(0, 1fr); gap: 34px; }
  .welcome h1 { margin-top: 12px; margin-bottom: 18px; font-size: 47px; }
  .welcome .intro { font-size: 16px; }
  .welcome-journal-folio { margin-top: 27px; padding: 25px 24px; }
  .welcome-actions { gap: 20px; }
  .welcome-bottom { margin-top: 22px; }
  .specimen-card { margin: 5px 0 0; padding: 24px 22px; }
  .specimen-photo { height: 220px; }
}
@media (max-width: 600px) {
  .welcome-eyebrow { font-size: 12px; }
  .loading, .error { margin: 34px auto 45px; }
  .error-actions { gap: 8px 18px; }
}
@media (hover: hover) and (pointer: fine) {
  .welcome :is(button, a):hover:not(:disabled),
  .error button:hover { color: var(--ink-accent); }
}
@media (forced-colors: active) {
  .welcome-journal-folio::before,
  .specimen-card::before { background: Canvas; }
  .welcome :is(button, a):focus-visible,
  .loading-search:focus-visible { outline: 2px solid Highlight; outline-offset: 2px; }
  .specimen-tab[aria-checked="true"] { text-decoration: underline; }
}

/* The approved loading sketch is compact; only the sun moves. */
.loader-horizon { position: relative; width: 180px; max-width: 100%; height: 105px; overflow: hidden; }
.loader-horizon::before { content: ""; position: absolute; left: 0; right: 0; top: 82px; height: 5px; background: url("../assets/paper/supporting-rule.png") center / 100% 100% no-repeat; }
.horizon-sun { position: absolute; width: 48px; height: 47px; left: 65px; top: 22px; border: 1px solid #a56b3d; border-radius: 49% 51% 48% 52%; background: #e8c79055; animation: horizon-sun-rise 3.2s var(--ease-in-out) infinite; }
@keyframes horizon-sun-rise { 0%, 100% { transform: translateY(17px); opacity: .5; } 50% { transform: translateY(-8px); opacity: .9; } }
@media (prefers-reduced-motion: reduce) { .horizon-sun { animation: none; } }

/* ---------- Sky Letter: four independent papers and real forecast states ---------- */
.ready { position: relative; min-width: 0; margin-top: 42px; padding: 0 0 40px; color: var(--ink); }
.ready p:not([data-sl-part]) { line-height: 1.7; }
.forecast-context { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 6px 24px; margin-bottom: 30px; color: var(--sky-ink); }
.home-location { min-width: 0; max-width: 100%; }
.home-region { margin: 2px 0 0; font-size: 13px; }
.home-city { display: flex; align-items: baseline; gap: 12px; min-height: 44px; max-width: 100%; margin: 0; padding: 0 0 7px; border: 0; background: none; color: inherit; font-size: 46px; line-height: 1.15; text-align: left; overflow-wrap: anywhere; cursor: pointer; }
.home-city > span:last-child { flex-shrink: 0; font-size: 18px; }
.home-weather { grid-column: 1 / -1; margin: 0; font-size: 13px; }
.ready-toolbar { display: flex; flex-direction: column-reverse; align-items: flex-end; gap: 4px; min-width: 0; }
.event-status { display: flex; align-items: center; min-height: 22px; max-width: 260px; padding: 0 6px; }
.event-status > p { margin: 0; font-size: 12px; line-height: 1.65; }
.event-tabs { display: flex; align-items: center; gap: 18px; }
.event-tabs button { position: relative; min-width: 52px; min-height: 44px; padding: 8px 6px; border: 0; background: none; font-size: 18px; line-height: 1.5; cursor: pointer; }
.event-tabs button[aria-pressed="true"]::after { content: ""; position: absolute; left: 4px; right: 4px; bottom: 1px; height: 7px; background: var(--sky-accent); mask: url("../assets/paper/supporting-pencil.png") center / 100% 100% no-repeat; pointer-events: none; }
.event-tabs button:disabled { cursor: default; color: var(--ink-muted); }

/* Card material and geometry live in the design system; this file owns page placement. */
:root {
  --sl-asset-paper-mask: url("../assets/paper/supporting-paper-mask.svg");
  --sl-asset-paper-grain: url("../assets/paper/paper-grain-wide.png");
  --sl-asset-time-marks: url("../assets/paper/home-time-marks.png");
  --sl-asset-pencil: url("../assets/paper/supporting-pencil.png");
  --sl-asset-brace: url("../assets/paper/supporting-brace.png");
  --sl-asset-leader: url("../assets/paper/supporting-leader.png");
  --sl-asset-focus: url("../assets/paper/outlook-focus.png");
  --sl-asset-clip: url("../assets/paper/clip.png");
}
.hero-master-card { position: relative; min-width: 0; margin: 0 0 24px; padding: 0; }
.hero-journal-grid { display: grid; grid-template-columns: minmax(0, 480px) 300px; align-items: start; justify-content: space-between; gap: 44px; }
.hero-score-col { margin-top: 70px; }
body[data-tier="epic"] .hero-score-col { --paper-score-color: var(--ink-epic); }
body[data-tier="great"] .hero-score-col { --paper-score-color: var(--ink-score); }
body[data-tier="good"] .hero-score-col { --paper-score-color: var(--ink-good); }
body[data-tier="fair"] .hero-score-col { --paper-score-color: var(--ink-fair); }
body[data-tier="dull"] .hero-score-col { --paper-score-color: var(--ink-dull); }
.hero-event-time:focus { outline: none; }
.hero-event-time:focus-visible { text-decoration: underline dashed var(--ink); text-decoration-thickness: 1.5px; text-underline-offset: 8px; }
.hero-window-text { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; margin: 0; color: var(--ink-muted); font-size: 13px; }
.hero-lunar-badge { position: absolute; left: 480px; right: 300px; bottom: 62px; display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 44px; min-height: 44px; margin: 0 16px; padding: 4px 0; border: 0; background: none; color: var(--sky-ink); font-size: 13px; line-height: 1.65; text-align: left; cursor: pointer; }
body:not([data-light="night"]) :is(.sky-moon, .hero-lunar-badge) { display: none; }
.lunar-badge-icon { display: inline-flex; width: 22px; height: 22px; flex-shrink: 0; }
.lunar-badge-icon svg { display: block; width: 100%; height: 100%; }
.hero-comment { display: flex; justify-content: flex-end; min-height: 44px; padding: 0 22px 8px; }
.hero-companion-pill { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 3px 8px; min-width: 44px; min-height: 44px; max-width: 100%; margin: 0; padding: 8px 0; border: 0; background: none; color: var(--sky-ink); font-size: 14px; line-height: 1.65; text-align: left; cursor: pointer; }
.companion-arrow { font-size: 12px; white-space: nowrap; }

/* One reserved metadata row: refresh never moves or replaces the forecast papers. */
.forecast-note { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; min-height: 44px; min-width: 0; font-size: 13px; line-height: 20px; }
.freshness-copy { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; min-width: 0; }
.freshness-message { display: inline-flex; flex-wrap: wrap; gap: 0 8px; }
.freshness-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.forecast-note .text-button { width: auto; min-width: 44px; min-height: 44px; padding: 8px 4px; border: 0; border-radius: 0; background: none; box-shadow: none; color: inherit; font-size: 14px; white-space: nowrap; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; }
.forecast-note .text-button:disabled { cursor: wait; opacity: .7; }
.forecast-note .text-button:focus-visible { text-decoration-color: currentColor; }
#event-pending-label:focus { outline: none; }
#event-pending-label:focus-visible { text-decoration: underline dashed; text-decoration-thickness: 1.5px; text-underline-offset: 5px; }
.forecast-note:is([data-state="switchfailed"], [data-state="error"]) #event-pending-label { color: var(--sky-accent); }

/* Grouped cloud and air notes, with the actual largest measured penalty. */
.section-block { min-width: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; }
.section-head > div { display: flex; align-items: baseline; gap: 12px; }
.section-head h2 { margin: 0; font-size: 27px; line-height: 1.3; }
.section-head p { margin: 0; color: var(--ink-muted); font-size: 12px; }
.factors-block { width: 100%; margin: 0; }
.factors-block > .section-head { margin: 16px 8px 24px; color: var(--sky-ink); }
.factors-block > .section-head p { color: inherit; }
.factor-sheet { margin: 0 0 0 auto; }
.factor-details .factor-reason { padding: 5px 0; }
.factor-range { display: block; color: var(--ink); }
.factor-note { display: block; font-size: 13px; line-height: 1.7; }

/* One uncreased seven-day slip: current underline and highest-score circle. */
.week-block { margin-top: 44px; }
.week-block > .section-head { min-height: 52px; margin: 0 8px 5px; gap: 8px 28px; }
.week-block .section-head h2 { font-size: 25px; }
.week-best { min-width: 44px; min-height: 44px; padding: 8px 4px; border: 0; background: none; color: var(--sky-accent); font-size: 13px; line-height: 1.65; cursor: pointer; }
.horizontal-scroll-region { position: relative; max-width: 100%; overflow-x: auto; padding: 12px 5px 15px; scroll-snap-type: x proximity; scroll-padding-inline: 8px; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.day-card:active:not(:disabled) .day-score { opacity: .65; }
.week-foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 20px; margin: 7px 0 0; padding: 10px 0; color: var(--sky-ink); font-size: 12px; line-height: 1.65; }
.week-swipe-hint { display: none; }
.horizontal-scroll-region.can-scroll + .week-foot .week-swipe-hint { display: inline; }
.ready :is(button, summary):focus-visible { outline: none; text-decoration: underline dashed var(--ink); text-underline-offset: 7px; text-decoration-thickness: 1.5px; }
.ready .day-card:focus-visible { text-decoration: none; }
.ready .day-card:focus-visible .day-date { text-decoration: underline dashed var(--ink); text-underline-offset: 6px; }
.horizontal-scroll-region:focus-visible, .ready :is(.paper-clip-action, .paper-tape-action):focus-visible { outline: 1px dashed var(--ink); outline-offset: 2px; text-decoration: none; }
@media (hover: hover) and (pointer: fine) {
  .ready :is(.home-city, .event-tabs button, .hero-lunar-badge, .hero-companion-pill, .week-best):hover:not(:disabled) { color: var(--sky-accent); }
  .day-card:hover:not(:disabled) .day-date { text-decoration: underline; text-underline-offset: 5px; }
}
@media (max-width: 900px) {
  .hero-journal-grid { grid-template-columns: minmax(0, 440px) 270px; gap: 32px; }
  .hero-score-col { margin-top: 130px; }
  .hero-lunar-badge { left: auto; right: 0; bottom: 50px; max-width: 40%; margin: 0; }
}
@media (max-width: 700px) {
  .ready { margin-top: 26px; padding-bottom: 32px; }
  .forecast-context { gap: 5px 8px; margin-bottom: 28px; }
  .ready-toolbar { gap: 2px; }
  .event-status { max-width: 128px; padding: 0; text-align: right; }
  .event-status > p { font-size: 11px; }
  .home-city { font-size: 36px; }
  .home-region, .home-weather { font-size: 12px; }
  .event-tabs { gap: 6px; }
  .event-tabs button { min-width: 44px; padding: 7px 3px; font-size: 17px; }
  .hero-master-card { margin-top: 0; margin-bottom: 20px; }
  .hero-journal-grid { display: flex; flex-direction: column; align-items: flex-start; gap: 30px; }
  .hero-score-col { margin: 0; }
  .hero-meta-col { align-self: flex-end; }
  .hero-lunar-badge { position: static; max-width: 100%; margin-top: 14px; }
  .hero-comment { justify-content: flex-start; padding: 0; }
  .forecast-note { justify-content: space-between; gap: 8px; min-height: 64px; font-size: 12px; }
  .freshness-copy { flex-direction: column; gap: 0; }
  .freshness-message { display: flex; flex-direction: column; }
  .freshness-actions { gap: 4px; }
  .factors-block > .section-head { margin: 22px 0 24px; }
  .section-head h2 { font-size: 23px; white-space: nowrap; }
  .week-block { margin-top: 35px; }
  .week-block > .section-head { margin-left: 0; gap: 8px; }
  .week-block .section-head h2 { font-size: 23px; }
  .horizontal-scroll-region { margin-inline: -8px; max-width: calc(100% + 16px); padding-inline: 8px; }
}
@media (max-width: 370px) {
  .app-shell { width: calc(100% - 36px); }
  .home-city { font-size: 34px; }
  .event-tabs { gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .ready *, .favorite-feedback, .loading * { animation: none !important; transition: none !important; scroll-behavior: auto; }
}
body[data-input="keyboard"] :is(.ready, .favorite-feedback) * { transition: none; }
@media (forced-colors: active) {
  :is(.ready, .loading, .error, .brand, .top-actions, .favorite-feedback) { color: CanvasText; forced-color-adjust: auto; }
  :is(.hero-score-col, .hero-meta-col, .factor-sheet, .week-strip, .state-paper)::before { background: Canvas !important; mask: none; }
  .score-annotations { display: none; }
  .ready :is(button, summary):focus-visible, .brand:focus-visible, .top-actions .icon-button:focus-visible, .horizontal-scroll-region:focus-visible { outline: 2px solid Highlight; outline-offset: 2px; }
  .day-card[aria-pressed="true"] .day-score, .event-tabs button[aria-pressed="true"], .factor-row[data-major="true"] .factor-value { text-decoration: underline; }
  .day-card[data-best="true"] .day-mark { text-decoration: underline double; }
  :is(.factor-list, .factor-group-heading h3, .factor-value) { background-image: none !important; }
  .factor-margin::before, .day-score::before, .day-score::after { display: none; }
}

/* ---------- 弹窗与抽屉：地点与月相 ---------- */
dialog.paper-surface {
  isolation: isolate;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  filter: drop-shadow(1px 6px 7px #43352b16);
  transform: translateY(var(--sheet-translate-y, 0px));
}

dialog.paper-surface::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--paper) url("../assets/paper/paper-grain-wide.png") center / cover no-repeat;
  background-blend-mode: multiply;
  mask: url("../assets/paper/supporting-paper-mask.svg") center / 100% 100% no-repeat;
}


dialog {
  width: min(calc(100% - 48px), 590px);
  max-height: calc(100dvh - 64px);
  margin: auto;
  padding: 33px 38px 31px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 0;
  color: var(--ink);
  color-scheme: light;
  font-family: var(--font-hand);
  font-synthesis: none;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
}
.dialog-head p { margin: 0 0 5px; color: var(--ink-muted); font-size: 12px; font-weight: 400; }
.dialog-head h2 { margin: 0; font-size: 34px; line-height: 1.3; font-weight: 400; }
.dialog-close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
}
.dialog-close svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 1.5; }
.dialog-close:focus-visible { outline: 1px dashed currentColor; outline-offset: -3px; }
.dialog-close:active { opacity: .65; }
@media (hover: hover) and (pointer: fine) {
  .dialog-close:hover { color: var(--ink-accent); }
}

/* Approved SkyPlaces: one paper sheet and an independently scrolling list. */
dialog#places-dialog {
  width: min(590px, calc(100% - 48px));
  max-width: 590px;
  max-height: calc(100dvh - 143px);
  margin: 111px max(6vw, 24px) auto auto;
  padding: 37px 38px 31px;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-hand);
}
dialog#places-dialog[open] { display: flex; flex-direction: column; }
#places-dialog :is(button, input) { font-family: inherit; font-weight: 400; }
#places-dialog button { min-width: 44px; min-height: 44px; border: 0; border-radius: 0; background: none; color: inherit; cursor: pointer; touch-action: manipulation; }
#places-dialog button:disabled { cursor: default; opacity: .55; }
#places-dialog button:focus-visible { outline: none; text-decoration: underline dashed var(--ink); text-underline-offset: 6px; }
#places-dialog :is(.dialog-close, .delete-favorite):focus-visible { outline: 1px dashed var(--ink); outline-offset: -4px; border-radius: 50%; text-decoration: none; }
#places-dialog button:active:not(:disabled) { opacity: .65; transform: none; }
#places-dialog svg { width: 22px; height: 22px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
#places-dialog .dialog-head { align-items: flex-start; flex-shrink: 0; gap: 18px; margin: 0; padding: 0; }
#places-dialog .dialog-head p { margin: 0 0 6px; color: var(--ink-muted); font-size: 13px; letter-spacing: 1px; }
#places-dialog .dialog-head h2 { width: fit-content; padding-bottom: 12px; background: url("../assets/paper/supporting-pencil.png") left bottom / 90% 10px no-repeat; font-size: 34px; line-height: 1.3; }
#places-dialog .dialog-close { margin: -5px -9px 0 0; }
#places-dialog .places-search-block { flex-shrink: 0; margin-top: 25px; padding-bottom: 0; }
#places-dialog .search-label { display: block; margin-bottom: 8px; font-size: 17px; }
#places-dialog .search-field { display: flex; align-items: center; gap: 10px; position: relative; border: 0; background: url("../assets/paper/supporting-rule.png") left bottom / 100% 3px no-repeat; }
#places-dialog .search-field:focus-within { box-shadow: none; background-image: url("../assets/paper/supporting-pencil.png"); background-size: 100% 5px; }
#places-dialog .search-field input {
  width: 100%;
  min-width: 0;
  min-height: 54px;
  margin: 0;
  padding: 7px 0;
  appearance: none;
  border: 0;
  border-radius: 0;
  outline: none;
  background: none;
  box-shadow: none;
  color: inherit;
  caret-color: var(--ink-accent);
  font-size: 23px;
  line-height: 1.5;
}
#places-dialog .search-field input::placeholder { color: #6f685c; opacity: 1; }
#places-dialog .search-field input::-webkit-search-cancel-button { display: none; }
#places-dialog .clear-search { flex-shrink: 0; padding: 8px 0 8px 8px; font-size: 14px; }
#places-dialog .search-hint { margin: 9px 0 0; color: var(--ink-muted); font-size: 12px; line-height: 1.6; }
#places-dialog .search-spinner { width: 18px; height: 18px; border-color: #d4cbbb; border-top-color: var(--ink-accent); }
#places-dialog .places-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #9d8d72 transparent; padding: 0 1px; touch-action: pan-y; }
#places-dialog .places-scroll:focus-visible { outline: 1px dashed var(--ink); outline-offset: -1px; }
#places-dialog .location-row { display: flex; align-items: center; gap: 13px; width: 100%; margin-top: 16px; padding: 13px 0; text-align: left; }
#places-dialog .location-row > span { flex: 1; min-width: 0; }
#places-dialog .location-row strong { display: block; font-size: 18px; line-height: 1.5; }
#places-dialog .location-row small { display: block; margin-top: 4px; color: var(--ink-muted); font-size: 12px; line-height: 1.65; }
#places-dialog .location-arrow { width: 18px; }
#places-dialog .dialog-status { padding: 16px 0 6px; color: var(--ink-muted); font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
#places-dialog .dialog-status:empty { display: none; }
#places-dialog .dialog-status[data-status="results"] { margin: 15px 0 5px; padding: 0; font-size: 12px; }
#places-dialog .dialog-status:is([data-status="loading"], [data-status="locating"]) { display: flex; align-items: center; gap: 10px; }
#places-dialog .search-status-icon { stroke-dasharray: 3 5; }
#places-dialog .search-status-copy { min-width: 0; }
#places-dialog .search-status-copy strong { display: block; color: var(--ink); font-size: 18px; line-height: 1.5; }
#places-dialog .search-status-copy p { margin: 5px 0 0; font-size: 13px; }
#places-dialog .dialog-status[data-status="error"] strong { color: var(--ink-accent); }
#places-dialog .search-retry { padding: 8px 0; color: var(--ink-accent); font-size: 14px; text-decoration: underline; text-underline-offset: 5px; }
#places-dialog :is(.search-results, #favorites-list) { margin: 0; padding: 0; list-style: none; }
#places-dialog .search-results li button { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 65px; padding: 10px 0; text-align: left; }
#places-dialog .result-copy { min-width: 0; }
#places-dialog .search-results .place-label { font-size: 20px; }
#places-dialog .search-results small { display: block; margin-top: 4px; color: var(--ink-muted); font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; }
#places-dialog .choose-arrow { color: var(--ink-accent); font-size: 21px; }
#places-dialog .favorites-section { position: relative; margin-top: 18px; padding-top: 21px; }
#places-dialog :is(.favorites-section, .favorite-feedback, .places-footer)::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: url("../assets/paper/supporting-rule.png") center / 100% 100%; mask: none; pointer-events: none; }
#places-dialog .favorites-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
#places-dialog .favorites-head h3 { width: fit-content; padding-bottom: 8px; background: url("../assets/paper/supporting-pencil.png") left bottom / 100% 7px no-repeat; margin: 0; font-size: 21px; line-height: 1.5; }
#places-dialog .save-current { display: flex; align-items: center; gap: 6px; padding: 8px 0 8px 8px; font-size: 12px; line-height: 1.5; }
#places-dialog .save-current svg { width: 18px; height: 18px; }
#places-dialog :is(.delete-favorite, .save-current)[aria-pressed="true"] svg { fill: var(--ink-accent-wash); color: var(--ink-accent); }
#places-dialog .favorites-capacity { margin: 4px 0 14px; color: var(--ink-muted); font-size: 12px; line-height: 1.65; }
#places-dialog .favorites-notice { margin: 0; padding: 13px 0 13px 20px; background: url("../assets/paper/supporting-brace.png") left center / 11px 90% no-repeat; color: var(--ink-accent); font-size: 13px; line-height: 1.7; }
#places-dialog .favorite-row { display: flex; align-items: center; gap: 8px; min-height: 67px; }
#places-dialog .favorite-place { display: flex; align-items: center; flex: 1; min-width: 0; gap: 15px; padding: 9px 0; text-align: left; }
#places-dialog .favorite-number { align-self: flex-start; min-width: 2ch; margin-top: 6px; color: var(--ink-muted); font-size: 12px; line-height: 1.4; }
#places-dialog .favorite-copy { flex: 1; min-width: 0; line-height: 1.4; }
#places-dialog .place-label { font-size: 21px; font-weight: 400; overflow-wrap: anywhere; }
#places-dialog .favorite-copy small { display: block; margin-top: 4px; color: var(--ink-muted); font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; }
#places-dialog .favorite-current { padding: 0 0 5px 6px; transform: rotate(-5deg); background: url("../assets/paper/supporting-leader.png") left bottom / 35px 13px no-repeat; align-self: flex-start; flex-shrink: 0; margin-top: 6px; color: var(--ink-accent); font-size: 12px; line-height: 1.4; white-space: nowrap; }
#places-dialog .favorite-place[aria-current="location"] .place-label { text-decoration: none; padding-bottom: 7px; background: url("../assets/paper/supporting-pencil.png") left bottom / 100% 7px no-repeat; }
#places-dialog .favorite-place:focus-visible .place-label { text-decoration-style: dashed; text-decoration-color: var(--ink); }
#places-dialog .delete-favorite { display: grid; place-items: center; flex: 0 0 44px; padding: 8px; }
#places-dialog .delete-favorite svg { width: 21px; height: 21px; }
#places-dialog #favorites-empty { display: flex; align-items: flex-start; gap: 17px; padding: 24px 0 15px; }
#places-dialog #favorites-empty > svg { width: 32px; height: 32px; margin-top: 3px; color: #86745d; }
#places-dialog .favorite-empty-copy strong { display: block; font-size: 19px; line-height: 1.5; }
#places-dialog .favorite-empty-copy p { margin: 7px 0 0; color: var(--ink-muted); font-size: 13px; line-height: 1.65; }
#places-dialog .favorite-feedback { position: relative; align-items: center; justify-content: space-between; gap: 16px; margin-top: 13px; padding: 9px 0; color: var(--ink); }
#places-dialog .favorite-feedback p { padding-left: 16px; background: url("../assets/paper/supporting-brace.png") left center / 8px 90% no-repeat; font-size: 13px; }
#places-dialog .favorite-feedback[data-status="error"] { color: var(--ink-accent); }
#places-dialog .favorite-feedback .text-button { min-width: 44px; padding: 8px 0 8px 8px; color: var(--ink-accent); font-size: 14px; text-decoration: underline; text-underline-offset: 5px; }
#places-dialog .places-footer { position: relative; margin-top: 22px; padding-top: 18px; }
#places-dialog .dialog-privacy { margin: 0; color: var(--ink-muted); font-size: 12px; line-height: 1.75; }
#places-dialog [hidden] { display: none !important; }
@media (hover: hover) and (pointer: fine) {
  #places-dialog button:hover:not(:disabled) { color: var(--ink-accent); }
}
@media (max-width: 760px) {
  dialog#places-dialog { width: 100%; max-width: none; height: calc(100dvh - 245px); max-height: calc(100dvh - max(24px, env(safe-area-inset-top))); margin: auto 0 0; padding: 20px 25px 0; }
    #places-dialog .dialog-head { gap: 15px; }
  #places-dialog .dialog-head p { margin-bottom: 3px; font-size: 12px; }
  #places-dialog .dialog-head h2 { font-size: 29px; }
  #places-dialog .dialog-close { margin: -3px -8px 0 0; }
  #places-dialog .places-search-block { margin-top: 20px; padding-bottom: 14px; }
  #places-dialog .search-label { margin-bottom: 6px; font-size: 16px; }
  #places-dialog .search-field { gap: 9px; }
  #places-dialog .search-field input { min-height: 49px; padding-block: 6px; font-size: 21px; }
  #places-dialog .clear-search { font-size: 13px; }
  #places-dialog .search-hint { margin-top: 8px; }
  #places-dialog .places-scroll { padding-bottom: calc(26px + env(safe-area-inset-bottom)); }
  #places-dialog .location-row { min-height: 65px; margin: 0; padding: 10px 0; gap: 11px; }
  #places-dialog .location-row strong { font-size: 17px; }
  #places-dialog .dialog-status { padding: 13px 0 7px; }
  #places-dialog .search-status-copy strong { font-size: 17px; }
  #places-dialog .search-status-copy p { font-size: 12px; }
  #places-dialog .search-retry { font-size: 13px; }
  #places-dialog .search-results li button { padding-block: 9px; }
  #places-dialog .favorites-section { margin-top: 13px; padding-top: 15px; }
  #places-dialog .favorites-head { gap: 8px; margin-bottom: 4px; }
  #places-dialog .favorites-head h3 { font-size: 20px; white-space: nowrap; }
  #places-dialog .save-current { gap: 5px; }
  #places-dialog .save-current svg { width: 17px; height: 17px; }
  #places-dialog .favorite-row { gap: 6px; }
  #places-dialog .favorite-place { gap: 11px; }
  #places-dialog .favorite-number { margin-top: 5px; }
  #places-dialog .place-label { font-size: 20px; }
  #places-dialog .delete-favorite { padding: 8px 0; }
  #places-dialog .delete-favorite svg { width: 20px; height: 20px; }
  #places-dialog #favorites-empty { gap: 15px; padding-top: 22px; }
  #places-dialog #favorites-empty > svg { width: 30px; height: 30px; }
  #places-dialog .favorite-empty-copy strong { font-size: 18px; }
  #places-dialog .favorite-empty-copy p { margin-top: 6px; font-size: 12px; }
  #places-dialog .favorite-feedback { gap: 10px; margin-top: 12px; padding-block: 8px; }
  #places-dialog .favorite-feedback p { font-size: 12px; }
  #places-dialog .favorite-feedback .text-button { font-size: 13px; }
  #places-dialog .places-footer { margin-top: 18px; padding-top: 15px; }
}
@media (max-width: 760px) and (max-height: 700px) {
  dialog#places-dialog { height: calc(100dvh - 195px); }
  #places-dialog .places-search-block { margin-top: 12px; }
  #places-dialog .dialog-head h2 { font-size: 26px; }
}
@media (max-width: 760px) and (max-height: 560px) {
  dialog#places-dialog { height: calc(100dvh - 24px); padding-top: 15px; }
  #places-dialog .dialog-head p { display: none; }
  #places-dialog .dialog-head h2 { font-size: 25px; }
  #places-dialog .places-search-block { margin-top: 10px; padding-bottom: 7px; }
  #places-dialog .search-hint { margin-top: 3px; }
}
@media (forced-colors: active) {
  #places-dialog :is(button, input, .places-scroll):focus-visible { outline: 2px solid Highlight; outline-offset: 2px; }
  #places-dialog .favorite-place[aria-current="location"] .place-label { color: LinkText; text-decoration-color: LinkText; }
}
@media (prefers-reduced-motion: reduce) {
  #places-dialog :is(button, .search-spinner) { animation: none; transition: none; }
}

.drawer-handle {
  display: none;
}


dialog.is-dragging {
  user-select: none;
  -webkit-user-select: none;
  animation: none !important;
  transition: none !important;
}

dialog.is-settling {
  animation: none !important;
  transition: transform 280ms var(--ease-drawer) !important;
}

dialog.is-dismissing {
  animation: none !important;
  transition: transform 240ms var(--ease-drawer), opacity 200ms ease-out !important;
  transform: translateY(100%);
  opacity: 0;
}

dialog.paper-surface::backdrop {
  background: rgba(25, 39, 44, .38);
  backdrop-filter: blur(2px);
  opacity: var(--backdrop-opacity, 1);
}
@media (max-width: 760px) {
  dialog {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - 24px);
    margin: auto 0 0;
    padding: 20px 25px calc(24px + env(safe-area-inset-bottom));
  }
  dialog.paper-surface { filter: drop-shadow(0 -5px 12px #45372b20); }
  .dialog-head h2 { font-size: 29px; }
  .drawer-handle {
    display: block;
    width: 38px;
    height: 4px;
    margin: 0 auto 16px;
    background: url("../assets/paper/supporting-rule.png") center / 100% 100% no-repeat;
    cursor: grab;
    touch-action: none;
    flex-shrink: 0;
  }
  dialog.is-dragging .drawer-handle { cursor: grabbing; }
}
@media (prefers-reduced-motion: reduce) {
  dialog.is-settling, dialog.is-dismissing { transition: none !important; }
}
@media (forced-colors: active) {
  dialog.paper-surface { color: CanvasText; border: 1px solid CanvasText; filter: none; }
  dialog.paper-surface::before { background: Canvas; }
}
/* ---------- 月相札记 ---------- */
dialog#lunar-dialog { width: min(1040px,calc(100% - 80px)); max-width: none; max-height: 94dvh; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; filter: none; overflow: visible; color: var(--ink); color-scheme: light; }
dialog#lunar-dialog::before { content: none; }
dialog#lunar-dialog::backdrop { background: linear-gradient(180deg,var(--sky-top,#9dbecb),var(--sky-mid,#c2d0cd) 58%,var(--sky-horizon,#e5dcc0)); backdrop-filter: none; }
#lunar-dialog button:focus-visible { outline: none; text-decoration: underline dashed var(--ink); text-underline-offset: 6px; }
#lunar-dialog .dialog-close:focus-visible { outline: 1px dashed var(--ink); outline-offset: -4px; border-radius: 50%; text-decoration: none; }
.lunar-dialog-scroll { display: grid; grid-template-columns: minmax(0,1fr) minmax(360px,430px); align-items: center; gap: 45px; max-height: 94dvh; padding: 32px 14px 20px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.lunar-observation-sheet { position: relative; isolation: isolate; min-width: 0; padding: 30px 32px 26px; color: var(--ink); filter: drop-shadow(1px 6px 7px #43352b16); }
.lunar-observation-sheet::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--paper) url("../assets/paper/paper-grain-wide.png") center / cover no-repeat; background-blend-mode: multiply; mask: url("../assets/paper/supporting-paper-mask.svg") center / 100% 100% no-repeat; }
#lunar-dialog .dialog-head { position: static; margin: 0; padding: 0; gap: 8px; align-items: flex-start; background: none; border: 0; box-shadow: none; }
#lunar-dialog .dialog-head h2 { width: fit-content; margin-top: 9px; padding-bottom: 12px; background: url("../assets/paper/supporting-pencil.png") left bottom / 90% 10px no-repeat; font-size: 25px; line-height: 1.3; }
#lunar-dialog .dialog-close { flex: 0 0 44px; margin: -10px -15px 0 0; background: none; border: 0; box-shadow: none; color: var(--ink); }
#lunar-dialog .lunar-sheet-tag { margin: 0; color: var(--ink-muted); font-size: 12px; line-height: 1.65; letter-spacing: 1.8px; }
.lunar-sheet-date { margin: 11px 0 0; font-size: 13px; line-height: 1.65; color: var(--ink-muted); }
.lunar-study { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; min-height: 480px; margin: 0; padding: 18px; color: var(--sky-ink); text-align: center; }
.lunar-moon-figure { position: relative; width: 184px; height: 184px; margin-bottom: 32px; }
#lunar-dialog-moon { position: relative; width: 100%; height: 100%; }
#lunar-dialog-moon svg { display: block; width: 100%; height: 100%; overflow: visible; }
.lunar-study-halo { position: absolute; inset: -72px; border-radius: 50%; background: radial-gradient(circle,#e6e3bd20,transparent 68%); animation: lunar-study-breathe 12s ease-in-out infinite alternate; }
.lunar-study h3 { margin: 0; font-size: 42px; letter-spacing: 6px; line-height: 1.3; font-weight: 400; }
.lunar-visibility { max-width: 350px; margin: 12px 0 0; font-size: 14px; line-height: 1.7; }
.lunar-diagram-note { margin: 14px 0 0; font-size: 12px; line-height: 1.65; }
.lunar-below-mark { width: 240px; min-height: 184px; margin-bottom: 32px; align-content: center; }
.lunar-below-mark svg { display: block; width: 100%; height: 42px; margin: 20px 0; }
.lunar-below-mark span { display: block; font-size: 14px; line-height: 1.65; }
.lunar-values { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 22px 24px; margin: 22px 0 0; padding: 24px 0 24px 20px; background: url("../assets/paper/supporting-brace.png") left center / 12px 91% no-repeat; }
.lunar-values, .lunar-advice { position: relative; }
.lunar-advice::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: url("../assets/paper/supporting-rule.png") center/100% 100% no-repeat; opacity: .6; }
.lunar-values dt { color: var(--ink-muted); font-size: 13px; line-height: 1.5; }
.lunar-values dd { margin: 7px 0 0; font-size: 27px; line-height: 1.25; }
.lunar-values small { display: block; margin-top: 6px; color: var(--ink-muted); font-size: 12px; line-height: 1.5; }
.lunar-unit { font-size: 15px; }
.lunar-advice { padding-top: 21px; }
.lunar-advice h3 { width: fit-content; padding-bottom: 8px; background: url("../assets/paper/supporting-pencil.png") left bottom / 100% 7px no-repeat; margin: 0 0 10px; color: var(--ink-accent); font-size: 18px; line-height: 1.5; font-weight: 400; }
.lunar-advice p { margin: 0; font-size: 16px; line-height: 1.7; }
.lunar-sheet-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 20px; }
.lunar-sheet-foot p { margin: 0; color: var(--ink-muted); font-size: 12px; line-height: 1.6; }
.lunar-sheet-foot form { margin: 0; }
.lunar-sheet-return { position: relative; min-height: 44px; padding: 9px 0; border: 0; background: none; font-family: var(--font-hand); color: var(--ink-accent); font-size: 14px; white-space: nowrap; cursor: pointer; }
.lunar-sheet-return::after { content: ""; position: absolute; left: 0; right: 0; bottom: 6px; height: 4px; background: url("../assets/paper/supporting-pencil.png") center/100% 100% no-repeat; }
@keyframes lunar-study-breathe { from { opacity: .5; } to { opacity: .8; } }
@media (max-width: 760px) {
  dialog#lunar-dialog { width: 100%; margin: auto 0 0; max-height: 94dvh; }
  .lunar-dialog-scroll { grid-template-columns: minmax(0,1fr); gap: 20px; padding: 0 22px max(0px,env(safe-area-inset-bottom)); }
  .lunar-study { flex-direction: row-reverse; justify-content: space-between; gap: 18px; min-height: 170px; margin: 16px 6px 0; padding: 0; text-align: left; }
  .lunar-study figcaption { min-width: 0; }
  .lunar-study h3 { font-size: 34px; letter-spacing: 3px; }
  .lunar-visibility { max-width: 158px; margin-top: 11px; font-size: 13px; }
  .lunar-diagram-note { margin-top: 9px; }
  .lunar-moon-figure { width: 128px; height: 128px; flex: 0 0 128px; margin: 0; }
  .lunar-study-halo { inset: -42px; }
  .lunar-below-mark { width: 128px; flex: 0 0 128px; min-height: 0; margin: 0; text-align: center; }
  .lunar-below-mark svg { height: 35px; margin: 0; }
  .lunar-below-mark span { margin-top: 9px; font-size: 12px; }
  .lunar-observation-sheet { padding: 28px 24px 23px; }
  #lunar-dialog .dialog-head h2 { font-size: 23px; margin-top: 7px; }
  .lunar-sheet-date { font-size: 12px; }
  .lunar-values { gap: 21px 14px; margin-top: 17px; padding: 19px 0 19px 17px; background-size: 10px 91%; }
  .lunar-values dt { font-size: 12px; }
  .lunar-values dd { font-size: 25px; margin-top: 6px; }
  .lunar-unit { font-size: 14px; }
  .lunar-values small { margin-top: 5px; }
  .lunar-advice { padding-top: 18px; }
  .lunar-advice h3 { font-size: 17px; margin-bottom: 8px; }
  .lunar-advice p { font-size: 15px; }
  .lunar-sheet-foot { margin-top: 16px; }
  .lunar-sheet-return { font-size: 13px; }
}
@media (max-width: 350px) {
  .lunar-dialog-scroll { padding-inline: 17px; }
  .lunar-study { gap: 12px; margin-inline: 0; }
  .lunar-moon-figure, .lunar-below-mark { width: 108px; flex-basis: 108px; }
  .lunar-moon-figure { height: 108px; }
  .lunar-study h3 { font-size: 29px; }
  .lunar-visibility { font-size: 12px; }
  .lunar-observation-sheet { padding: 25px 21px; }
}
@media (prefers-reduced-motion: reduce) {
  .lunar-study-halo { animation: none; }
}
@media (forced-colors: active) {
  .lunar-study-halo { display: none; }
  .lunar-observation-sheet::before { background: Canvas; }
  .lunar-observation-sheet { color: CanvasText; }
}


@media (min-width: 761px) {
  dialog.is-dismissing {
    transform: scale(0.98) translateY(6px);
    transition: transform 200ms var(--ease-out), opacity 200ms var(--ease-out) !important;
  }
}


/* Retained forecast remains a separate, explicitly selected-context note. */
.lunar-forecast-context { grid-column: 1 / -1; grid-row: 1; justify-self: end; position: relative; isolation: isolate; width: min(360px,63%); padding: 23px 25px; color: var(--ink); filter: drop-shadow(1px 6px 7px #43352b16); }
.lunar-forecast-context::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--paper) url("../assets/paper/paper-grain-wide.png") center / cover no-repeat; background-blend-mode: multiply; mask: url("../assets/paper/supporting-paper-mask.svg") center / 100% 100% no-repeat; }
.lunar-forecast-context p { margin: 0; font-size: 13px; line-height: 1.7; }
#lunar-context-place { font-size: 20px; margin-bottom: 5px; }
.lunar-context-reading { display: flex; gap: 20px; align-items: center; margin: 9px 0; }
#lunar-context-score { display: grid; place-items: center; flex-shrink: 0; width: 88px; height: 77px; font-size: 45px; color: var(--ink-score); background: url("../assets/paper/outlook-focus.png") center / 100% 100% no-repeat; }
#lunar-context-grade { padding-bottom: 12px; background: url("../assets/paper/supporting-leader.png") left bottom / 65px 18px no-repeat; }
.lunar-forecast-context .lunar-context-note { margin-top: 8px; color: var(--ink-muted); font-size: 12px; }
@media(max-width:760px) {
 .lunar-forecast-context { padding: 15px 16px; }
 .lunar-context-reading { gap: 9px; }
 #lunar-context-score { width: 62px; height: 57px; font-size: 32px; }
 #lunar-context-grade { font-size: 14px; background-size: 45px 15px; }
 #places-dialog .favorite-row { min-height: 69px; }
}
@media(forced-colors:active) {
 .lunar-forecast-context::before { mask: none; background: Canvas; }
 #lunar-context-score { background: none; color: CanvasText; }
 dialog.paper-surface::before, .lunar-observation-sheet::before { mask: none; }
 #places-dialog .favorite-place[aria-current="location"] .place-label { background: none; text-decoration: underline; }
 #places-dialog .search-field { background: none; border-bottom: 1px solid CanvasText; }
}
/* ---------- Page colophon: readable on every current sky ---------- */
.app-shell > footer {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 20px;
  width: fit-content;
  max-width: 100%;
  margin-top: auto;
  padding: 24px 0 0;
  color: var(--sky-ink);
  font-size: 12px;
  line-height: 1.65;
}


.app-shell > footer div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.app-shell > footer a { display: inline-flex; align-items: center; min-height: 44px; color: inherit; text-underline-offset: 4px; }
.app-shell > footer p { margin: 0; }

/* ---------- Current weather touches paper edges, never the data ---------- */
[data-weather-surface].is-rain-damp { --paper-weather-wash: radial-gradient(ellipse at 98% 95%, #abc1c354, transparent 38%); }
[data-weather-surface].is-cloud-shadowed { --paper-weather-wash: linear-gradient(140deg, #697a8312, transparent 60%); }
/* Include var(--paper-weather-wash, linear-gradient(transparent,transparent)) as the TOP layer of the existing masked paper ::before background-image. Do not mask the content element. */
.paper-edge-contact { position:absolute; inset:0; z-index:1; pointer-events:none; mask:url('../assets/paper/supporting-paper-mask.svg') center/100% 100% no-repeat; }
.paper-edge-contact::before { content:""; position:absolute; left:4%; right:4%; top:1.3%; height:9px; opacity:0; background:radial-gradient(ellipse at 20% 100%,#edf1ea 0 24%,transparent 26%),radial-gradient(ellipse at 64% 100%,#e1e9e7 0 28%,transparent 30%); }
.is-snow-contact .paper-edge-contact::before { opacity:.85; }
.paper-edge-contact i { position:absolute; top:2%; left:22%; width:5px; height:5px; opacity:0; border:1px solid #b6ced3; border-radius:50%; }
.paper-edge-contact i + i { left:72%; animation-delay:-.7s; }
.is-rain-damp .paper-edge-contact i { animation:paper-edge-drop 1.6s ease-out infinite; }
.is-rain-damp .paper-edge-contact i + i { animation-delay:-.7s; }
.is-hail-contact .paper-edge-contact i { width:4px; height:4px; background:#c5d8df; border:0; border-radius:1px; animation:paper-edge-hail 1.8s linear infinite; }
/* Lift the original paper and its ink together; no detached corner overlay. */
#panel-ready [data-weather-surface] { transform-origin:50% 0; transition:transform var(--duration-scene) cubic-bezier(.23,1,.32,1); transition-delay:240ms; }
#panel-ready [data-weather-surface]::after { content:""; position:absolute; z-index:-2; pointer-events:none; left:5%; right:5%; bottom:-12px; height:22px; background:radial-gradient(ellipse at center,#43352b55,transparent 70%); opacity:0; transition:opacity var(--duration-scene) linear; transition-delay:240ms; }
#panel-ready .hero-meta-col { transition-delay:160ms; }
#panel-ready .factor-sheet { transition-delay:320ms; }
body[data-paper-wind] #panel-ready [data-weather-surface] { transform:perspective(1000px) translateY(-1px) rotateX(1.5deg) rotateZ(-.12deg); }
body[data-paper-wind="high"] #panel-ready [data-weather-surface] { transform:perspective(1000px) translateY(-2px) rotateX(3deg) rotateZ(-.25deg); }
body[data-paper-wind] #panel-ready :is(.factor-sheet,.week-strip) { transform:perspective(1000px) translateY(-1px) rotateX(.35deg) rotateZ(-.05deg); }
body[data-paper-wind="high"] #panel-ready :is(.factor-sheet,.week-strip) { transform:perspective(1000px) translateY(-2px) rotateX(.6deg) rotateZ(-.1deg); }
body[data-paper-wind] #panel-ready [data-weather-surface]::after { opacity:.65; }
#paper-tape-action::before { transform-origin: left center; transition: transform var(--duration-scene) cubic-bezier(.23,1,.32,1), opacity var(--duration-scene) linear; }
body[data-weather="wind"] #paper-tape-action::before { animation: paper-tape-tail 4.5s cubic-bezier(.25,1,.4,1) infinite; }
body[data-paper-wind] #paper-tape-action::before { transform: rotate(-5deg); animation: none; }
body[data-paper-wind="high"] #paper-tape-action::before { transform: rotate(-9deg); }
#score-circle-action { isolation:isolate; }
#score-circle-action::after,#paper-clip-action::after { content:""; position:absolute; inset:-10px; z-index:-1; background:radial-gradient(ellipse,#f2ce804d,transparent 70%); opacity:0; pointer-events:none; transition:opacity var(--duration-scene) linear; }
#score-circle-action.is-sun-warmed::after,#paper-clip-action.is-sun-glowing::after { opacity:.65; }
#paper-clip-action.is-lightning-struck::after { opacity:1; background:radial-gradient(ellipse,#f5e9baaa,transparent 70%); }
#paper-tape-action.is-sun-translucent { opacity:.62; }
@keyframes paper-edge-drop { 0%,60%,100%{opacity:0;transform:scale(.7)}15%{opacity:.65;transform:scale(1)}40%{opacity:0;transform:scale(1.5)} }
@keyframes paper-edge-hail { 0%,65%,100%{opacity:0;transform:translate(0,0)}12%{opacity:.8;transform:translate(0,0)}25%{opacity:.8;transform:translate(8px,-12px)}45%{opacity:0;transform:translate(17px,3px)} }
@keyframes paper-tape-tail { 0%,65%,100%{transform:rotate(-8deg)}18%{transform:rotate(-15deg)}34%{transform:rotate(-9deg)} }
/* Effective motion flag is set by motion.mjs; system reduction always wins. */
body[data-motion="false"],body[data-motion="false"] *,body[data-motion="false"] *::before,body[data-motion="false"] *::after { animation:none!important; transition:none!important; scroll-behavior:auto!important; }
body[data-motion="false"] :is(.weather-canvas,.weather-contact-canvas,.weather-foreground-canvas) { visibility:hidden; }
body[data-motion="false"] #panel-ready [data-weather-surface] { transform:none; }
body[data-motion="false"] #panel-ready [data-weather-surface]::after { opacity:0; }
body[data-motion="false"] #paper-tape-action::before { transform: rotate(-8deg); }
body[data-motion="false"] .is-rain-damp .paper-edge-contact i,body[data-motion="false"] .is-hail-contact .paper-edge-contact i { opacity:.55; }
body[data-motion="false"] :is(#score-circle-action,#paper-clip-action)::after { opacity:0; }
@media(prefers-reduced-motion:reduce){
 *,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}
 #panel-ready [data-weather-surface]{transform:none!important}
 #panel-ready [data-weather-surface]::after{opacity:0!important}
 #paper-tape-action::before{transform:rotate(-8deg)!important}
 .is-rain-damp .paper-edge-contact i,.is-hail-contact .paper-edge-contact i{opacity:.55}
 #score-circle-action::after,#paper-clip-action::after{opacity:0}
 .weather-canvas,.weather-contact-canvas,.weather-foreground-canvas{visibility:hidden}
}
@media(forced-colors:active){
 body{--sky-ink:CanvasText;--sky-accent:Highlight}
 .sky,.weather-atmosphere,.weather-canvas,.weather-contact-canvas,.weather-foreground-canvas{visibility:hidden}
 .app-shell>footer,.app-shell>footer a{color:CanvasText}
 .error::before{background:Canvas}
 :is(.hero-score-col,.hero-meta-col,.factor-sheet,.week-strip)::before{background:Canvas!important}
 #panel-ready [data-weather-surface]{transform:none!important}
 #panel-ready [data-weather-surface]::after{display:none}
 .paper-edge-contact,#score-circle-action::after,#paper-clip-action::after{display:none}
 :is(button,a):focus-visible{outline:2px solid Highlight;outline-offset:2px}
}
