:root {
  --ink: #3d4458;
  --muted: #6d7590;
  --accent: #8f7ad6;
  --me: #7aa2f7;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.85);
}
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  color: var(--ink);
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  min-height: 100vh;
  overflow: hidden;
}

/* ---- 缘之空动画实景(奥木染)背景 ---- */
.scenery-photo {
  position: fixed; inset: 0; z-index: 0;
  background: url("bg_okukizome.jpg") center / cover no-repeat;
  /* 轻微提亮+柔化, 保证前景可读 */
  filter: saturate(1.05);
}
.scenery-photo::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(240,247,255,0.10), rgba(255,255,255,0.16) 70%, rgba(255,255,255,0.22));
}

/* ---- 布局:聊天靠左,给右下桌宠留位 ---- */
.app {
  position: relative; z-index: 1;
  height: 100vh;
  width: min(680px, 92vw);
  margin-left: max(24px, 6vw);
  display: flex; flex-direction: column;
  padding: 18px 0 10px;
}
.glass {
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 30px rgba(70, 90, 130, 0.18);
}
.header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 16px;
}
.avatar {
  width: 46px; height: 46px; border-radius: 50%;
  background: linear-gradient(160deg, #c9b8ee, #8f7ad6);
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 20px;
  box-shadow: 0 3px 10px rgba(143, 122, 214, 0.45);
}
.title h1 { font-size: 18px; font-weight: 600; }
.title p { font-size: 12px; color: var(--muted); }
.ghost {
  margin-left: auto; background: rgba(255,255,255,0.55); border: 1px solid rgba(143,122,214,0.35);
  color: var(--muted); border-radius: 10px; padding: 6px 11px; cursor: pointer; font-size: 14px;
}
.ghost + .ghost { margin-left: 8px; }
.ghost:hover { color: var(--ink); border-color: var(--accent); }

.settings {
  margin-top: 10px; padding: 12px 16px; border-radius: 14px;
  display: flex; flex-direction: column; gap: 8px; font-size: 13px;
}
.settings input {
  width: 100%; margin-top: 4px; padding: 8px; border-radius: 8px;
  border: 1px solid rgba(143,122,214,0.35); background: rgba(255,255,255,0.8); color: var(--ink);
}
.settings button {
  align-self: flex-start; padding: 6px 16px; border-radius: 8px; border: none;
  background: var(--accent); color: #fff; cursor: pointer;
}
.settings .hint { color: var(--muted); font-size: 12px; }
.hidden { display: none; }

.chat {
  flex: 1; overflow-y: auto; padding: 16px 6px;
  display: flex; flex-direction: column; gap: 12px;
}
.chat::-webkit-scrollbar { width: 6px; }
.chat::-webkit-scrollbar-thumb { background: rgba(143,122,214,0.35); border-radius: 3px; }
.msg {
  max-width: 80%; padding: 10px 15px; border-radius: 16px;
  line-height: 1.65; white-space: pre-wrap; word-break: break-word;
  box-shadow: 0 3px 12px rgba(70, 90, 130, 0.12);
  animation: pop 0.22s ease-out;
}
@keyframes pop { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
.msg.user { align-self: flex-end; background: linear-gradient(150deg, #8fb0f7, #7aa2f7); color: #fff; border-bottom-right-radius: 5px; }
.msg.bot { align-self: flex-start; background: var(--glass); border: 1px solid var(--glass-border); border-bottom-left-radius: 5px; }
.msg .voice-btn {
  margin-top: 6px; font-size: 12px; color: var(--accent);
  background: rgba(255,255,255,0.6); border: 1px solid var(--accent);
  border-radius: 8px; padding: 3px 10px; cursor: pointer;
}
.msg .voice-btn:hover { background: var(--accent); color: #fff; }

.composer {
  display: flex; gap: 8px; padding: 10px; border-radius: 16px;
}
.composer input {
  flex: 1; min-width: 0; padding: 12px 14px; border-radius: 12px;
  border: 1px solid rgba(143,122,214,0.35); background: rgba(255,255,255,0.85);
  color: var(--ink); font-size: 15px; outline: none;
}
.composer input:focus { border-color: var(--accent); }
.composer button {
  padding: 12px 24px; border-radius: 12px; border: none;
  background: linear-gradient(150deg, #a48fe0, #8f7ad6); color: #fff;
  font-weight: 600; cursor: pointer; box-shadow: 0 3px 10px rgba(143,122,214,0.4);
}
.composer button:disabled { opacity: 0.55; cursor: default; }
.status { padding: 8px 10px 0; font-size: 12px; color: var(--muted); min-height: 18px; text-shadow: 0 1px 2px rgba(255,255,255,0.6); }

/* ---- 穹 Live2D 桌宠 ---- */
.pet {
  position: fixed; right: max(18px, 4vw); bottom: 6px; z-index: 2;
  width: min(280px, 34vw);
  filter: drop-shadow(0 10px 18px rgba(70, 90, 130, 0.35));
  transform-origin: 50% 100%;
  animation: pet-idle 3.6s ease-in-out infinite;
}
.pet canvas { width: 100%; display: block; cursor: pointer; }
@keyframes pet-idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
/* 收到回复时跳一下 */
.pet.hop { animation: pet-hop 0.55s ease-out 2; }
@keyframes pet-hop {
  0% { transform: translateY(0) scale(1, 1); }
  35% { transform: translateY(-26px) scale(0.96, 1.06) rotate(-2deg); }
  70% { transform: translateY(0) scale(1.04, 0.94); }
  100% { transform: translateY(0) scale(1, 1); }
}

/* 窄屏:桌宠缩小并上移避开输入栏,聊天占满 */
@media (max-width: 720px) {
  body { overflow: auto; }
  .app {
    margin: 0 auto; width: 100%;
    min-height: 100dvh; height: auto;
    padding: 10px 8px 6px;
  }
  .chat { flex: 1 1 auto; min-height: 45dvh; }
  .pet {
    width: 110px;
    right: 4px;
    bottom: 96px; /* 始终在输入栏上方, 不挡发送按钮 */
  }
  .composer {
    position: sticky; bottom: 0;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(143,122,214,0.45);
    box-shadow: 0 6px 20px rgba(70, 90, 130, 0.3);
  }
  .composer input { font-size: 16px; padding: 14px; } /* >=16px 防 iOS 自动缩放 */
  .composer button { padding: 14px 20px; font-size: 15px; }
}
