.logo-img { width: 28px; height: 28px; border-radius: 8px; }
.onboard-logo-img { width: 80px; height: 80px; border-radius: 20px; }
/* 小骞AI 网页版 —— 深色为主，浅色可切 */
:root {
  --bg: #101418;
  --bg2: #171d24;
  --panel: #1c242d;
  --line: #2a3542;
  --text: #e8edf2;
  --text-dim: #93a1b0;
  --accent: #4da3ff;
  --accent2: #7c5cff;
  --danger: #ff6b6b;
  --me: #2b5278;
  --ai: #232c36;
  --radius: 14px;
  --stage-h: 28vh;
}
body[data-theme="light"] {
  --bg: #f2f5f8;
  --bg2: #ffffff;
  --panel: #ffffff;
  --line: #dde5ec;
  --text: #1a222b;
  --text-dim: #66727e;
  --me: #cfe6ff;
  --ai: #ffffff;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  overflow: hidden;
}
button { font-family: inherit; }
.hidden { display: none !important; }

#app { display: flex; flex-direction: column; height: 100dvh; max-width: 860px; margin: 0 auto; overflow: hidden; }
/* 功能区不被挡：舞台和聊天可收缩，底部按钮始终可见 */
#stage { flex-shrink: 0; }
#chat { flex: 1 1 0; min-height: 50px; }
#featureBar, #inputBar { flex-shrink: 0; }

/* ---------- 顶栏 ---------- */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--bg2); border-bottom: 1px solid var(--line); z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; }
.logo { font-size: 22px; }
.brand-text b { font-size: 15px; display: block; line-height: 1.1; }
.brand-text small { color: var(--text-dim); font-size: 11px; }
.top-actions { display: flex; gap: 4px; }
.icon-btn {
  background: none; border: none; color: var(--text); font-size: 18px;
  padding: 6px 8px; border-radius: 10px; cursor: pointer; line-height: 1;
}
.icon-btn:active { background: var(--panel); }

/* ---------- 数字人舞台 ---------- */
#stage {
  position: relative; height: var(--stage-h); min-height: 220px;
  background: linear-gradient(180deg, var(--bg2), var(--bg));
  border-bottom: 1px solid var(--line); overflow: hidden;
  transition: background .3s;
}
#l2d { position: absolute; inset: 0; }
#l2d canvas { display: block; }
#stageHint {
  position: absolute; left: 0; right: 0; top: 42%; text-align: center;
  color: var(--text-dim); font-size: 13px; pointer-events: none;
}
#stage.greenscreen { background: #00b140 !important; }
#stage.greenscreen #l2d { background: #00b140; }
#subtitle {
  position: absolute; left: 12px; right: 12px; bottom: 8px;
  background: rgba(0,0,0,.45); color: #fff; padding: 6px 10px;
  border-radius: 10px; font-size: 13px; line-height: 1.5;
  max-height: 42%; overflow: hidden; pointer-events: none;
}
#stage.greenscreen #subtitle { display: none; }

/* ---------- 聊天区 ---------- */
#chat { flex: 1; overflow-y: auto; padding: 12px 12px 0; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 86%; padding: 9px 13px; border-radius: var(--radius); font-size: 14.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.msg.me { align-self: flex-end; background: var(--me); border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--ai); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.tool { align-self: center; background: none; color: var(--text-dim); font-size: 12px; padding: 2px; border: none; }
.msg.err { align-self: flex-start; background: rgba(255,107,107,.12); color: var(--danger); border: 1px solid var(--danger); font-size: 13px; }
.msg.typing { animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* ---------- 表情行 ---------- */

/* ---------- 功能页签 ---------- */
#featureBar {
  display: flex; gap: 6px; padding: 3px 10px; overflow-x: auto;
  background: transparent;  scrollbar-width: none;
}
#featureBar::-webkit-scrollbar { display: none; }
#featureBar button {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 20px; padding: 7px 12px; font-size: 13px; white-space: nowrap; cursor: pointer;
}
#featureBar button:active { background: var(--line); }

