/* 声影 · 前台样式（移动优先，无外部字体依赖） */
:root {
  --bg: #070b0a;
  --ink: #eaf3ee;
  --ink-2: #9db0a8;
  --ink-3: #63736c;
  --jade: #59e3b8;
  --jade-dim: #2f8f74;
  --gold: #e8c98a;
  --line: rgba(120, 200, 175, .14);
  --panel: rgba(18, 28, 25, .72);
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  overflow: hidden;
  overscroll-behavior: none;
}
body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(58% 42% at 50% 8%, rgba(47, 143, 116, .28), transparent 70%),
    radial-gradient(40% 30% at 82% 78%, rgba(232, 201, 138, .10), transparent 70%),
    linear-gradient(180deg, #08100d 0%, #070b0a 55%, #060a09 100%);
  pointer-events: none;
}
.glow { position: fixed; border-radius: 50%; filter: blur(80px); pointer-events: none; opacity: .5; }
.glow-a { width: 420px; height: 420px; left: 50%; top: -160px; transform: translateX(-50%); background: rgba(46, 180, 145, .22); }
.glow-b { width: 320px; height: 320px; right: -120px; bottom: -80px; background: rgba(232, 201, 138, .10); }

.shell {
  position: relative;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 20px calc(12px + var(--safe-b));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
}

/* 顶部 */
.top { display: flex; align-items: center; justify-content: space-between; height: 40px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--jade); }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: rgba(89, 227, 184, .10); border: 1px solid rgba(89, 227, 184, .22); }
.brand-name { font-size: 17px; letter-spacing: .34em; color: var(--ink); font-weight: 500; }
.ghost-btn {
  appearance: none; border: 1px solid var(--line); background: rgba(255,255,255,.02);
  color: var(--ink-3); font-size: 12.5px; padding: 6px 12px; border-radius: 999px;
  font-family: inherit; cursor: pointer; transition: all .2s;
}
.ghost-btn:hover { color: var(--ink-2); border-color: rgba(120,200,175,.3); }

