/* 呜姆 · 设计 token（SSOT）v2 —— 塔塔冒险队画风方向（2026-07-05 Lyn 定调）
   取色源: design/pet-gen/ 生成形象（薄荷绿场景/深棕描边/奶油白/桃粉腮红）
   规则: 所有颜色走 token，禁止组件内硬编码 hex（CLAUDE.md 协作约定） */
:root {
  --bg: #93D6AC;            /* 薄荷草地绿（呜姆的房间） */
  --bg-deep: #7BC698;       /* 场景深一档 */
  --bg-card: #FFF9EF;       /* 奶油白卡片 */
  --bg-elevated: #FFFDF6;
  --bg-tag: #F6ECD9;
  --ink: #4A2E23;           /* 深棕描边（与形象描边同源） */
  --primary: #FF8A5C;       /* 红橙 CTA（塔塔按钮语言） */
  --primary-deep: #F26D3D;
  --primary-subtle: #FFEFE0;
  --primary-muted: #9C6B52;
  --accent-blue: #8FC8DC;
  --accent-yellow: #FFD666;  /* 星星黄 */
  --accent-green: #A8D89A;
  --accent-mocha: #F0DCC4;
  --success: #6BAE6B;
  --danger: #E07856;
  --border-w: 3px;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 5px 0 rgba(74,46,35,.28);    /* 软墩墩投影（塔塔按钮的厚度感） */
  --shadow-sm: 0 3px 0 rgba(74,46,35,.24);
  /* 五风味色（呜姆外观联动） */
  --flavor-sweet: #FF9AA0;   /* 甜=美食 */
  --flavor-wind: #6FC3DE;    /* 风=户外 */
  --flavor-warm: #FFBE76;    /* 暖=人 */
  --flavor-lively: #D8A055;  /* 闹=宠物 */
  --flavor-still: #8E9AD6;   /* 静=书桌 */
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg) 55%, var(--bg-deep) 100%);
  color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  overscroll-behavior: none;
  user-select: none; -webkit-user-select: none;
}
img { max-width: 100%; }
button { font: inherit; color: inherit; }

/* ---- 布局骨架：单页 + 底部 tab ---- */
#app { height: 100%; display: flex; flex-direction: column; }
.view { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; display: none; }
.view.active { display: block; }
nav {
  display: flex; background: var(--bg-card);
  border-top: var(--border-w) solid var(--ink);
  border-radius: 22px 22px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  flex-shrink: 0;
}
nav button {
  flex: 1; padding: 10px 0 8px; background: none; border: none;
  font-size: 12px; font-weight: 600; opacity: .45; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
nav button.active { opacity: 1; }
nav button svg { width: 26px; height: 26px; }

/* ---- 主场（呜姆） ---- */
#home { flex-direction: column; align-items: center; justify-content: center;
        padding: max(20px, env(safe-area-inset-top)) 20px 20px; }
#home.active { display: flex; }
#sky { width: 100%; max-width: 420px; display: flex; flex-direction: column;
       align-items: center; justify-content: center; min-height: 270px; position: relative; }
#pet-stage { width: 260px; height: 260px; position: relative; }
#pet-wrap { position: relative; z-index: 2; width: 100%; height: 100%;
  display: flex; align-items: flex-end; justify-content: center;
  transform: scale(var(--pet-scale, 1)); transform-origin: 50% 88%; }
#pet-img { max-width: 100%; max-height: 100%; object-fit: contain;
  filter: drop-shadow(0 6px 10px rgba(74,46,35,.18)); }
#pet-glow { position: absolute; inset: 8%; z-index: 1; border-radius: 50%; pointer-events: none; }
#hatch-flash { position: fixed; inset: 0; background: #FFFDF0; z-index: 80;
  animation: flash-fade .66s ease-out forwards; }
@keyframes flash-fade { 0% { opacity: 0 } 30% { opacity: 1 } 100% { opacity: 0 } }

