/* ══════════════════════════════════════════════
   LUCY — 舞台
   立绘用官方透明图，两层叠放：身体 + 头（遮罩软接缝）
   ══════════════════════════════════════════════ */

:root{
  --ink:        #05070a;
  --chrome:     #cfd8e3;
  --chrome-dim: #8c97a6;
  --amber:      #f5a742;
  --amber-soft: #ffd79a;
  --teal:       #7ea9bb;
  --paper:      #ece5d8;
  --paper-dim:  #9b9489;
  --line:       rgba(255,255,255,.08);
  --line-warm:  rgba(245,167,66,.28);
  --font-serif: "Songti SC","Noto Serif SC","Source Han Serif SC","SimSun","STSong",Georgia,serif;
  --font-ui:    "PingFang SC","Microsoft YaHei","Helvetica Neue",Arial,sans-serif;
  --font-mono:  "JetBrains Mono","Cascadia Mono",Consolas,"Courier New",monospace;
  /* 立绘关键坐标（由像素扫描量出） */
  --head-x: 36%;
  --head-y: 7%;
  --neck-y: 13.8%;
  --visor-x: 36.95%;
  --visor-y: 9.86%;
}

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

html,body{
  height:100%;
  background:var(--ink);
  color:var(--paper);
  font-family:var(--font-ui);
  overflow:hidden;
  -webkit-font-smoothing:antialiased;
  -webkit-tap-highlight-color:transparent;
}

#stage{
  position:fixed; inset:0;
  background:
    radial-gradient(1000px 760px at 66% 40%, rgba(40,56,66,.5) 0%, rgba(10,13,17,.18) 45%, rgba(5,7,10,0) 72%),
    radial-gradient(700px 520px at 16% 18%, rgba(245,167,66,.06) 0%, rgba(5,7,10,0) 65%),
    linear-gradient(160deg,#0a0f14 0%,#05070a 45%,#080a0e 100%);
  overflow:hidden;
}
#stage::before{
  content:""; position:absolute; inset:0; pointer-events:none;
  background-image:
    linear-gradient(rgba(255,255,255,.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.02) 1px, transparent 1px);
  background-size:64px 64px;
  mask-image:radial-gradient(70% 70% at 60% 45%, #000 0%, transparent 100%);
}

