/* 设计变量沿用 shenaai.cc：暗色玻璃态 */
/* 黑白两种、最简单的设计：深色=纯黑底白字，浅色=纯白底黑字；只用灰度，不用彩色；默认跟随系统，可在右上角手动切换 */
:root {
  --bg-dark: #000;
  --bg-light: #0b0b0b;
  --accent-blue: #fff;
  --accent-gold: #fff;
  --accent-purple: #fff;
  --text-primary: #fff;
  --text-secondary: #a3a3a3;
  --glass: #000;
  --border: rgba(255, 255, 255, 0.28);
  --ok: #fff;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --tabbar-h: 62px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg-dark: #fff; --bg-light: #f4f4f4; --accent-blue: #000; --accent-gold: #000; --accent-purple: #000;
    --text-primary: #000; --text-secondary: #525252; --glass: #fff; --border: rgba(0, 0, 0, 0.3); --ok: #000; color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg-dark: #fff; --bg-light: #f4f4f4; --accent-blue: #000; --accent-gold: #000; --accent-purple: #000;
  --text-primary: #000; --text-secondary: #525252; --glass: #fff; --border: rgba(0, 0, 0, 0.3); --ok: #000; color-scheme: light;
}
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: Inter, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  overflow: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent-blue); outline-offset: 2px;
}

.app {
  height: 100dvh; max-width: 760px; margin: 0 auto;
  display: flex; flex-direction: column;
  background:
    radial-gradient(900px 400px at 50% -10%, rgba(56, 189, 248, 0.10), transparent 70%),
    var(--bg-dark);
}

/* 顶栏 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-family: Outfit, Inter, sans-serif; font-weight: 600; font-size: 17px; }
.proto-tag { font-size: 11px; color: var(--accent-gold); border: 1px solid rgba(251, 191, 36, 0.4); padding: 1px 8px; border-radius: 999px; }

/* 舞台与视图 */
.stage { flex: 1; min-height: 0; position: relative; }
.view { position: absolute; inset: 0; display: none; flex-direction: column; overflow-y: auto; }
.view.active { display: flex; animation: fade 0.3s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
#view-chat { overflow: hidden; }

/* 对话 */
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }
.hero { text-align: center; padding: 28px 8px 12px; }
.hero h1 { font-family: Outfit, Inter, sans-serif; font-size: 26px; font-weight: 600; letter-spacing: 0.04em; }
.hero h1 { background: linear-gradient(90deg, var(--text-primary), var(--accent-gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--text-secondary); margin-top: 6px; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.chip {
  padding: 7px 14px; border-radius: 999px; font-size: 13px;
  background: var(--glass); border: 1px solid var(--border); color: var(--text-secondary);
  transition: all 0.3s var(--ease);
}
.chip:hover { color: var(--text-primary); border-color: var(--accent-blue); }

.msgs { display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, #0ea5e9, var(--accent-purple)); color: #020617; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--glass); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.route {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; margin-bottom: 6px;
  color: var(--accent-gold);
}
.route::before { content: "太极调度官 →"; color: var(--text-secondary); }
.msg .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ai-mark { display: block; margin-top: 8px; font-size: 11px; color: var(--text-secondary); }
.typing span { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: var(--text-secondary); animation: blink 1s infinite; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.composer {
  display: flex; gap: 8px; padding: 10px 16px 12px;
  border-top: 1px solid var(--border); background: var(--glass); backdrop-filter: blur(12px);
}
.composer input {
  flex: 1; min-width: 0; padding: 11px 16px; border-radius: 999px;
  background: var(--bg-light); border: 1px solid var(--border);
}
.composer input::placeholder { color: var(--text-secondary); }
.composer select { max-width: 135px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-light); color: var(--text-primary); padding: 7px; }
.workspace-tools { margin-top: 20px; }
.workspace-tools details { margin: 12px 0; padding: 12px; border: 1px solid var(--border); border-radius: 12px; }
.workspace-tools summary { cursor: pointer; font-weight: 600; }
.workspace-tools select, .workspace-tools input { width: 100%; color: var(--text-primary); background: var(--bg-light); border: 1px solid var(--border); padding: 10px; border-radius: 10px; }
.workspace-tools button { margin: 8px 6px 0 0; }
@media (max-width: 480px) { .composer { flex-wrap: wrap; } .composer select { flex-basis: 100%; max-width: 100%; } }
.send {
  width: 44px; height: 44px; border-radius: 50%; font-size: 20px; font-weight: 700;
  background: var(--accent-blue); color: #020617; transition: transform 0.3s var(--ease);
}
.send:active { transform: scale(0.92); }

/* 证据卡片 */
.evi-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.evi { background: var(--bg-light); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; font-size: 13px; }
.evi blockquote { margin: 8px 0; padding-left: 10px; border-left: 2px solid var(--accent-gold); color: var(--text-primary); white-space: pre-wrap; }
.evi .hash { font-family: Consolas, monospace; font-size: 11px; word-break: break-all; }

.answer { white-space: pre-wrap; margin-bottom: 8px; }
.warn { color: var(--accent-gold); font-size: 12px; margin: 4px 0; }

/* 登录与账号 */
.who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.who-btn { max-width: 56vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; padding: 4px 10px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--glass); color: var(--text-primary); }
.who-btn::after { content: " ▾"; color: var(--text-secondary); }
.login-card { max-height: 86vh; overflow-y: auto; }
.login-warn { color: var(--accent-gold); font-size: 13px; margin-bottom: 12px; }
.persona-list { display: flex; flex-direction: column; gap: 8px; }
.persona { text-align: left; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-dark);
  transition: border-color 0.3s var(--ease); }
