:root{color-scheme:dark;--bg:#0b1423;--panel:#111e30;--line:#25354b;--muted:#9aabc0;--text:#eaf0f7;--accent:#c9ddf4;font-family:Inter,"Microsoft YaHei","PingFang SC",sans-serif;font-size:14px}*{box-sizing:border-box}body{margin:0;background:radial-gradient(ellipse at top,#192e47 0, var(--bg) 65%);color:var(--text);min-height:100vh}button,a,input,textarea{-webkit-tap-highlight-color:transparent}button{font:inherit;cursor:pointer;border:1px solid #455b74;border-radius:8px;padding:9px 13px;background:var(--accent);color:#11243a;font-weight:600}button:hover{filter:brightness(1.12)}button:disabled{opacity:.4;cursor:not-allowed}a{color:var(--accent);text-decoration:none}a:hover{text-decoration:underline}.quiet{background:transparent;color:var(--muted);border-color:var(--line)}header{height:85px;padding:0 32px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--line);gap:15px}.brand{display:flex;gap:13px;align-items:center;color:var(--text);font-size:20px;font-weight:650;letter-spacing:1px}.brand small{display:block;font-size:10px;color:var(--muted);letter-spacing:2px;margin-top:6px}.mark{width:39px;height:43px;border:1px solid #728aa4;border-radius:10px;display:grid;place-items:center;background:linear-gradient(135deg,#39536f,#15283e);font-family:Georgia,serif;font-size:29px}.notice{padding:12px 32px;color:var(--muted);font-size:12px;display:flex;gap:15px;align-items:center;flex-wrap:wrap}.notice button{padding:3px 9px;font-size:11px;margin-left:auto}main{display:grid;grid-template-columns:230px minmax(0,1fr) 260px;gap:16px;padding:4px 24px 24px;max-width:1800px;margin:auto;height:calc(100vh - 140px);min-height:580px}.panel{border:1px solid var(--line);border-radius:14px;background:var(--panel);min-width:0;overflow:hidden}.panel-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:22px 18px}.panel h2{font-size:14px;margin:0}.sessions{display:flex;flex-direction:column}.sessions nav{overflow:auto;padding:0 10px;flex:1}.session{display:block;width:100%;background:transparent;color:var(--muted);text-align:left;border:1px solid transparent;padding:13px 10px;margin-bottom:5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:400}.session.active{background:#21364e;border-color:#3a526c;color:#fff}.aside-note{color:#7689a2;padding:18px;font-size:11px;line-height:1.9;border-top:1px solid var(--line);margin:0}.conversation{display:flex;flex-direction:column;position:relative;background:linear-gradient(160deg,#15253a,#101b2b)}.conversation-head{display:flex;justify-content:space-between;align-items:center;padding:24px 26px 16px;gap:10px}.eyebrow{color:#93abc5;letter-spacing:2px;font-size:10px;margin:0 0 9px}h1{font-size:20px;font-weight:550;margin:0;overflow-wrap:anywhere}.engine-line{padding:0 26px 16px;color:var(--muted);display:flex;gap:9px;align-items:center;font-size:12px;border-bottom:1px solid var(--line)}.dot{height:6px;width:6px;flex-shrink:0;background:#bba77f;border-radius:50%}.dot.ready{background:#8dbda9}.messages{padding:20px 26px;overflow:auto;min-height:0;flex:1;scroll-behavior:smooth}.messages:empty{display:none}.message{margin-bottom:24px;overflow-wrap:anywhere}.message .role{display:block;font-size:11px;color:#a0b5ce;margin-bottom:8px;letter-spacing:1px}.message .body{white-space:pre-wrap;line-height:1.85;font-size:14px}.message.user .body{background:#22374f;border:1px solid #334b67;padding:14px 16px;border-radius:10px}.message details{border:1px solid var(--line);border-radius:7px;margin-top:10px;padding:12px;color:var(--muted);font-size:12px}.message pre{white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.6}summary{cursor:pointer}.empty{margin:auto;text-align:center;padding:30px 25px;max-width:650px;width:100%}.empty-icon{font-size:40px;color:#aec4df;display:block;margin-bottom:22px}.empty h2{font-size:23px;font-weight:500}.empty p{color:var(--muted);line-height:1.8;font-size:12px}.examples{display:flex;gap:10px;margin-top:30px}.examples button{flex:1;min-width:0;text-align:left;background:#192d44;color:#d7e3ef;border-color:#334b65;font-size:12px;padding:14px 12px;white-space:nowrap}.examples span{color:#819bb7;float:right;margin-left:8px}#composer{margin:0 20px;border:1px solid #415873;border-radius:12px;background:#0e1a2b;overflow:hidden}textarea{display:block;width:100%;resize:vertical;min-height:90px;max-height:240px;background:transparent;border:0;padding:16px;color:var(--text);font:inherit;line-height:1.6;outline:none}textarea:focus{box-shadow:inset 0 0 0 1px #809dbd;border-radius:10px}textarea::placeholder{color:#71869f}.composer-actions{display:flex;align-items:center;gap:10px;padding:0 12px 12px}.upload-button{color:#b6c9de;font-size:12px;cursor:pointer;white-space:nowrap}#taskStatus{font-size:11px;color:var(--muted);margin-left:auto;overflow-wrap:anywhere}.footnote{font-size:10px;color:#8295ad;text-align:center;padding:0 14px;margin:12px 0 18px}.file-hint{font-size:11px;color:var(--muted);line-height:1.9;padding:0 18px;margin:0 0 18px}.files{display:flex;flex-direction:column}#fileList{padding:0 12px;overflow:auto;flex:1}.file{padding:14px 8px;border-top:1px solid var(--line);display:flex;gap:10px;align-items:center}.file div{min-width:0;flex:1}.file span{display:block;font-size:12px;overflow-wrap:anywhere}.file small{display:block;color:var(--muted);font-size:10px;margin-top:6px}.file button{padding:5px 7px;font-size:11px;flex-shrink:0}.doc-push-box{border-top:1px solid var(--line);margin-top:10px}.doc-push-box .panel-head{padding:14px 18px 8px}.doc-push-box .file-hint{margin-bottom:8px}#docPushList{padding:0 12px 10px;max-height:180px;overflow:auto}.doc-push{display:flex;justify-content:space-between;gap:8px;align-items:baseline;padding:8px 6px;border-top:1px solid var(--line);font-size:11px}.doc-push span:first-child{overflow-wrap:anywhere}.push-status{color:var(--muted);white-space:nowrap;flex-shrink:0}.doc-push-box .doc-push:not(.failed) .push-status{color:#8dbda9}.doc-push.failed .push-status{color:#c98d8d}.workspace-card{margin:16px;border:1px solid var(--line);border-radius:9px;padding:14px;color:var(--muted);font-size:11px;line-height:1.9}.workspace-card span{color:#c7d6e6}.workspace-card p{margin:6px 0 0}.banner{padding:14px 24px;background:#273d54;color:#e1eaf6;overflow-wrap:anywhere}.error{background:#3b2830;display:flex;gap:15px;align-items:center;justify-content:space-between}.banner[hidden],[hidden]{display:none!important}.permissions{max-height:180px;overflow:auto;margin:0 20px}.permission{border:1px solid #7d704f;background:#302f28;border-radius:9px;padding:12px;margin-bottom:10px;font-size:12px;overflow-wrap:anywhere}.permission p{white-space:pre-wrap}.permission button{margin-right:8px;font-size:12px}dialog{max-width:500px;width:calc(100% - 32px);background:#15263b;border:1px solid #506883;color:var(--text);border-radius:15px;padding:25px;line-height:1.9}dialog::backdrop{background:#030911b8}dialog p{color:#b4c4d7;font-size:13px}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0)}:focus-visible{outline:2px solid #afc9e7;outline-offset:3px}@media(min-width:1550px){main{grid-template-columns:260px minmax(0,1fr) 290px}}@media(max-width:1150px){main{grid-template-columns:190px minmax(0,1fr)}.files{grid-column:1/-1;min-height:200px}main{height:auto;min-height:0}.conversation,.sessions{height:calc(100vh - 165px);min-height:580px}.files #fileList{max-height:250px}.workspace-card{display:none}}@media(max-width:650px){header{height:75px;padding:0 15px}header>a:last-child{font-size:11px}.brand{font-size:17px;gap:9px}.brand small{font-size:8px;letter-spacing:1px}.mark{width:32px;height:36px;font-size:24px}.notice{padding:10px 15px;gap:7px;line-height:1.8;font-size:10px}.notice button{margin-left:0}main{display:flex;flex-direction:column;padding:0 10px 14px;gap:10px}.sessions{height:auto;min-height:0;flex-shrink:0}.sessions .panel-head{padding:11px 12px}.panel-head button{padding:6px 10px;font-size:12px}.sessions nav{display:flex;flex-direction:column;gap:0;overflow-y:auto;max-height:220px;padding:0 10px 8px}.session{width:100%;max-width:none;flex-shrink:0;margin:0 0 5px;padding:10px;font-size:12px}.aside-note{display:none}.conversation{height:720px;min-height:620px}.conversation-head{padding:18px 16px 12px}h1{font-size:17px}.engine-line{padding:0 16px 12px;font-size:11px}.messages{padding:18px 15px}.empty{padding:25px 15px}.empty h2{font-size:20px}.empty p{font-size:11px}.examples{gap:6px;margin-top:23px}.examples button{font-size:11px;padding:12px 8px}.examples span{display:none}#composer{margin:0 10px}.composer-actions{gap:7px;padding:0 10px 10px}.composer-actions button{padding:8px 10px;font-size:12px}#taskStatus{font-size:10px}.permissions{margin:0 10px}.banner{padding:12px 15px;font-size:12px}.file-hint{margin-bottom:10px}.files{min-height:180px}.footnote{font-size:9px}}
[hidden] { display:none !important; }
.ops-tabs { display:flex; gap:8px; padding:12px 24px; flex-wrap:wrap; }
.ops-tabs [aria-pressed="true"] { background:#dce9e3; color:#173e31; }
.ops-view { margin:16px auto; padding:24px; max-width:1000px; overflow-wrap:anywhere; }
.ops-view article { padding:12px 0; border-bottom:1px solid #ddd; }
.ops-view textarea { width:100%; min-height:100px; box-sizing:border-box; }
.ops-view label { display:block; margin:12px 0; }
.ops-view button { margin:8px 8px 8px 0; }
@media(max-width:600px) { .ops-view { margin:8px; padding:16px; } .ops-tabs { padding:8px; } }

/* ---- v2: stats bar / todo / diff / agent toggle / streaming ---- */
.stats-bar { display:flex; gap:14px; flex-wrap:wrap; padding:6px 18px; font-size:11px; color:var(--muted); border-bottom:1px solid var(--line); min-height:24px; }
.stats-line, .diff-line { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.diff-line { color:#8fd3a8; }
.todo-box { margin:10px 18px; border:1px solid var(--line); border-radius:10px; padding:10px 14px; background:rgba(255,255,255,.02); max-height:220px; overflow:auto; }
.todo-box h3 { margin:0 0 8px; font-size:12px; color:var(--muted); letter-spacing:1px; }
.todo-row { display:flex; gap:8px; padding:3px 0; font-size:13px; align-items:baseline; }
.todo-row.done .todo-text { color:var(--muted); text-decoration:line-through; }
.todo-row.doing .todo-mark { color:#7fc7ff; }
.todo-mark { width:14px; flex:none; }
.todo-text { flex:1; overflow-wrap:anywhere; }
.diff-box { margin:10px 18px; border:1px solid var(--line); border-radius:10px; padding:10px 14px; background:rgba(0,0,0,.25); max-height:260px; overflow:auto; }
.diff-box h3 { margin:0 0 8px; font-size:12px; color:var(--muted); letter-spacing:1px; }
.diff-pre { margin:0; font:11px/1.5 ui-monospace,Menlo,Consolas,monospace; white-space:pre; }
.diff-file { color:var(--accent); padding:4px 0 2px; }
.diff-line.add { color:#7ee2a0; } .diff-line.del { color:#ff9b9b; }
.message.streaming .text::after { content:'▊'; animation:blink 1s steps(2) infinite; color:var(--accent); }
@keyframes blink { 50% { opacity:0; } }
.head-actions { display:flex; gap:6px; align-items:center; flex-wrap:wrap; justify-content:flex-end; }
.agent-toggle { display:inline-flex; border:1px solid var(--line); border-radius:8px; overflow:hidden; }
.agent-toggle .toggle { border:none; border-radius:0; padding:5px 10px; font-size:12px; }
.agent-toggle .toggle.on { background:var(--accent); color:#11243a; }
.composer-actions { flex-wrap:wrap; }

/* ---- v0.4.3: permission tiers card + file preview ---- */
.perm-card { border:1px solid var(--line); border-radius:10px; padding:12px 16px; margin:10px 0; background:rgba(255,255,255,.02); }
.perm-card h3 { margin:0 0 6px; font-size:13px; }
.perm-tiers { display:flex; gap:8px; flex-wrap:wrap; margin-top:8px; }
.perm-tiers .tier { border:1px solid var(--line); background:transparent; color:var(--muted); padding:7px 12px; font-size:12px; border-radius:8px; }
.perm-tiers .tier.on { background:var(--accent); color:#11243a; border-color:var(--accent); }
.perm-tiers .tier:disabled { opacity:.35; }
#preview { width:min(720px,92vw); max-height:84vh; border:1px solid var(--line); border-radius:12px; background:var(--panel); color:var(--text); padding:0; }
#preview::backdrop { background:rgba(4,10,18,.7); }
.preview-head { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:12px 16px; border-bottom:1px solid var(--line); font-size:13px; overflow-wrap:anywhere; }
#previewBody { padding:12px 16px; overflow:auto; max-height:calc(84vh - 58px); font-size:13px; }
#previewBody pre { margin:0; white-space:pre-wrap; overflow-wrap:anywhere; font:12px/1.6 ui-monospace,Menlo,Consolas,monospace; }
#previewBody img { max-width:100%; border-radius:8px; }
.file a.previewable { cursor:pointer; }

/* ---- v0.4.4: right-panel tabs (files | skills & capabilities) ---- */
.files-tabs { display:flex; gap:6px; margin:8px 0 10px; }
.ftab { border:1px solid var(--line); background:transparent; color:var(--muted); padding:5px 10px; font-size:12px; border-radius:8px; }
.ftab.on { background:var(--accent); color:#11243a; border-color:var(--accent); }
/* v0.4.8c: browser observation tab */
.browser-status { font-size:12px; color:var(--muted); margin:2px 0 6px; }
.browser-status.on { color:#3fb96f; }
.browser-tabs { display:flex; gap:6px; margin:2px 0 8px; }
.bact-badge { display:inline-block; min-width:16px; padding:0 4px; margin-left:4px; border-radius:8px; background:var(--accent); color:#11243a; font-size:10px; font-weight:700; line-height:15px; text-align:center; }
.browser-addr { display:flex; gap:6px; margin:2px 0 6px; }
.browser-addr input { flex:1; min-width:0; padding:7px 10px; border:1px solid var(--line); border-radius:6px; background:var(--card); color:inherit; font:inherit; font-size:13px; }
.browser-addr button { flex:none; }
.browser-frame { position:relative; border:1px solid var(--line); border-radius:8px; overflow:hidden; background:#0d1622; min-height:60px; display:flex; align-items:center; justify-content:center; }
.browser-frame img { display:block; width:100%; height:auto; }
.browser-idle { color:#5a6b80; font-size:12px; padding:18px 8px; text-align:center; }
.browser-url { margin-top:6px; word-break:break-all; min-height:14px; }
.browser-log { font-size:12px; max-height:150px; overflow:auto; }
.browser-log .bl-row { display:flex; gap:8px; padding:3px 2px; border-bottom:1px dashed rgba(255,255,255,.06); }
.browser-log .bl-t { color:#5a6b80; flex:none; }
.browser-log .bl-c { color:var(--muted); flex:none; font-weight:600; }
.browser-log .bl-a { color:var(--fg); word-break:break-all; }
.skill-row { padding:8px 2px; border-bottom:1px solid var(--line); }
.skill-row:last-child { border-bottom:none; }
.skill-row a { color:var(--text); font-size:12px; font-weight:600; text-decoration:none; overflow-wrap:anywhere; }
.skill-row a:hover { text-decoration:underline; }
.skill-desc { color:var(--muted); font-size:11px; line-height:1.5; margin-top:3px; }
.cap-head { display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.cap-head strong { font-size:12px; }
.cap-tag { border:1px solid var(--line); border-radius:6px; padding:1px 6px; font-size:10px; color:var(--muted); }
/* v0.4.5: panes own the scroll (v0.4.4 wrapper broke #fileList's flex chain) */
#filesPane, #skillsPane { flex:1; min-height:0; overflow:auto; }
#filesPane #fileList { overflow:visible; }
@media(max-width:1150px){ #filesPane,#skillsPane{flex:none;max-height:300px;} #filesPane #fileList{max-height:none;} }
@media(max-width:650px){ #filesPane,#skillsPane{max-height:260px;} }

/* ---- v0.4.6: vertical view rail (was top tabs) + interaction fixes ---- */
#shell { display:flex; gap:14px; align-items:stretch; padding:0 18px 18px; flex:1; min-height:0; }
nav.tabs { display:flex; flex-direction:column; gap:4px; width:132px; flex:none; align-self:stretch; padding:10px 8px; border:1px solid var(--line); border-radius:12px; background:var(--panel); margin:0; }
nav.tabs .panel-head { padding:0 6px 6px; border-bottom:1px solid var(--line); margin-bottom:6px; }
nav.tabs .panel-head h2 { margin:0; font-size:11px; letter-spacing:1px; color:var(--muted); text-transform:uppercase; }
nav.tabs button { display:block; width:100%; text-align:left; padding:8px 10px; font-size:13px; border:1px solid transparent; background:transparent; color:var(--text); border-radius:8px; }
nav.tabs button:hover { background:rgba(255,255,255,.05); }
nav.tabs button[aria-pressed="true"] { background:var(--accent); color:#11243a; border-color:var(--accent); font-weight:600; }
nav.tabs .rail-note { margin-top:auto; padding:8px 6px 2px; font-size:10px; line-height:1.7; color:var(--muted); border-top:1px solid var(--line); }
#views { flex:1; min-width:0; display:flex; flex-direction:column; }
#views > section.panel.view { margin:0; flex:1; min-height:0; overflow:auto; }
#chatView { flex:1; min-height:0; display:flex; flex-direction:column; }
#chatView > main { flex:1; min-height:0; }
@media(max-width:900px) {
  #shell { flex-direction:column; padding:0 10px 10px; }
  nav.tabs { width:auto; flex-direction:row; flex-wrap:wrap; align-items:center; }
  nav.tabs button { width:auto; }
  nav.tabs .rail-note { display:none; }
  #views > section.panel.view { overflow:visible; }
}
/* expired sessions visually distinct */
#sessionList button.expired { opacity:.45; }
#sessionList button.expired::after { content:"（已过期）"; font-size:10px; }
/* textarea auto-grow cap */
#draft { max-height:140px; }
/* ---- v0.4.8: height chain fix (right-pane scroll lost + workspace shrink on new session) ----
   #shell needs a bounded height for its flex:1 to mean anything. body was a plain block,
   so #shell/#views/#chatView/main collapsed to content height: file list stretched the grid
   row (page grew, no inner scroll) and short content shrank the whole workspace. */
html, body { height:100%; }
body { display:flex; flex-direction:column; }
#shell { min-height:540px; }
/* grid row must be pinned, else auto row still stretches to content height */
#chatView > main { grid-template-rows: minmax(0, 1fr); }
#views { min-height:0; }
/* JS toggles .dot.on/.dot.off but CSS only had .dot.ready — status dot never turned green */
.dot.on { background:#8dbda9; }
/* right column scrolls as one: static boxes below (doc-push/preview/workspace-card) were
   squeezing #filesPane to a ~43px strip; let the aside scroll and panes take natural height */
aside.files { overflow:auto; }
aside.files #filesPane, aside.files #skillsPane { flex:none; overflow:visible; }
/* narrow layout: aside is content-height row again — restore per-pane scroll caps */
@media(max-width:1150px) {
  aside.files { overflow:visible; }
  aside.files #filesPane, aside.files #skillsPane { overflow:auto; max-height:300px; }
}
/* v0.4.8b: width chain — inside #chatView (flex column) the cross-axis
   margin:auto on main cancels the default stretch: main shrank to fit-content
   and centered (new/empty sessions looked "squeezed in from both sides";
   long messages masked it). Pin width:100% so stretching is explicit and
   max-width:1800px + auto-centering only engage on ultra-wide, matching the
   original block-layout intent. box-sizing:border-box keeps padding safe. */
#chatView > main { width:100%; }

/* ---- v0.4.8d: standalone browser panel, Hermes-style split ----
   #stage wraps #shell + #browserPanel. Browser gets a fixed generous slice
   (clamp 480–820px ≈ the conversation column's width — the Hermes "right
   preview as big as the chat" feel), shell keeps the rest. While open,
   body.browser-open compacts the chat grid side columns (190/230) so the
   conversation keeps usable width. Below 1400px the stage stacks: browser
   panel goes under the chat instead of crushing the 3-column grid. */
#stage { flex:1; min-height:540px; display:flex; gap:14px; padding:0 18px 18px; }
#shell { flex:1 1 auto; min-width:0; padding:0; }
#browserPanel { position:relative; flex:0 0 clamp(480px, 46%, 1040px); min-width:0; display:flex; flex-direction:column; gap:10px; padding:14px; overflow:hidden; }
#browserPanel.dragging { user-select:none; }
#browserPanel.dragging .browser-frame img { pointer-events:none; }
#browserDrag { position:absolute; left:-8px; top:0; bottom:0; width:8px; cursor:col-resize; }
#browserDrag::after { content:''; position:absolute; left:3px; top:28%; bottom:28%; width:2px; border-radius:2px; background:var(--line); }
#browserDrag:hover::after, #browserPanel.dragging #browserDrag::after { background:var(--accent); }
#browserPanel .panel-head { padding:0 2px; }
#browserToggle.on { background:var(--accent); color:#11243a; border-color:var(--accent); }
/* v0.4.8f: page pane fills the panel height; the frame grows with it so the
   screenshot (object-fit:contain) uses the full panel instead of a short strip */
.bpane-page { flex:1 1 auto; min-height:360px; display:flex; flex-direction:column; }
#browserPanel .browser-frame { flex:1 1 auto; min-height:0; }
.browser-frame img { width:100%; height:100%; object-fit:contain; }
#browserPanel .browser-url { flex:none; }
.browser-clickhint { position:absolute; left:8px; bottom:8px; padding:3px 8px; border-radius:6px; background:rgba(13,22,34,.78); color:#9fb3c8; font-size:11px; pointer-events:none; }
#browserPanel .browser-log { flex:1 1 auto; min-height:0; max-height:none; overflow:auto; }
@media(min-width:1536px){
  body.browser-open #chatView main { grid-template-columns:190px minmax(0,1fr) 230px; }
}
@media(max-width:1535px){
  #stage { flex-direction:column; }
  #browserPanel { flex:none; max-height:64vh; }
  #browserPanel .browser-log { flex:none; max-height:160px; }
}
/* v0.4.7 服务预览 */
.preview-controls { display:flex; gap:6px; margin:8px 0 4px; }
.preview-controls input { flex:1; min-width:0; padding:6px 8px; border:1px solid var(--line); border-radius:6px; background:var(--card); color:inherit; font:inherit; }
.preview-url { margin-top:4px; }
.preview-url a { color:var(--accent); text-decoration:none; }
.preview-url a:hover { text-decoration:underline; }

/* v0.4.8h: live iframe tab + type row */
.browser-type-row { display:flex; gap:6px; margin:6px 0; flex:none; }
.browser-type-row input { flex:1 1 auto; min-width:0; padding:7px 10px; border:1px solid var(--line); border-radius:6px; background:var(--card); color:inherit; font:inherit; font-size:13px; }

.browser-type-row select { flex:none; }
.bpane-live { flex:1 1 auto; min-height:360px; display:flex; flex-direction:column; gap:6px; }
.browser-live { flex:1 1 auto; min-height:0; width:100%; border:1px solid var(--line); border-radius:8px; background:#0d1622; }
.browser-live-hint { flex:none; margin:0; }
/* v0.4.8i: laptop & short-screen adaptation (2026-11-24)
   The 1151–1399 band had no rules: desktop columns (230 sessions / 260 files
   / 132 rail / 24px paddings) left the conversation ~530-620px on laptops,
   and on 768p laptop screens the hard floors (main 580 / shell 540 /
   conversation 580) exceeded the viewport, stacking page scroll on top of
   pane scroll. All changes below are additive. */

/* laptop band: slim the fixed columns and paddings so the conversation wins width */
@media(min-width:1151px) and (max-width:1535px){
  main{ grid-template-columns:200px minmax(0,1fr) 232px; gap:12px; padding:4px 16px 16px; }
  #shell{ gap:12px; padding:0 16px 16px; }
  #stage{ gap:12px; padding:0 16px 16px; }
  nav.tabs{ width:110px; padding:8px 6px; }
  nav.tabs button{ padding:7px 8px; font-size:12px; }
  .conversation-head{ padding:16px 18px 12px; flex-wrap:wrap; }
  .head-actions{ margin-left:auto; }
  .head-actions button, .agent-toggle button{ padding:6px 10px; font-size:12px; }
  .engine-line{ padding:0 18px 12px; }
  .messages{ padding:16px 18px; }
}

/* keep the vertical rail slim just above the horizontal-rail breakpoint */
@media(min-width:901px) and (max-width:1150px){
  nav.tabs{ width:104px; }
}

/* short screens (768p laptops): viewport-fit heights — inner panes scroll, page doesn't */
@media(max-height:820px){
  main{ height:calc(100vh - 128px); min-height:440px; }
  #shell,#stage{ min-height:440px; }
  textarea{ min-height:64px; }
  .footnote{ margin:6px 0 10px; }
}
@media(max-width:1150px) and (max-height:820px){
  .conversation,.sessions{ height:max(420px, calc(100vh - 158px)); min-height:0; }
}

/* stacked browser panel (≤1399): 360px pane floor exceeded the panel's own
   max-height and clipped the log — scale both together */
@media(max-width:1535px){
  #browserPanel{ max-height:70vh; }
  .bpane-page, .bpane-live{ min-height:280px; }
}

/* very narrow: wrap the header instead of overflowing */
@media(max-width:900px){
  header{ flex-wrap:wrap; height:auto; min-height:75px; padding:10px 15px; row-gap:6px; }
}

/* ---- v0.4.8j: laptop layout — rail sub-sessions, browser focus mode, compact composer ---- */
/* C. compact composer (all widths): the draft box was ~105px tall empty */
textarea { min-height:60px; padding:10px 14px; line-height:1.5; }
.composer-actions { padding:6px 10px; gap:6px; }
.composer-actions button, .composer-actions .upload-button { padding:5px 10px; font-size:12px; }
.conversation-head { padding:16px 20px 10px; }
.conversation-head h1 { font-size:18px; }
.engine-line { padding:4px 20px; }

/* B. rail sub-list under "对话" (hidden until the chat view is active; JS flips `hidden`) */
.rail-sessions { display:flex; flex-direction:column; gap:2px; margin:2px 0 4px; min-height:0; }
.rail-sessions[hidden] { display:none; }
.rail-sub-head { display:flex; align-items:center; justify-content:space-between; padding:2px 10px 2px 14px; font-size:10px; letter-spacing:1px; color:var(--muted); text-transform:uppercase; }
.rail-sub-head button { padding:0 6px; font-size:13px; line-height:16px; border:0; background:transparent; color:var(--muted); }
.rail-sub-head button:hover { color:var(--text); background:transparent; }
#railSessionList { display:flex; flex-direction:column; gap:2px; overflow:auto; min-height:0; max-height:32vh; }
#railSessionList button.session { font-size:12px; padding:5px 8px 5px 16px; color:var(--muted); font-weight:400; border-radius:6px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#railSessionList button.session:hover { background:rgba(255,255,255,.05); color:var(--text); }
#railSessionList button.session.active { background:rgba(201,221,244,.14); color:var(--accent); border-color:transparent; font-weight:600; }
#railSessionList button.session.expired { opacity:.45; }
@media (min-width:901px) and (max-width:1535px) {
  nav.tabs { width:196px; }
  nav.tabs .rail-note { display:none; }
}
@media (max-width:900px) {
  .rail-sessions { display:none !important; }
}

/* A. laptop (<=1399px) normal mode: drop the middle session column — sessions live in the rail now */
@media (min-width:901px) and (max-width:1535px) {
  main { grid-template-columns: minmax(0,1fr) 300px; }
  aside.sessions { display:none; }
}

/* A. laptop browser mode: focus mode — only the conversation + the browser, side by side */
@media (min-width:901px) and (max-width:1535px) {
  body.browser-open #stage { flex-direction:row; }
  body.browser-open #shell { flex:1 1 0; }
  body.browser-open nav.tabs { display:none; }
  body.browser-open #chatView main { grid-template-columns:minmax(0,1fr); }
  body.browser-open aside.sessions, body.browser-open aside.files { display:none; }
  body.browser-open .notice { display:none; }
  body.browser-open #browserPanel { flex:0 0 54%; max-height:none; min-height:0; }
  body.browser-open #browserPanel .bpane-page, body.browser-open #browserPanel .bpane-live { min-height:0; }
  body.browser-open #browserPanel .browser-log { max-height:none; }
  body.browser-open #shell, body.browser-open #stage { min-height:440px; }
  body.browser-open main { height:calc(100vh - 112px); min-height:440px; }
}
/* the "☰ 文件" entry is only meaningful in focus mode */
#railFilesBtn { display:none; }
@media (min-width:901px) and (max-width:1535px) {
  body.browser-open #railFilesBtn { display:inline-block; }
  body.browser-open aside.files.as-drawer { display:flex; position:fixed; top:76px; right:16px; bottom:16px; width:min(420px,42vw); z-index:40; box-shadow:-12px 0 40px rgba(0,0,0,.55); background:var(--panel); }
}
/* ---- end v0.4.8j ---- */

/* ===== v0.4.8k3 — laptop focus layout (2026-11-25) =====
   Measured on the user's laptop (1432x768): v0.4.8j never fired because its band ended at 1399px.
   Scope (user-circled, 2026-11-25):
     browser mode  -> ONLY the conversation and the browser remain (all widths >= 901px).
                      rail / session column / files column are hidden; "☰ 文件" opens files as an overlay.
     normal mode   -> 901-1535px: the session column folds into the left rail under "对话";
                      files column 232px; conversation takes the rest.
     composer      -> shorter draft box.
   Header, top notice band and conversation eyebrow keep the v0.4.8j geometry at every width. */

/* ---- browser focus mode: all widths >= 901px ---- */
@media (min-width:901px) {
  body.browser-open #stage { flex-direction:row; padding:0 10px 10px; }
  body.browser-open #shell { flex:1 1 0; min-width:0; padding:0; gap:0; }
  body.browser-open nav.tabs { display:none; }
  body.browser-open #chatView main { grid-template-columns:minmax(0,1fr); gap:0; padding:0; }
  body.browser-open aside.sessions, body.browser-open aside.files { display:none; }
  body.browser-open .notice { display:none; }
  body.browser-open #browserPanel { flex:0 0 46%; max-height:none; min-height:0; }
  body.browser-open #browserPanel .bpane-page, body.browser-open #browserPanel .bpane-live { min-height:0; }
  body.browser-open #browserPanel .browser-log { max-height:none; }
  body.browser-open #shell, body.browser-open #stage { min-height:440px; }
}
/* the "☰ 文件" entry is only meaningful in focus mode */
#railFilesBtn { display:none; }
@media (min-width:901px) {
  body.browser-open #railFilesBtn { display:inline-block; }
  body.browser-open aside.files.as-drawer { display:flex; position:fixed; top:76px; right:16px; bottom:16px; width:min(420px,42vw); z-index:40; box-shadow:-12px 0 40px rgba(0,0,0,.55); background:var(--panel); }
}

/* ---- normal mode, laptop band 1151-1535px ----
   (901-1150px keeps the v0.4.8i stacked layout untouched: files span the full row under the conversation) */
@media (min-width:1151px) and (max-width:1535px) {
  nav.tabs { width:150px; }
  body:not(.browser-open) aside.sessions { display:none; }
  body:not(.browser-open) #chatView main { grid-template-columns:minmax(0,1fr) 232px; gap:10px; padding:0; }
  body:not(.browser-open) aside.files { width:auto; overflow:auto; grid-column:auto; }
  body:not(.browser-open) aside.files #filesPane, body:not(.browser-open) aside.files #skillsPane { flex:none; overflow:visible; max-height:none; }
  body:not(.browser-open) #shell { flex:1 1 0; min-width:0; padding:0; gap:0; }
  body:not(.browser-open) #stage { padding:0 10px 10px; }

  /* composer: shorter draft box */
  #composer { margin:0 14px 10px; }
  .composer-actions { flex-wrap:nowrap; padding:0 10px 8px; gap:6px; }
  .composer-actions button.quiet, .composer-actions .upload-button { padding:3px 8px; font-size:12px; }
}
/* 901-1150px normal mode: same composer compaction only; layout stays as v0.4.8i */
@media (min-width:901px) and (max-width:1150px) {
  #composer { margin:0 14px 10px; }
  .composer-actions { flex-wrap:nowrap; padding:0 10px 8px; gap:6px; }
  .composer-actions button.quiet, .composer-actions .upload-button { padding:3px 8px; font-size:12px; }
}
/* ---- end v0.4.8k3 ---- */


/* ---- v0.4.8k4: (1) narrower rail so session titles never compete with the conversation,
                   (2) composer draft is user-resizable (JS: autoGrowDraft keeps the user's height) ---- */
/* (1) laptop band, normal mode: rail 150 -> 124px, session titles 12 -> 11.5px.
       Long titles still ellipsize (they can never widen the rail: width is fixed + overflow hidden),
       and the full title is a hover tooltip (btn.title, existing JS). */
@media (min-width:1151px) and (max-width:1535px) {
  nav.tabs { width:124px; padding:8px 6px; }
  nav.tabs > button[data-view] { padding:7px 8px; font-size:12.5px; }
  nav.tabs .panel-head { padding:0 4px 6px; }
  nav.tabs .panel-head h2 { font-size:10.5px; }
  .rail-sub-head { padding:2px 6px 2px 10px; }
  #railSessionList button.session { font-size:11.5px; padding:5px 6px 5px 11px; }
}
/* (2) all widths: draft box limits. min = half of the current 60px default, max = 1.5x the current 140px cap. */
textarea#draft { min-height:30px; max-height:210px; }
