:root{
  --bg-purple: #7d739a;
  --card-gray: #dbe2ea;
  --soft-blue: #d2e1ec;
  --soft-white: #f1eef5;
  --angel: #f6efe9;
  --accent-pink: #f0b6c1;
  --accent-berry: #c87c8f;
  --text-main: #4d5262;
  --text-soft: #646b7f;
  --text-light: rgba(255,255,255,.9);

  --glass-bg: rgba(219, 226, 234, .72);
  --glass-border: rgba(255,255,255,.42);
  --shadow: rgba(32, 30, 48, .24);
}

*{
  box-sizing:border-box;
}

html,
body{
  width:100%;
  height:100%;
  margin:0;
  overflow:hidden;
  background:var(--bg-purple);
  color:var(--text-main);
  font-family:
    "Noto Sans SC",
    "Microsoft YaHei",
    system-ui,
    sans-serif;
}

button,
input{
  font:inherit;
}

button{
  cursor:pointer;
}

.hidden{
  display:none !important;
}

/* =========================
   迎宾页
========================= */

.welcome-screen{
  position:fixed;
  inset:0;
  overflow:hidden;
  background:var(--bg-purple);
}

.welcome-bg{
  position:absolute;
  inset:0;
  z-index:0;
}

.welcome-bg img{
  width:100%;
  height:100%;
  object-fit:cover;
  filter:saturate(.9) contrast(.95);
  transform:scale(1.03);
}

.welcome-overlay{
  position:absolute;
  inset:0;
  background:
    linear-gradient(90deg, rgba(68,60,92,.92) 0%, rgba(68,60,92,.76) 38%, rgba(68,60,92,.30) 100%);
  backdrop-filter: blur(2px);
}

.welcome-layout{
  position:relative;
  z-index:2;
  height:100%;
  display:grid;
  grid-template-columns: 42% 58%;
  align-items:center;
  padding:6vh 6vw 5vh;
}

.welcome-copy{
  max-width:540px;
  color:var(--text-light);
}

.eyebrow{
  margin-bottom:18px;
  letter-spacing:.18em;
  font-size:13px;
  opacity:.78;
}

.welcome-copy h1{
  margin:0 0 24px;
  font-family:"Songti SC","SimSun","Noto Serif SC",serif;
  font-size:clamp(42px, 6vw, 82px);
  line-height:1.05;
  font-weight:400;
  letter-spacing:.04em;
}

.welcome-line{
  margin:0 0 36px;
  max-width:28em;
  font-size:16px;
  line-height:1.9;
  color:rgba(255,255,255,.84);
  min-height:64px;
  white-space:pre-line;
}

.enter-btn{
  border:none;
  padding:14px 32px;
  border-radius:999px;
  color:#fff;
  background:linear-gradient(135deg, var(--accent-pink), var(--accent-berry));
  box-shadow:
    0 14px 30px rgba(0,0,0,.18),
    inset 0 1px 0 rgba(255,255,255,.45);
  transition:transform .25s ease, box-shadow .25s ease;
}

.enter-btn:hover{
  transform:translateY(-2px);
  box-shadow:
    0 18px 38px rgba(0,0,0,.22),
    inset 0 1px 0 rgba(255,255,255,.55);
}

.welcome-portrait-wrap{
  position:relative;
  height:100%;
  display:flex;
  align-items:flex-end;
  justify-content:center;
  pointer-events:none;
}

.welcome-portrait{
  position:relative;
  z-index:2;
  height:82vh;
  max-height:860px;
  max-width:92%;
  object-fit:contain;
  object-position:center bottom;
  filter:
    drop-shadow(0 26px 36px rgba(0,0,0,.36))
    drop-shadow(0 0 28px rgba(240,182,193,.18));
  animation:breathing 4.2s ease-in-out infinite;
  transition:opacity .35s ease, transform .45s ease;
}

.character-dock{
  position:absolute;
  z-index:4;
  left:6vw;
  bottom:5.5vh;
  display:flex;
  gap:14px;
  padding:12px;
  border-radius:999px;
  background:rgba(219,226,234,.18);
  border:1px solid rgba(255,255,255,.22);
  backdrop-filter:blur(12px);
}

.avatar-btn{
  width:58px;
  height:58px;
  border-radius:50%;
  border:2px solid rgba(255,255,255,.42);
  background:rgba(255,255,255,.14);
  overflow:hidden;
  padding:0;
  transition:transform .25s ease, border-color .25s ease, box-shadow .25s ease;
}