.persona:hover, .persona.current { border-color: var(--accent-blue); }
.persona b { display: block; font-size: 14px; }
.persona span { color: var(--text-secondary); font-size: 12px; }

.field { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; }
.field input, .code-row input { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border-radius: 10px;
  background: var(--bg-dark); border: 1px solid var(--border); color: var(--text-primary); }
.code-row { display: flex; gap: 8px; align-items: stretch; margin-bottom: 10px; }
.code-row input { margin-top: 0; flex: 1; min-width: 0; }
.code-row .btn { white-space: nowrap; min-width: 104px; }
.agree { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--text-secondary); margin: 6px 0 12px; }
.agree input { margin-top: 3px; }
.agree a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.btn.wide { width: 100%; padding: 11px; }
#devBox { margin-top: 12px; font-size: 13px; }
#devBox summary { cursor: pointer; color: var(--text-secondary); margin-bottom: 8px; }
#inviteTitle { margin: 12px 0 6px; font-size: 14px; }

/* 账号设置 */
.settings-card { width: min(1100px, calc(100vw - 80px)); max-height: 92vh; overflow-y: auto; border-radius: 0; }
.tabs { display: flex; gap: 6px; margin: 12px 0; flex-wrap: wrap; }
.tab-btn { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border); font-size: 13px; color: var(--text-secondary); }
.tab-btn.active { color: var(--accent-gold); border-color: rgba(251, 191, 36, 0.5); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv span { color: var(--text-secondary); }
.device { margin-top: 10px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.row-actions select, .invite-form select, .invite-form input { padding: 7px 10px; border-radius: 10px; background: var(--bg-dark);
  border: 1px solid var(--border); color: var(--text-primary); font-size: 13px; }
.invite-form { display: flex; flex-direction: column; gap: 8px; }
.invite-token { display: block; word-break: break-all; padding: 8px; margin: 8px 0; border-radius: 8px; background: #010409; font-size: 12px; }
.btn.danger { background: #f87171; color: #020617; }
ul.plain { padding-left: 20px; color: var(--text-secondary); font-size: 13px; margin: 8px 0; }
h4 { margin: 14px 0 6px; font-size: 14px; }

/* 通用组件 */
.page { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.page h2 { font-family: Outfit, Inter, sans-serif; font-size: 20px; }
.page .sub { color: var(--text-secondary); font-size: 13px; margin-top: -8px; }
.card {
  background: var(--glass); border: 1px solid var(--border); border-radius: 16px; padding: 14px;
  backdrop-filter: blur(10px);
}
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.btn {
  padding: 8px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--accent-blue); color: #020617; transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
}
.btn:active { transform: scale(0.96); }
.btn.ghost { background: transparent; color: var(--text-primary); border: 1px solid var(--border); }
.btn.gold { background: var(--accent-gold); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.tag { font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-secondary); }
.tag.gold { color: var(--accent-gold); border-color: rgba(251, 191, 36, 0.4); }
.tag.blue { color: var(--accent-blue); border-color: rgba(56, 189, 248, 0.4); }
.tag.experiment { align-self: center; border-style: dashed; margin: 0 auto 0 10px; }
button[data-experimental]::after { content: '实验'; margin-left: 6px; font-size: 11px; padding: 0 6px; border: 1px dashed var(--border); border-radius: 999px; color: var(--text-secondary); }
.answer .layer { font-size: 10px; margin: 0 4px 0 2px; padding: 0 5px; border: 1px solid var(--border); border-radius: 999px; color: var(--text-secondary); vertical-align: 1px; }
.answer .seg-coined .layer { border-style: dashed; color: var(--text-primary); }
#askMode[hidden] { display: none; }
@media(max-width:650px){ #askMode { max-width: 64px; } }
.muted { color: var(--text-secondary); font-size: 13px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* 智能体 */
.agent .name { font-weight: 600; margin-bottom: 4px; }
.agent p { color: var(--text-secondary); font-size: 12px; min-height: 38px; }
.agent .btn { margin-top: 10px; width: 100%; }

/* API */
.bar { height: 8px; border-radius: 999px; background: var(--bg-light); overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple)); border-radius: 999px; transition: width 0.6s var(--ease); }
pre.code {
  background: #010409; border: 1px solid var(--border); border-radius: 12px; padding: 12px;
  font-size: 12px; overflow-x: auto; color: #cbd5e1; font-family: Consolas, "SFMono-Regular", monospace;
}
.key { font-family: Consolas, monospace; font-size: 13px; letter-spacing: 0.02em; }

/* IDE */
.factor { display: grid; grid-template-columns: 76px 1fr 36px; gap: 8px; align-items: center; font-size: 13px; margin-top: 8px; }
.factor .bar { margin-top: 0; }
.asset { cursor: pointer; transition: border-color 0.3s var(--ease); }
.asset.sel { border-color: var(--accent-gold); }
.asset .tier { font-weight: 700; color: var(--accent-gold); }
.result-num { font-family: Outfit, Inter, sans-serif; font-size: 30px; color: var(--accent-gold); }

/* 电子书 */
.shelf { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.book { text-align: left; }
.cover {
  aspect-ratio: 3 / 4; border-radius: 12px; padding: 12px; display: flex; flex-direction: column; justify-content: flex-end;
  border: 1px solid var(--border); font-family: Outfit, "Songti SC", serif; font-weight: 600; font-size: 16px; line-height: 1.3;
}
.book .meta { margin-top: 6px; font-size: 12px; color: var(--text-secondary); }
.reader { line-height: 2; font-family: "Songti SC", "Noto Serif SC", serif; font-size: 17px; }
.reader p { margin-bottom: 12px; text-indent: 2em; }
.reader .ai { font-family: Inter, sans-serif; font-size: 14px; text-indent: 0; }
.back { align-self: flex-start; color: var(--accent-blue); font-size: 14px; }
.lock { color: var(--accent-gold); font-size: 13px; text-align: center; padding: 14px; border: 1px dashed rgba(251, 191, 36, 0.4); border-radius: 12px; }

/* 底部标签 */
.tabbar {
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--glass); backdrop-filter: blur(14px); border-top: 1px solid var(--border);
}
.tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text-secondary); transition: color 0.3s var(--ease); }
.tabbar i { font-style: normal; font-size: 18px; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 10px; transition: all 0.3s var(--ease); }
.tabbar span { font-size: 11px; }
.tabbar button.active { color: var(--accent-gold); }
.tabbar button.active i { background: rgba(251, 191, 36, 0.14); }

.legal { font-size: 10px; text-align: center; color: var(--text-secondary); padding: 4px 12px; padding-bottom: 4px; }

/* 弹窗与提示 */
.modal { position: fixed; inset: 0; background: rgba(2, 6, 23, 0.7); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 24px; z-index: 10; }
.modal[hidden], .toast[hidden] { display: none; }
.modal-card { width: min(380px, 100%); background: var(--bg-light); border: 1px solid var(--border); border-radius: 18px; padding: 20px; }
.modal-card.settings-card { width: min(1100px, calc(100vw - 80px)); max-height: 92vh; overflow-y: auto; border-radius: 0; }
.modal-card h3 { margin-bottom: 8px; font-size: 17px; }
.modal-card p { color: var(--text-secondary); font-size: 14px; }
#modalBody { white-space: pre-line; }
#modal { z-index: 15; }   /* 确认框要压在设置等面板之上（同为 10 时后出现的面板会盖住它，点不到“确认”），仍在提示条之下 */
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--bg-light); border: 1px solid var(--accent-blue); padding: 8px 18px; border-radius: 999px; font-size: 13px; z-index: 20; }