/* ── 立绘 ── */
#charAnchor{
  position:absolute; inset:0; z-index:1;
  display:flex; align-items:flex-end; justify-content:flex-end;
  padding-right:3.5%;
  pointer-events:none;
}
#charWrap{
  position:relative;
  height:99vh;
  aspect-ratio:1100 / 2048;
  transform-origin:50% 100%;
  will-change:transform;
  filter:drop-shadow(0 30px 80px rgba(0,0,0,.7));
}
.layer{
  position:absolute; inset:0;
  width:100%; height:100%;
  object-fit:contain;
  user-select:none; -webkit-user-drag:none;
  pointer-events:none;
}
.layer.head{
  /* 只在脖子那一层做渐隐：左右完全实心，头发边缘就不会露出发丝重影。
     旋转支点正好也在脖子，那里两层位移为零，接缝看不见。 */
  -webkit-mask-image:radial-gradient(ellipse 92% 7.6% at var(--head-x) 7%, #000 88%, transparent 100%);
  mask-image:radial-gradient(ellipse 92% 7.6% at var(--head-x) 7%, #000 88%, transparent 100%);
  transform-origin:var(--head-x) var(--neck-y);
  will-change:transform;
}

/* 鍏夋Ы鐨勫厜 */
.visor{
  position:absolute;
  left:var(--visor-x); top:var(--visor-y);
  width:9.5%; height:2.1%;
  transform:translate(-50%,-50%);
  border-radius:50%;
  background:radial-gradient(ellipse at center,
    rgba(255,236,200,.95) 0%,
    rgba(255,190,110,.6) 30%,
    rgba(245,167,66,.28) 55%,
    rgba(245,167,66,0) 78%);
  filter:blur(5px);
  mix-blend-mode:screen;
  opacity:0;
  will-change:opacity,transform;
  pointer-events:none;
}

/* 鑳屾櫙鍏夎疆 */
#ring{
  position:absolute;
  left:var(--head-x); top:13%;
  width:150%; height:150%;
  transform:translate(-50%,-50%);
  pointer-events:none;
  opacity:.55;
  will-change:transform;
}

.fade-bottom{
  position:absolute; left:0; right:0; bottom:0; height:34vh; z-index:2;
  background:linear-gradient(to top, var(--ink) 0%, rgba(5,7,10,.86) 28%, rgba(5,7,10,0) 100%);
  pointer-events:none;
}
.grain{
  position:absolute; inset:-50%; pointer-events:none; opacity:.3; z-index:4;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/><feColorMatrix type='saturate' values='0'/></filter><rect width='140' height='140' filter='url(%23n)' opacity='0.5'/></svg>");
  mix-blend-mode:overlay;
  animation:grainShift 7s steps(3) infinite;
}
@keyframes grainShift{
  0%{transform:translate(0,0)} 33%{transform:translate(-2%,1%)} 66%{transform:translate(1%,-2%)} 100%{transform:translate(0,0)}
}
.vignette{
  position:absolute; inset:0; pointer-events:none; z-index:5;
  background:radial-gradient(120% 95% at 58% 40%, transparent 42%, rgba(3,4,6,.75) 100%);
}

#dust{ position:absolute; inset:0; z-index:3; pointer-events:none; }
.mote{
  position:absolute; width:2px; height:2px; border-radius:50%;
  background:var(--amber-soft); opacity:0;
  animation:float linear infinite;
  box-shadow:0 0 6px rgba(255,215,154,.9);
}
@keyframes float{
  0%{ opacity:0; transform:translateY(0) translateX(0) }
  12%{ opacity:.7 }
  85%{ opacity:.3 }
  100%{ opacity:0; transform:translateY(-58vh) translateX(22px) }
}

/* ── 顶栏 ── */
#topbar{
  position:absolute; top:0; left:0; right:0; z-index:20;
  display:flex; align-items:center; justify-content:space-between;
  padding:20px 30px;
  background:linear-gradient(to bottom, rgba(5,7,10,.8), rgba(5,7,10,0));
}
.brand{ display:flex; align-items:center; gap:9px; }
.brand b{ font-family:Georgia,serif; font-size:15px; letter-spacing:.34em; font-weight:400; color:var(--chrome); }
.brand .sep{ color:rgba(255,255,255,.2); }
.brand .sub{ font-size:11.5px; letter-spacing:.26em; color:var(--paper-dim); }

.dot{
  width:6px; height:6px; border-radius:50%;
  background:var(--amber); box-shadow:0 0 10px var(--amber);
  transition:background .3s, box-shadow .3s;
}
.dot.busy{ background:var(--teal); box-shadow:0 0 12px var(--teal); animation:pulseDot 1.1s ease-in-out infinite; }
@keyframes pulseDot{ 0%,100%{opacity:1} 50%{opacity:.25} }

.tools{ display:flex; align-items:center; gap:8px; }
.tbtn{
  font-family:var(--font-ui); font-size:11.5px; letter-spacing:.1em;
  color:var(--chrome-dim); background:rgba(255,255,255,.03);
  border:1px solid var(--line); border-radius:2px;
  padding:7px 12px; cursor:pointer;
  transition:all .22s ease;
}
.tbtn:hover{ color:var(--paper); border-color:rgba(245,167,66,.5); background:rgba(245,167,66,.07); }
.tbtn.icon{ padding:7px 10px; font-size:13px; line-height:1; }
.tbtn.on{ color:var(--amber-soft); border-color:var(--line-warm); background:rgba(245,167,66,.1); }

