:root {
  --mist: #eaf2f4;
  --fog: #f8fbfa;
  --paper: rgba(255, 255, 255, .58);
  --ice: #dce8eb;
  --blue: #8fb5c0;
  --sage: #9db8b5;
  --slate: #25323a;
  --muted: #687980;
  --line: rgba(37, 50, 58, .14);
  --shadow: 0 20px 52px rgba(37, 50, 58, .12);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--mist);
  overscroll-behavior-x: none;
  -webkit-text-size-adjust: 100%;
}

body {
  color: var(--slate);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

button {
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
}

img {
  display: block;
  max-width: 100%;
  -webkit-user-drag: none;
}

.safe-top {
  padding-top: max(14px, var(--safe-top));
}

.safe-bottom {
  padding-bottom: max(14px, var(--safe-bottom));
}

.ambient-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 10%, rgba(255,255,255,.88), transparent 24%),
    radial-gradient(circle at 88% 26%, rgba(143,181,192,.22), transparent 30%),
    linear-gradient(150deg, rgba(255,255,255,.4), transparent 54%),
    url("./assets/noise.svg");
  opacity: .92;
}

.app-header,
.app-footer {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-title {
  min-width: 0;
  text-align: center;
}

.header-title p,
.app-footer {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
}

.header-title h1 {
  margin: 4px 0 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: .06em;
}

.icon-button {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.44);
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  transition: transform .2s ease, background-color .2s ease;
}

.hero-panel {
  position: relative;
  z-index: 12;
  margin: 10px 0 6px;
  padding: 18px 16px;
  border: 1px solid rgba(255,255,255,.7);
  background: rgba(255,255,255,.38);
  box-shadow: 0 14px 34px rgba(37,50,58,.08);
}

.hero-copy h2 {
  margin: 6px 0 10px;
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: clamp(25px, 7vw, 38px);
  font-weight: 400;
  line-height: 1.35;
}

.hero-copy p:last-child {
  margin: 0 0 14px;
  color: var(--muted);
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 15px;
  line-height: 1.9;
}

.primary-action {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--slate);
  background: var(--slate);
  color: var(--fog);
  cursor: pointer;
  font-size: 13px;
  letter-spacing: .12em;
}

.timeline-strip {
  position: relative;
  z-index: 18;
  margin: 8px -20px 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.timeline-strip::-webkit-scrollbar {
  display: none;
}

.timeline-track {
  display: flex;
  width: max-content;
  min-width: 100%;
  gap: 8px;
  padding: 0 20px 12px;
}

.timeline-dot {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.36);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  font-size: 10px;
  letter-spacing: .04em;
  transition: transform .2s ease, background-color .2s ease, border-color .2s ease;
}

.timeline-dot span {
  color: var(--slate);
  font-weight: 800;
}

.timeline-dot.is-active {
  border-color: rgba(37,50,58,.5);
  background: rgba(255,255,255,.78);
  color: var(--slate);
}

.story-stage {
  position: relative;
  z-index: 10;
  flex: 1;
  min-height: 0;
}

.scene {
  position: relative;
  display: none;
  min-height: calc(100svh - 260px);
  padding: 12px 0 20px;
  opacity: 0;
  transform: translate3d(18px, 0, 0);
  filter: blur(6px);
}

.scene.is-active {
  display: block;
  animation: pageIn .46s cubic-bezier(.2, .82, .24, 1) both;
}

.scene-scroll {
  display: flex;
  flex-direction: column;
  gap: 15px;
  min-height: calc(100svh - 280px);
}

.cat-stage {
  --cat-x: 0px;
  --cat-y: 0px;
  --escape-x: 72px;
  --escape-y: -14px;
  --settle-x: 50px;
  --settle-y: -10px;
  align-self: center;
  position: relative;
  width: min(55vw, 238px);
  padding: 8px;
  border: 1px solid rgba(255,255,255,.78);
  background: rgba(255,255,255,.48);
  box-shadow: var(--shadow);
  cursor: pointer;
  transform: translate3d(var(--cat-x), var(--cat-y), 0);
  transition: transform .18s ease, box-shadow .22s ease;
  will-change: transform;
}