@media (min-width: 761px) {
  .app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

.para.hl { background: rgba(251, 191, 36, 0.18); border-radius: 6px; }
.reader h3 { margin: 4px 0 10px; }
.reader .para { cursor: text; user-select: text; }
[hidden] { display: none !important; }

/* ---------- 黑白覆盖：去掉渐变、毛玻璃、彩色，只保留黑/白/灰 ---------- */
.app { background: var(--bg-dark); }
.proto-tag, .tag.gold, .tag.blue { color: var(--text-primary); border-color: var(--border); }
.hero h1 { background: none; -webkit-background-clip: initial; background-clip: initial; color: var(--text-primary); }
.msg.user { background: var(--text-primary); color: var(--bg-dark); }
.msg.bot, .card, .chip, .tabbar, .composer, .modal-card, .toast { background: var(--bg-dark); backdrop-filter: none; -webkit-backdrop-filter: none; }
.tabbar, .composer { backdrop-filter: none; }
.send, .btn, .btn.gold { background: var(--text-primary); color: var(--bg-dark); }
.btn.ghost { background: transparent; color: var(--text-primary); border: 1px solid var(--text-primary); }
.btn.danger { background: transparent; color: var(--text-primary); border: 2px solid var(--text-primary); font-weight: 700; }
.btn[disabled] { opacity: 0.4; }
.bar { background: var(--border); }
.bar > i { background: var(--text-primary); }
.code, .invite-token, pre.code { background: var(--bg-light); color: var(--text-primary); border: 1px solid var(--border); }
.warn, .login-warn, .lock { color: var(--text-primary); font-weight: 600; border-color: var(--text-primary); }
.evi blockquote { border-left-color: var(--text-primary); }
.tab-btn { border-color: var(--border); color: var(--text-secondary); }
.tab-btn.active { color: var(--bg-dark); background: var(--text-primary); border-color: var(--text-primary); }
.tabbar button { color: var(--text-secondary); }
.tabbar button.active { color: var(--text-primary); font-weight: 700; }
.tabbar button.active i { background: var(--text-primary); color: var(--bg-dark); }
.asset.sel, .persona:hover, .persona.current, .chip:hover { border-color: var(--text-primary); }
.modal { background: rgba(0, 0, 0, 0.55); backdrop-filter: none; }
.toast { border-color: var(--text-primary); }
.para.hl { background: var(--border); }
.back { color: var(--text-primary); text-decoration: underline; }
.result-num, .asset .tier { color: var(--text-primary); }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 2px; }
.theme-btn { font-size: 12px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; color: var(--text-primary); }

