/* 灵犀小程序 IDE：深色主题。布局：上面工具栏；下面五块：资源管理器 | 编辑器 / 调试面板 | 模拟器 | AI 面板 */
:root { --bg: #0f1320; --bg2: #161b2b; --bg3: #1d2336; --line: #262d42; --ink: #d7dbe6; --dim: #8b93a7; --brand: #6366f1; --go: #07c160; --red: #f87171;
  --fs: 13px; --lh: 20px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }
* { box-sizing: border-box; }
/* 写了 display 的元素（.viewer 是 grid、.btn 是 inline-flex…）会盖过 hidden 属性：图片预览层就这样一直盖在编辑器上 */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 13px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; }
button, select, input, textarea { font: inherit; color: inherit; }
.btn { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg3); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #3a4361; background: #232a40; }
a.btn { color: inherit; text-decoration: none; }
.btn.go { border: 0; background: var(--go); color: #fff; font-weight: 600; }
.btn.new { border-color: var(--brand); background: rgba(99, 102, 241, .22); color: #e0e7ff; font-weight: 600; }
.btn.plan { border-color: #b45309; color: #fde68a; }
.btn.sm { padding: 3px 8px; }
.btn[aria-pressed="false"] { color: var(--dim); }
.sel { padding: 5px 7px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg3); max-width: 220px; }
.sel.sm { padding: 3px 4px; font-size: 12px; }
.chk { display: inline-flex; gap: 5px; align-items: center; color: var(--dim); white-space: nowrap; }
.dim { color: var(--dim); }
.top { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 12px; background: var(--bg2); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.brand { color: #fff; text-decoration: none; font-size: 15px; white-space: nowrap; margin-right: 6px; }
.brand b { color: #a5b4fc; }
.status { flex: 1; min-width: 80px; text-align: right; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status.bad { color: var(--red); }
#userBox { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.ide { --side: 210px; --chat: 340px; --sim: 330px; --panel: 210px; display: grid; height: calc(100vh - 48px);
  grid-template-columns: var(--side) minmax(0, 1fr) var(--sim) var(--chat); grid-template-rows: minmax(0, 1fr) var(--panel);
  grid-template-areas: "side code sim chat" "side panel sim chat"; }
.ide.nochat { grid-template-columns: var(--side) minmax(0, 1fr) var(--sim) 0; }
.ide.nochat .chat { display: none; }
/* 分栏把手（layout.js 加）：拖资源管理器、模拟器、AI 面板的宽与调试面板的高，双击恢复默认 */
.side, .chat, .panel { position: relative; }
.split { position: absolute; z-index: 5; touch-action: none; }
.split.x { top: 0; bottom: 0; width: 8px; cursor: col-resize; }
.split.r { right: -4px; } .split.l { left: -4px; }
.split.y { left: 0; right: 0; top: -4px; height: 8px; cursor: row-resize; }
.split:hover, .split.on { background: rgba(129, 140, 248, .4); }
body.dragging { user-select: none; cursor: col-resize; }
body.dragging.y { cursor: row-resize; }
.side { grid-area: side; display: flex; flex-direction: column; min-height: 0; background: var(--bg2); border-right: 1px solid var(--line); }
.side-h { display: flex; justify-content: space-between; padding: 8px 10px; color: var(--dim); font-size: 11px; font-weight: 700; letter-spacing: .06em; }
.fileops { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 8px 6px; }
.fileops button { padding: 2px 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg3); cursor: pointer; font-size: 12px; }
.fileops.foot { padding: 0 8px 8px; }
.tree { flex: 1; overflow: auto; padding: 0 6px 8px; }
.tree details > summary { list-style: none; cursor: pointer; padding: 2px 6px; border-radius: 5px; white-space: nowrap; }
.tree details > summary::before { content: "▸ "; color: var(--dim); }
.tree details[open] > summary::before { content: "▾ "; }
.tree .kids { padding-left: 12px; }
.tree button { display: block; width: 100%; padding: 2px 6px 2px 18px; border: 0; border-radius: 5px; background: none; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.tree button:hover, .tree summary:hover { background: var(--bg3); }
.tree button[aria-current="true"] { background: #283050; color: #fff; }
.tree button.bin { color: var(--dim); }
.tree .dot::after, .tabs .dot::after { content: " ●"; color: #fbbf24; font-size: 9px; }
.hint { margin: 0; padding: 8px 10px; border-top: 1px solid var(--line); color: var(--dim); font-size: 12px; }
.code { grid-area: code; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tabs { display: flex; overflow-x: auto; background: var(--bg2); border-bottom: 1px solid var(--line); }
.tabs > div { display: flex; align-items: center; border-right: 1px solid var(--line); color: var(--dim); }
.tabs > div[aria-selected="true"] { background: var(--bg); color: #fff; box-shadow: inset 0 2px 0 #818cf8; }
.tabs button { padding: 7px 4px 7px 12px; border: 0; background: none; cursor: pointer; font: 12.5px var(--mono); }
.tabs .x { padding: 7px 9px 7px 4px; opacity: .55; }
.err { margin: 0; padding: 8px 12px; background: #3b1219; color: #fecaca; font: 12px/1.55 var(--mono); white-space: pre-wrap; max-height: 30%; overflow: auto; }
.ed { position: relative; flex: 1; min-height: 0; display: flex; overflow: hidden; }
.gutter { flex: none; min-width: 44px; padding: 12px 10px 12px 0; overflow: hidden; white-space: pre; text-align: right; color: #4b5470; user-select: none; }
.gutter, .hl, .ta { font: var(--fs)/var(--lh) var(--mono); tab-size: 2; }
.ed-body { position: relative; flex: 1; min-width: 0; }
.hl, .ta { position: absolute; inset: 0; margin: 0; padding: 12px 14px; white-space: pre; overflow: auto; border: 0; }
.hl { pointer-events: none; }
.ta { resize: none; outline: none; background: transparent; color: transparent; caret-color: #fff; -webkit-text-fill-color: transparent; }
.ta::selection { background: rgba(129, 140, 248, .35); }
.viewer { position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim); background: var(--bg); text-align: center; }
.viewer img { max-width: 80%; max-height: 70%; }
.t-com { color: #6b7591; font-style: italic; } .t-str { color: #a5e3a0; } .t-kw { color: #c4a5ff; } .t-num, .t-lit { color: #f9b36b; }
.t-fn, .t-key { color: #82c8ff; } .t-tag { color: #ff8fa3; } .t-attr { color: #ffd479; } .t-mus { color: #67e8f9; }
.sim { grid-area: sim; display: flex; flex-direction: column; min-height: 0; background: #e9ebf2; color: #1f2433; }
.simbar { display: flex; align-items: center; gap: 5px; padding: 6px 8px; background: #f6f7fb; border-bottom: 1px solid #d9dce6; }
.simbar .btn, .simbar .sel { background: #fff; border-color: #d4d8e3; color: #1f2433; }
.route { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 12px var(--mono); color: #545b70; }
.stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 12px; overflow: auto; }
.phone { padding: 9px; border-radius: 32px; background: #11151f; box-shadow: 0 10px 30px rgba(17, 21, 31, .35); }
.screen { position: relative; overflow: hidden; border-radius: 23px; background: #fff; }
.screen canvas { display: block; touch-action: none; }
.cover { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 20px; background: #f7f8fa; color: #1f2433; text-align: center; font-size: 13px; }
.cover.err b { color: #dc2626; }
.cover span, .cover small { color: #6b7280; }
.bar { width: 200px; height: 6px; border-radius: 3px; background: #e2e5ee; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .15s; }
.bar.busy > i { width: 30%; animation: busy 1s ease-in-out infinite alternate; }
@keyframes busy { to { margin-left: 70%; } }
.panel { grid-area: panel; display: flex; flex-direction: column; min-height: 0; border-top: 1px solid var(--line); }
.ptabs { display: flex; align-items: center; gap: 2px; padding: 0 8px; background: var(--bg2); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.ptabs > button { flex: none; white-space: nowrap; padding: 6px 9px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--dim); cursor: pointer; }
.ptabs > button[aria-selected="true"] { color: #fff; border-bottom-color: #818cf8; }
.badge { margin-left: 4px; padding: 0 6px; border-radius: 9px; font-size: 11px; background: #7f1d1d; color: #fecaca; }
.badge.n { background: #1e3a5f; color: #bfdbfe; }
.badge:empty { display: none; }
.ptools { margin-left: auto; display: flex; gap: 6px; flex: none; }
.pbody { flex: 1; min-height: 0; overflow: auto; font: 12px/1.55 var(--mono); }
.row-l { display: flex; gap: 10px; padding: 2px 12px; border-bottom: 1px solid #171c2b; white-space: pre-wrap; overflow-wrap: anywhere; }
.row-l time { flex: none; color: #4b5470; }
.lv-error { background: #2a1015; color: #fca5a5; } .lv-warn { background: #2a2210; color: #fde68a; } .lv-sys { color: #6b7591; } .lv-ok { color: #86efac; } .lv-in { color: #a5b4fc; }
.repl { display: flex; gap: 6px; align-items: center; padding: 4px 12px; border-top: 1px solid var(--line); font: 12px var(--mono); color: #a5b4fc; }
.repl input { flex: 1; border: 0; outline: none; background: none; font: 12px var(--mono); }
.kv { width: 100%; border-collapse: collapse; }
.kv td, .kv th { padding: 3px 12px; border-bottom: 1px solid #1b2131; text-align: left; vertical-align: top; }
.kv th { color: var(--dim); font-weight: 600; }
.pre { margin: 0; padding: 8px 12px; white-space: pre-wrap; }
.empty { padding: 10px 12px; color: var(--dim); font-family: -apple-system, "PingFang SC", sans-serif; }
.chat { grid-area: chat; display: flex; flex-direction: column; min-height: 0; background: var(--bg2); border-left: 1px solid var(--line); }
.chat-h { display: flex; gap: 6px; align-items: center; padding: 8px; border-bottom: 1px solid var(--line); }
.chat-h .sel { flex: 1; max-width: none; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button { padding: 5px 10px; border: 0; background: none; color: var(--dim); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.msgs { flex: 1; min-height: 0; overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.msg-u, .msg-a { padding: 8px 11px; border-radius: 10px; line-height: 1.6; overflow-wrap: anywhere; }
.msg-u { align-self: flex-end; max-width: 90%; background: #283050; white-space: pre-wrap; }
.msg-a { background: var(--bg3); }
.msg-a pre { margin: 6px 0; padding: 8px; border-radius: 6px; background: #0b0e18; overflow: auto; font: 12px/1.5 var(--mono); }
.msg-a code { font-family: var(--mono); font-size: 12px; }
.chip { display: inline-block; margin: 2px 4px 2px 0; padding: 1px 7px; border-radius: 9px; background: #1e293b; color: #93c5fd; font: 11px var(--mono); }
.chip.f { background: #14361f; color: #86efac; }
.msg-e { color: var(--red); }
.ask { padding: 8px; border-top: 1px solid var(--line); }
.ask textarea { width: 100%; resize: none; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); outline: none; }
.ask-b { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; color: var(--dim); font-size: 12px; }
.dlg { width: min(460px, calc(100vw - 32px)); padding: 0; border: 1px solid #2c3450; border-radius: 14px; background: var(--bg2); color: var(--ink); }
.dlg.wide { width: min(820px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(8, 10, 18, .6); }
.dlg form { padding: 18px 20px; }
.dlg h2 { margin: 0 0 12px; font-size: 18px; color: #fff; }
.dlg label { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; color: var(--dim); }
.dlg label input { flex: 1; padding: 7px 9px; border: 1px solid #2c3450; border-radius: 8px; background: var(--bg); }
.dlg .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; }
.dlg .msg { min-height: 1.2em; margin: 0; color: var(--red); }
.dlg .msg.note { color: #a5b4fc; }
.tag { padding: 3px 8px; border-radius: 7px; background: rgba(7, 193, 96, .15); color: #86efac; font-size: 12px; }
.dlg a { color: #a5b4fc; }
.tpls { display: grid; gap: 8px; }
.tpls label { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 9px 12px; border: 1px solid #2c3450; border-radius: 10px; cursor: pointer; margin: 0; color: var(--ink); }
.tpls label:has(input:checked) { border-color: #818cf8; background: rgba(99, 102, 241, .16); }
.tpls input { grid-row: span 2; }
.tpls span { color: var(--dim); font-size: 12px; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.plan-c { display: flex; flex-direction: column; gap: 6px; padding: 14px; border: 1px solid #2c3450; border-radius: 12px; }
.plan-c.cur { border-color: var(--go); }
.plan-c b { font-size: 16px; color: #fff; }
.plan-c .price { font-size: 22px; color: #fde68a; }
.plan-c ul { margin: 0; padding-left: 18px; color: #b5bccc; }
.plan-c .btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.paybox { margin-top: 12px; padding: 14px; border-radius: 12px; background: #fff; color: #1f2433; text-align: center; }
.paybox img { width: 220px; height: 220px; }
@media (max-width: 1200px) { .ide { --chat: 300px; --side: 180px; } }
@media (max-width: 900px) {
  .ide, .ide.nochat { grid-template-columns: 1fr; grid-template-rows: auto 380px 220px auto auto; grid-template-areas: "sim" "code" "panel" "chat" "side"; height: auto; }
  .chat { min-height: 420px; } .side { max-height: 360px; } .split { display: none; }
  .ta, .hl, .gutter { font-size: 16px; line-height: 24px; }
}
