/* 灵枢控制台：左 目录信息 + 目录树 · 中 星图 · 右 会话列表 + 终端；云端枢纽收在右上角；手机上三栏变成三个标签页 */
.console-page { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.console-page::before, .console-page::after { display: none; }
.ctop { display: flex; align-items: center; gap: 12px; padding: 9px 16px; border-bottom: 1px solid var(--hairline); background: var(--ink-0); flex: 0 0 auto; z-index: 5; }
.ctop .brand img { width: 32px; height: 32px; } .ctop .brand-name { font-size: 19px; }
.ctop select { width: auto; min-width: 200px; max-width: 280px; padding: 6px 10px; font-size: 13.5px; }
.ctop .grow { flex: 1; }
.ctop .navlink { color: var(--muted); font-size: 14px; }
.hubbtn { position: relative; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--accent-line); background: var(--accent-dim); color: var(--paper);
  border-radius: 999px; padding: 5px 13px 5px 10px; cursor: pointer; font: 13px var(--font-body); }
.hubbtn:hover, .hubbtn.on { border-color: var(--accent); box-shadow: 0 0 18px rgba(111,227,196,.18); }
.hubbtn .hz { font-family: var(--font-display); font-size: 15px; color: var(--accent); }
.hubbtn .badge { position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; border-radius: 9px; background: var(--matrix); color: var(--ink-0); font: 600 10.5px/17px var(--font-mono); text-align: center; padding: 0 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: 0 0 auto; display: inline-block; }
.dot.on { background: var(--accent); } .dot.busy { background: var(--matrix); animation: pulse 1.2s infinite; } .dot.bad { background: var(--bad); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(61,255,154,.6); } 70% { box-shadow: 0 0 0 8px rgba(61,255,154,0); } }