/* Minimal chat layout, preserving the existing v3 application and permissions. */
.app {max-width:none; padding-left:86px; background:var(--bg-dark)}
.topbar {border:0; height:64px; padding:16px 28px; flex-shrink:0}
.brand img,.proto-tag {display:none}
.brand {font-family:inherit;font-size:18px}
.tabbar {position:fixed;left:0;top:0;bottom:0;width:86px;height:auto;display:flex;flex-direction:column;justify-content:flex-start;gap:14px;padding:22px 6px;border:0;border-right:1px solid var(--border);background:var(--bg-dark)}
.tabbar button {width:100%;min-height:54px;flex:none;border-radius:8px;color:var(--text-secondary)}
.tabbar button.active {color:var(--text-primary);background:var(--bg-light)}
.stage {width:100%;max-width:1120px;margin:0 auto}
.chat-scroll {padding:24px max(20px,calc((100% - 820px)/2))}
.hero {padding:15vh 0 0}
.hero h1 {background:none;color:var(--text-primary);font-size:30px;letter-spacing:0;font-weight:500}
.hero p {font-size:14px;margin-top:12px}
.suggest {display:none}
.composer {max-width:820px;width:calc(100% - 40px);margin:0 auto 8px;padding:10px;border:1px solid var(--border);border-radius:16px;background:var(--bg-dark);backdrop-filter:none;align-items:center}
.composer input {border:0;border-radius:0;background:transparent;padding:12px 6px}
.composer select {font-size:12px;border:0;background:var(--bg-dark);max-width:110px}
.send,.btn:not(.ghost) {background:var(--text-primary);color:var(--bg-dark)}
.msg.user {background:var(--bg-light);color:var(--text-primary);border:1px solid var(--border)}
.msg.bot {background:var(--bg-dark)}
.agent-shortcuts {display:flex;justify-content:center;flex-wrap:wrap;gap:6px;padding:0 18px 12px;flex-shrink:0}
.agent-shortcuts[hidden] {display:none}
.agent-shortcuts button {font-size:12px;padding:5px 10px;border-radius:6px;color:var(--text-secondary)}
.agent-shortcuts button:hover,.agent-shortcuts button[aria-pressed="true"] {color:var(--text-primary);background:var(--bg-light)}
#loginEntry, #registerEntry {font-size:12px;color:var(--text-secondary)}
.legal {border:0;background:var(--bg-dark);font-size:10px;padding:4px 14px 10px;color:var(--text-secondary)}
.modal {background:rgba(0,0,0,.45)}
.modal-card,.card {background:var(--bg-dark);box-shadow:none}
.proto-tag,.tab-btn.active,.btn.danger {border-color:var(--border);color:var(--text-primary);background:var(--bg-light)}
.invite-token {background:var(--bg-light)}
@media(max-width:650px){.agent-shortcuts{gap:6px;padding:0 12px 8px}.agent-shortcuts button{font-size:12px;padding:5px 8px}}

