/* ===== Agnes 桌面宠物 样式 ===== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; background: transparent; }
body {
  font-family: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  color: #6b4a5b;
  user-select: none;
  -webkit-user-select: none;
}
/* 网页形态给个柔和底色；桌面形态必须全透明 */
body:not(.desktop) { background: linear-gradient(180deg, #fff7fb 0%, #ffeef5 100%); }
button { font-family: inherit; }

#stage { position: fixed; inset: 0; overflow: hidden; }

/* ===== 网页版提示条 ===== */
#web-hint {
  position: fixed; left: 14px; top: 12px; z-index: 20;
  font-size: 12px; color: #a87b93;
  background: rgba(255, 255, 255, .85); border: 1px solid #f3c9da;
  padding: 6px 10px; border-radius: 10px; max-width: 460px;
  animation: fadeout 1s ease 10s forwards;
}
body.desktop #web-hint { display: none; }
@keyframes fadeout { to { opacity: 0; visibility: hidden; } }

/* ===== 宠物 ===== */
#pet-wrap {
  position: absolute; left: 0; top: 0;
  width: 220px; height: 230px;
  z-index: 10;
}
#pet-wrap.ghosted { display: none; }
#pet { width: 100%; height: 100%; cursor: grab; touch-action: none; }
#pet:active { cursor: grabbing; }
#pet-svg { width: 100%; height: 100%; overflow: visible; }

