/* ═══════════════════════════════════════════════════════════════
   天痕主脑 · 驾驶舱 v3「雅致版」— 桌面端覆盖层
   只作用于 ≥761px；手机端保持原样（手机版另做落地）
   原则：不改任何 JS 逻辑，只重排视觉与信息层级
   ═══════════════════════════════════════════════════════════════ */
@media (min-width: 761px) {

  :root {
    --bg0: #070a0f;
    --bg1: #0c1017;
    --bg2: #111621;
    --bg3: #171d2a;
    --line: rgba(236, 242, 255, .07);
    --line2: rgba(236, 242, 255, .13);
    --txt: #e7ebf3;
    --txt2: #98a3b6;
    --txt3: #77818f;
    --accent: #7dd3c0;
    --accent2: #d5b183;
    --user: rgba(125, 211, 192, .075);
    --danger: #e08d86;
    --panel-w: 566px;
    --fig-glow: rgba(125, 211, 192, .22);
  }

  html, body { height: 100%; }

  body {
    background: #070a0f;
    color: var(--txt);
    font-family: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.72;
    letter-spacing: .01em;
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
  }

  /* 极细颗粒，抽掉会觉得"太干净像假图" */
  body::after {
    content: "";
    position: fixed; inset: 0; z-index: 9998; pointer-events: none;
    opacity: .026;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
    mix-blend-mode: overlay;
  }

  ::selection { background: rgba(125, 211, 192, .24); }
  ::-webkit-scrollbar { width: 7px; height: 7px; }
  ::-webkit-scrollbar-thumb { background: transparent; border-radius: 99px; }
  *:hover::-webkit-scrollbar-thumb { background: var(--line2); }
  ::-webkit-scrollbar-track { background: transparent; }

  #app {
    display: flex; height: 100vh; width: 100vw; overflow: hidden;
    background: #070a0f;
  }

  /* ═══════ 舞台 ═══════ */
  #stage, #stage3d {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    position: relative;
    overflow: hidden;
    background:
      radial-gradient(78% 42% at 50% 0%, rgba(125, 211, 192, .10), transparent 62%),
      radial-gradient(64% 38% at 78% 82%, rgba(167, 139, 250, .08), transparent 66%),
      linear-gradient(180deg, #222b42 0%, #161d2c 46%, #0b0f18 88%, #080b12 100%);
  }
  #stage3d {
    background:
      radial-gradient(58% 22% at 50% 96%, rgba(167, 139, 250, .16), transparent 72%),
      radial-gradient(78% 42% at 50% 0%, rgba(125, 211, 192, .10), transparent 62%),
      linear-gradient(180deg, #222b42 0%, #161d2c 46%, #0b0f18 88%, #080b12 100%);
  }
  /* 光效两档：rich＝光铺开 / tight＝只留一束 */
  body[data-light="rich"] #stage,
  body[data-light="rich"] #stage3d {
    background:
      radial-gradient(86% 46% at 50% -4%, rgba(125, 211, 192, .26), transparent 64%),
      radial-gradient(64% 34% at 22% 26%, rgba(167, 139, 250, .20), transparent 66%),
      radial-gradient(70% 34% at 82% 62%, rgba(213, 177, 131, .10), transparent 66%),
      linear-gradient(180deg, #2b3553 0%, #1c2438 44%, #0d1220 88%, #080b12 100%);
  }
  body[data-light="rich"] #stage::before,
  body[data-light="rich"] #stage3d::before {
    width: 62%; height: 130px;
    background: radial-gradient(ellipse at center, rgba(125, 211, 192, .34), rgba(167, 139, 250, .16) 46%, transparent 78%);
  }
  body[data-light="tight"] #stage,
  body[data-light="tight"] #stage3d {
    background:
      radial-gradient(64% 30% at 50% 0%, rgba(125, 211, 192, .13), transparent 66%),
      linear-gradient(180deg, #202a40 0%, #161d2c 46%, #0a0e16 90%, #070a0f 100%);
  }
  body[data-light="tight"] #stage::before,
  body[data-light="tight"] #stage3d::before {
    width: 44%; height: 86px;
    background: radial-gradient(ellipse at center, rgba(125, 211, 192, .16), transparent 76%);
  }

  /* 舞台暗角：把四周压下去，视线收在中间的她身上 */
  #stage::after, #stage3d::after {
    content: "";
    position: absolute; inset: 0; z-index: 3; pointer-events: none;
    background:
      linear-gradient(180deg, transparent 62%, rgba(5, 8, 12, .42) 86%, rgba(5, 8, 12, .78) 100%),
      radial-gradient(ellipse 76% 66% at 50% 46%,
        transparent 42%, rgba(6, 9, 14, .26) 74%, rgba(5, 8, 12, .62) 100%);
    transition: opacity .4s;
  }
  body[data-light="rich"] #stage::after,
  body[data-light="rich"] #stage3d::after { opacity: .72; }
  body[data-light="tight"] #stage::after,
  body[data-light="tight"] #stage3d::after { opacity: 1; }
  /* 地面光斑（在 canvas 之下，从她脚下透出） */
  #stage::before, #stage3d::before {
    content: "";
    position: absolute; left: 50%; bottom: 2%; transform: translateX(-50%);
    width: 54%; height: 92px; z-index: 0; pointer-events: none;
    background: radial-gradient(ellipse at center, rgba(125, 211, 192, .20), rgba(167, 139, 250, .08) 46%, transparent 76%);
    filter: blur(20px);
  }
  #stage canvas, #stage3d canvas { z-index: 1; }
  #loading, #loading3d { z-index: 5; color: var(--txt3); font-size: 13px; }
  .spinner { border-color: var(--line2); border-top-color: var(--accent); }

  /* 舞台左上：她在做什么 */
  #v3live {
    position: absolute; left: 20px; top: 18px; z-index: 8;
    display: flex; align-items: center; gap: 7px;
    font-size: 11px; letter-spacing: .04em;
    color: rgba(231, 236, 246, .62);
    text-shadow: 0 1px 10px rgba(0, 0, 0, .8);
  }
  #v3live s {
    width: 5px; height: 5px; border-radius: 99px; display: block;
    background: var(--accent); box-shadow: 0 0 10px 1px rgba(125, 211, 192, .85);
    animation: v3pulse 2.6s ease-in-out infinite;
  }
  #v3live b { font-weight: 500; color: rgba(238, 243, 252, .92); }
  @keyframes v3pulse { 0%, 100% { opacity: 1 } 50% { opacity: .32 } }

  /* 舞台右上：任务轨道 */
  #v3orbit {
    position: absolute; right: 20px; top: 18px; z-index: 8;
    width: 196px; display: flex; flex-direction: column; gap: 2px;
  }
  #v3orbit .lb {
    font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
    color: rgba(231, 236, 246, .34); padding: 0 8px 6px;
  }
  #v3orbit .tk {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 8px; border-radius: 7px; transition: background .16s;
    font-size: 11.5px; color: rgba(231, 236, 246, .62);
  }
  #v3orbit .tk:hover { background: rgba(255, 255, 255, .05); }
  #v3orbit .tk s { width: 5px; height: 5px; border-radius: 99px; flex: 0 0 auto; background: rgba(231, 236, 246, .3); }
  #v3orbit .tk .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #v3orbit .tk .v { font-size: 10px; color: rgba(231, 236, 246, .32); white-space: nowrap; }
  #v3orbit .tk.run s { background: var(--accent); box-shadow: 0 0 8px 1px rgba(125, 211, 192, .85); animation: v3pulse 1.8s infinite; }
  #v3orbit .tk.run .n { color: rgba(238, 243, 252, .94); }
  #v3orbit .tk.run .v { color: rgba(125, 211, 192, .8); }
  #v3orbit .tk.wait s { background: var(--accent2); }
  #v3orbit .tk.ok { opacity: .5; }

  /* 舞台底部：电影字幕，无框，只靠光 */
  #v3sub {
    position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%);
    width: min(78%, 700px); text-align: center; z-index: 8; pointer-events: none;
    transition: opacity .35s;
    opacity: 0;
  }
  #v3sub.show { opacity: 1; }
  #v3sub .ln {
    display: inline-block;
    font-size: 16px; line-height: 1.7; color: #f4f8ff; letter-spacing: .02em;
    text-shadow: 0 1px 2px #000, 0 2px 6px rgba(0, 0, 0, .95), 0 8px 30px rgba(0, 0, 0, .9);
    text-wrap: balance;
  }
  #v3sub .ln em { font-style: normal; color: #9fe8d8; font-weight: 500; }

  /* ═══════ 右侧面板 ═══════ */
  #panel {
    flex: 0 0 var(--panel-w);
    width: var(--panel-w);
    max-width: var(--panel-w);
    min-height: 0;
    height: 100%;
    display: flex; flex-direction: column;
    border-left: 1px solid var(--line);
    background: var(--bg1);
    position: relative;
  }

  /* ═══════ 顶栏：一行，品牌 + 状态 + 图标组 ═══════ */
  #topbar {
    flex: 0 0 auto;
    flex-direction: row !important;      /* ⛔ 原样式是 column，必须盖掉 */
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 4px;
    height: 54px;
    padding: 0 14px;
    border-bottom: 1px solid var(--line);
    background: transparent;
    position: relative;
    overflow: visible;
  }
  #topbar .row { display: none !important; }

  #v3brand { flex: 0 0 auto; display: flex; align-items: center; gap: 7px; }
  #v3brand .ic {
    width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center;
    background: rgba(125, 211, 192, .13); border: 1px solid rgba(125, 211, 192, .26);
    color: var(--accent); font-size: 11px;
  }
  #v3brand .nm { font-size: 13px; font-weight: 600; letter-spacing: .02em; color: var(--txt); white-space: nowrap; }

  #topbar .iconbtn {
    width: 36px !important; height: 36px !important; flex: 0 0 36px !important;
    border-radius: 10px; border: 1px solid transparent;
    background: transparent; color: var(--txt2);
    font-size: 17px; line-height: 1;
    transition: background .16s, color .16s, border-color .16s;
  }
  #topbar .iconbtn:hover { background: var(--bg3); color: var(--txt); }
  #topbar .iconbtn.on {
    background: rgba(125, 211, 192, .14); color: var(--accent);
    border-color: rgba(125, 211, 192, .30);
  }
  #topbar .iconbtn.lbl {
    width: auto; flex: 0 0 auto; padding: 0 11px;
    font-size: 12px; letter-spacing: .02em;
  }
  #topbar .iconbtn:first-of-type { margin-left: auto; }

  #status {
    flex: 0 0 auto;
    display: flex; align-items: center; gap: 6px;
    font-size: 11px; color: var(--txt3);
    padding: 0 8px 0 2px;
    white-space: nowrap; max-width: 140px;
  }
  #status #dot {
    width: 5px; height: 5px; border-radius: 99px; flex: 0 0 auto;
    background: var(--accent);
    box-shadow: 0 0 10px 1px rgba(125, 211, 192, .8);
    animation: v3pulse 2.6s infinite;
  }
  #status #dot.off { background: var(--danger); box-shadow: none; }
  #status #statusText { color: var(--txt2); overflow: hidden; text-overflow: ellipsis; }

  #v3tray {
    position: absolute; left: 12px; right: 12px; top: calc(100% + 2px);
    z-index: 70;
    display: none; flex-direction: column; gap: 11px;
    padding: 15px 16px;
    border-radius: 14px;
    background: rgba(13, 18, 28, .97);
    border: 1px solid var(--line2);
    box-shadow: 0 28px 64px -28px rgba(0, 0, 0, .95), inset 0 1px 0 rgba(255, 255, 255, .04);
    backdrop-filter: blur(26px) saturate(150%);
  }
  body.v3-set #v3tray { display: flex; animation: v3pop .18s cubic-bezier(.22, 1, .36, 1) both; }
  @keyframes v3pop { from { opacity: 0; transform: translateY(-5px) } to { opacity: 1; transform: none } }
  #v3tray .row { display: flex !important; align-items: center; gap: 11px; }
  #v3tray label { flex: 0 0 62px; font-size: 11.5px; color: var(--txt3); white-space: nowrap; }
  #v3tray select, #v3tray .brainstatic {
    flex: 1; min-width: 0; height: 32px; padding: 0 10px; border-radius: 8px;
    background: var(--bg2); border: 1px solid var(--line);
    color: var(--txt); font-size: 12.5px; font-family: inherit; outline: none;
  }
  #v3tray select:focus { border-color: rgba(125, 211, 192, .5); }
  #v3tray .brainstatic { display: flex; align-items: center; font-size: 11.5px; color: var(--txt2); }
  #brainInfo {
    margin: 0 !important; border: 1px solid var(--line) !important;
    border-radius: 10px !important; background: rgba(255, 255, 255, .022) !important; overflow: hidden;
  }
  #brainInfoHead {
    padding: 9px 12px !important; font-size: 11.5px !important;
    color: var(--txt2) !important; border: 0 !important; background: transparent !important; cursor: pointer;
  }
  #brainInfoBody { padding: 0 12px 12px !important; }
  #brainInfoBody .bi-row { font-size: 11.5px !important; line-height: 1.75 !important; color: var(--txt2) !important; }
  #brainInfoBody .bi-tag {
    background: rgba(125, 211, 192, .13) !important; color: var(--accent) !important;
    font-size: 10px !important; padding: 1px 6px !important; border-radius: 4px !important;
  }
  #brainInfoBody .bi-note { font-size: 11px !important; color: var(--txt3) !important; }
  #brainInfoBody .bi-divider { background: var(--line) !important; }

  /* ═══════ 能力条：给 agent 互动按钮留的位置 ═══════ */
  #v3caps {
    flex: 0 0 auto;
    display: flex; align-items: center; gap: 6px;
    padding: 8px 14px 9px;
    overflow-x: auto;
    border-bottom: 1px solid var(--line);
  }
  #v3caps::-webkit-scrollbar { display: none; }
  #v3caps button {
    display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto;
    height: 30px; padding: 0 12px; border-radius: 99px;
    background: rgba(255, 255, 255, .045);
    border: 1px solid var(--line);
    color: var(--txt2); font-size: 12px; white-space: nowrap;
    transition: background .16s, color .16s, border-color .16s;
  }
  #v3caps button svg {
    width: 13px; height: 13px; fill: none; stroke: currentColor;
    stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
  }
  #v3caps button:hover {
    background: rgba(125, 211, 192, .10);
    border-color: rgba(125, 211, 192, .30);
    color: var(--txt);
  }
  #v3caps button.soon { opacity: .5; }
  #v3caps button.soon:hover { background: rgba(255, 255, 255, .05); border-color: var(--line); color: var(--txt3); }
  #v3caps .sep { width: 1px; height: 16px; background: var(--line); flex: 0 0 auto; margin: 0 2px; }

  /* ═══════ 对话流 ═══════ */
  #messages {
    flex: 1; min-height: 0;
    overflow-y: auto; overflow-x: hidden;
    padding: 18px 18px 10px;
    display: flex; flex-direction: column;
    gap: 20px;
    background: transparent;
    scroll-behavior: smooth;
  }
  #messages::-webkit-scrollbar { width: 0; }

  .msg {
    max-width: 100%;
    padding: 11px 14px !important;
    border: 0 !important;
    border-radius: 14px !important;
    font-size: 14px !important;
    line-height: 1.76 !important;
    color: var(--txt);
    background: rgba(255, 255, 255, .05) !important;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .028) !important;
    animation: v3rise .4s cubic-bezier(.22, 1, .36, 1) both;
  }
  @keyframes v3rise { from { opacity: 0; transform: translateY(7px) } to { opacity: 1; transform: none } }

  .msg.ai {
    align-self: flex-start;
    max-width: 94%;
  }
  .msg.me {
    align-self: flex-end;
    max-width: 88%;
    background: rgba(125, 211, 192, .085) !important;
    box-shadow: none !important;
  }
  .msg .who {
    display: block;
    font-size: 10.5px !important;
    letter-spacing: .1em;
    color: rgba(125, 211, 192, .62) !important;
    margin-bottom: 4px !important;
    font-weight: 500;
  }
  .msg.me .who { color: rgba(231, 236, 246, .28) !important; text-align: right; }
  .msg b, .msg strong { color: #fff; font-weight: 600; }
  .msg code {
    background: rgba(255, 255, 255, .07); padding: 1px 5px;
    border-radius: 4px; font-size: 12.5px; color: #d8e6ff;
  }
  .msg.ai.thinking::after { color: var(--accent); }

  /* 原有的「派给」按钮：这是 agent 互动的落点，只美化不替换 */
  .msgDispatch, .msg-dispatch, .dispatch {
    display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px;
  }
  .msgDispatch button, .msg-dispatch button, .dispatch button {
    height: 27px; padding: 0 12px; border-radius: 99px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid var(--line);
    color: var(--txt2); font-size: 11.5px; white-space: nowrap;
    transition: background .16s, color .16s, border-color .16s;
  }
  .msgDispatch button:hover, .msg-dispatch button:hover, .dispatch button:hover {
    background: rgba(125, 211, 192, .12);
    border-color: rgba(125, 211, 192, .32);
    color: var(--accent);
  }
  /* 消息正文 */
  .msg .body { display: block; line-height: 1.78; }

  /* 行动条（JS 注入：只补一个「复制」，不重复派活） */
  #messages .v3acts { display: contents; }
  #messages .v3acts button {
    height: 27px; padding: 0 12px; border-radius: 99px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid var(--line);
    color: var(--txt2); font-size: 11.5px; white-space: nowrap;
    display: inline-flex; align-items: center; gap: 4px;
    transition: background .16s, color .16s, border-color .16s;
  }
  #messages .v3acts button:hover {
    background: rgba(125, 211, 192, .12);
    border-color: rgba(125, 211, 192, .32); color: var(--accent);
  }

  #toBottom {
    right: 18px !important; bottom: 96px !important;
    width: 32px !important; height: 32px !important;
    border-radius: 99px !important;
    border: 1px solid var(--line2) !important;
    background: rgba(18, 24, 36, .95) !important;
    color: var(--txt2) !important; font-size: 14px !important;
    box-shadow: 0 14px 32px -16px rgba(0, 0, 0, .95) !important;
  }
  #toBottom:hover { color: var(--accent) !important; }

  /* ═══════ 指挥条 ═══════ */
  #composer {
    flex: 0 0 auto;
    border-top: 1px solid var(--line) !important;
    padding: 12px 14px 14px !important;
    display: flex; gap: 7px; align-items: flex-end;
    background: transparent;
  }
  #composer .iconbtn {
    width: 32px; height: 32px; flex: 0 0 32px;
    border-radius: 9px; border: 1px solid transparent;
    background: transparent; color: var(--txt3);
    font-size: 15px;
    transition: background .16s, color .16s;
  }
  #composer .iconbtn:hover { background: var(--bg3); color: var(--txt); }
  #composer .iconbtn.voice {
    width: auto !important; flex: 0 0 auto !important;
    padding: 0 11px !important; gap: 5px; font-size: 13px !important;
  }
  #composer .iconbtn.voice::after { content: "朗读"; font-size: 11.5px; letter-spacing: .02em; }
  #composer .iconbtn.voice.on {
    color: var(--accent2) !important;
    background: rgba(213, 177, 131, .14) !important;
    border-color: rgba(213, 177, 131, .34) !important;
  }
  #composer .iconbtn.voice.on::after { content: "朗读·开"; }
  #composer .iconbtn.mic.on {
    background: rgba(224, 141, 134, .16) !important;
    color: #f0a9a2 !important;
    border: 1px solid rgba(224, 141, 134, .34) !important;
    animation: v3pulse 1.4s ease-in-out infinite;
  }
  #input {
    flex: 1; min-width: 0;
    background: var(--bg2) !important;
    border: 1px solid var(--line) !important;
    border-radius: 11px !important;
    padding: 8px 13px !important;
    font-size: 14px !important;
    line-height: 1.65 !important;
    max-height: 112px;
    color: var(--txt) !important;
    outline: none;
    transition: box-shadow .2s, border-color .2s;
  }
  #input::placeholder { color: var(--txt3); }
  #input:focus {
    border-color: rgba(125, 211, 192, .5) !important;
    box-shadow: 0 0 0 1px rgba(125, 211, 192, .18) !important;
  }
  #composer .iconbtn.send {
    width: 34px; height: 32px; flex: 0 0 34px;
    border-radius: 9px;
    background: var(--accent) !important;
    color: #062018 !important;
    font-size: 15px;
    box-shadow: 0 8px 22px -12px rgba(125, 211, 192, .9);
  }
  #composer .iconbtn.send:hover { filter: brightness(1.08); }
  #composer .iconbtn.send:disabled { opacity: .38; box-shadow: none; }

  /* 沉浸模式（桌面）：保留他的做法，只统一色温 */
  body.immersive #immerseShade {
    display: block !important;
    position: fixed; left: 0; right: 0; top: 30%; bottom: 0; z-index: 2;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(7, 10, 15, 0) 0%, rgba(7, 10, 15, .55) 32%, rgba(7, 10, 15, .92) 100%);
  }
  body.immersive #panel {
    flex: 0 0 640px; width: 640px; max-width: 640px;
    background: transparent !important;
    border-left: none !important;
  }
  body.immersive #messages {
    background: transparent;
    padding-bottom: 0;
  }
  body.immersive .msg {
    background: transparent !important;
    box-shadow: none !important;
    color: #f6f9fc;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .92), 0 0 14px rgba(0, 0, 0, .6);
    padding: 0 2px !important;
    font-size: 14.5px !important;
    line-height: 1.7 !important;
  }
  body.immersive .msg.me { text-align: right; }
  body.immersive #composer {
    background: rgba(10, 14, 22, .72);
    backdrop-filter: blur(22px) saturate(140%);
    border-radius: 14px;
    margin: 0 14px 14px;
    border: 1px solid var(--line) !important;
  }
}

/* 麦克风被浏览器拦下时的说明条（只在 http 非本机地址时出现） */
.mic-secure-hint {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 9999; width: min(560px, 88vw);
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px 16px; border-radius: 14px;
  background: rgba(13, 18, 28, .97);
  border: 1px solid rgba(213, 177, 131, .38);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .95);
  backdrop-filter: blur(20px);
  font-size: 12.5px; line-height: 1.7; color: #b9c8de;
  animation: v3pop .24s cubic-bezier(.22, 1, .36, 1) both;
}
.mic-secure-hint b { color: #e7ebf3; font-weight: 600; }
.mic-secure-hint code {
  background: rgba(255, 255, 255, .07); padding: 1px 5px; border-radius: 4px;
  font-size: 11.5px; color: #d8e6ff;
}
.mic-secure-hint a { color: #7dd3c0; text-decoration: none; border-bottom: 1px solid rgba(125, 211, 192, .4); }
.mic-secure-hint a:hover { border-bottom-color: #7dd3c0; }