.tabbar{gap:8px;padding-top:14px;overflow-y:auto}.tabbar button i{font-style:normal;font-size:20px}.tabbar button span{display:block;font-size:11px}.tabbar button{min-height:55px}.tabbar button:hover{background:var(--bg-light);color:var(--text-primary)}

/* Account stays at the bottom of the sidebar on every page. */
.tabbar {padding-bottom:max(14px,env(safe-area-inset-bottom));box-sizing:border-box}
#nav-user {margin-top:auto;flex-shrink:0;border-top:1px solid var(--border);border-radius:0;padding-top:10px;min-height:64px;color:var(--text-primary)}
/* 投诉举报对话框 */
#reportPane .modal-card { width: min(460px, 100%); }
#reportPane label:not(.agree) { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--text-secondary); }
#reportPane select, #reportPane textarea { display: block; width: 100%; box-sizing: border-box; margin-top: 4px; font: inherit; padding: 8px; border-radius: 10px; border: 1px solid var(--border); background: transparent; color: inherit; }
#reportPane textarea { margin-top: 10px; resize: vertical; }
footer.legal a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
footer.legal .gongan-badge { height: 12px; width: auto; vertical-align: -2px; margin-right: 2px; }

/* 多端使用页：步骤列表编号留在卡片内 */
#view-sidebar ol { padding-left: 1.6em; margin: 8px 0; }
#view-sidebar ol li { margin: 4px 0; }