.avatar-btn img{
  width:100%;
  height:100%;
  object-fit:contain;
  background:rgba(255,255,255,.18);
}

.avatar-btn.active{
  border-color:var(--accent-pink);
  box-shadow:0 0 0 4px rgba(240,182,193,.22);
  transform:translateY(-3px);
}

@keyframes breathing{
  0%,100%{ transform:translateY(0) scale(1); }
  50%{ transform:translateY(-8px) scale(1.012); }
}

/* =========================
   主控制台
========================= */

.app-shell{
  width:100%;
  height:100vh;
  display:grid;
  grid-template-columns:260px 1fr;
  background:
    radial-gradient(circle at 18% 20%, rgba(255,255,255,.16), transparent 28%),
    var(--bg-purple);
}

.side-nav{
  position:relative;
  z-index:5;
  padding:22px 18px;
  display:flex;
  flex-direction:column;
  gap:22px;
  color:var(--text-light);
  background:rgba(58,51,78,.52);
  border-right:1px solid rgba(255,255,255,.18);
  backdrop-filter:blur(18px);
}

.side-profile{
  display:flex;
  gap:14px;
  align-items:center;
  padding:14px;
  border-radius:24px;
  background:rgba(219,226,234,.16);
  border:1px solid rgba(255,255,255,.20);
}

.side-avatar-frame{
  width:68px;
  height:68px;
  border-radius:22px;
  overflow:hidden;
  background:rgba(255,255,255,.18);
  border:1px solid rgba(255,255,255,.28);
}

.side-avatar-frame img{
  width:100%;
  height:100%;
  object-fit:contain;
}

.side-name{
  font-family:"Songti SC","SimSun",serif;
  font-size:21px;
  margin-bottom:6px;
}

.side-status{
  font-size:12px;
  opacity:.72;
}

.mode-menu{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.mode-btn{
  display:flex;
  align-items:center;
  justify-content:space-between;
  width:100%;
  padding:15px 16px;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.16);
  color:rgba(255,255,255,.82);
  background:rgba(219,226,234,.10);
  transition:.25s ease;
}

.mode-btn span{
  font-size:15px;
}

.mode-btn small{
  font-size:11px;
  opacity:.55;
}

.mode-btn.active,
.mode-btn:hover{
  color:#fff;
  background:linear-gradient(135deg, rgba(240,182,193,.92), rgba(200,124,143,.82));
  box-shadow:0 10px 24px rgba(0,0,0,.16);
  transform:translateX(4px);
}

.side-section-title{
  margin-bottom:10px;
  font-size:12px;
  letter-spacing:.12em;
  opacity:.62;
}

.mini-avatar-grid{
  display:grid;
  grid-template-columns:repeat(4, 1fr);
  gap:8px;
}

.mini-avatar{
  aspect-ratio:1;
  border-radius:16px;
  border:1px solid rgba(255,255,255,.18);
  background:rgba(255,255,255,.10);
  overflow:hidden;
  padding:0;
}

.mini-avatar img{
  width:100%;
  height:100%;
  object-fit:contain;
}

.mini-avatar.active{
  border-color:var(--accent-pink);
  box-shadow:0 0 0 3px rgba(240,182,193,.22);
}