.cat-stage img {
  position: relative;
  z-index: 2;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 4px;
  filter: saturate(.84) contrast(.98);
}

.cat-shadow {
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 28px;
  height: 13px;
  border-radius: 50%;
  background: rgba(37,50,58,.12);
  filter: blur(3px);
}

.cat-caption {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .12em;
  text-align: center;
}

.chapter-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chapter-meta span,
.scene-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.chapter-meta span {
  flex: 1;
  text-align: right;
  letter-spacing: .06em;
}

.scene h2 {
  margin: 0;
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: clamp(27px, 7.4vw, 42px);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.34;
}

.diary-fragment {
  margin: 0;
  padding: 12px 13px;
  border-left: 2px solid var(--blue);
  background: rgba(255,255,255,.36);
  color: var(--muted);
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 12px;
  line-height: 1.75;
  word-break: break-word;
}

.diary-fragment::before {
  content: "日记里留下的词句";
  display: block;
  margin-bottom: 6px;
  color: var(--slate);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
}

.story-copy {
  display: grid;
  gap: 12px;
  padding: 18px 0 0;
  border-top: 1px solid var(--line);
}

.story-copy p {
  margin: 0;
  color: var(--muted);
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 16px;
  letter-spacing: 0;
  line-height: 2;
  word-break: break-word;
}

.typing-target::after {
  content: "";
  display: inline-block;
  width: 1px;
  height: 1.1em;
  margin-left: 3px;
  background: var(--slate);
  transform: translateY(3px);
  animation: blink 1s steps(2, start) infinite;
}

.typing-target.is-done::after {
  display: none;
}

.interaction-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  margin-top: 4px;
}

.interaction-row button,
.nav-row button {
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.44);
  color: var(--slate);
  cursor: pointer;
  font-size: 13px;
  letter-spacing: .06em;
  text-align: left;
  transition: transform .18s ease, background-color .18s ease, border-color .18s ease;
}

.choice-panel {
  position: relative;
  padding: 15px 14px 16px;
  border: 1px solid rgba(37,50,58,.16);
  background: rgba(248,251,250,.66);
  box-shadow: 0 16px 38px rgba(37,50,58,.1);
  transform-origin: top center;
}

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

.choice-panel.is-open {
  animation: letterOpen .34s cubic-bezier(.2, .82, .24, 1) both;
}

.choice-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.choice-panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
}

.choice-panel-head button {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.55);
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.choice-panel h3 {
  margin: 0 0 8px;
  color: var(--slate);
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 19px;
  font-weight: 400;
  line-height: 1.45;
}

.choice-panel p {
  margin: 0;
  color: var(--muted);
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 14px;
  line-height: 1.9;
}

.choice-panel .choice-ask {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--slate);
}

.interaction-row button:active,
.nav-row button:active,
.icon-button:active,
.timeline-dot:active,
.primary-action:active {
  transform: translateY(2px) scale(.99);
}

.nav-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: auto;
  padding-top: 10px;
}

.nav-row button:last-child {
  border-color: var(--slate);
  background: var(--slate);
  color: var(--fog);
  text-align: center;
}

.nav-row button:disabled {
  opacity: .36;
  cursor: default;
}

.response-panel {
  position: relative;
  z-index: 12;
  margin: 4px 0 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.4);
}

.response-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.loader-sticker {
  width: 118px;
  height: 118px;
  object-fit: cover;
  border-radius: 999px;
  box-shadow: var(--shadow);
  animation: breathe 1.8s ease-in-out infinite;
}

.paw-bubble {
  position: absolute;
  z-index: 30;
  min-width: 64px;
  padding: 7px 10px;
  border: 1px solid rgba(37,50,58,.14);
  background: rgba(248,251,250,.92);
  color: var(--slate);
  box-shadow: 0 10px 24px rgba(37,50,58,.12);
  font-size: 12px;
  text-align: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: bubbleFloat .9s ease both;
}