/* ── 对话 ── */
#chat{
  position:absolute; left:clamp(18px,4vw,64px); bottom:clamp(16px,3vh,38px);
  width:min(480px, 43vw);
  top:18vh; height:auto; max-height:none; min-height:0;
  z-index:10;
  display:flex; flex-direction:column;
  background:linear-gradient(160deg, rgba(10,13,18,.7), rgba(6,8,11,.86));
  border:1px solid var(--line);
  border-radius:3px;
  backdrop-filter:blur(22px) saturate(.9);
  -webkit-backdrop-filter:blur(22px) saturate(.9);
  box-shadow:0 30px 90px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.045);
  overflow:hidden;
}
#chat::after{
  content:""; position:absolute; left:0; top:0; width:1px; height:100%;
  background:linear-gradient(to bottom, transparent, var(--line-warm) 30%, transparent 85%);
}

.log{
  flex:1 1 auto; min-height:0; overflow-y:auto; padding:26px 26px 8px;
  display:flex; flex-direction:column; gap:22px;
  scrollbar-width:thin; scrollbar-color:rgba(255,255,255,.14) transparent;
}
.log::-webkit-scrollbar{ width:4px; }
.log::-webkit-scrollbar-thumb{ background:rgba(255,255,255,.14); border-radius:2px; }

.turn{ display:flex; flex-direction:column; gap:6px; animation:rise .45s cubic-bezier(.19,1,.22,1); }
@keyframes rise{ from{ opacity:0; transform:translateY(10px) } to{ opacity:1; transform:none } }
.turn .who{ font-size:9.5px; letter-spacing:.32em; color:rgba(255,255,255,.26); font-family:var(--font-mono); }
.turn .body{
  font-family:var(--font-serif);
  font-size:16.5px; line-height:2.0; letter-spacing:.02em;
  color:var(--paper);
  white-space:pre-wrap; word-break:break-word;
}
.turn.lucy .body{
  border-left:1px solid rgba(245,167,66,.3);
  padding-left:16px;
  color:#f2ece1;
  text-shadow:0 1px 24px rgba(0,0,0,.6);
  transition:border-color .3s;
}
.turn.lucy .body.speaking{ border-left-color:rgba(245,167,66,.9); }
.turn.lucy .who{ color:rgba(245,167,66,.5); }

.turn.me{ align-items:flex-end; }
.turn.me .body{
  font-family:var(--font-ui); font-size:14.5px; line-height:1.75;
  color:#dbe3ec; letter-spacing:0;
  background:rgba(255,255,255,.045);
  border:1px solid rgba(255,255,255,.06);
  border-radius:2px 2px 0 2px;
  padding:11px 15px; max-width:88%;
}

.sysnote{
  font-size:11.5px; line-height:1.7; color:rgba(255,255,255,.32);
  border-left:1px dashed rgba(255,255,255,.14); padding-left:12px;
  font-family:var(--font-ui);
}
.caret{
  display:inline-block; width:7px; height:15px; vertical-align:-2px;
  background:var(--amber); opacity:.9; margin-left:2px;
  animation:blink 1s steps(1) infinite;
}
@keyframes blink{ 50%{opacity:0} }

#composer{
  display:flex; align-items:flex-end; gap:8px;
  padding:14px 16px 10px; margin:0 12px;
  border-top:1px solid var(--line);
}
#input{
  flex:1; resize:none; border:0; outline:0; background:transparent;
  font-family:var(--font-ui); font-size:14.5px; line-height:1.7;
  color:var(--paper); max-height:132px; padding:6px 2px;
}
#input::placeholder{ color:rgba(255,255,255,.22); }