/* 部件 */
.ear { fill: #fff; stroke: #f3a8c5; stroke-width: 5; stroke-linejoin: round; }
.ear-in { fill: #ffd6e6; }
.body { fill: #fff; stroke: #f3a8c5; stroke-width: 4; }
.belly { fill: #fff2f7; }
.paw { fill: #fff; stroke: #f3a8c5; stroke-width: 4; }
.eye { fill: #4a3b45; transform-box: fill-box; transform-origin: center; transition: transform 60ms ease; }
.highlight { fill: #fff; transition: opacity 60ms ease; }
.eye-happy, .eye-sleep { fill: none; stroke: #4a3b45; stroke-width: 4; stroke-linecap: round; display: none; }
.blush { fill: #ffd6e6; opacity: .85; }
.nose { fill: #e58bad; }
.mouth { fill: none; stroke: #b06e8c; stroke-width: 3; stroke-linecap: round; }
.whiskers line { stroke: #d9a3ba; stroke-width: 2.5; stroke-linecap: round; }

/* 状态 */
#pet-svg.blink .eye { transform: scaleY(0.12); }
#pet-svg.blink .highlight { opacity: 0; }
#pet-svg.happy .eye, #pet-svg.sleep .eye { display: none; }
#pet-svg.happy .eye-happy { display: block; }
#pet-svg.sleep .eye-sleep { display: block; }
#pet-svg.sleep .highlight { opacity: 0; }

/* 待机漂浮 + 尾巴摆动 */
.body-g { animation: bob 3.2s ease-in-out infinite; }
.tail { transform-origin: 168px 168px; animation: wag 2.6s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes wag { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(10deg); } }

/* 开心：蹦一下 + 笑眼 + 星星 */
#pet-svg.happy .body-g { animation: bounce .55s ease-in-out 3; }
@keyframes bounce {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  30% { transform: translateY(-14px) scale(1.03, .97); }
  60% { transform: translateY(0) scale(.97, 1.03); }
}
.sparkle { opacity: 0; }
#pet-svg.happy .sparkle { opacity: 1; transition: opacity .2s; }
.sparkle text { font-size: 18px; }

/* 锻炼：跳一跳 */
#pet-svg.jump .body-g { animation: hop .5s ease-in-out 3; }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-22px); } }

/* 睡觉 */
#pet-svg.sleep .body-g { animation: bob 5s ease-in-out infinite; }
.zzz { opacity: 0; }
#pet-svg.sleep .zzz { opacity: 1; }
.zzz text { fill: #b78ca6; font-weight: bold; font-family: sans-serif; }
#pet-svg.sleep .z1 { font-size: 14px; animation: zfloat 2.4s ease-in-out infinite; }
#pet-svg.sleep .z2 { font-size: 18px; animation: zfloat 2.4s ease-in-out .4s infinite; }
#pet-svg.sleep .z3 { font-size: 22px; animation: zfloat 2.4s ease-in-out .8s infinite; }
@keyframes zfloat {
  0% { transform: translateY(0); opacity: .2; }
  30% { opacity: 1; }
  100% { transform: translateY(-14px); opacity: 0; }
}

/* ===== 气泡 ===== */
#bubble {
  position: absolute; bottom: 100%; left: 50%;
  transform: translate(-50%, 0);
  background: #fff; border: 2px solid #f3a8c5; border-radius: 14px;
  padding: 9px 13px; font-size: 14px; line-height: 1.45;
  max-width: min(300px, 88vw);
  box-shadow: 0 8px 22px rgba(243, 168, 197, .35);
  z-index: 20; cursor: pointer;
  transform-origin: bottom center;
}
#bubble.hidden { display: none; }
#bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -8px;
  width: 12px; height: 12px; background: #fff;
  border-right: 2px solid #f3c9da; border-bottom: 2px solid #f3c9da;
  transform: translateX(-50%) rotate(45deg);
}
#bubble.pop { animation: pop .22s ease; }
@keyframes pop { from { transform: translate(-50%, 0) scale(.6); opacity: .3; } to { transform: translate(-50%, 0) scale(1); opacity: 1; } }
#bubble-text { white-space: pre-wrap; }

/* ===== 工具条（桌面端默认隐藏，鼠标靠近宠物自动浮现） ===== */
#toolbar { position: fixed; right: 10px; bottom: 10px; display: flex; gap: 7px; z-index: 30; }
#toolbar button {
  width: 38px; height: 38px; border-radius: 50%; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #f3c9da; background: rgba(255, 255, 255, .96);
  cursor: pointer; box-shadow: 0 3px 10px rgba(214, 120, 160, .28);
  transition: transform .15s ease, background .15s ease;
}
#toolbar button:hover { transform: translateY(-2px); background: #fff5f9; }
#toolbar svg {
  width: 19px; height: 19px; display: block;
  stroke: #c95c86; fill: none; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
#toolbar svg .fill { fill: #c95c86; stroke: none; }
body.desktop #toolbar { opacity: 0; pointer-events: none; transition: opacity .3s ease; }
body.desktop.toolbar-near #toolbar { opacity: 1; pointer-events: auto; }

/* ===== 右键菜单 ===== */
#ctx {
  position: fixed; z-index: 40; min-width: 150px;
  background: #fff; border: 2px solid #f3c9da; border-radius: 12px;
  padding: 6px; box-shadow: 0 10px 26px rgba(243, 168, 197, .4);
  display: flex; flex-direction: column;
}
#ctx.hidden { display: none; }
#ctx button {
  border: 0; background: transparent; text-align: left;
  padding: 8px 10px; border-radius: 8px; font-size: 14px;
  cursor: pointer; color: #6b4a5b;
}
#ctx button:hover { background: #ffeef5; }

/* ===== 隐藏后的恢复入口 ===== */
#restore-dot {
  position: fixed; right: 10px; top: 10px; z-index: 30;
  border: 2px solid #f3c9da; background: rgba(255, 255, 255, .92);
  border-radius: 999px; padding: 6px 12px;
  font-size: 13px; color: #6b4a5b; cursor: pointer;
}
#restore-dot.hidden { display: none; }

/* ===== 面板 ===== */
#panel {
  position: fixed; top: 10px; right: 10px;
  width: min(400px, calc(100vw - 20px)); max-height: calc(100vh - 20px);
  display: flex; flex-direction: column;
  background: rgba(255, 246, 250, .97);
  border: 2px solid #f3c9da; border-radius: 16px;
  box-shadow: 0 14px 34px rgba(214, 120, 160, .28);
  z-index: 50; overflow: hidden;
}
#panel.hidden { display: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; font-weight: 600; }
#panel-close { border: 0; background: transparent; font-size: 14px; cursor: pointer; color: #a87b93; }
.panel-tabs { display: flex; gap: 4px; padding: 0 10px; }
.panel-tabs button {
  flex: 1; border: 0; background: transparent;
  padding: 7px 0; border-radius: 10px 10px 0 0;
  cursor: pointer; color: #a87b93; font-size: 13px;
}
.panel-tabs button.active { background: #fff; color: #d4537e; font-weight: 600; }
.panel-body { overflow-y: auto; background: #fff; padding: 12px; font-size: 13px; }
.tab { display: none; }
.tab.active { display: block; }

/* 计划行 */
.plan-row { display: grid; grid-template-columns: 26px 92px 1fr 78px 26px; gap: 6px; align-items: center; margin-bottom: 6px; }
.plan-row input[type="time"] { border: 1px solid #f0c9d8; border-radius: 8px; padding: 5px 6px; font-size: 12px; color: #6b4a5b; background: #fff; }
.plan-row input[type="text"] { border: 1px solid #f0c9d8; border-radius: 8px; padding: 5px 8px; font-size: 12px; color: #6b4a5b; width: 100%; }
.plan-row select { border: 1px solid #f0c9d8; border-radius: 8px; padding: 5px 4px; font-size: 12px; background: #fff; color: #6b4a5b; width: 100%; }
.plan-row input[type="checkbox"] { accent-color: #f78fb3; }
.p-del { border: 0; background: transparent; cursor: pointer; font-size: 14px; opacity: .6; padding: 0; }
.p-del:hover { opacity: 1; }
.row-actions { display: flex; gap: 8px; margin-top: 10px; }
.row-actions button {
  flex: 1; border: 1px solid #f0c9d8; background: #fff;
  border-radius: 10px; padding: 7px 0; font-size: 13px;
  cursor: pointer; color: #6b4a5b;
}
.row-actions button.primary { background: #f78fb3; border-color: #f78fb3; color: #fff; font-weight: 600; }
.row-actions button:hover { filter: brightness(1.05); }
.tip { color: #b78ca6; font-size: 12px; line-height: 1.6; margin: 10px 2px 2px; }

/* 设置行 */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 2px; font-size: 13px; }
.set-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: #f78fb3; }
.set-row input[type="number"], .set-row input[type="password"], .set-row input[type="text"], .set-row select {
  border: 1px solid #f0c9d8; border-radius: 8px; padding: 5px 8px;
  font-size: 12px; color: #6b4a5b; width: 158px; background: #fff;
}
.set-row .pair { display: flex; align-items: center; gap: 4px; }
.set-row .pair input { width: 62px; }
.sec-title { font-weight: 600; margin: 10px 2px 2px; color: #d4537e; }
button.block { width: 100%; margin-top: 10px; border: 0; border-radius: 10px; padding: 9px 0; font-size: 13px; cursor: pointer; }
button.primary.block { background: #f78fb3; color: #fff; font-weight: 600; }

/* 桌面 / 网页 专属区块 */
.desktop-only { display: none; }
body.desktop .desktop-only { display: block; }
body.desktop label.desktop-only { display: flex; }
body.desktop .sec-title.desktop-only, body.desktop div.desktop-only { display: block; }
.web-only { display: block; }
body.desktop .web-only { display: none; }

/* 关于 */
.about p { margin: 6px 2px; line-height: 1.6; }
.about ul { margin: 8px 0; padding-left: 18px; }
.about li { line-height: 1.8; }