/* 舞台 */
.stage { display: flex; flex-direction: column; align-items: center; min-height: 0; }
.voice-chip {
  margin: 2px 0 0; font-size: 11.5px; letter-spacing: .18em; color: var(--ink-3);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px;
}
.orb-wrap { position: relative; display: grid; place-items: center; margin: 8px 0 4px; flex: 0 0 auto; }
.halo { position: absolute; width: 320px; height: 320px; pointer-events: none; }
.orb {
  position: relative; width: 148px; height: 148px; border-radius: 50%;
  border: 0; padding: 0; cursor: pointer; background: transparent;
  display: grid; place-items: center;
  transition: transform .25s cubic-bezier(.2,.8,.3,1);
  touch-action: manipulation;
}
.orb:active { transform: scale(.96); }
.orb-core {
  position: absolute; inset: 0; border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, rgba(255,255,255,.92), rgba(255,255,255,0) 42%),
    radial-gradient(circle at 50% 58%, #7df0cd 0%, #35b894 42%, #1d6f5a 72%, #123a31 100%);
  box-shadow:
    0 0 0 1px rgba(255,255,255,.16) inset,
    0 18px 50px -12px rgba(53,184,148,.55),
    0 0 90px -18px rgba(89,227,184,.45);
  transition: box-shadow .4s, filter .4s;
}
.orb-icon { position: relative; color: #052a21; opacity: .85; display: grid; place-items: center; transition: opacity .2s; }
body[data-state="listening"] .orb-core { filter: brightness(1.08); box-shadow: 0 0 0 1px rgba(255,255,255,.22) inset, 0 18px 60px -10px rgba(89,227,184,.8), 0 0 120px -10px rgba(89,227,184,.5); }
body[data-state="speaking"] .orb-core,
body[data-state="thinking"] .orb-core { filter: brightness(.86) saturate(.9); }
body[data-state="speaking"] .orb-icon svg rect,
body[data-state="speaking"] .orb-icon svg path { opacity: 0; }
body[data-state="speaking"] .orb-icon::after {
  content: ""; width: 26px; height: 26px; border-radius: 7px; background: #06231c;
  display: block; position: absolute;
}
body[data-state="error"] .orb-core { filter: grayscale(.5) brightness(.8); }

.status { margin: 14px 0 0; font-size: 16px; font-weight: 500; letter-spacing: .02em; }
.status-sub { margin: 5px 0 0; font-size: 12.5px; color: var(--ink-3); min-height: 18px; }

/* 对话气泡 */
.transcript {
  width: 100%; margin-top: 14px; flex: 1 1 auto; min-height: 0;
  overflow-y: auto; display: flex; flex-direction: column; gap: 9px;
  padding: 2px 2px 6px; scrollbar-width: thin; scrollbar-color: rgba(120,200,175,.2) transparent;
  mask-image: linear-gradient(180deg, transparent 0, #000 14px, #000 calc(100% - 4px), transparent 100%);
}
.transcript::-webkit-scrollbar { width: 4px; }
.transcript::-webkit-scrollbar-thumb { background: rgba(120,200,175,.18); border-radius: 4px; }
.msg {
  max-width: 86%; padding: 9px 14px; border-radius: 16px; font-size: 14.5px; line-height: 1.62;
  animation: rise .28s ease both; word-break: break-word; white-space: pre-wrap;
}
.msg.user {
  align-self: flex-end; background: linear-gradient(180deg, rgba(89,227,184,.18), rgba(89,227,184,.10));
  border: 1px solid rgba(89,227,184,.26); color: #d9fff1; border-bottom-right-radius: 6px;
}
.msg.ai {
  align-self: flex-start; background: var(--panel); border: 1px solid rgba(255,255,255,.06);
  color: var(--ink); border-bottom-left-radius: 6px; backdrop-filter: blur(8px);
}
.msg.ai.typing::after { content: "▍"; color: var(--jade); animation: blink 1s steps(2) infinite; margin-left: 1px; }
.msg.note { align-self: center; background: transparent; border: 0; color: var(--ink-3); font-size: 12.5px; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes blink { 50% { opacity: 0; } }

/* 输入区 */
.composer { padding-top: 6px; }
.composer-inner {
  display: flex; align-items: center; gap: 8px;
  background: rgba(20, 30, 27, .82); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 5px 5px 18px; backdrop-filter: blur(10px);
}
.composer-inner:focus-within { border-color: rgba(89,227,184,.4); }
#textInput {
  flex: 1; min-width: 0; background: transparent; border: 0; outline: none;
  color: var(--ink); font-size: 15px; font-family: inherit; padding: 9px 0;
}
#textInput::placeholder { color: var(--ink-3); }
.send {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(180deg, #6cebc7, #35b894); color: #04241c;
  display: grid; place-items: center; transition: transform .15s, filter .2s;
}
.send:active { transform: scale(.94); }
.send[disabled] { filter: grayscale(1) brightness(.7); cursor: default; }
.hint { margin: 8px 0 0; text-align: center; font-size: 11.5px; color: var(--ink-3); }

/* 口令 / 提示 */
.gate {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(5, 9, 8, .86); backdrop-filter: blur(12px); padding: 24px;
}
.gate[hidden] { display: none; }
.gate-card {
  width: 100%; max-width: 320px; text-align: center;
  background: rgba(18,28,25,.9); border: 1px solid var(--line); border-radius: 22px; padding: 28px 24px;
}
.gate-card h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: .3em; color: var(--jade); font-weight: 500; }
.gate-card p { margin: 0 0 16px; font-size: 13px; color: var(--ink-2); }
#gateInput {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(0,0,0,.25); color: var(--ink); font-size: 16px; outline: none; text-align: center; letter-spacing: .1em;
}
#gateInput:focus { border-color: rgba(89,227,184,.45); }
#gateBtn {
  width: 100%; margin-top: 12px; padding: 12px; border-radius: 12px; border: 0; cursor: pointer;
  background: linear-gradient(180deg, #6cebc7, #35b894); color: #04241c; font-size: 15px; font-weight: 600; font-family: inherit;
}
.gate-err { margin: 10px 0 0; min-height: 16px; color: #ff9a9a; font-size: 12.5px; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translate(-50%, 12px);
  background: rgba(28, 16, 16, .92); border: 1px solid rgba(255,120,120,.28); color: #ffd7d7;
  padding: 9px 16px; border-radius: 12px; font-size: 13px; opacity: 0; pointer-events: none;
  transition: all .25s; max-width: 88vw; text-align: center; z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-height: 720px) {
  .orb { width: 126px; height: 126px; }
  .halo { width: 270px; height: 270px; }
  .status { margin-top: 10px; }
}
@media (min-width: 760px) {
  .shell { padding-left: 32px; padding-right: 32px; }
  .orb { width: 168px; height: 168px; }
  .halo { width: 380px; height: 380px; }
  .msg { max-width: 72%; font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