.c3 { flex: 1; min-height: 0; display: grid; grid-template-columns: clamp(250px, 19vw, 330px) minmax(0, 1fr) clamp(400px, 34vw, 640px); }
.lcol, .rcol { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--ink-1); }
.lcol { border-right: 1px solid var(--hairline); } .rcol { border-left: 1px solid var(--hairline); }
.info { flex: 0 0 33.4%; overflow-y: auto; padding: 14px 16px; border-bottom: 1px solid var(--hairline); min-height: 0; }
.treebox, .sess { display: flex; flex-direction: column; min-height: 0; }
.treebox { flex: 1; } .sess { flex: 0 0 33.4%; border-bottom: 1px solid var(--hairline); } .term { flex: 1; display: flex; flex-direction: column; min-height: 0; background: #0b0c0f; }
.ph { display: flex; align-items: center; gap: 8px; padding: 8px 12px 7px 14px; border-bottom: 1px solid var(--hairline); flex: 0 0 auto; }
.ph b, .info h3 { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .14em; color: var(--accent); font-weight: 500; margin: 0; white-space: nowrap; }
.ph .pm { font-family: var(--font-mono); font-size: 11px; color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib { background: none; border: 1px solid transparent; color: var(--muted); border-radius: 6px; width: 26px; height: 24px; cursor: pointer; font-size: 14px; line-height: 1; }
.ib:hover { border-color: var(--hairline-strong); color: var(--accent); } .ib.on { color: var(--accent); }
.tmsg { color: var(--muted); font-size: 12.5px; padding: 10px 14px; line-height: 1.6; } .tmsg.bad { color: var(--bad); }

/* 目录信息 */
.info .node-title { font-family: var(--font-display); font-size: 19px; margin: 0; line-height: 1.3; word-break: break-all; }
.info .node-sub { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); word-break: break-all; }
.info .kv { grid-template-columns: 52px 1fr; font-size: 12.5px; margin-top: 10px; line-height: 1.55; }
.info details { margin-top: 10px; } .info details summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
.info label { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; }
.info textarea { font-size: 13px; }
.usage { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.inline { display: flex; gap: 8px; align-items: center; } .inline input, .inline select { flex: 1; min-width: 0; }
.chip.bad { border-color: rgba(224,108,91,.5); color: var(--bad); }
.nrow { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.nrow:hover { background: var(--ink-2); } .nrow .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nrow .ns { font-family: var(--font-mono); font-size: 11px; color: var(--faint); }

/* 目录树（Windows 资源管理器式） */
.tree { flex: 1; overflow: auto; padding: 4px 0 12px; outline: none; font: 13px/1 "Segoe UI", var(--font-body); }
.explorer .tr { display: flex; align-items: center; gap: 5px; height: 24px; padding-right: 8px; cursor: default; white-space: nowrap; color: #e3e3e3; border: 1px solid transparent; user-select: none; }
.explorer .tr:hover { background: rgba(255,255,255,.055); }
.explorer .tr.sel { background: rgba(111,227,196,.13); border-color: rgba(111,227,196,.32); }
.explorer .tr.hid { opacity: .55; }
.explorer .tw { width: 14px; flex: 0 0 14px; text-align: center; color: #9aa0a8; font-size: 14px; line-height: 1; }
.explorer .fi { width: 16px; height: 16px; flex: 0 0 16px; }
.explorer .tn { overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.explorer .ts { font-size: 11px; color: var(--faint); margin-left: 6px; }
.explorer .root .tn { font-weight: 600; }

/* 会话列表 */
.sbar { display: flex; gap: 6px; padding: 8px 12px; flex: 0 0 auto; }
.sbar input { padding: 6px 10px; font-size: 13px; }
.slist { flex: 1; overflow-y: auto; padding: 0 6px 8px; min-height: 0; }
.si { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; padding: 6px 8px; border-radius: 7px; cursor: pointer; border: 1px solid transparent; }
.si:hover { background: var(--ink-2); } .si.on { background: var(--accent-dim); border-color: var(--accent-line); }
.si .eb { grid-row: span 2; align-self: center; font: 600 10px/1 var(--font-mono); border-radius: 4px; padding: 4px 4px; color: #fff; }
.eb.codex { background: #2b2f3a; border: 1px solid #555c6e; } .eb.claude { background: #8a3f26; border: 1px solid #d97757; }
.si .st { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.si .sm { font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); }
.si .busy { color: var(--matrix); font-style: normal; animation: pulse 1.2s infinite; border-radius: 50%; }

/* 终端：尽量还原 Codex / Claude Code 的 TUI */
.th { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--hairline); flex: 0 0 auto; background: var(--ink-1); }
.th .eng { display: inline-flex; border: 1px solid var(--hairline-strong); border-radius: 7px; overflow: hidden; flex: 0 0 auto; }
.th .eng button { background: none; border: 0; color: var(--muted); padding: 3px 10px; font: 12px var(--font-mono); cursor: pointer; }
.th .eng button.on.codex { background: #262a33; color: #fff; } .th .eng button.on.claude { background: rgba(217,119,87,.2); color: #f0a184; }
.th .eng button:disabled { opacity: .35; cursor: not-allowed; }
.th .tt { flex: 1; min-width: 0; font: 12px var(--font-mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tui { flex: 1; overflow-y: auto; padding: 10px 12px 6px; font: 13px/1.55 "Cascadia Mono", "JetBrains Mono", Consolas, "Microsoft YaHei UI", monospace; color: #d4d4d4; outline: none;
  white-space: pre-wrap; word-break: break-word; min-height: 0; }
.tui .tmsg { white-space: normal; font-family: var(--font-body); }
.tui .dim { color: #8a8f98; } .tui .red { color: #f4776a; } .tui .green { color: #4eba65; } .tui .orange { color: #d97757; }
.tui b { color: #fff; font-weight: 700; }
.tui .wb { border: 1px solid #4b505a; border-radius: 6px; padding: 6px 12px; margin: 2px 0 10px; display: block; white-space: pre-wrap; }
.tui .wb.claude { border-color: #d97757; } .tui .wb div { white-space: pre-wrap; }
.tui .tip { margin: -2px 0 12px; white-space: normal; }
.tui .ev { margin: 0 0 9px; }
.tui .ev.a, .tui .ev.x, .tui .ev.r, .tui .ev.e { display: grid; grid-template-columns: 1.4em 1fr; }
.tui .ev .b { color: #d4d4d4; } .tui .ev .b.wd { color: #fff; }
.tui .ev.u.cx { background: #1d2026; margin-left: -12px; margin-right: -12px; padding: 5px 12px; color: #e8e8e8; }
.tui .ev.u.cx .g { color: #9aa0a8; font-weight: 700; }
.tui .ev.u.cc { color: #9aa0a8; } .tui .ev.u.cc .g { color: #9aa0a8; }
.tui .ev.r i { color: #9aa0a8; } .tui .think { color: #6f747d; font-size: 12px; margin-top: 2px; max-height: 7.5em; overflow: hidden; }
.tui .cmd { color: #7dd3fc; } .tui.claude .cmd { color: #e5e5e5; }
.tui .o { color: #b8bcc4; } .tui .more { cursor: pointer; } .tui .more:hover { color: var(--accent); }
.tui .md code { color: #7dd3fc; } .tui.claude .md code { color: #b4a0ff; }
.tui .md .h { color: #fff; } .tui .md .quote { color: #9aa0a8; border-left: 2px solid #4b505a; padding-left: 8px; }
.tui pre.code { background: #15171c; border: 1px solid #262a32; border-radius: 5px; padding: 6px 10px; margin: 4px 0; overflow-x: auto; white-space: pre; font: inherit; color: #e3e3e3; position: relative; }
.tui pre.code .lang { position: absolute; right: 8px; top: 2px; font-size: 10.5px; color: #6f747d; }
.tui .diff { margin-top: 3px; white-space: pre; overflow-x: auto; font-size: 12px; } .tui .add { color: #7ee787; background: rgba(46,160,67,.13); } .tui .del { color: #ffa198; background: rgba(248,81,73,.13); }
.tui .sep { text-align: left; color: #6f747d; margin: 2px 0 12px; }
.tui .s { margin-top: -4px; }
.tui .spin { animation: blink 1s infinite; } @keyframes blink { 50% { opacity: .25; } }
.tui .pickm, .tui .picks { cursor: pointer; } .tui .pickm:hover, .tui .picks:hover { color: var(--matrix); text-decoration: underline; }
.cmpwrap { position: relative; flex: 0 0 auto; padding: 4px 10px 6px; font: 13px/1.5 "Cascadia Mono", "JetBrains Mono", Consolas, monospace; }
.cmpwrap .work { padding: 2px 4px 6px; color: #d4d4d4; }
.shimmer { background: linear-gradient(90deg, #8a8f98 0%, #ffffff 45%, #8a8f98 60%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shim 2s linear infinite; }
@keyframes shim { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.cmp { display: flex; align-items: flex-start; gap: 8px; padding: 7px 10px; }
.cmpwrap.codex .cmp { background: #1d2026; border-radius: 4px; }
.cmpwrap.claude .cmp { border: 1px solid #6f747d; border-radius: 8px; }
.cmpwrap.claude .cmp:focus-within { border-color: #9aa0a8; }
.cmp .pr { color: #e8e8e8; font-weight: 700; line-height: 22px; }
.cmp textarea { flex: 1; border: 0; background: transparent; box-shadow: none !important; resize: none; padding: 0; color: #f0f0f0; font: inherit; line-height: 22px; min-height: 22px; max-height: 180px; outline: none; }
.cmp textarea::placeholder { color: #6f747d; }
.cmp .send { background: none; border: 1px solid #4b505a; color: #9aa0a8; border-radius: 6px; width: 30px; height: 24px; cursor: pointer; flex: 0 0 auto; }
.cmp .send:hover { color: var(--matrix); border-color: var(--matrix); }
.foot { display: flex; gap: 14px; padding: 4px 6px 0; font-size: 11.5px; color: #6f747d; white-space: nowrap; overflow: hidden; }
.foot .r { margin-left: auto; overflow: hidden; text-overflow: ellipsis; } .foot .red { color: #f4776a; }
.popup { position: absolute; left: 10px; right: 10px; bottom: 100%; background: #121419; border: 1px solid #3a3f49; border-radius: 6px; padding: 4px 0; max-height: 260px; overflow-y: auto; z-index: 5; box-shadow: 0 -10px 30px rgba(0,0,0,.5); }
.popup .pi { display: grid; grid-template-columns: 9.5em 1fr; gap: 10px; padding: 3px 12px; cursor: pointer; }
.popup .pi.on { background: #1f2a33; } .popup .pi .cmd { color: #7dd3fc; } .popup .pi .dim { color: #8a8f98; }
.cmpwrap.claude .popup .pi .cmd { color: #b4a0ff; }

.th .wbadge { font: 11px var(--font-mono); padding: 2px 8px; border-radius: 999px; border: 1px solid var(--accent-line); color: var(--accent); white-space: nowrap; }
.th .wbadge.busy { border-color: rgba(61,255,154,.5); color: var(--matrix); } .th .wbadge.dialog, .th .wbadge.draft { border-color: rgba(224,168,62,.5); color: var(--warn); }
.th #tt-open { white-space: nowrap; }
.modebtn { font: 11px var(--font-mono); padding: 3px 9px; border-radius: 999px; cursor: pointer; white-space: nowrap; background: none; }
.modebtn.headed { border: 1px solid var(--accent-line); color: var(--accent); } .modebtn.headless { border: 1px solid var(--hairline-strong); color: var(--muted); }
.wtag { font: 10.5px var(--font-mono); color: var(--accent); margin-left: 4px; } .wtag.busy { color: var(--matrix); } .wtag.dialog, .wtag.draft { color: var(--warn); }
.dlg { border-top: 1px solid rgba(224,168,62,.4); background: rgba(224,168,62,.06); padding: 8px 12px; flex: 0 0 auto; max-height: 45%; overflow: auto; }
.dlg .dh { font-size: 12.5px; color: var(--warn); margin-bottom: 4px; }
.dlg pre { font: 12px/1.45 "Cascadia Mono", Consolas, monospace; color: #d4d4d4; margin: 0 0 6px; white-space: pre-wrap; }
.dlg .dk { display: flex; gap: 6px; flex-wrap: wrap; }

/* 星图 */
.map .legend { font-size: 11px; }
.zoom { position: absolute; right: 14px; top: 14px; display: grid; gap: 6px; z-index: 3; }
.zoom button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--hairline-strong); background: rgba(15,17,22,.85); color: var(--paper); cursor: pointer; font: 15px var(--font-mono); }
.zoom button:hover { border-color: var(--accent-line); color: var(--accent); }
.map .title h2 { pointer-events: auto; cursor: default; } .map .title h2.editable { cursor: pointer; } .map .title h2.editable:hover::after { content: " ✎"; color: var(--accent); font-size: 15px; }
.mpick { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 10px;
  background: rgba(15,17,22,.92); border: 1px solid var(--accent-line); font-size: 13.5px; z-index: 3; }
.mpick .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 云端枢纽：收束在右上角，点开才有 */
.hubpop { position: fixed; top: 58px; right: 14px; width: min(460px, calc(100vw - 28px)); height: min(640px, calc(100vh - 80px)); z-index: 30; display: flex; flex-direction: column;
  background: var(--ink-1); border: 1px solid var(--accent-line); border-radius: 12px; box-shadow: 0 24px 80px rgba(0,0,0,.6), 0 0 40px rgba(111,227,196,.08); overflow: hidden; }
.hubhead { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--hairline); }
.hubhead b { font-family: var(--font-mono); font-size: 12px; letter-spacing: .14em; color: var(--accent); font-weight: 500; }
.hubhead span { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hublog { flex: 1; overflow-y: auto; padding: 10px 16px; font-size: 13px; display: grid; gap: 8px; align-content: start; min-height: 0; }
.msg { border-radius: 8px; padding: 7px 10px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.msg.user { background: var(--accent-dim); border: 1px solid var(--accent-line); justify-self: end; max-width: 90%; }
.msg.hub { background: var(--ink-2); border: 1px solid var(--hairline); max-width: 96%; }
.msg .who { font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); display: block; margin-bottom: 2px; }
.msg .act { font-family: var(--font-mono); font-size: 11.5px; color: var(--matrix); display: block; } .msg .act.no { color: var(--bad); }
.evt { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); border-left: 2px solid var(--hairline-strong); padding-left: 8px; }
.evt b { color: var(--accent); font-weight: 500; }
.hubform { display: flex; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--hairline); }
.hubform input { flex: 1; font-size: 13px; }

/* 抽屉、弹窗 */
.drawer-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; }
.drawer { position: fixed; top: 0; left: 0; bottom: 0; width: min(460px, 94vw); background: var(--ink-1); border-right: 1px solid var(--hairline-strong); z-index: 41; overflow-y: auto; box-shadow: 30px 0 80px rgba(0,0,0,.5); }
.drawer .dhead { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--hairline); position: sticky; top: 0; background: var(--ink-1); z-index: 1; }
.drawer section { padding: 16px 20px; border-bottom: 1px solid var(--hairline); }
.drawer h3 { font-family: var(--font-mono); font-size: 12px; letter-spacing: .16em; color: var(--accent); margin: 0 0 10px; font-weight: 500; }
.drawer details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.secret { font-family: var(--font-mono); letter-spacing: .06em; }
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 60; display: grid; place-items: center; }
.modal { width: min(440px, 92vw); border: 1px solid rgba(224,108,91,.45); border-radius: var(--radius-lg); background: var(--ink-1); padding: 24px; }
.modal h4 { font-family: var(--font-display); font-size: 20px; margin: 0 0 10px; }
.btn-danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 600; }
.btn-danger-solid:hover { background: #f07f6e; border-color: #f07f6e; color: #fff; }
.mtabs, .narrow-only { display: none; }

@media (max-width: 1180px) and (min-width: 901px) {
  .c3 { grid-template-columns: 240px minmax(0, 1fr) 420px; }
  .map .legend { display: none; }
}
/* 手机：三栏变三个标签页，底部切换；星图支持双指缩放 */
@media (max-width: 900px) {
  .wide-only { display: none !important; } .narrow-only { display: block; }
  .ctop { gap: 8px; padding: 7px 10px; padding-top: max(7px, env(safe-area-inset-top)); }
  .ctop .brand-en { display: none; } .ctop .brand img { width: 28px; height: 28px; } .ctop .brand-name { font-size: 17px; letter-spacing: .1em; }
  .ctop select { min-width: 0; flex: 1 1 auto; max-width: none; }
  .ctop .grow { display: none; }
  .hubbtn { padding: 5px 10px; }
  .c3 { display: block; position: relative; }
  .pane { position: absolute; inset: 0; display: none; border: 0; }
  body[data-tab="map"] .pane[data-pane="map"], body[data-tab="dir"] .pane[data-pane="dir"], body[data-tab="sess"] .pane[data-pane="sess"] { display: flex; }
  .map.pane { display: none; height: auto; } body[data-tab="map"] .map.pane { display: block; }  /* linkmesh.css gives .map 64vh on phones */
  .map .legend { display: none; }
  .map .title h2 { font-size: 18px; } .map .title p { font-size: 10.5px; max-width: 70vw; }
  .zoom { top: 12px; right: 10px; } .zoom button { width: 36px; height: 36px; }
  .sess { flex-basis: 34%; } .info { flex-basis: 36%; }
  .mtabs { display: flex; flex: 0 0 auto; border-top: 1px solid var(--hairline); background: var(--ink-0); padding-bottom: env(safe-area-inset-bottom); }
  .mtabs button { flex: 1; background: none; border: 0; color: var(--muted); font: 12px var(--font-body); padding: 7px 0 8px; display: grid; gap: 1px; cursor: pointer; }
  .mtabs button span { font: 15px var(--font-mono); }
  .mtabs button.on { color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); }
  .explorer .tr { height: 32px; font-size: 14px; } .si { padding: 8px; }
  .tui { font-size: 12.5px; padding: 8px 10px; } .tui .ev.u.cx { margin-left: -10px; margin-right: -10px; }
  .cmp textarea { font-size: 16px; }  /* iOS 不会因为聚焦而放大页面 */
  .foot span:nth-child(n+2):not(.r) { display: none; }
  .hubpop { top: 0; right: 0; left: 0; bottom: 0; width: auto; height: auto; border-radius: 0; border: 0; padding-top: env(safe-area-inset-top); }
  .toast { left: 12px; right: 12px; bottom: 70px; max-width: none; }
}