.side-data{
  margin-top:auto;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.data-row{
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding:12px 14px;
  border-radius:16px;
  background:rgba(219,226,234,.12);
  border:1px solid rgba(255,255,255,.14);
  font-size:12px;
}

.data-row strong{
  color:#fff;
  font-weight:500;
}

.main-view{
  position:relative;
  overflow:hidden;
  padding:32px;
}

.view-bg{
  position:absolute;
  inset:0;
  z-index:0;
}

.view-bg img{
  width:100%;
  height:100%;
  object-fit:cover;
  transition:opacity .35s ease, transform .7s ease;
  filter:saturate(.9) contrast(.96);
  transform:scale(1.02);
}

.view-dim{
  position:absolute;
  inset:0;
  background:
    linear-gradient(90deg, rgba(67,59,92,.80), rgba(67,59,92,.36)),
    linear-gradient(180deg, rgba(67,59,92,.20), rgba(67,59,92,.60));
}

.view-header{
  position:relative;
  z-index:2;
  display:flex;
  justify-content:space-between;
  gap:24px;
  align-items:flex-start;
  color:#fff;
  margin-bottom:28px;
}

.view-kicker{
  margin-bottom:12px;
  font-size:12px;
  letter-spacing:.16em;
  opacity:.72;
}

.view-header h2{
  margin:0 0 10px;
  font-family:"Songti SC","SimSun","Noto Serif SC",serif;
  font-size:clamp(30px, 4.5vw, 56px);
  line-height:1.15;
  font-weight:400;
  letter-spacing:.03em;
}

.view-header p{
  margin:0;
  font-size:15px;
  opacity:.78;
}

.header-pill{
  flex:none;
  padding:12px 20px;
  border-radius:999px;
  color:#fff;
  background:rgba(219,226,234,.18);
  border:1px solid rgba(255,255,255,.24);
  backdrop-filter:blur(10px);
}

.glass-panel{
  position:relative;
  z-index:2;
  background:var(--glass-bg);
  border:1px solid var(--glass-border);
  border-radius:34px;
  backdrop-filter:blur(10px);
  box-shadow:0 24px 60px rgba(0,0,0,.22);
}

.focus-panel{
  min-height:calc(100vh - 210px);
  display:grid;
  grid-template-columns:minmax(360px, .85fr) 1fr;
  align-items:center;
  gap:28px;
  padding:34px;
}

.panel-label{
  margin-bottom:18px;
  font-size:13px;
  letter-spacing:.18em;
  color:var(--text-soft);
}

.timer-display{
  font-family:"Songti SC","SimSun",serif;
  font-size:clamp(72px, 9vw, 124px);
  line-height:1;
  color:var(--text-main);
  letter-spacing:.06em;
}

.timer-hint{
  margin-top:12px;
  color:var(--text-soft);
}

.progress-track{
  height:12px;
  margin:34px 0 24px;
  border-radius:999px;
  overflow:hidden;
  background:rgba(255,255,255,.52);
}

.progress-bar{
  width:0%;
  height:100%;
  border-radius:999px;
  background:linear-gradient(90deg, var(--accent-pink), var(--accent-berry));
  transition:width .25s linear;
}

.control-row{
  display:flex;
  gap:14px;
}

.primary-btn,
.ghost-btn,
.chat-input-bar button{
  border:none;
  border-radius:999px;
  padding:13px 26px;
  color:#fff;
  background:linear-gradient(135deg, var(--accent-pink), var(--accent-berry));
  box-shadow:0 12px 26px rgba(200,124,143,.22);
}

.ghost-btn{
  color:var(--text-main);
  background:rgba(255,255,255,.56);
  box-shadow:none;
}

.panel-right{
  height:100%;
  min-height:480px;
  display:flex;
  align-items:flex-end;
  justify-content:center;
}

.companion-card{
  position:relative;
  width:100%;
  height:100%;
  min-height:480px;
  display:flex;
  align-items:flex-end;
  justify-content:center;
}

.companion-card::before{
  content:"";
  position:absolute;
  width:62%;
  height:52%;
  bottom:8%;
  border-radius:50%;
  background:radial-gradient(circle, rgba(240,182,193,.34), transparent 68%);
  filter:blur(30px);
}

.companion-card img{
  position:relative;
  z-index:2;
  height:72vh;
  max-height:720px;
  max-width:100%;
  object-fit:contain;
  object-position:center bottom;
  filter:drop-shadow(0 24px 30px rgba(0,0,0,.24));
  animation:breathing 4.4s ease-in-out infinite;
}

/* =========================
   对话模式
========================= */

.chat-panel{
  height:calc(100vh - 210px);
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.chat-header{
  padding:20px 24px;
  border-bottom:1px solid rgba(255,255,255,.38);
}

.chat-person{
  display:flex;
  align-items:center;
  gap:14px;
}

.chat-person img{
  width:52px;
  height:52px;
  border-radius:18px;
  background:rgba(255,255,255,.45);
  object-fit:contain;
}

.chat-name{
  font-family:"Songti SC","SimSun",serif;
  font-size:22px;
  color:var(--text-main);
}

.chat-state{
  margin-top:4px;
  font-size:12px;
  color:var(--text-soft);
}

.chat-list{
  flex:1;
  overflow-y:auto;
  padding:24px;
  display:flex;
  flex-direction:column;
  gap:16px;
}

.message{
  display:flex;
  gap:12px;
  align-items:flex-end;
  max-width:76%;
}

.message.from-me{
  margin-left:auto;
  flex-direction:row-reverse;
}

.message img{
  width:38px;
  height:38px;
  border-radius:14px;
  object-fit:contain;
  background:rgba(255,255,255,.5);
}

.bubble{
  padding:13px 16px;
  border-radius:20px 20px 20px 6px;
  line-height:1.7;
  font-size:14px;
  color:var(--text-main);
  background:rgba(255,255,255,.72);
  box-shadow:0 8px 20px rgba(0,0,0,.06);
}

.message.from-me .bubble{
  color:#fff;
  background:linear-gradient(135deg, var(--accent-pink), var(--accent-berry));
  border-radius:20px 20px 6px 20px;
}

.chat-input-bar{
  display:flex;
  gap:12px;
  padding:18px 20px;
  border-top:1px solid rgba(255,255,255,.38);
}

.chat-input-bar input{
  flex:1;
  min-width:0;
  border:none;
  outline:none;
  border-radius:999px;
  padding:0 20px;
  color:var(--text-main);
  background:rgba(255,255,255,.68);
}

.toast-layer{
  position:fixed;
  inset:0;
  z-index:99;
  pointer-events:none;
}

.toast{
  position:fixed;
  right:32px;
  top:32px;
  padding:12px 18px;
  border-radius:999px;
  color:#fff;
  background:linear-gradient(135deg, var(--accent-pink), var(--accent-berry));
  box-shadow:0 14px 28px rgba(0,0,0,.18);
  animation:toastIn .25s ease, toastOut .25s ease 1.55s forwards;
}

@keyframes toastIn{
  from{
    transform:translateY(-8px);
    opacity:0;
  }
  to{
    transform:translateY(0);
    opacity:1;
  }
}

@keyframes toastOut{
  to{
    transform:translateY(-8px);
    opacity:0;
  }
}

@keyframes breathing{
  0%,100%{ transform:translateY(0) scale(1); }
  50%{ transform:translateY(-8px) scale(1.012); }
}

/* 对话输入状态 */
.typing-bubble{
  display:flex;
  align-items:center;
  gap:5px;
  min-width:54px;
  min-height:34px;
}

.typing-dot{
  width:6px;
  height:6px;
  border-radius:50%;
  background:var(--text-soft);
  opacity:.45;
  animation:typingBounce 1.1s infinite ease-in-out;
}

.typing-dot:nth-child(2){
  animation-delay:.15s;
}

.typing-dot:nth-child(3){
  animation-delay:.3s;
}

@keyframes typingBounce{
  0%, 80%, 100%{
    transform:translateY(0);
    opacity:.35;
  }
  40%{
    transform:translateY(-4px);
    opacity:1;
  }
}

.chat-input-bar button:disabled{
  opacity:.55;
  cursor:not-allowed;
}

/* =========================
   响应式
========================= */

@media (max-width: 1100px){
  .welcome-layout{
    grid-template-columns:1fr;
    padding:5vh 6vw;
  }

  .welcome-portrait-wrap{
    position:absolute;
    right:0;
    bottom:0;
    height:82%;
    opacity:.92;
  }

  .welcome-copy{
    position:relative;
    z-index:4;
    max-width:620px;
  }

  .app-shell{
    grid-template-columns:220px 1fr;
  }

  .focus-panel{
    grid-template-columns:1fr;
  }

  .panel-right{
    min-height:360px;
  }

  .companion-card{
    min-height:360px;
  }

  .companion-card img{
    height:54vh;
  }
}

@media (max-width: 760px){
  html,
  body{
    overflow:auto;
  }

  .welcome-screen{
    position:relative;
    min-height:100vh;
  }

  .welcome-layout{
    min-height:100vh;
    display:flex;
    align-items:center;
  }

  .welcome-portrait{
    height:64vh;
  }

  .character-dock{
    left:50%;
    transform:translateX(-50%);
    bottom:22px;
  }

  .app-shell{
    height:auto;
    min-height:100vh;
    grid-template-columns:1fr;
  }

  .side-nav{
    position:relative;
  }

  .main-view{
    min-height:720px;
    padding:20px;
  }

  .view-header{
    flex-direction:column;
  }

  .focus-panel,
  .chat-panel{
    min-height:auto;
    height:auto;
  }

  .timer-display{
    font-size:64px;
  }
}