/* 手机窄屏页头：已登录时不再显示"登录/注册"入口；标签不换行、超长省略 */
#loginEntry, #registerEntry { white-space: nowrap; }
.who:has(#whoBtn:not([hidden])) #loginEntry,
.who:has(#whoBtn:not([hidden])) #registerEntry { display: none; }
@media (max-width: 480px) { .who { gap: 4px; min-width: 0; } .who .who-btn { max-width: 30vw; padding: 4px 8px; min-width: 0; } .who #bellBtn, .who #themeBtn { flex-shrink: 0; max-width: none; } }
/* 窄屏：顶栏按钮不再挤成单字或压住品牌名，改为横向滑动 */
@media (max-width: 480px) { .topbar { gap: 8px; } .brand { flex-shrink: 0; } .who { flex: 1 1 auto; overflow-x: auto; scrollbar-width: none; justify-content: flex-start; } .who::-webkit-scrollbar { display: none; } .who > * { flex-shrink: 0; } .who .who-btn { max-width: 44vw; } }
/* 多模态附件：回形针按钮与已选文件 */
.composer .attach { border: 1px solid var(--border); background: var(--bg-light); color: var(--text-primary); border-radius: 12px; padding: 6px 10px; cursor: pointer; flex: 0 0 auto; }
.composer .attach.live { background: #c0392b; color: #fff; border-color: #c0392b; }
@media (max-width: 480px) { .composer { flex-wrap: wrap; row-gap: 6px; } .composer input { order: -1; flex: 1 1 100%; min-width: 0; } .composer .send { margin-left: auto; } }   /* 手机：输入框独占一行，模块/附件/语音/发送在下一行 */
.voice-seg { margin: 6px 0; line-height: 1.7; overflow-wrap: anywhere; }
.voice-seg select { margin-left: 6px; max-width: 8em; }
.tag.speaker-0 { color: #2e86de; } .tag.speaker-1 { color: #e67e22; } .tag.speaker-2 { color: #27ae60; } .tag.speaker-3 { color: #8e44ad; }
.tag.speaker-4 { color: #c0392b; } .tag.speaker-5 { color: #16a085; } .tag.speaker-6 { color: #b7950b; } .tag.speaker-7 { color: #7f8c8d; }
.attach-list { max-width: 820px; width: calc(100% - 40px); margin: 0 auto 6px; display: flex; flex-wrap: wrap; gap: 6px; }

/* 2026-10-12 手机巡检：两列网格被长文字撑出屏幕（工具、角色设置、工具中心），一行里的下拉框不换行（验收页） */
.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid > * { min-width: 0; overflow-wrap: anywhere; }
.grid textarea, .grid input, .grid select { max-width: 100%; }
@media (max-width: 480px) { .row { flex-wrap: wrap; } .row > * { min-width: 0; max-width: 100%; } .row select { max-width: 100%; } }

/* 专著研读的输出是整页正文，不收进对话气泡或小卡片 */
.stage:has(.study-page) { max-width: none; }
#chatScroll.study-open { padding: 28px 48px 48px; }
.study-page { width: 100%; max-width: none; margin: 12px 0 36px; padding: 0; background: transparent; border: 0; border-radius: 0; }
.study-kicker { margin: 0 0 8px; font-size: 13px; letter-spacing: 0.08em; color: var(--text-secondary); }
.study-page h2 { margin: 0 0 20px; font-size: 28px; font-weight: 500; line-height: 1.4; }
.study-page .answer { font-size: 17px; line-height: 1.9; margin: 0 0 20px; }
.study-page .evi { background: transparent; border: 0; border-radius: 0; border-top: 1px solid var(--border); padding: 18px 0; font-size: 16px; }
.study-page .study-role { margin-top: 28px; }
.study-page .study-role h3 { margin: 0 0 10px; font-size: 20px; font-weight: 500; }
@media (max-width: 650px) { #chatScroll.study-open { padding: 16px; } .study-page h2 { font-size: 22px; } }

/* 专著正式阅读（monographs-ui.js） */
.mono-list { display: grid; gap: 8px; margin: 12px 0; }
.mono-book { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-light); }
.mono-bar { flex-wrap: wrap; gap: 6px; align-items: center; }
.mono-reader { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; margin-top: 10px; }
.mono-toc { position: sticky; top: 8px; align-self: start; max-height: 80vh; overflow-y: auto; border-right: 1px solid var(--border); padding-right: 8px; }
.mono-toc-item { display: block; width: 100%; text-align: left; padding: 5px 6px; font-size: 13px; color: var(--text-secondary); border-radius: 6px; }
.mono-toc-item.lvl-2 { padding-left: 1.2em; }
.mono-toc-item.lvl-3 { padding-left: 2.4em; }
.mono-toc-item.lvl-4 { padding-left: 3.6em; }
.mono-toc-item.current { color: var(--accent-gold); font-weight: 600; }
.mono-toc-item.locked { opacity: 0.65; }
.mono-toc-toggle { display: none; }
.mono-body { min-width: 0; line-height: 1.9; overflow-wrap: anywhere; }
.mono-body.font-s { font-size: 15px; }
.mono-body.font-m { font-size: 17px; }
.mono-body.font-l { font-size: 20px; }
.mono-body p { text-indent: 2em; margin: 0.6em 0; }
.mono-body .mono-note { text-indent: 0; font-size: 0.85em; color: var(--text-secondary); }
.mono-body .mono-title { margin: 12px 0; }
.mono-body .mono-h { margin: 1.2em 0 0.6em; }
.mono-body figure { margin: 1em 0; text-align: center; }
.mono-body img { max-width: 100%; height: auto; }
.app:has(.mono-open),
.app:has(.reader-open) { max-width: none; }
.stage:has(.mono-open),
.stage:has(.reader-open) { max-width: none; }
.mono-open { padding: 28px 48px 48px; }
.mono-open .mono-body,
.reader-open .reader {
  width: 100%; max-width: none; margin: 0; padding: 8px 0 32px;
  background: transparent; border: 0; border-radius: 0; box-shadow: none;
}
.reader-open .reader { font-size: 18px; }
@media (max-width: 720px) {
  .mono-open { padding: 16px; }
}
.app:has(.tool-open),
.stage:has(.tool-open) { max-width: none; }
.tool-open { padding: 28px 48px 48px; }
.tool-result { width: 100%; max-width: none; margin: 0; background: transparent; border: 0; border-radius: 0; }
.tool-result h2 { margin: 0 0 16px; font-size: 28px; font-weight: 500; line-height: 1.4; }
.tool-result .answer, .tool-block p { font-size: 17px; line-height: 1.9; }
.tool-block { background: transparent; border: 0; border-radius: 0; border-top: 1px solid var(--border); padding: 18px 0; }
.tool-block h3 { margin: 0 0 8px; font-size: 20px; font-weight: 500; }
@media (max-width: 720px) { .tool-open { padding: 16px; } }
.app:has(.directory-open),
.stage:has(.directory-open) { max-width: none; }
.directory-open { padding: 28px 48px 48px; }
.directory-list { display: flex; flex-direction: column; width: 100%; }
.directory-item {
  width: 100%; text-align: left; background: transparent; border: 0; border-radius: 0;
  border-bottom: 1px solid var(--border); padding: 14px 0; font-size: 17px; font-weight: 500;
}
.directory-open pre.code {
  width: 100%; max-width: none; margin: 8px 0 0; padding: 0 0 8px;
  background: transparent; border: 0; border-radius: 0; font-size: 15px; color: var(--text-primary);
}
@media (max-width: 720px) { .directory-open { padding: 16px; } }
.mono-table { overflow-x: auto; margin: 1em 0; }
.mono-table table { border-collapse: collapse; font-size: 0.9em; }
.mono-table td { border: 1px solid var(--border); padding: 4px 8px; text-indent: 0; vertical-align: top; }
.mono-nav { justify-content: space-between; margin: 10px 0; }
.mono-notes textarea { width: 100%; box-sizing: border-box; margin: 8px 0; }
@media (max-width: 720px) {
  .mono-reader { grid-template-columns: minmax(0, 1fr); }
  .mono-toc { display: none; position: static; max-height: 50vh; border-right: 0; border-bottom: 1px solid var(--border); padding: 0 0 8px; }
  .mono-reader.toc-open .mono-toc { display: block; }
  .mono-toc-toggle { display: inline-block; }
}

/* 平台服务未配置时收起依赖它的页内区块（feature-gate-ui.js 按 health.features 给 body 加 no-* 类） */
body.no-browser [data-feature~="browser"], body.no-code_runner [data-feature~="code_runner"],
body.no-asset_engine [data-feature~="asset_engine"], body.no-semantic [data-feature~="semantic"] { display: none !important; }

/* 首页分享条：图标按钮，文字留给读屏和悬停提示 */
.share-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 8px 10px; padding: 0 14px 8px; flex-shrink: 0;
}
.share-bar-title { font-size: 12px; letter-spacing: 0.08em; color: var(--text-secondary); }
.share-btn {
  position: relative; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 999px; color: var(--text-primary); text-decoration: none;
}
.share-btn svg { width: 15px; height: 15px; display: block; }
.share-btn:hover { background: var(--bg-light); }
.share-label {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.share-card { width: min(420px, 100%); }
.brand-mark, .share-mark { aspect-ratio: 1; object-fit: contain; }
.brand-mark { width: 72px; height: 72px; display: inline-block; }
.share-card .brand-mark { display: block; margin: 8px auto 0; }
.share-bar .share-mark { width: 28px; height: 28px; display: block; }
.share-qr { display: flex; justify-content: center; margin: 12px 0; }
.share-qr svg { display: block; background: #fff; border-radius: 8px; }
.share-url { margin: 8px 0 14px; font-size: 13px; color: var(--text-secondary); word-break: break-all; text-align: center; }
.wx-card { margin: 12px 0 4px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-light); text-align: left; }
.wx-card-title { margin: 0 0 8px; font-size: 15px; font-weight: 600; line-height: 1.4; color: var(--text-primary); }
.wx-card-body { display: flex; gap: 10px; align-items: flex-start; }
.wx-card-desc { flex: 1; margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-secondary); }
.wx-card-body img { width: 56px; height: 56px; object-fit: cover; border-radius: 4px; flex: 0 0 56px; }
.wx-card-source { display: block; margin: 8px 0 0; font-size: 12px; color: #1a5fb4; text-decoration: underline; }
@media (max-width: 650px) {
  .share-bar { gap: 6px 8px; padding: 0 8px 6px; }
  .share-btn { width: 28px; height: 28px; }
}

/* 会话和填写页铺满内容区。确认框和分享二维码仍保持原尺寸。 */
.stage { max-width: none; }
#chatScroll { padding: 28px 48px 48px; }
.composer, .attach-list {
  max-width: none; width: auto; margin: 0 48px 12px; border-radius: 0;
}
.msg {
  max-width: none; width: 100%; align-self: stretch; border-radius: 0;
  background: transparent; border: 0; border-bottom: 1px solid var(--border);
}
.directory-open .grid, .directory-open .shelf { grid-template-columns: minmax(0, 1fr); }
.directory-open .card, #settingsPane .card {
  width: 100%; max-width: none; margin: 0; background: transparent; border: 0; border-radius: 0;
  border-bottom: 1px solid var(--border); box-shadow: none; backdrop-filter: none; padding: 14px 0;
}
.directory-open .card input:not([type="checkbox"]):not([type="radio"]),
.directory-open .card textarea, .directory-open .card select,
.directory-open .invite-form input, .directory-open .invite-form textarea, .directory-open .invite-form select,
.model-form .field input, .model-form .field select,
#settingsPane .field input, #settingsPane .invite-form input, #settingsPane .invite-form select,
#settingsPane textarea, #settingsPane .field select {
  display: block; width: 100%; max-width: 100%; box-sizing: border-box;
}
.model-form .field { margin-bottom: 14px; }
img, svg, video, pre, table { max-width: 100%; }
pre { overflow-x: auto; }
#loginPane, #whoPane, #settingsPane, #stepPane, #reportPane, .form-sheet-modal {
  display: block; left: 86px; padding: 0; background: var(--bg-dark); overflow: auto;
}
#loginPane .modal-card, #whoPane .modal-card, #settingsPane .modal-card,
#stepPane .modal-card, #reportPane .modal-card, .form-sheet {
  width: 100%; max-width: none; min-height: 100%; max-height: none; height: auto;
  border: 0; border-radius: 0; padding: 28px 48px 48px; box-shadow: none;
}
@media (max-width: 1100px) {
  .app { padding-left: 72px; }
  .tabbar { width: 72px; }
  .directory-open, .tool-open, .mono-open, #chatScroll { padding: 24px 28px 40px; }
  .composer, .attach-list { margin: 0 28px 12px; }
  #loginPane, #whoPane, #settingsPane, #stepPane, #reportPane, .form-sheet-modal { left: 72px; }
}
#entryPrograms, #entryPrograms .card, #view-sidebar .page { text-align: left; }
#entryPrograms .btn, #view-sidebar .btn { display: inline-flex; max-width: 100%; white-space: normal; justify-content: center; }
.wx-card-desc { min-width: 0; overflow-wrap: anywhere; }
.composer { flex-shrink: 0; }
@media (max-width: 720px) {
  .modal { overflow: auto; align-items: start; padding: 12px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .shelf { grid-template-columns: minmax(0, 1fr); }
  .kv, .code-row, .row { flex-wrap: wrap; }
  .kv > *, .code-row > * { min-width: 0; max-width: 100%; }
  .app { padding-left: 0; padding-bottom: calc(124px + env(safe-area-inset-bottom)); }
  .tabbar {
    top: auto; bottom: 0; left: 0; right: 0; width: 100%; height: auto; z-index: 12;
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: stretch; justify-content: stretch;
    overflow: hidden; gap: 2px; padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--border);
  }
  .tabbar button { width: 100%; min-width: 0; min-height: 48px; flex: none; }
  .tabbar span { font-size: 11px; line-height: 1.15; white-space: normal; }
  #nav-user { margin: 0; border-top: 0; padding-top: 0; min-height: 48px; max-width: none; }
  .topbar { height: auto; min-height: 56px; padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
  .hero { padding: 4px 0 0; }
  .hero .brand-mark { width: 48px; height: 48px; }
  .hero h1 { font-size: 22px; line-height: 1.3; }
  .hero p { margin-top: 6px; }
  .directory-open, .tool-open, .mono-open, #chatScroll, #chatScroll.study-open { padding: 16px 16px 24px; }
  .composer, .attach-list { width: auto; max-width: none; margin: 0 12px 8px; flex-wrap: wrap; }
  .composer input { flex: 1 1 100%; min-width: 0; }
  .composer select { max-width: none; flex: 1 1 42%; }
  .agent-shortcuts { justify-content: flex-start; padding: 0 12px 8px; }
  .share-bar { justify-content: flex-start; padding: 0 12px 8px; }
  #loginPane, #whoPane, #settingsPane, #stepPane, #reportPane, .form-sheet-modal { left: 0; bottom: calc(124px + env(safe-area-inset-bottom)); }
  #loginPane .modal-card, #whoPane .modal-card, #settingsPane .modal-card,
  #stepPane .modal-card, #reportPane .modal-card, .form-sheet { padding: 16px; }
  input, select, textarea { font-size: 16px; }
}
#nav-user.user-card {
  align-items: stretch; justify-content: flex-start; text-align: left;
  min-height: 0; padding: 8px 6px; gap: 2px; line-height: 1.35;
}
#nav-user.user-card b, #nav-user.user-card span {
  display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 10px; font-weight: 400; font-style: normal;
}
#nav-user.user-card b { font-size: 12px; font-weight: 650; color: var(--text-primary); }
@media (max-width: 720px) {
  #nav-user.user-card { max-width: none; min-height: 48px; justify-content: center; padding: 4px; }
  #nav-user.user-card span { display: block; white-space: normal; }
}

/* 窄屏：整页可滚动。对话区保持足够高度，底栏两行都露出来，顶栏和页脚不再被裁切。 */
@media (max-width: 720px) {
  :root { --tabbar-h: 112px; }
  html, body { height: auto; min-height: 100%; overflow-x: hidden; overflow-y: auto; }
  .app {
    height: auto; min-height: 100dvh; width: 100%; max-width: 100%;
    overflow-x: hidden; padding-left: 0;
    padding-bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom));
  }
  .app > * { min-width: 0; max-width: 100%; }
  .topbar { width: 100%; max-width: 100%; flex-wrap: nowrap; overflow: hidden; }
  .brand { flex: 0 0 auto; }
  .who { flex: 1 1 auto; min-width: 0; overflow-x: auto; justify-content: flex-end; }
  .stage { flex: none; width: 100%; min-height: calc(100dvh - 56px - var(--tabbar-h)); }
  .view { position: absolute; }
  .view.active { min-height: 100%; }
  #view-chat { overflow: hidden; }
  .chat-scroll { overflow-y: auto; }
  .hero, .hero p, .muted, footer.legal, .agent-shortcuts, .share-bar { max-width: 100%; overflow-wrap: anywhere; }
  footer.legal { padding: 8px 12px 16px; }
  .tabbar {
    top: auto; height: auto; max-height: none; overflow: visible;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: minmax(52px, auto);
  }
  .tabbar span { white-space: nowrap; }
}
