@font-face {
  font-family: "WenKai";
  src: url("assets/fonts/LXGWWenKai-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f3ead8;
  --paper-deep: #e8dcc4;
  --ink: #2a3344;
  --ink-soft: #4a5568;
  --ink-faint: #8a919c;
  --coral: #e07a5f;
  --coral-soft: #f0a090;
  --gold: #c9a66b;
  --whisper: #8b7355;
  --shadow: rgba(42, 51, 68, 0.12);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --chrome-h: 72px;
  --bottom-h: 96px;
  color-scheme: light;
}

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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: "WenKai", "Songti SC", "STKaiti", "KaiTi", serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

.app {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 0%, #faf4e8 0%, var(--paper) 55%, var(--paper-deep) 100%);
}

.paper-breathe {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 30% 20%, rgba(255,255,255,0.35), transparent 60%),
    radial-gradient(ellipse 70% 50% at 80% 80%, rgba(201,166,107,0.08), transparent 55%);
  animation: breathe 8s ease-in-out infinite;
  z-index: 0;
}

@keyframes breathe {
  0%, 100% { opacity: 0.85; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.01); }
}

.paper-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.45;
  background: url("assets/textures/paper-grain.jpg") center / 280px repeat;
  mix-blend-mode: multiply;
  z-index: 1;
}

.paper-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 75% 70% at 50% 45%, transparent 40%, rgba(60,40,20,0.10) 100%);
  z-index: 2;
}

.chrome {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  pointer-events: none;
}

.chrome > * { pointer-events: auto; }

.chrome.top {
  top: 0;
  padding: calc(12px + var(--safe-t)) 20px 8px;
  justify-content: flex-start;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0.92;
}

.brand-mark {
  display: none;
}

.brand-title {
  font-size: clamp(22px, 3.2vw, 28px);
  font-weight: 400;
  letter-spacing: 0.18em;
  color: var(--ink);
  line-height: 1.2;
  text-indent: 0.18em;
}

.brand-tag {
  font-size: clamp(11px, 1.6vw, 13px);
  color: var(--whisper);
  letter-spacing: 0.12em;
  opacity: 0.85;
}

.stage {
  position: absolute;
  inset: 0;
  z-index: 10;
  cursor: crosshair;
  touch-action: none;
}

.ink-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.ink-layer.live {
  pointer-events: none;
}

/* 墨墨 */
.momo {
  position: absolute;
  width: 32px;
  height: 32px;
  margin-left: -16px;
  margin-top: -16px;
  pointer-events: none;
  z-index: 15;
  transition: opacity 0.55s ease;
  opacity: 0;
  will-change: transform;
}

.momo.visible { opacity: 1; }
.momo.thinking .momo-ring { animation: ring-pulse 1.25s ease-in-out infinite; opacity: 1; }
.momo.thinking .momo-glow { animation-duration: 1.6s; }
.momo.speaking .momo-core {
  background: radial-gradient(circle at 35% 30%, #f0a090, var(--coral) 72%);
  box-shadow: 0 0 20px rgba(224,122,95,0.6), 0 0 4px rgba(42,51,68,0.2);
}
.momo.curious .momo-core { box-shadow: 0 0 16px rgba(224,122,95,0.45); }
.momo.warm .momo-glow { opacity: 0.85; }

.momo-core {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #6a7588, var(--ink) 70%);
  box-shadow: 0 0 14px rgba(224,122,95,0.38), 0 0 4px rgba(42,51,68,0.22);
  animation: momo-breathe 2.6s ease-in-out infinite;
}

.momo-glow {
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(224,122,95,0.4), transparent 68%);
  animation: momo-glow 3s ease-in-out infinite;
}

.momo-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(224,122,95,0.4);
  opacity: 0;
}

@keyframes momo-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.14); }
}
@keyframes momo-glow {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(1.22); }
}
@keyframes ring-pulse {
  0% { opacity: 0; transform: scale(0.65); }
  45% { opacity: 0.75; transform: scale(1.12); }
  100% { opacity: 0; transform: scale(1.55); }
}