.is-hugging {
  animation: catHug .78s cubic-bezier(.2, .9, .25, 1) both;
}

.is-dodging {
  animation: catDodge .7s cubic-bezier(.2, .9, .25, 1) both;
}

.is-delivering {
  animation: catDeliver .86s cubic-bezier(.2, .9, .25, 1) both;
}

.is-comforting {
  animation: catComfort .92s ease both;
}

.is-peeking {
  animation: catPeek .72s ease both;
}

.privacy-on .story-stage,
.privacy-on .response-panel,
.privacy-on .hero-panel {
  filter: blur(5px) saturate(.62);
}

.privacy-on::after {
  content: "雾面保护";
  position: fixed;
  right: 18px;
  bottom: calc(18px + var(--safe-bottom));
  z-index: 60;
  padding: 7px 10px;
  background: rgba(37,50,58,.86);
  color: var(--fog);
  font-size: 11px;
  letter-spacing: .12em;
}

@keyframes pageIn {
  from { opacity: 0; transform: translate3d(18px, 0, 0); filter: blur(6px); }
  to { opacity: 1; transform: translate3d(0, 0, 0); filter: blur(0); }
}

@keyframes blink {
  0%, 45% { opacity: 1; }
  46%, 100% { opacity: 0; }
}

@keyframes breathe {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-5px) scale(1.025); }
}

@keyframes bubbleFloat {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(.92); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -110%) scale(1.04); }
}

@keyframes letterOpen {
  from { opacity: 0; transform: translate3d(0, -8px, 0) scaleY(.96); filter: blur(5px); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scaleY(1); filter: blur(0); }
}

@keyframes catHug {
  0%, 100% { transform: translate3d(var(--cat-x), var(--cat-y), 0) scale(1); }
  48% { transform: translate3d(calc(var(--cat-x) * 2.2), calc(var(--cat-y) * 2.2), 0) scale(1.08); }
}

@keyframes catDodge {
  0% { transform: translate3d(var(--cat-x), var(--cat-y), 0) rotate(0) scale(1); }
  48% { transform: translate3d(calc(var(--cat-x) + var(--escape-x)), calc(var(--cat-y) + var(--escape-y)), 0) rotate(-7deg) scale(.97); }
  68% { transform: translate3d(calc(var(--cat-x) + var(--settle-x)), calc(var(--cat-y) + var(--settle-y)), 0) rotate(3deg) scale(1.01); }
  100% { transform: translate3d(var(--cat-x), var(--cat-y), 0) rotate(0) scale(1); }
}

@keyframes catDeliver {
  0%, 100% { transform: translate3d(var(--cat-x), var(--cat-y), 0); }
  38% { transform: translate3d(calc(var(--cat-x) + 28px), calc(var(--cat-y) - 5px), 0) rotate(2deg); }
  68% { transform: translate3d(calc(var(--cat-x) - 10px), var(--cat-y), 0) rotate(-1deg); }
}

@keyframes catComfort {
  0%, 100% { transform: translate3d(var(--cat-x), var(--cat-y), 0) scale(1); box-shadow: var(--shadow); }
  45% { transform: translate3d(var(--cat-x), calc(var(--cat-y) - 8px), 0) scale(1.04); box-shadow: 0 22px 58px rgba(143,181,192,.28); }
}

@keyframes catPeek {
  0%, 100% { transform: translate3d(var(--cat-x), var(--cat-y), 0); }
  35% { transform: translate3d(calc(var(--cat-x) + 18px), var(--cat-y), 0); }
  65% { transform: translate3d(calc(var(--cat-x) - 8px), var(--cat-y), 0); }
}

@media (min-width: 520px) {
  #app {
    padding-left: 34px;
    padding-right: 34px;
  }
  .interaction-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-height: 720px) {
  .cat-stage {
    width: min(42vw, 188px);
  }
  .scene h2,
  .hero-copy h2 {
    font-size: clamp(24px, 7vw, 34px);
  }
  .story-copy p {
    font-size: 15px;
    line-height: 1.9;
  }
}

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