/* ---------- 输入区 ---------- */
#inputBar {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px; padding-bottom: 12px;
  background: var(--bg2); border-top: 1px solid var(--line);
}
#textWrap { display: flex; flex: 1; gap: 6px; align-items: center; }
#textInput {
  flex: 1; background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 22px; padding: 10px 14px; font-size: 15px; outline: none;
}
#textInput:focus { border-color: var(--accent); }
.mic-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff;
  border: none; border-radius: 14px; padding: 8px; cursor: pointer; font-size: 20px; line-height: 1.1;
}
.mic-btn small { font-size: 11px; font-weight: 500; }
.mic-btn.listening { animation: glow 1.2s infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 8px rgba(124,92,255,.25); } }
#btnHandsfree.on { background: var(--accent); border-radius: 12px; }

/* ---------- 底部抽屉 ---------- */
#sheetMask, #settingsMask {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40;
}
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  background: var(--bg2); border-radius: 18px 18px 0 0; border-top: 1px solid var(--line);
  max-height: 76dvh; display: flex; flex-direction: column;
  animation: slideUp .22s ease-out;
}
@keyframes slideUp { from { transform: translateY(40%); opacity: .4; } }
#sheet > header, #settings > header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
#sheetBody { overflow-y: auto; padding: 12px 16px 24px; }

/* 通用列表（频道/电台/歌曲/书） */
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 11px 10px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.list-item:active { background: var(--panel); }
.list-item .li-title { font-size: 14.5px; }
.list-item .li-sub { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.list-item .li-icon { font-size: 20px; margin-right: 10px; }
.list-item.playing .li-title { color: var(--accent); }
.empty { color: var(--text-dim); text-align: center; padding: 28px 10px; font-size: 13.5px; line-height: 1.8; }
.btn {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 16px; font-size: 14px; cursor: pointer;
}
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: none; color: #fff; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.big { width: 100%; margin-top: 10px; padding: 13px; font-size: 15px; }
.btn-row { display: flex; gap: 8px; margin-top: 8px; }
.btn-row .btn { flex: 1; }

/* ---------- 设置 ---------- */
#settings {
  position: fixed; inset: 0; z-index: 51; background: var(--bg);
  display: flex; flex-direction: column; animation: fadeIn .18s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } }
.settings-body { overflow-y: auto; padding: 10px 16px 30px; }
#settings details {
  border: 1px solid var(--line); border-radius: 14px; padding: 4px 14px; margin: 10px 0;
  background: var(--bg2);
}
#settings summary { padding: 10px 0; cursor: pointer; font-weight: 600; font-size: 14.5px; }
.row { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 14px; }
.row > :first-child { flex-shrink: 0; }
.row input[type=text], .row input[type=password], .row select {
  flex: 1; min-width: 0; background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font-size: 14px; outline: none;
}
.row input[type=range] { flex: 1; accent-color: var(--accent); }
.row.check { justify-content: flex-start; }
.row.check input { accent-color: var(--accent); width: 18px; height: 18px; }
.sub { border-left: 2px solid var(--line); padding-left: 10px; margin: 6px 0; }
.hint { color: var(--text-dim); font-size: 12px; line-height: 1.7; margin: 8px 0; }
.about { color: var(--text-dim); font-size: 11.5px; text-align: center; margin-top: 18px; line-height: 1.7; }