.whisper {
  position: absolute;
  left: 50%;
  bottom: calc(var(--bottom-h) + 20px + var(--safe-b));
  transform: translateX(-50%);
  max-width: min(84vw, 460px);
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(250,244,232,0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--whisper);
  font-family: WenKai, "LXGW WenKai", "Songti SC", serif;
  font-size: 15px;
  letter-spacing: 0.16em;
  text-align: center;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.55) inset,
    0 6px 28px rgba(42,51,68,0.10);
  z-index: 18;
  pointer-events: none;
  animation: whisper-in 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes whisper-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.status {
  position: absolute;
  top: calc(64px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 16;
  pointer-events: none;
}
.status.show { opacity: 0.85; }

.chrome.bottom {
  bottom: 0;
  padding: 8px 20px calc(16px + var(--safe-b));
  justify-content: center;
  gap: 18px;
  background: linear-gradient(to top, rgba(243,234,216,0.92), rgba(243,234,216,0));
}

.orb {
  position: relative;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  color: var(--ink-soft);
  backdrop-filter: blur(10px);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.5) inset,
    0 6px 20px rgba(42,51,68,0.08);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.orb svg { width: 22px; height: 22px; }

.orb:active { transform: scale(0.92); }
.orb:hover { background: rgba(255,255,255,0.55); color: var(--ink); }

.orb-listen {
  width: 68px;
  height: 68px;
  color: var(--ink);
  background: linear-gradient(145deg, rgba(255,255,255,0.65), rgba(232,220,196,0.55));
  box-shadow:
    0 1px 0 rgba(255,255,255,0.7) inset,
    0 10px 28px rgba(42,51,68,0.12),
    0 0 0 1px rgba(201,166,107,0.25);
}

.orb-listen svg { width: 26px; height: 26px; margin-top: -6px; }

.orb-label {
  position: absolute;
  bottom: 8px;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--whisper);
}

.orb-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid rgba(224,122,95,0.35);
  opacity: 0;
  pointer-events: none;
}
.orb-listen.ready .orb-pulse {
  animation: ring-pulse 2s ease-in-out infinite;
}

.orb-listen.busy {
  color: var(--coral);
  pointer-events: none;
}
.orb-listen.busy .orb-pulse { animation: ring-pulse 1s ease-in-out infinite; opacity: 1; }

.orb-danger:hover { color: var(--coral); }

/* aria-pressed=true means muted */
.orb[aria-pressed="true"] .ico-mute-on { display: none; }
.orb[aria-pressed="true"] .ico-mute-off { display: block; }
.orb[aria-pressed="false"] .ico-mute-off { display: none; }
.orb[aria-pressed="false"] .ico-mute-on { display: block; }

.toast {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  padding: 14px 22px;
  border-radius: 16px;
  background: rgba(42,51,68,0.88);
  color: #f3ead8;
  font-size: 15px;
  letter-spacing: 0.12em;
  z-index: 40;
  animation: whisper-in 0.35s ease;
  pointer-events: none;
}

/* first-run soft veil */
.app.first-run .brand-tag { animation: soft-blink 2.4s ease-in-out 2; }
@keyframes soft-blink {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; color: var(--coral); }
}

@media (orientation: landscape) and (max-height: 500px) {
  .brand-tag { display: none; }
  .chrome.bottom { gap: 14px; padding-bottom: calc(10px + var(--safe-b)); }
  .orb { width: 42px; height: 42px; }
  .orb-listen { width: 58px; height: 58px; }
}

/* Tablet hit targets — Apple HIG ~44pt minimum */
@media (pointer: coarse) {
  .orb { width: 56px; height: 56px; }
  .orb-listen { width: 80px; height: 80px; }
  .orb svg { width: 24px; height: 24px; }
  .orb-listen svg { width: 30px; height: 30px; }
  .orb-label { font-size: 11px; bottom: 9px; }
  .chrome.bottom { gap: 24px; padding-bottom: calc(22px + var(--safe-b)); }
}


/* Prevent iOS callout / magnifier */
.stage, .ink-layer, .orb {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
}

/* Empty paper: soft hint only via brand tag; no dashed boxes */
.app.empty-hint .brand-tag {
  color: var(--coral);
  opacity: 0.9;
}


/* Soft caption after ink replay — readable WenKai, still subordinate to ink */
.whisper.ink-echo {
  opacity: 0.92;
  font-size: 18px;
  letter-spacing: 0.20em;
  padding: 10px 20px;
  background: rgba(250,244,232,0.94);
  box-shadow: 0 2px 18px rgba(42,51,68,0.09);
  font-family: WenKai, "LXGW WenKai", "Songti SC", serif;
}
