* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow-x: hidden; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; }
/* Clean rewrite: plain CSS gradients by local hour, no WebGL, no copied sky code. */
#sky { position: fixed; inset: 0; z-index: 0; transition: background 2s; background: linear-gradient(180deg, #1d2b3a, #31435e); }
/* 白天：按用户 Rakazo 截图实测取色（顶部 #203d83 → 底部 #ccdce9），纯 CSS 渐变 + 三团柔云，无 WebGL、无复用代码 */
body.light #sky { background:
  radial-gradient(ellipse 50% 20% at 72% 75%, rgba(255,255,255,.45), rgba(255,255,255,0) 70%),
  radial-gradient(ellipse 42% 16% at 22% 58%, rgba(255,255,255,.38), rgba(255,255,255,0) 70%),
  radial-gradient(ellipse 38% 14% at 88% 42%, rgba(255,255,255,.32), rgba(255,255,255,0) 70%),
  linear-gradient(180deg, #203d83 0%, #446aa6 28%, #6992c9 50%, #98b7d5 68%, #b8ccde 84%, #ccdce9 100%); }
/* 天空顶部是深蓝，直接贴在天空上的深色字改白（卡片里的字仍是深色，卡片还是白的） */
body.light .brand, body.light #chatTitle, body.light .meta, body.light .progress, body.light .processing { color: #fff; }
body.dusk #sky { background: linear-gradient(180deg, #3a3f66 0%, #c97b5a 60%, #f2b879 100%); }
body.dark #sky { background: linear-gradient(180deg, #101623 0%, #1d2b3a 60%, #31435e 100%); }
#app { position: relative; z-index: 1; display: flex; height: 100vh; height: 100dvh; overflow: hidden; color: #f2f2f2; }
/* 白天也跟 Rakazo 一样：深色玻璃卡片 + 白字（2026-11-18 用户定） */
body.light #app { color: #f2f2f2; }
#sidebar { width: 420px; flex-shrink: 0; padding: 16px; overflow-y: auto; background: transparent; }
.brand { font-size: 22px; font-weight: 700; padding: 8px 4px 16px; text-shadow: 0 1px 8px rgba(0,0,0,.3); }
.new-bot { display: flex; gap: 8px; margin-bottom: 12px; }
.new-bot input { flex: 1; min-width: 0; }
input, button { font: inherit; border-radius: 12px; border: 1px solid rgba(255,255,255,.25); padding: 10px 12px; background: rgba(255,255,255,.12); color: inherit; }
body.light input, body.light button { background: rgba(29,29,31,.55); border-color: rgba(255,255,255,.25); color: #f2f2f2; }
body.dusk input { background: rgba(29,29,31,.55); }
button { cursor: pointer; background: rgba(29,29,31,.7); color: #fff; border: none; }
.bot-card { border-radius: 24px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.16); backdrop-filter: blur(50px); -webkit-backdrop-filter: blur(50px); padding: 16px; margin-bottom: 12px; cursor: pointer; box-shadow: 0 4px 24px rgba(0,0,0,.18); }
body.light .bot-card { background: rgba(29,29,31,.55); border-color: rgba(255,255,255,.16); }
body.dusk .bot-card { background: rgba(29,29,31,.55); border-color: rgba(255,255,255,.16); }
.bot-card.active { outline: 2px solid rgba(255,255,255,.6); }
.bot-card h3 { margin: 0 0 4px; font-size: 16px; }
.bot-card p { margin: 0; font-size: 13px; opacity: .9; }
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#chatHeader { display: flex; align-items: center; gap: 12px; padding: 14px 20px; font-weight: 600; min-width: 0; }
#chatTitle { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#menuBtn { display: none; }
#stopBtn { margin-left: auto; background: #c0392b; }
#messages { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 0 24px; }
.msg { display: flex; margin: 10px auto; width: min(640px, calc(100vw - 32px)); }
.msg.user { justify-content: flex-end; }
.bubble { max-width: 512px; min-width: 0; overflow-wrap: anywhere; padding: 12px 16px; border-radius: 18px; font-size: 15px; line-height: 1.5; background: rgba(29,29,31,.618); backdrop-filter: blur(50px); }
body.light .bubble { background: rgba(29,29,31,.618); }
.msg.user .bubble { background: #31435e; color: #fff; }
.ask-card { width: 512px; max-width: 100%; border-radius: 18px; background: rgba(29,29,31,.618); backdrop-filter: blur(50px); padding: 16px; }
body.light .ask-card { background: rgba(29,29,31,.618); }
.ask-card .q { font-size: 15px; line-height: 1.5; margin-bottom: 10px; }
.opt-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px 8px; background: transparent; border-radius: 12px; color: inherit; }
.opt-row:hover { background: rgba(255,255,255,.12); }
.opt-row:disabled { cursor: default; }
.opt-row.dim { opacity: .45; }
.letter { width: 28px; height: 28px; flex-shrink: 0; display: grid; place-items: center; border-radius: 8px; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.12); font-size: 13px; }
.meta { text-align: center; opacity: .7; font-size: 13px; margin: 12px auto; width: min(640px, calc(100vw - 32px)); }
.progress { margin: 10px auto; width: min(640px, calc(100vw - 32px)); opacity: .75; font-size: 14px; }
#composer { display: flex; gap: 8px; width: min(640px, calc(100vw - 32px)); margin: 0 auto 20px; }
#composer input { flex: 1; min-width: 0; height: 48px; border-radius: 24px; padding: 0 18px; }
#composer button { width: 48px; height: 48px; border-radius: 24px; }
/* 侧栏遮罩：手机上点右侧空白关侧栏（只在抽屉模式下出现） */
#sideBackdrop { position: fixed; inset: 0; z-index: 9; background: rgba(0,0,0,.35); display: none; }
#sideBackdrop[hidden] { display: none; }
@media (max-width: 900px) {
  #sideBackdrop:not([hidden]) { display: block; }
  #sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 10; width: min(420px, 85vw); transform: translateX(-105%); transition: transform .25s; background: rgba(43,48,62,.94); backdrop-filter: blur(50px); }
  #sidebar.open { transform: none; }
  #menuBtn { display: block; }
}
#settingsBtn { margin-top: 12px; width: 100%; }
#settingsModal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(0,0,0,.5); }
#settingsModal[hidden] { display: none; }
.modal-card { width: 420px; max-width: calc(100vw - 32px); border-radius: 24px; background: rgba(29,29,31,.95); backdrop-filter: blur(50px); padding: 20px; color: #f2f2f2; }
.modal-card h3 { margin: 0 0 12px; }
.modal-card label { display: block; font-size: 13px; margin-bottom: 10px; opacity: .9; }
.modal-card input { width: 100%; margin-top: 4px; }
.modal-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
#cfgStatus { font-size: 13px; min-height: 18px; opacity: .85; }
#composerStop { background: #c0392b; }
.processing { display: flex; align-items: center; gap: 10px; margin: 10px auto; width: min(640px, calc(100vw - 32px)); }
.processing .avatar { width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; background: #d43d3d; color: #fff; display: grid; place-items: center; font-size: 15px; font-weight: 700; }
.processing .ptext { font-size: 15px; opacity: .85; }
@media (max-width: 620px) {
  .bubble, .ask-card { max-width: 340px; }
  .msg { width: calc(100vw - 32px); }
}
#attachBtn { width: 48px; height: 48px; border-radius: 24px; font-size: 20px; }
#chips { display: flex; flex-wrap: wrap; gap: 8px; width: min(640px, calc(100vw - 32px)); margin: 0 auto 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 8px 4px 4px; border-radius: 12px; background: rgba(29,29,31,.618); backdrop-filter: blur(50px); font-size: 13px; }
.chip img { width: 36px; height: 36px; object-fit: cover; border-radius: 8px; }
.chip button { padding: 2px 6px; border-radius: 8px; }
.img-thumb { max-width: 100%; max-height: 320px; border-radius: 12px; display: block; }
.att-name { font-size: 12px; opacity: .75; margin-top: 4px; }
.file-card { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.file-ico { font-size: 24px; }
.file-card small { opacity: .75; }
.steps { width: 512px; max-width: 100%; border-radius: 12px; background: rgba(29,29,31,.4); padding: 8px 12px; font-size: 13px; opacity: .85; }
.steps summary { cursor: pointer; }
.bubble code { background: rgba(0,0,0,.25); padding: 1px 5px; border-radius: 6px; font-size: 13px; }
.bubble pre { background: rgba(0,0,0,.3); padding: 10px; border-radius: 10px; overflow-x: auto; }
.bubble pre code { background: none; padding: 0; }
.bubble a { color: #8ecbff; }
.bubble li { margin: 2px 0 2px 16px; }
.streaming .caret { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* --- Rakazo parity additions (appended; existing class names untouched) --- */
.msg { position: relative; }
.msg-body { display: flex; flex-direction: column; align-items: flex-start; max-width: 100%; min-width: 0; }
.msg.user .msg-body { align-items: flex-end; }
.quote-line { font-size: 12px; opacity: .75; margin: 0 4px 4px; max-width: 512px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-actions { position: absolute; top: -16px; right: 6px; display: flex; gap: 2px; padding: 2px; border-radius: 12px; background: rgba(29,29,31,.92); box-shadow: 0 2px 12px rgba(0,0,0,.3); opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 5; }
.msg:hover .msg-actions { opacity: 1; pointer-events: auto; }
.ma-btn { padding: 4px 7px; border-radius: 8px; background: transparent; font-size: 14px; }
.ma-btn:hover { background: rgba(255,255,255,.15); }
.react-picker, .msg-menu { position: absolute; top: 34px; right: 0; display: flex; gap: 2px; padding: 4px; border-radius: 12px; background: rgba(29,29,31,.95); box-shadow: 0 2px 12px rgba(0,0,0,.35); z-index: 6; }
/* hidden 会被上面那条 display: flex 盖掉（作者样式优先于 UA 样式），不加这条两个弹窗永远同时出现、重在同一个位置 */
.react-picker[hidden], .msg-menu[hidden] { display: none; }
.react-picker button { background: transparent; padding: 4px 6px; font-size: 17px; }
.react-picker button:hover { background: rgba(255,255,255,.15); }
.msg-menu { flex-direction: column; min-width: 110px; }
.msg-menu button { background: transparent; text-align: left; padding: 7px 10px; font-size: 13px; color: #fff; }
.msg-menu button:hover { background: rgba(255,255,255,.12); }
.reactions { display: flex; gap: 6px; margin-top: 6px; }
.reaction-chip { padding: 2px 8px; border-radius: 12px; font-size: 13px; background: rgba(29,29,31,.5); }

/* 侧栏分页 + 删除按钮 */
.bot-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 2px 0 12px; font-size: 13px; opacity: .9; }
.bot-pager[hidden] { display: none; }
.bot-pager button { padding: 6px 10px; font-size: 13px; }
.bot-pager button:disabled { opacity: .4; cursor: default; }
.danger-btn { background: #c0392b !important; color: #fff; }

/* 侧栏：新建 +、bot 卡片头像/未读/齿轮 */
.side-top { display: flex; align-items: center; justify-content: space-between; }
.side-top .brand { padding-bottom: 16px; }
#newBotBtn { width: 36px; height: 36px; border-radius: 50%; font-size: 20px; padding: 0; flex-shrink: 0; }
.bot-card { display: flex; align-items: center; gap: 10px; position: relative; }
.bot-ava { width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; font-size: 20px; background: #555; }
.bot-ava.big { width: 96px; height: 96px; font-size: 48px; margin: 0 auto 12px; }
.bot-info { flex: 1; min-width: 0; }
.unread-dot { width: 10px; height: 10px; border-radius: 50%; background: #e33; flex-shrink: 0; }
.bot-gear { background: transparent; padding: 4px 6px; font-size: 15px; flex-shrink: 0; }
#mcpBtn { margin-top: 8px; width: 100%; }
#clearBtn { background: rgba(29,29,31,.7); }

/* 输入区外壳：模型小字、引用条、技能菜单 */
#composerWrap { width: min(640px, calc(100vw - 32px)); margin: 0 auto 20px; position: relative; }
.composer-top { display: flex; justify-content: flex-end; margin-bottom: 4px; }
#modelLabel { background: transparent; font-size: 12px; opacity: .7; padding: 2px 8px; }
#composer { width: 100%; margin: 0; }
#chips { width: 100%; margin: 0 0 8px; }
#composerWrap.dragging #composer { outline: 2px dashed rgba(255,255,255,.6); }
#quoteBar { display: flex; align-items: center; gap: 8px; font-size: 13px; opacity: .85; padding: 6px 10px; border-radius: 10px; background: rgba(29,29,31,.5); margin-bottom: 8px; }
#quoteBar[hidden] { display: none; }
#quoteText { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#quoteCancel { padding: 2px 8px; }
#skillMenu { position: absolute; bottom: 60px; left: 48px; right: 60px; max-height: 240px; overflow-y: auto; border-radius: 12px; background: rgba(29,29,31,.96); box-shadow: 0 4px 24px rgba(0,0,0,.4); z-index: 8; }
#skillMenu[hidden] { display: none; }
#skillMenu button { display: block; width: 100%; text-align: left; background: transparent; padding: 9px 12px; font-size: 14px; border-radius: 0; }
#skillMenu button:hover { background: rgba(255,255,255,.12); }
#skillMenu small { opacity: .7; margin-left: 6px; }

/* 新弹窗（复用 .modal-card） */
#createBotModal, #botSettingsModal, #mcpModal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(0,0,0,.5); }
#createBotModal[hidden], #botSettingsModal[hidden], #mcpModal[hidden] { display: none; }
.modal-card.wide { width: 520px; }
.modal-card { max-height: 90vh; overflow-y: auto; }
.modal-card textarea, .modal-card select { width: 100%; margin-top: 4px; border-radius: 12px; border: 1px solid rgba(255,255,255,.25); padding: 10px 12px; background: rgba(255,255,255,.12); color: inherit; font: inherit; }
.modal-card h4 { margin: 14px 0 8px; font-size: 14px; }
.modal-card small.hint, .hint { font-size: 12px; opacity: .75; display: block; margin: 2px 0 10px; }
.color-row, .avatar-row { display: flex; gap: 8px; margin: 4px 0 12px; }
.color-swatch { width: 32px; height: 32px; border-radius: 50%; padding: 0; border: 2px solid transparent; }
.color-swatch.sel { border-color: #fff; outline: 2px solid rgba(255,255,255,.6); }
.avatar-opt { font-size: 22px; padding: 6px 10px; background: transparent; }
.avatar-opt.sel { background: rgba(255,255,255,.2); outline: 2px solid rgba(255,255,255,.6); }
.picker-label { font-size: 13px; opacity: .85; }
.create-preview { text-align: center; }
.modal-error { font-size: 13px; min-height: 18px; color: #ffb3b3; }
.modal-status { font-size: 13px; min-height: 18px; opacity: .85; }

/* ask 卡扩展 */
.ask-detail { font-size: 13px; opacity: .8; margin-bottom: 10px; white-space: pre-wrap; }
.ask-text, .ask-secret { display: flex; gap: 8px; }
.ask-text input, .ask-secret input { flex: 1; min-width: 0; }
.ask-text button, .ask-secret button { white-space: nowrap; }

/* steps 卡升级 */
.step-row { display: flex; gap: 8px; align-items: baseline; padding: 2px 0; }
.step-ico { width: 16px; flex-shrink: 0; text-align: center; }
.step-ico.run { color: #f5c542; animation: blink 1s steps(1) infinite; }
.step-ico.done { color: #4caf50; }
.step-ico.fail { color: #e53935; }
.step-note { opacity: .8; padding: 2px 0 4px; }
.step-note-inline { opacity: .7; font-size: 12px; }
.step-more { opacity: .7; padding: 2px 0; }

/* 通用小卡片（subagent / skill_draft / page / mcp_approval） */
.mini-card { width: 512px; max-width: 100%; border-radius: 18px; background: rgba(29,29,31,.618); backdrop-filter: blur(50px); padding: 16px; font-size: 14px; line-height: 1.5; }
body.light .mini-card { background: rgba(29,29,31,.618); }
/* 底部天空是淡色，白字贴上去加深色底/阴影才看得清 */
body.light #modelLabel { background: rgba(29,29,31,.55); }
body.light .bot-pager { text-shadow: 0 1px 6px rgba(0,0,0,.45); }
.mini-title { font-weight: 600; margin-bottom: 6px; }
.mini-body { opacity: .85; }
.mini-note { font-size: 13px; color: #f5c542; margin-top: 6px; }
.mini-status { font-size: 13px; margin-top: 6px; }
.mini-status.running { color: #f5c542; }
.mini-status.completed, .mini-status.saved, .mini-status.connected { color: #4caf50; }
.mini-status.failed, .mini-status.dismissed { color: #e53935; }
.mini-progress, .mini-result { margin-top: 6px; font-size: 13px; opacity: .85; }
.mini-card a { color: #8ecbff; }

/* Bot 设置：禁用工具 / MCP 管理 */
.tools-list { display: flex; flex-direction: column; gap: 4px; max-height: 180px; overflow-y: auto; margin-bottom: 10px; }
.tool-check { display: flex; gap: 8px; align-items: center; font-size: 13px; margin: 0; }
.tool-check input { width: auto; margin: 0; }
.mcp-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.12); }
.mcp-info { flex: 1; min-width: 0; font-size: 13px; }
.mcp-info small { opacity: .75; overflow-wrap: anywhere; }
.mcp-health.ok { color: #4caf50; }
.mcp-health.error { color: #e53935; }
.mcp-health.unknown, .mcp-health.installing { color: #f5c542; }
.mcp-row-btns { display: flex; gap: 6px; flex-shrink: 0; }
.mcp-row-btns button { padding: 6px 10px; font-size: 13px; }

/* Markdown 表格：模型返回的 | 表格 | 渲染成真表格，超 10 行翻页 */
.md-table-wrap { margin: 6px 0; overflow-x: auto; }
.md-table { border-collapse: collapse; width: 100%; font-size: 14px; color: #f2f2f2; }
.md-table th, .md-table td { border: 1px solid rgba(255,255,255,.16); padding: 6px 10px; text-align: left; overflow-wrap: anywhere; }
.md-table thead th { background: rgba(255,255,255,.10); font-weight: 600; }
.md-table tbody tr:nth-child(even) { background: rgba(255,255,255,.04); }
.md-table-pager { display: flex; align-items: center; gap: 8px; padding-top: 6px; color: rgba(255,255,255,.8); font-size: 13px; }
.md-table-wrap .md-table-pager button { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); color: #f2f2f2; border-radius: 6px; padding: 2px 10px; cursor: pointer; font-size: 14px; line-height: 1.4; }
.md-table-wrap .md-table-pager button:disabled { opacity: .35; cursor: default; }