/* 呜姆动画 */
@keyframes idle-float { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-7px) } }
@keyframes idle-breath { 0%,100% { transform: scale(1,1) } 50% { transform: scale(1.02,.98) } }
@keyframes bounce { 0%,100% { transform: translateY(0) scale(1,1) } 30% { transform: translateY(2px) scale(1.06,.92) } 60% { transform: translateY(-14px) scale(.96,1.06) } }
@keyframes chew { 0%,100% { transform: scale(1,1) } 25% { transform: scale(1.05,.93) } 50% { transform: scale(.97,1.04) } 75% { transform: scale(1.04,.94) } }
@keyframes wiggle { 0%,100% { transform: rotate(-2deg) } 50% { transform: rotate(2deg) } }
@keyframes egg-wobble { 0%,88%,100% { transform: rotate(0) } 90% { transform: rotate(-4deg) } 94% { transform: rotate(4deg) } 97% { transform: rotate(-2deg) } }
.pet-idle    #pet-img { animation: idle-float 3.2s ease-in-out infinite; }
.pet-hungry  #pet-img { animation: idle-float 5.8s ease-in-out infinite; }
.pet-excited #pet-img { animation: bounce .55s ease-in-out infinite; transform-origin: 50% 100%; }
.pet-eating  #pet-img { animation: chew .42s ease-in-out infinite; transform-origin: 50% 100%; }
.pet-happy   #pet-img { animation: wiggle 1s ease-in-out infinite; transform-origin: 50% 92%; }
.pet-egg     #pet-img { animation: egg-wobble 3.5s ease-in-out infinite; transform-origin: 50% 94%; }
.hatching    #pet-img { animation: egg-wobble .5s ease-in-out infinite !important; }

/* 拟声气泡 */
#pet-bubble {
  position: absolute; top: -6px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card); border: var(--border-w) solid var(--ink);
  border-radius: 14px; box-shadow: var(--shadow-sm);
  padding: 6px 12px; font-size: 14px; font-weight: 700; white-space: nowrap;
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 3;
}
#pet-bubble.show { opacity: 1; }

/* 反应台词卡 */
#speech {
  min-height: 76px; width: 100%; max-width: 420px;
  background: var(--bg-card); border: var(--border-w) solid var(--ink);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; font-size: 15px; line-height: 1.75; margin-top: 18px;
}
#speech .who { font-size: 11px; opacity: .5; margin-bottom: 2px; }

/* 喂食按钮 */
#feed-area { width: 100%; max-width: 420px; margin-top: 16px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px; font-size: 18px; font-weight: 800; color: #FFF;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-deep) 100%);
  border: var(--border-w) solid var(--ink);
  border-radius: 22px; box-shadow: var(--shadow), inset 0 2px 0 rgba(255,255,255,.35);
  cursor: pointer;
  text-shadow: 0 2px 0 rgba(74,46,35,.3);
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(74,46,35,.28); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn svg { width: 22px; height: 22px; }
input[type=file] { display: none; }
.hint { text-align: center; font-size: 12px; opacity: .5; margin-top: 10px; line-height: 1.6; }

/* 喂食过程遮罩层（贴纸飞入嘴里） */
#feeding-layer {
  position: fixed; inset: 0; z-index: 50; display: none;
  align-items: center; justify-content: center; pointer-events: none;
}
#feeding-layer.show { display: flex; }
#feeding-sticker {
  max-width: 45vw; max-height: 38vh;
  filter: drop-shadow(3px 3px 0 rgba(56,41,35,.28));
}
@keyframes fly-to-mouth {
  0% { transform: translate(0, 40vh) scale(.4) rotate(-6deg); opacity: 0 }
  18% { transform: translate(0, 0) scale(1) rotate(2deg); opacity: 1 }
  62% { transform: translate(0, -2vh) scale(1) rotate(-1deg); opacity: 1 }
  100% { transform: translate(0, -26vh) scale(.12) rotate(8deg); opacity: 0 }
}
#feeding-sticker.fly { animation: fly-to-mouth 2.6s cubic-bezier(.5,.1,.4,1) forwards; }

