:root {
  color-scheme: dark;
  --bg:#05070c; --sidebar:#0a0d14; --top:#10141f; --surface:#171d2a;
  --surface2:#23293b; --selected:#1a2234; --terminal:#05070c;
  --text:#dce4f2; --terminal-text:#e1e5ef; --muted:#8d9ab2; --faint:#61708a;
  --accent:#89b4fa; --branch:#b49cfa; --stroke:rgba(148,163,184,.14);
  --glass:#151b28; --shadow:0 18px 60px rgba(0,0,0,.32); --viewport:100dvh; --terminal-size:12px;
}
:root[data-theme=light] {
  color-scheme:light; --bg:#e8edf4; --sidebar:#f1f4f9; --top:#e6ebf3; --surface:#fff;
  --surface2:#dde5f1; --selected:#cdddf4; --terminal:#f9fbfe; --text:#1d2b40;
  --terminal-text:#202b3a; --muted:#52637b; --faint:#6e7d92; --accent:#326fc2;
  --branch:#7054ac; --stroke:rgba(45,67,96,.2); --glass:#fff; --shadow:0 18px 50px rgba(36,54,78,.18);
}
*{box-sizing:border-box}
html,body{margin:0;width:100%;height:100%;font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI","Microsoft YaHei",sans-serif;color:var(--text);background:var(--bg)}
body{overflow:hidden} button,input,textarea{font:inherit} button{border:0;color:inherit;cursor:pointer;touch-action:manipulation}
button:focus-visible,input:focus-visible,textarea:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
button:disabled{opacity:.4;cursor:not-allowed}.hidden{display:none!important}
.horizontal-scroll{display:flex;overflow-x:auto;overscroll-behavior-x:contain;scrollbar-width:none}
.horizontal-scroll::-webkit-scrollbar{display:none}
.herdr-shell{position:relative;display:flex;width:100%;height:var(--viewport,100dvh);overflow:hidden}
.sidebar{flex:0 0 244px;width:244px;min-width:0;display:flex;flex-direction:column;padding:calc(env(safe-area-inset-top) + 10px) 9px calc(env(safe-area-inset-bottom) + 4px);background:var(--sidebar);border-right:1px solid var(--stroke);transition:margin-left .2s ease,transform .2s ease;z-index:5}
.herdr-shell.sidebar-collapsed .sidebar{margin-left:-244px}
.sidebar-backdrop{display:none}
.machine-switcher{display:flex;gap:5px;overflow-x:auto;scrollbar-width:none;padding-bottom:8px}
.machine-button{position:relative;flex:1;min-width:72px;min-height:36px;border:1px solid transparent;border-radius:6px;background:var(--surface);color:var(--muted);font-size:12px;white-space:nowrap}
.machine-button.active{border-color:var(--stroke);background:var(--selected);color:var(--text);font-weight:700}
.node-dot{display:inline-block;width:7px;height:7px;border-radius:50%;background:#64748b;margin-right:6px}
.node-dot.online{background:#74e09b}.node-count{display:inline-grid;place-items:center;min-width:16px;height:16px;margin-left:4px;padding:0 4px;border-radius:8px;background:#f59e0b;color:#1c1408;font-size:10px;font-weight:800}
.search-wrap{display:flex;align-items:center;margin:0 0 10px;background:var(--surface);border:1px solid var(--stroke);border-radius:6px}
.search-wrap input{width:100%;min-width:0;height:34px;padding:0 8px;background:transparent;border:0;outline:0;color:var(--text);font-size:12px}
.search-wrap input::-webkit-search-cancel-button{display:none}.search-wrap button{width:32px;height:32px;background:transparent;color:var(--muted);font-size:18px}
.sidebar-section{display:flex;flex-direction:column;min-height:0}.spaces-section{flex:1.15;min-height:120px}.agents-section{flex:.85;min-height:110px;border-top:1px solid var(--stroke);padding-top:8px}
.sidebar-heading{display:flex;align-items:center;justify-content:space-between;flex:none;height:28px;padding:0 5px;color:var(--faint);font:700 13px ui-monospace,Consolas,monospace}
.sidebar-heading span,.sidebar-heading button{color:var(--faint);font:700 11px ui-monospace,Consolas,monospace}
.sidebar-heading button{background:transparent;padding:4px}
.sidebar-list{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:var(--surface2) transparent}
.space-row,.agent-row{display:flex;width:100%;min-width:0;align-items:flex-start;gap:8px;text-align:left;border-radius:2px;padding:5px 7px;background:transparent;color:var(--muted)}
.space-row:hover,.agent-row:hover{background:var(--surface)}.space-row.active,.agent-row.active{background:var(--selected);color:var(--text);font-weight:700}
.state-mark{flex:none;width:11px;font:700 14px/18px ui-monospace,monospace;color:#64748b;text-align:center}
.state-mark.ready{color:#74e09b}.state-mark.working{color:#89b4fa}.state-mark.attention{color:#f59e0b;animation:pulse 1.5s infinite}
.row-copy{min-width:0;flex:1}.row-main,.row-sub{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.row-main{font-size:13px;line-height:18px}.row-sub{font-size:11px;line-height:16px;color:var(--faint);font-weight:400}.row-sub.branch{color:var(--branch);font-family:ui-monospace,Consolas,monospace}
.agent-row .row-main{font-weight:700}.agent-machine{flex:none;font-size:9px;color:var(--accent);padding-top:3px}
.sidebar-empty{padding:8px;color:var(--faint);font-size:11px}
.space-footer,.sidebar-bottom{display:flex;justify-content:space-between;flex:none}.space-footer{padding:5px 3px 7px}
.space-footer button,.sidebar-bottom button{min-height:30px;background:transparent;color:var(--faint);font:700 12px ui-monospace,Consolas,monospace}.space-footer span{color:#89b4fa}.sidebar-bottom{justify-content:flex-end}.sidebar-bottom button{font-size:19px}
.workspace-main{display:flex;flex:1;min-width:0;min-height:0;flex-direction:column;padding-top:env(safe-area-inset-top);background:var(--bg)}
.renew-banner{display:flex;flex:none;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;padding:9px 12px;background:#5e4213;color:#fff0c2;border-bottom:1px solid #a7792a;font-size:12px;line-height:1.45}
.renew-text{flex:1 1 220px}.renew-actions{display:flex;gap:6px;flex:none}.renew-btn{min-height:34px;padding:5px 10px;border-radius:7px;background:#78571e;color:#fff3cf;font-weight:600}.renew-btn.primary-mini{background:#d99827;color:#211604}.notice-text{padding:11px 12px;border-radius:8px;background:#164a36;color:#b8f4c9;font-size:12px;line-height:1.6}
.topbar{display:flex;flex:none;align-items:center;gap:4px;min-height:46px;padding:5px 7px;background:var(--top);border-bottom:1px solid var(--stroke)}
.sidebar-toggle{display:flex;align-items:center;gap:6px;flex:none;max-width:160px;min-height:36px;padding:0 7px;background:transparent;color:var(--muted);border-radius:4px}
.hamburger{font-size:18px}.current-location{display:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;font-weight:700}.location-attention{flex:none;width:7px;height:7px;border-radius:50%;background:#f59e0b;animation:pulse 1.5s infinite}
.tab-strip{flex:1;min-width:0;gap:5px;align-items:center}
.tab-button{flex:none;max-width:220px;min-height:36px;padding:0 12px;border-radius:3px;background:var(--surface2);color:#9aa7bd;font:600 12px ui-monospace,Consolas,"Microsoft YaHei",monospace;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.tab-button.active{background:#89b4fa;color:#0b101b;font-weight:700}.tab-button .tab-dot{margin-right:5px}.tab-button.active .state-mark{color:#0b101b}.tab-button.active .state-mark.attention{color:#7c2d12}
:root[data-theme=light] .tab-button{color:#52637b}:root[data-theme=light] .tab-button.active{color:#0b101b}
.top-tools{display:flex;flex:none;align-items:center}.top-tool{flex:none;width:33px;min-height:36px;background:transparent;color:var(--muted);font-size:18px;border-radius:4px}.top-tool:hover,.sidebar-toggle:hover{background:var(--surface2);color:var(--text)}.add-tab{font-size:20px}
.pane-bar{display:flex;flex:none;align-items:center;gap:4px;min-height:39px;padding:3px 8px;background:var(--top);border-bottom:1px solid var(--stroke)}
.pane-list{flex:1;min-width:0;gap:5px}.pane-button{flex:none;max-width:230px;min-height:30px;padding:0 9px;border:1px solid transparent;border-radius:4px;background:transparent;color:var(--muted);font-size:11px;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}
.pane-button.active{border-color:var(--accent);background:var(--selected);color:var(--text)}.pane-tools{display:flex;flex:none;gap:2px}.pane-tools button{min-height:30px;padding:0 7px;background:transparent;color:var(--muted);font-size:11px;white-space:nowrap}
.statusbar{display:flex;flex:none;align-items:center;gap:8px;min-height:26px;padding:3px 12px;color:var(--muted);font-size:10px}.statusbar .grow{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.status-pill{flex:none;border-radius:8px;padding:3px 7px;background:var(--surface);color:var(--muted)}.status-pill.blocked,.status-pill.picker_or_blocked,.status-pill.continuity_choice{color:#e7a93e}.status-pill.working,.status-pill.agent_working{color:#89b4fa}.status-pill.done,.status-pill.idle,.status-pill.agent_idle{color:#74c991}
.terminal-wrap{position:relative;display:flex;flex:1;min-height:65px;flex-direction:column;overflow:hidden;background:var(--terminal);border-top:1px solid var(--stroke)}
.terminal-top{display:flex;flex:none;align-items:center;justify-content:space-between;min-height:23px;padding:5px 12px;color:var(--faint);font:9px ui-monospace,monospace;letter-spacing:.08em}.terminal-top-left{display:flex;align-items:center;gap:8px;min-width:0}.mode-toggle{min-height:20px;padding:1px 7px;border-radius:4px;border:1px solid var(--stroke);background:var(--surface2);color:var(--text);font:600 10px ui-sans-serif,-apple-system,"Microsoft YaHei",sans-serif;letter-spacing:0}.stream-status{color:#74c991}
.terminal{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;padding:4px 12px 16px;color:var(--terminal-text);background:var(--terminal);font:var(--terminal-size)/1.48 ui-monospace,SFMono-Regular,Consolas,"Microsoft YaHei",monospace}
.terminal pre{font:inherit;margin:0;white-space:pre;min-width:max-content}.terminal.wrap pre{white-space:pre-wrap;overflow-wrap:anywhere;min-width:0}
.terminal-loading{position:absolute;top:38px;left:12px;color:var(--muted);font-size:12px;pointer-events:none}
.scroll-bottom{position:absolute;bottom:10px;right:10px;min-height:36px;padding:0 10px;border-radius:18px;background:var(--surface2);border:1px solid var(--stroke);color:var(--text);font-size:10px;opacity:.88}.scroll-bottom.unread{background:#345c8f;border-color:var(--accent);color:#fff;font-weight:700;opacity:.96;box-shadow:var(--shadow)}
.conversation{display:grid;gap:10px}.bubble{max-width:92%;padding:11px 13px;border-radius:12px;background:var(--surface2);color:var(--text);white-space:pre-wrap;overflow-wrap:anywhere}.bubble.user{justify-self:end;background:var(--selected)}.bubble small{display:block;color:var(--muted);margin-bottom:5px}
.empty-state{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:20px;background:var(--terminal);color:var(--muted);font-size:12px}.empty-state strong{color:var(--text);font-size:15px}.empty-state p{line-height:1.6}.empty-symbol{font-size:30px;margin-bottom:12px;color:var(--faint)}.empty-state button{padding:9px 16px;border-radius:6px;background:var(--surface2);color:var(--text)}
.controls{flex:none;max-height:min(60%,calc(var(--viewport) - 180px));overflow-y:auto;overscroll-behavior:contain;padding:9px 12px calc(8px + env(safe-area-inset-bottom));border-top:1px solid var(--stroke);background:var(--top)}
.context-title{display:flex;align-items:center;gap:7px;font-size:11px;font-weight:700}.context-title span:last-child{margin-left:auto;font-size:10px;font-weight:400;color:var(--muted)}.context-pulse{width:7px;height:7px;border-radius:50%;background:#89b4fa}
.action-row{gap:7px;padding:7px 0 3px}.action-row button,.deck-toggles button,.key-grid button,.arrows button,.composer-tools button{min-height:40px;white-space:nowrap;border:1px solid var(--stroke);border-radius:7px;background:var(--surface2);color:var(--text);padding:0 11px;font-size:11px}
.action-row .emphasis{background:#345c8f;color:#fff}.action-row .warn{color:#ffd4a0;background:#523521}.deck-toggles{display:flex;gap:5px;overflow-x:auto}.deck-toggles button{background:transparent;color:var(--muted);padding:0 7px;border:0}.deck-toggles .danger{margin-left:auto;color:#df8b8b}
.deck-toggles button.active{color:var(--accent);background:var(--selected);border:1px solid var(--stroke);border-radius:6px}
.key-deck{display:flex;flex-direction:column;gap:7px;padding:4px 0 8px}
.key-deck-top{display:flex;gap:10px}
.arrows{display:grid;grid-template-columns:repeat(3,40px);gap:4px}.arrows button{padding:0;font-size:18px;touch-action:none;user-select:none}
.key-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px;flex:1;min-width:0}.key-grid button{padding:0 4px;font-size:10px;touch-action:none;user-select:none}.key-grid .key-accent{background:#345c8f;color:#fff}
.combo-section{border-top:1px solid var(--stroke);padding-top:6px}
.combo-header{display:flex;align-items:center;gap:7px;margin-bottom:5px}
.combo-badge{flex:none;padding:3px 7px;border-radius:999px;color:var(--accent);background:var(--selected);font-size:10px;font-weight:700}
.combo-hint{color:var(--muted);font-size:10px}
.combo-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:4px}
.combo-btn,.action-row .quick-combo{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px}
.combo-btn{min-width:0;min-height:40px;padding:3px 4px;border:1px solid var(--stroke);border-radius:7px;background:var(--surface2);color:var(--text);touch-action:pan-y;user-select:none}
.action-row .quick-combo{flex:none;padding:3px 8px}
.combo-chord{font:700 11px ui-monospace,SFMono-Regular,Consolas,monospace}
.combo-desc{max-width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-size:9.5px;color:var(--muted)}
.combo-btn.key-accent{background:#345c8f;color:#fff}
.key-accent .combo-desc,.action-row .emphasis .combo-desc,.action-row .warn .combo-desc{color:inherit}
.composer{display:flex;align-items:stretch;gap:8px;margin-top:4px}.composer-input{display:flex;flex:1;min-width:0;flex-direction:column;border:1px solid var(--stroke);border-radius:8px;background:var(--surface);padding:6px 8px 0}.composer textarea{width:100%;min-height:30px;max-height:120px;resize:none;color:var(--text);background:transparent;border:0;outline:0;padding:4px;font-size:13px;line-height:20px}.composer textarea::placeholder{color:var(--faint)}.composer-tools{display:flex;gap:4px}.composer-tools button{padding:0 4px;font-size:10px;border:0;background:transparent;color:var(--muted)}.send-button{min-width:70px;border-radius:8px;background:#527eb8;color:white;font-weight:700;font-size:12px}.send-button span{display:block;font-size:17px}
.composer-tools{overflow-x:auto;overscroll-behavior-x:contain}.composer-tools button{flex:none}.attachment-tray{display:flex;gap:6px;overflow-x:auto;padding:2px 0 5px;overscroll-behavior-x:contain}.attachment-chip{display:flex;align-items:center;flex:none;gap:5px;height:54px;max-width:180px;padding:4px;border:1px solid var(--stroke);border-radius:8px;background:var(--surface2)}.attachment-chip img{width:42px;height:42px;object-fit:cover;border-radius:5px;background:var(--terminal)}.attachment-status{min-width:0;color:var(--muted);font-size:10px;white-space:nowrap}.attachment-remove{width:30px;height:38px;flex:none;border:0;border-radius:6px;background:transparent;color:var(--text);font-size:18px}
.sheet-backdrop{position:fixed;inset:0;z-index:20;display:flex;align-items:flex-end;justify-content:center;background:rgba(1,5,11,.67)}.sheet{width:min(100%,600px);max-height:80dvh;overflow:auto;padding:10px 18px calc(20px + env(safe-area-inset-bottom));border:1px solid var(--stroke);border-radius:18px 18px 0 0;background:var(--glass);box-shadow:var(--shadow)}.sheet-handle{width:38px;height:4px;border-radius:4px;background:var(--faint);margin:0 auto 8px}.sheet-heading{display:flex;align-items:center;justify-content:space-between}.sheet-heading h2{font-size:17px}.icon-button{min-width:40px;min-height:40px;border-radius:8px;background:transparent;color:var(--muted);font-size:20px}.sheet-choice{width:100%;min-height:48px;text-align:left;display:flex;align-items:center;justify-content:space-between;padding:0 14px;margin:8px 0;background:var(--surface2);border:1px solid var(--stroke);border-radius:8px}.sheet-note{font-size:12px;line-height:1.7;color:var(--muted)}
.sheet-field{display:block;margin:12px 0;color:var(--muted);font-size:12px}.sheet-field input{display:block;width:100%;min-height:42px;margin-top:5px;padding:0 10px;border:1px solid var(--stroke);border-radius:6px;background:var(--surface);color:var(--text)}.technical-details{padding-top:12px;border-top:1px solid var(--stroke);overflow-wrap:anywhere;color:var(--faint);font:10px/1.6 ui-monospace,monospace}
.filter-pill{flex:none;min-height:40px;padding:0 14px;border:1px solid var(--stroke);border-radius:8px;background:var(--surface2);color:var(--muted);font-size:12px;white-space:nowrap}.filter-pill.active{border-color:var(--accent);color:var(--text)}.pair-channels{gap:8px;padding-bottom:5px}.qr-image{display:block;width:min(75vw,280px);height:auto;margin:15px auto;border:10px solid white;border-radius:12px}.pair-origin{font-size:12px;text-align:center;color:var(--muted);overflow-wrap:anywhere}.pair-manual{display:block;width:100%;min-height:74px;margin-top:10px;padding:10px;border:1px solid var(--stroke);border-radius:8px;color:var(--text);background:var(--surface2);font:11px/1.5 ui-monospace,monospace;overflow-wrap:anywhere}
.toast{position:fixed;z-index:40;left:50%;bottom:calc(25px + env(safe-area-inset-bottom));transform:translateX(-50%);max-width:90vw;padding:12px 16px;border-radius:8px;background:#263b52;color:#fff;box-shadow:var(--shadow);font-size:12px;text-align:center}
.login-screen{display:grid;place-items:center;min-height:100dvh;padding:20px;background:radial-gradient(ellipse at top,#1c2942,var(--bg) 70%)}.login-card{width:min(100%,430px);padding:30px;border:1px solid var(--stroke);border-radius:22px;background:var(--glass);box-shadow:var(--shadow)}.brand-mark{display:grid;place-items:center;width:55px;height:55px;border-radius:16px;background:#273c58}.brand-mark svg{width:40px;height:40px;fill:none;stroke:#a4dcff;stroke-width:2.8;stroke-linecap:round;stroke-linejoin:round}.eyebrow{font-size:9px;font-weight:800;letter-spacing:.18em;color:var(--accent);margin:30px 0 0}.login-card h1{font-size:32px;line-height:1.27;letter-spacing:-.04em}.login-card h1 span{color:var(--accent)}.muted{color:var(--muted)}.login-copy{font-size:13px;line-height:1.8;margin:14px 0 25px}.login-card label{display:block;font-size:11px;color:var(--muted);margin-bottom:8px}.login-card input{width:100%;min-height:48px;border:1px solid var(--stroke);border-radius:8px;background:var(--surface2);padding:0 13px;color:var(--text);font-size:13px}.primary{min-height:48px;border-radius:8px;background:#527eb8;color:white;font-weight:700}.primary.wide{width:100%;margin-top:12px}.primary span{margin-left:8px}.error-text{min-height:17px;color:#fa8e8e;font-size:11px}.login-foot{display:flex;align-items:center;gap:8px;margin-top:22px;font-size:9px;letter-spacing:.1em;color:var(--faint)}.live-dot{width:7px;height:7px;border-radius:50%;background:#74e09b}
@media(max-width:859px){
  .sidebar{position:fixed;inset:0 auto 0 0;width:min(82vw,296px);margin:0!important;transform:translateX(-104%);box-shadow:var(--shadow)}
  .space-row,.agent-row{padding:8px 9px;min-height:36px}
  .herdr-shell.drawer-open .sidebar{transform:translateX(0)}
  .sidebar-backdrop{position:fixed;inset:0;z-index:4;background:rgba(0,0,0,.6)}
  .herdr-shell.drawer-open .sidebar-backdrop{display:block}
  .current-location{display:block;max-width:86px}.sidebar-toggle{max-width:120px}.topbar{gap:1px;padding-left:3px;padding-right:3px}
  .top-tool{width:30px}.tab-button{max-width:160px}.pane-tools button{padding:0 5px}
}
@media(max-width:390px){.current-location{max-width:48px}.top-tool{width:27px}.sidebar-toggle{padding:0 4px}.pane-tools button{font-size:10px;padding:0 4px}.combo-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media(max-height:650px){.controls{padding-top:5px}.context-title{display:none}.action-row{padding-top:2px}.statusbar{min-height:22px}.key-grid button,.arrows button{min-height:36px}}
.keyboard-open .key-deck{display:none!important}.keyboard-open .statusbar{display:none}
@media(prefers-reduced-motion:reduce){.sidebar{transition:none}.state-mark.attention,.location-attention{animation:none}}
@keyframes pulse{50%{opacity:.45}}