#btnSend,#btnMic{
  width:36px; height:36px; flex:0 0 auto;
  border-radius:2px; border:1px solid var(--line);
  background:rgba(255,255,255,.04); color:var(--chrome-dim);
  cursor:pointer; font-size:14px; line-height:1;
  transition:all .2s; display:grid; place-items:center;
}
#btnSend:hover,#btnMic:hover{ color:var(--amber-soft); border-color:var(--line-warm); background:rgba(245,167,66,.1); }
#btnSend:disabled{ opacity:.3; cursor:default; }
#btnMic.rec{ color:#ff8a8a; border-color:rgba(255,120,120,.5); animation:pulseDot 1s infinite; }


/* 空状态提示 */
.hint{ padding:6px 0 4px; animation:rise .6s cubic-bezier(.19,1,.22,1); }
.hint-line{ font-family:var(--font-serif); font-size:15px; color:rgba(236,229,216,.5); letter-spacing:.06em; }
.hint-sub{ font-size:11.5px; color:rgba(255,255,255,.24); margin-top:7px; letter-spacing:.05em; }
.chips{ display:flex; flex-wrap:wrap; gap:7px; margin-top:14px; }
.chip{
  font-family:var(--font-ui); font-size:12px; color:rgba(236,229,216,.6);
  background:transparent; border:1px solid rgba(255,255,255,.1);
  border-radius:999px; padding:6px 13px; cursor:pointer; transition:all .2s;
}
.chip:hover{ color:var(--amber-soft); border-color:rgba(245,167,66,.45); background:rgba(245,167,66,.06); }

.footnote{
  padding:2px 26px 14px; font-size:10.5px; letter-spacing:.06em;
  color:rgba(255,255,255,.18); font-family:var(--font-mono);
}

/* ── 设置 ── */
.drawer{
  position:absolute; top:0; right:0; bottom:0; z-index:40;
  width:min(440px, 94vw);
  background:linear-gradient(180deg, #0a0d11, #06080b);
  border-left:1px solid var(--line);
  box-shadow:-30px 0 80px rgba(0,0,0,.6);
  display:flex; flex-direction:column;
  animation:slideIn .35s cubic-bezier(.19,1,.22,1);
}
@keyframes slideIn{ from{ transform:translateX(30px); opacity:0 } to{ transform:none; opacity:1 } }
.drawer[hidden]{ display:none; }
.drawer-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:22px 24px 16px; border-bottom:1px solid var(--line);
}
.drawer-head h2{ font-family:Georgia,serif; font-size:16px; font-weight:400; letter-spacing:.3em; color:var(--chrome); }
.drawer-body{ flex:1; overflow-y:auto; padding:18px 24px 40px; }
.drawer-body::-webkit-scrollbar{ width:4px; }
.drawer-body::-webkit-scrollbar-thumb{ background:rgba(255,255,255,.14); }

.block{ margin-bottom:28px; padding-bottom:22px; border-bottom:1px solid rgba(255,255,255,.05); }
.block:last-child{ border-bottom:0; }
.block h3{ font-size:12px; font-weight:500; letter-spacing:.22em; color:var(--chrome); margin-bottom:8px; }
.block .note{ font-size:11.5px; line-height:1.7; color:rgba(255,255,255,.34); margin-bottom:14px; }
.block .note code{ font-family:var(--font-mono); color:var(--amber-soft); }

label{ display:block; font-size:11px; letter-spacing:.1em; color:rgba(255,255,255,.42); margin-bottom:12px; }
label input,label select,label textarea,#setMemory{
  display:block; width:100%; margin-top:7px;
  background:rgba(255,255,255,.035); border:1px solid rgba(255,255,255,.09);
  border-radius:2px; padding:9px 11px;
  font-family:var(--font-mono); font-size:12.5px; color:var(--paper);
  outline:none; transition:border-color .2s;
}
label textarea{ resize:vertical; line-height:1.65; }
label input:focus,label select:focus,label textarea:focus,#setMemory:focus{
  border-color:rgba(245,167,66,.5); background:rgba(245,167,66,.05);
}
label input[type=range]{ display:block; width:100%; margin-top:8px; accent-color:var(--amber); height:2px; }
select{ font-family:var(--font-ui) !important; }
.row{ display:flex; gap:14px; }
.row > label{ flex:1; }
.switch{ display:flex; align-items:center; gap:9px; font-size:12px; color:rgba(255,255,255,.6); cursor:pointer; }
.switch input{ accent-color:var(--amber); width:14px; height:14px; margin:0; }