/* ---- 手帐视图 ---- */
#journal { padding: max(16px, env(safe-area-inset-top)) 14px 20px; }
#journal h2, #me h2 { font-size: 18px; margin: 6px 2px 14px; }
.day-page {
  background: var(--bg-card); border: var(--border-w) solid var(--ink);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 20px; position: relative;
}
.day-page::before { /* 胶带 */
  content: ""; position: absolute; top: -9px; left: 50%; transform: translateX(-50%) rotate(-2deg);
  width: 88px; height: 20px; background: var(--accent-yellow); opacity: .85;
  border: 2px solid var(--ink); border-radius: 3px;
}
.day-page .date { font-size: 12px; font-weight: 700; opacity: .55; margin-bottom: 10px; }
.stk-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stk-grid .cell { aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background: var(--primary-subtle); border-radius: var(--radius-sm); overflow: hidden; cursor: pointer; }
.stk-grid img { max-width: 92%; max-height: 92%; object-fit: contain;
  transform: rotate(var(--tilt, 0deg)); }
.day-note { margin-top: 12px; font-size: 13.5px; line-height: 1.8;
  background: var(--bg-elevated); border-radius: var(--radius-sm); padding: 10px 12px; }
.day-note .who { font-size: 11px; opacity: .5; }
.empty-state { text-align: center; padding: 60px 24px; opacity: .55; font-size: 14px; line-height: 2; }

/* 贴纸大图 */
#lightbox {
  position: fixed; inset: 0; background: rgba(56,41,35,.55); z-index: 90;
  display: none; align-items: center; justify-content: center; padding: 24px;
}
#lightbox.show { display: flex; }
#lightbox .sheet {
  background: var(--bg); border: var(--border-w) solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; max-width: 420px; width: 100%; max-height: 82vh; overflow-y: auto;
}
#lightbox img { display: block; margin: 0 auto; max-height: 46vh; }
#lightbox .meta { font-size: 13px; line-height: 1.8; margin-top: 12px; }
#lightbox .actions { display: flex; gap: 10px; margin-top: 14px; }
#lightbox .actions .btn { padding: 10px; font-size: 14px; }

/* ---- 「它」状态视图 ---- */
#me { padding: max(16px, env(safe-area-inset-top)) 16px 20px; }
.panel {
  background: var(--bg-card); border: var(--border-w) solid var(--ink);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 16px;
}
.panel h3 { font-size: 14px; margin-bottom: 10px; }
.flavor-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 13px; }
.flavor-row .name { width: 64px; font-weight: 700; }
.flavor-bar { flex: 1; height: 14px; background: var(--primary-subtle);
  border: 2px solid var(--ink); border-radius: 7px; overflow: hidden; }
.flavor-bar i { display: block; height: 100%; background: var(--fc, var(--primary)); transition: width .6s; }
.flavor-row .val { width: 34px; text-align: right; font-variant-numeric: tabular-nums; opacity: .6; }
.kv { display: flex; justify-content: space-between; font-size: 13.5px; padding: 7px 0;
  border-bottom: 1px dashed var(--primary-subtle); }
.kv:last-child { border-bottom: none; }
.kv .v { font-weight: 700; }
.coop-teaser { text-align: center; font-size: 13px; line-height: 1.9; opacity: .75; }
.coop-teaser .egg-ico { font-size: 26px; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); font-size: 13.5px;
  padding: 10px 18px; border-radius: 20px; opacity: 0; transition: all .25s;
  z-index: 99; pointer-events: none; max-width: 86vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 加载/进度 */
#boot {
  position: fixed; inset: 0; background: var(--bg); z-index: 200;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
#boot .egg-boot { font-size: 44px; animation: idle-float 2s ease-in-out infinite; }
#boot p { font-size: 13px; opacity: .6; }
#boot.hide { display: none; }