/* ---------- 阅读器 ---------- */
#reader {
  position: fixed; inset: 0; z-index: 45; background: var(--bg);
  display: flex; flex-direction: column; animation: fadeIn .18s ease-out;
}
#reader > header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--bg2); border-bottom: 1px solid var(--line);
}
#readerTitle { flex: 1; text-align: center; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-chapters { display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto; background: var(--bg2); border-bottom: 1px solid var(--line); scrollbar-width: none; }
.reader-chapters::-webkit-scrollbar { display: none; }
.reader-chapters button {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 16px; padding: 5px 11px; font-size: 12px; white-space: nowrap; cursor: pointer; flex-shrink: 0;
}
.reader-chapters button.cur { background: var(--accent); border-color: var(--accent); color: #fff; }
#readerContent { flex: 1; overflow-y: auto; padding: 18px 18px 60px; font-size: 16.5px; line-height: 2; }
#readerContent .para { margin: 0 0 2px; text-indent: 2em; }
#readerContent .para.speaking { background: rgba(77,163,255,.18); border-radius: 6px; }
#readerContent .chapter-title { font-weight: 700; text-align: center; margin: 18px 0; text-indent: 0; }

/* ---------- 播放器浮窗（电视） ---------- */
#mediaVideo {
  position: fixed; z-index: 60; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: min(94vw, 860px); max-height: 80vh; background: #000;
  border-radius: 14px; box-shadow: 0 8px 40px rgba(0,0,0,.6);
}
#mediaVideo.fullscreen { position: fixed; inset: 0; width: 100vw; height: 100vh; max-height: none; transform: none; border-radius: 0; }
.video-bar {
  position: fixed; z-index: 61; bottom: max(14px, env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); display: flex; gap: 8px;
}
.video-bar .btn { background: rgba(0,0,0,.7); color: #fff; border-color: rgba(255,255,255,.3); }

/* ---------- 授权锁 ---------- */
#licenseGate {
  position: fixed; inset: 0; z-index: 75; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  overflow-y: auto;
}
#licenseGate input {
  width: 100%; background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 13px; font-size: 15px; outline: none;
}

/* ---------- 引导 ---------- */
#onboard {
  position: fixed; inset: 0; z-index: 70; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.onboard-card { max-width: 420px; width: 100%; text-align: center; }
.onboard-logo { font-size: 54px; }
.onboard-card h1 { margin: 6px 0 2px; font-size: 26px; }
.tagline { color: var(--text-dim); font-size: 13.5px; margin: 0 0 18px; }
#obApiForm { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
#obApiForm input {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; font-size: 14px; outline: none;
}

/* 桌面端宽屏适配 */
@media (min-width: 700px) {
  :root { --stage-h: 40vh; }
  .msg { max-width: 70%; }
}

/* ---------- 拍照识物 ---------- */
#photoMask { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 55; }
#photoModal {
  position: fixed; z-index: 56; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: min(92vw, 520px); background: var(--bg2); border: 1px solid var(--line);
  border-radius: 16px; overflow: hidden;
}
#photoModal > header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.photo-body { padding: 12px 16px 18px; display: flex; flex-direction: column; gap: 10px; }
#photoVideo { width: 100%; border-radius: 12px; background: #000; max-height: 46vh; }
#photoQ {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font-size: 14px; outline: none; width: 100%;
}

/* ---------- 聊天气泡头像 / 背景 ---------- */
.msg-row { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.msg-row.me { flex-direction: row-reverse; }
.msg-row .avatar-img {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  background: var(--panel); border: 1px solid var(--line);
}
#chat.with-bg {
  background-size: cover; background-position: center; background-attachment: local;
}

/* 绿幕模式：隐藏除舞台外的所有界面 */
body.greenscreen-only #topbar,
body.greenscreen-only #chat,
body.greenscreen-only #featureBar,
body.greenscreen-only #inputBar { display: none; }
body.greenscreen-only #stage { flex: 1; height: auto; border: none; }
#gsExit {
  position: fixed; right: 14px; bottom: 14px; z-index: 62; display: none;
  opacity: .5; background: rgba(0,0,0,.5); color: #fff; border-color: rgba(255,255,255,.25);
}
#gsExit:hover { opacity: 1; }
body.greenscreen-only #gsExit { display: block; }