.sub-block{
  padding:14px; margin-bottom:14px;
  background:rgba(255,255,255,.018);
  border:1px solid rgba(255,255,255,.05);
  border-radius:2px;
  transition:opacity .3s;
}
.sub-block.off{ opacity:.32; pointer-events:none; }

.btn{
  display:inline-block; font-family:var(--font-ui); font-size:11.5px; letter-spacing:.12em;
  color:var(--ink); background:var(--amber);
  border:0; border-radius:2px; padding:9px 16px; cursor:pointer;
  transition:all .2s; margin:4px 6px 4px 0;
}
.btn:hover{ background:var(--amber-soft); box-shadow:0 0 24px rgba(245,167,66,.3); }
.btn.ghost{ background:transparent; color:var(--chrome-dim); border:1px solid var(--line); }
.btn.ghost:hover{ color:var(--amber-soft); border-color:var(--line-warm); background:rgba(245,167,66,.07); box-shadow:none; }

.msg{ font-size:11.5px; line-height:1.6; margin-top:9px; min-height:1em; color:rgba(255,255,255,.45); }
.msg.err{ color:#ff9a9a; }
.msg.ok{ color:#8fd6a8; }
.upload{ margin-bottom:12px; }
.upload .btn{ width:100%; text-align:center; }
#setMemory{ font-family:var(--font-serif); font-size:13px; line-height:1.9; min-height:120px; resize:vertical; }

.toast{
  position:absolute; left:50%; bottom:46px; transform:translate(-50%,20px);
  z-index:60; padding:11px 20px; border-radius:2px;
  background:rgba(12,16,21,.96); border:1px solid var(--line-warm);
  font-size:12.5px; color:var(--paper); letter-spacing:.04em;
  opacity:0; pointer-events:none; transition:all .3s cubic-bezier(.19,1,.22,1);
  max-width:min(560px,86vw); line-height:1.6;
}
.toast.show{ opacity:1; transform:translate(-50%,0); }

/* ── 平板 ── */
@media (max-width: 1100px){
  #charAnchor{ padding-right:0; }
  #charWrap{ height:92vh; }
  #chat{ width:min(440px, 52vw); }
}

/* ── 手机 ── */
@media (max-width: 780px){
  #charAnchor{ justify-content:center; align-items:flex-end; }
  #charWrap{ height:88vh; filter:drop-shadow(0 20px 50px rgba(0,0,0,.7)); }
  #chat{
    top:auto; left:0; right:0; bottom:0; width:auto; height:58vh;
    border-radius:16px 16px 0 0; border-bottom:0; border-left:0; border-right:0;
    background:linear-gradient(180deg, rgba(9,12,17,.82), rgba(5,7,10,.97) 40%);
  }
  #chat::after{ display:none; }
  #topbar{ padding:12px 16px; }
  .brand .sub{ display:none; }
  .tbtn{ font-size:11px; padding:6px 10px; }
  .log{ padding:20px 18px 4px; gap:18px; }
  .turn .body{ font-size:16px; line-height:1.95; }
  .turn.me .body{ font-size:14px; }
  .footnote{ display:none; }
  #composer{ padding:10px 12px calc(10px + env(safe-area-inset-bottom)); margin:0 6px; }
  .fade-bottom{ height:24vh; }
  .drawer{ width:100vw; }
}

@media (prefers-reduced-motion: reduce){
  *{ animation-duration:.001ms !important; transition-duration:.001ms !important; }
}
.reduce-motion .mote{ display:none; }




.toolnote{
  font-size:11px; letter-spacing:.08em; color:rgba(245,167,66,.55);
  font-family:var(--font-mono);
  padding:2px 0 2px 17px;
  border-left:1px dashed rgba(245,167,66,.25);
  animation:pulseDot 1.6s ease-in-out infinite;
}
/* 辅助字幕：小一号、灰一档，像注释 */
.turn.lucy .sub{
  font-family: var(--font-serif);
  font-size: 13.5px;
  line-height: 1.85;
  letter-spacing: .015em;
  color: rgba(200,193,180,.58);
  padding-left: 17px;
  margin-top: 7px;
  max-width: 96%;
  white-space: pre-wrap;
  word-break: break-word;
  animation: subIn .5s cubic-bezier(.19,1,.22,1);
}
@keyframes subIn{ from{opacity:0; transform:translateY(-3px)} to{opacity:1; transform:none} }
/* ══════════ 按住说话 ══════════ */
.rec-overlay{
  position:absolute; left:50%; bottom:120px; transform:translateX(-50%);
  z-index:50; pointer-events:none;
  display:flex; flex-direction:column; align-items:center; gap:10px;
}
.rec-overlay[hidden]{ display:none; }
.rec-capsule{
  display:flex; align-items:center; gap:12px;
  padding:12px 18px; border-radius:999px;
  background:rgba(10,13,18,.92);
  border:1px solid rgba(245,167,66,.35);
  box-shadow:0 12px 40px rgba(0,0,0,.6);
  backdrop-filter:blur(16px);
}
.rec-dot{
  width:9px; height:9px; border-radius:50%;
  background:#ff5d5d; box-shadow:0 0 10px #ff5d5d;
  animation:pulseDot .9s ease-in-out infinite;
  flex:0 0 auto;
}
.rec-time{
  font-family:var(--font-mono); font-size:13px; color:var(--chrome);
  min-width:42px; text-align:right;
}
#recWave{ display:block; width:180px; height:34px; }
.rec-hint{
  font-size:11.5px; letter-spacing:.1em; color:rgba(255,255,255,.45);
  background:rgba(10,13,18,.8); padding:6px 14px; border-radius:999px;
}
.rec-overlay.cancel .rec-capsule{ border-color:rgba(255,93,93,.7); }
.rec-overlay.cancel .rec-hint{ color:#ff9a9a; }

/* ══════════ 语音条消息 ══════════ */
.turn.me.voice .vbubble{
  display:flex; align-items:center; gap:9px;
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.08);
  border-radius:2px 2px 0 2px;
  padding:10px 14px;
  cursor:pointer;
  transition:background .2s, border-color .2s;
  min-width:88px;
}
.turn.me.voice .vbubble:hover{ background:rgba(245,167,66,.1); border-color:rgba(245,167,66,.4); }
.turn.me.voice .vbubble.playing{ border-color:rgba(245,167,66,.75); background:rgba(245,167,66,.12); }
.vic{
  font-size:11px; color:var(--amber); letter-spacing:-1px;
  font-family:var(--font-mono);
}
.vwave{ display:flex; align-items:center; gap:2px; height:16px; flex:1; }
.vwave i{
  display:block; width:2px; border-radius:1px;
  background:rgba(245,167,66,.55);
}
.turn.me.voice .vbubble.playing .vwave i{ background:var(--amber); }
.vtime{
  font-family:var(--font-mono); font-size:11px;
  color:rgba(255,255,255,.42); letter-spacing:.04em;
}
.turn.me.voice .vtxt{
  font-family:var(--font-ui); font-size:12.5px; line-height:1.75;
  color:rgba(200,193,180,.55);
  max-width:88%; margin-top:6px; text-align:right;
}
.turn.me.voice .vtxt.pending{ color:rgba(245,167,66,.5); }