:root {
  --bg: #0b0b0c;
  --bg-2: #111113;
  --bg-3: #18181b;
  --bg-4: #222226;
  --line: #26262b;
  --line-2: #333339;
  --text: #ececf1;
  --text-2: #b4b4bd;
  --muted: #7d7d88;
  --accent: #8ab4ff;
  --accent-2: #5b8def;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --blue: #60a5fa;
  --yellow: #eab308;
  --radius: 14px;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.6 var(--sans); }
body { overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
code, pre, kbd { font-family: var(--mono); font-size: 0.88em; }
::selection { background: #3b4a6b; }
* { scrollbar-width: thin; scrollbar-color: #2e2e35 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a2a30; border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }

/* ------------------------------------------------------------ buttons & inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--bg-3); color: var(--text); cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--bg-4); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--text); color: #0b0b0c; border-color: var(--text); font-weight: 600; }
.btn.primary:hover { background: #fff; }
.btn.danger { color: #fca5a5; border-color: #5b2323; background: #1f1214; }
.btn.danger:hover { background: #2a1517; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--bg-3); color: var(--text); }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid transparent; background: transparent;
  color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 17px;
}
.icon-btn:hover { background: var(--bg-3); color: var(--text); }

.input, select.input, textarea.input {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--bg-2); outline: none; transition: border-color .15s;
}
textarea.input { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: #4b5568; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
label.field small { display: block; color: var(--muted); font-size: 12px; margin-top: 5px; }
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; cursor: pointer; color: var(--text-2); }
.seg button.on { background: var(--bg-4); color: var(--text); }
.seg button:disabled { opacity: .4; cursor: not-allowed; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }

/* ------------------------------------------------------------ login */
.login-wrap { height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; }
.login-card .logo { font-size: 30px; font-weight: 700; letter-spacing: -.5px; margin-bottom: 4px; }
.login-card .logo span { color: var(--muted); font-weight: 400; }
.login-card p { color: var(--muted); margin: 0 0 26px; }
.login-card .btn { width: 100%; height: 42px; margin-top: 6px; }
.login-err { color: #fca5a5; min-height: 22px; font-size: 14px; margin-top: 10px; }

/* ------------------------------------------------------------ layout */
.layout { display: grid; grid-template-columns: 270px 1fr; height: 100%; height: 100dvh; }
.layout.with-board { grid-template-columns: 270px 1fr 330px; }
.sidebar { background: var(--bg-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.board { background: var(--bg-2); border-left: 1px solid var(--line); display: none; flex-direction: column; min-height: 0; }
.layout.with-board .board { display: flex; }
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }

.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 10px; font-weight: 700; font-size: 17px; letter-spacing: -.2px; }
.brand .star { font-size: 20px; }
.brand .host { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: auto; }
.viewing { padding: 0 12px 6px; }
.viewing select { height: 30px; font-size: 13px; }

.side-scroll { flex: 1; overflow-y: auto; padding: 4px 8px 12px; min-height: 0; }
.side-title { display: flex; align-items: center; justify-content: space-between; padding: 14px 8px 6px; color: var(--muted); font-size: 12px; letter-spacing: .5px; }
.side-title .icon-btn { width: 26px; height: 26px; font-size: 16px; }
.owner-title { padding: 12px 8px 4px; font-size: 12px; color: var(--accent); }

.agent-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; cursor: pointer;
  position: relative; user-select: none;
}
.agent-item:hover { background: var(--bg-3); }
.agent-item.active { background: var(--bg-4); }
.agent-item.secretary { border: 1px solid var(--line-2); margin: 4px 0; padding: 10px; background: linear-gradient(135deg, #17171c, #121216); }
.agent-item.secretary.active { border-color: #3d4660; background: linear-gradient(135deg, #1d2130, #15161c); }
.agent-item .avatar { width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; background: var(--bg-4); font-size: 15px; flex: none; position: relative; }
.agent-item.secretary .avatar { background: #2a3350; }
.agent-item .avatar .dot { position: absolute; right: -2px; bottom: -2px; border: 2px solid var(--bg-2); }
.agent-item .meta { min-width: 0; flex: 1; }
.agent-item .name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-item .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-item .pill { font-size: 11px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bg-4); color: var(--text-2); display: flex; align-items: center; justify-content: center; }
.agent-item .pill.warn { background: #3d2a0b; color: #fcd34d; }
.agent-item .pill.new { background: var(--accent-2); color: #fff; width: 8px; min-width: 8px; height: 8px; padding: 0; }
details.archived { margin-top: 8px; }
details.archived summary { cursor: pointer; color: var(--muted); font-size: 12px; padding: 8px; list-style: none; }
details.archived summary::-webkit-details-marker { display: none; }
details.archived .agent-item { opacity: .6; }

.dot { width: 9px; height: 9px; border-radius: 50%; background: #55555f; flex: none; display: inline-block; }
.dot.running { background: var(--green); box-shadow: 0 0 0 0 rgba(34, 197, 94, .6); animation: pulse 1.6s infinite; }
.dot.starting { background: var(--yellow); animation: pulse 1.6s infinite; }
.dot.waiting { background: var(--amber); animation: pulse 1s infinite; }
.dot.queued { background: var(--blue); }
.dot.error { background: var(--red); }
.dot.sleep { background: #3a3a42; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,.25); } 70% { box-shadow: 0 0 0 6px rgba(255,255,255,0); } 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); } }

.side-foot { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; align-items: center; gap: 8px; }
.side-foot .who { flex: 1; min-width: 0; font-size: 13px; }
.side-foot .who b { display: block; font-weight: 600; }
.side-foot .who span { color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------ chat header */
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); min-height: 58px; background: rgba(11,11,12,.85); backdrop-filter: blur(8px); }
.chat-head .title { font-weight: 650; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; min-width: 0; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--text-2); white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.tag.host { border-color: #3b4a6b; color: #a9c1ff; }
.tag.sandbox { border-color: #2f5140; color: #8fe0b0; }
.tag.cwd { font-family: var(--mono); font-size: 11px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.menu-btn { display: none; }

/* ------------------------------------------------------------ messages */
.messages { flex: 1; overflow-y: auto; min-height: 0; scroll-behavior: auto; }
.messages-inner { max-width: 860px; margin: 0 auto; padding: 22px 20px 30px; }
.load-more { display: block; margin: 0 auto 16px; }
.empty-chat { text-align: center; color: var(--muted); padding: 12vh 20px 0; }
.empty-chat .big { font-size: 26px; color: var(--text); font-weight: 650; margin-bottom: 8px; letter-spacing: -.3px; }
.empty-chat .hints { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 22px; }
.empty-chat .hints button { border: 1px solid var(--line-2); background: var(--bg-2); border-radius: 999px; padding: 7px 14px; cursor: pointer; color: var(--text-2); font-size: 13px; }
.empty-chat .hints button:hover { color: var(--text); background: var(--bg-3); }

.msg { margin: 14px 0; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble { max-width: 82%; background: var(--bg-4); border-radius: 18px 18px 6px 18px; padding: 10px 15px; white-space: pre-wrap; word-break: break-word; }
.msg.user .queued { font-size: 11px; color: var(--blue); margin: 4px 6px 0 0; text-align: right; }
.msg.user-wrap { display: flex; flex-direction: column; align-items: flex-end; }

.card { border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--bg-2); overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 13px; color: var(--text-2); border-bottom: 1px solid var(--line); }
.card-body { padding: 10px 14px; }
.msg.from-sec .card { border-color: #33405f; background: #11141c; }
.msg.from-sec .card-head { color: #a9c1ff; }
.msg.hub .card { border-color: #2a3a30; background: #0f1512; }
.msg.hub .card-head { color: #8fe0b0; }
.msg.hub.fail .card { border-color: #4a2626; background: #160f10; }
.msg.hub.fail .card-head { color: #fca5a5; }
.collapsible { position: relative; max-height: 220px; overflow: hidden; }
.collapsible.open { max-height: none; }
.collapsible:not(.open)::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 60px; background: linear-gradient(transparent, var(--bg-2)); pointer-events: none; }
.msg.hub .collapsible:not(.open)::after { background: linear-gradient(transparent, #0f1512); }
.msg.from-sec .collapsible:not(.open)::after { background: linear-gradient(transparent, #11141c); }
.expand-btn { border: 0; background: transparent; color: var(--accent); cursor: pointer; font-size: 13px; padding: 4px 14px 10px; }

.md { word-break: break-word; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: .55em 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 1em 0 .45em; line-height: 1.35; }
.md h1 { font-size: 1.35em; } .md h2 { font-size: 1.2em; } .md h3 { font-size: 1.07em; }
.md ul, .md ol { padding-left: 1.5em; margin: .5em 0; }
.md li { margin: .2em 0; }
.md blockquote { margin: .6em 0; padding: .1em 1em; border-left: 3px solid var(--line-2); color: var(--text-2); }
.md code { background: var(--bg-3); border: 1px solid var(--line); padding: .1em .35em; border-radius: 6px; }
.md pre { background: #0e0e10; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; overflow-x: auto; line-height: 1.5; }
.md pre code { background: none; border: 0; padding: 0; font-size: 13px; }
.md table { border-collapse: collapse; margin: .7em 0; display: block; overflow-x: auto; max-width: 100%; }
.md th, .md td { border: 1px solid var(--line-2); padding: 6px 10px; text-align: left; }
.md th { background: var(--bg-3); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1em 0; }
.md img { max-width: 100%; }
.msg.assistant .md { padding: 0 2px; }
.msg.sub { margin-left: 22px; padding-left: 12px; border-left: 2px solid var(--line); }
.msg.sub .md { font-size: 14px; color: var(--text-2); }

details.thinking { margin: 8px 0; color: var(--muted); font-size: 13.5px; }
details.thinking summary { cursor: pointer; list-style: none; display: inline-flex; gap: 6px; align-items: center; }
details.thinking summary::-webkit-details-marker { display: none; }
details.thinking .think-body { white-space: pre-wrap; border-left: 2px solid var(--line-2); padding: 4px 0 4px 12px; margin-top: 6px; }

.tool { margin: 6px 0; border: 1px solid var(--line); border-radius: 11px; background: var(--bg-2); font-size: 13.5px; }
.tool > summary { display: flex; align-items: center; gap: 8px; padding: 7px 12px; cursor: pointer; list-style: none; min-width: 0; }
.tool > summary::-webkit-details-marker { display: none; }
.tool .t-icon { width: 18px; text-align: center; flex: none; }
.tool .t-name { font-weight: 600; color: var(--text-2); flex: none; }
.tool .t-sum { color: var(--muted); font-family: var(--mono); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.tool .t-state { flex: none; font-size: 12px; }
.tool .t-state.ok { color: var(--green); }
.tool .t-state.err { color: var(--red); }
.tool .t-state.run { color: var(--muted); }
.tool[open] > summary { border-bottom: 1px solid var(--line); }
.tool .t-body { padding: 8px 12px 10px; }
.tool .t-label { font-size: 11px; color: var(--muted); margin: 6px 0 4px; letter-spacing: .4px; }
.tool pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 12.5px; background: #0e0e10; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; max-height: 420px; overflow: auto; }
.tool pre.del { border-color: #4a2626; background: #160f10; color: #fecaca; }
.tool pre.add { border-color: #23402d; background: #0e1611; color: #bbf7d0; }
.tool.sub { margin-left: 22px; }

.result-line { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; margin: 10px 0 22px; }
.result-line::before, .result-line::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.result-line.err { color: #fca5a5; }
.sys-line { text-align: center; color: var(--muted); font-size: 12px; margin: 10px 0; white-space: pre-wrap; word-break: break-word; }
.sys-line.warn { color: #fcd34d; }
.sys-line.error { color: #fca5a5; text-align: left; background: #160f10; border: 1px solid #3a1d1f; border-radius: 10px; padding: 8px 12px; font-family: var(--mono); }

.perm { border: 1px solid #5a4210; background: #17130a; border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; }
.perm .p-title { color: #fcd34d; font-weight: 600; margin-bottom: 8px; }
.perm pre { white-space: pre-wrap; word-break: break-word; background: #0e0e10; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; max-height: 260px; overflow: auto; margin: 0 0 10px; }
.perm .p-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.perm.done { border-color: var(--line); background: var(--bg-2); opacity: .75; }
.perm .p-reason { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }

.live { margin: 14px 0; }
.live .md { opacity: .95; }
.live .think-live { color: var(--muted); font-size: 13.5px; white-space: pre-wrap; border-left: 2px solid var(--line-2); padding-left: 12px; max-height: 160px; overflow: hidden; }
.typing { display: inline-flex; gap: 5px; padding: 10px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #6b6b75; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.to-bottom { position: absolute; left: 50%; transform: translateX(-50%); bottom: 118px; z-index: 5; box-shadow: 0 6px 20px rgba(0,0,0,.5); }

/* ------------------------------------------------------------ composer */
.composer-wrap { padding: 0 20px 18px; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
.composer { max-width: 860px; margin: 0 auto; border: 1px solid var(--line-2); background: var(--bg-2); border-radius: 22px; padding: 10px 10px 10px 16px; display: flex; align-items: flex-end; gap: 8px; transition: border-color .15s; }
.composer:focus-within { border-color: #474752; }
.composer textarea { flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; outline: none; resize: none; max-height: 40vh; min-height: 26px; line-height: 1.55; padding: 4px 0; }
.composer .send { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--text); color: #0b0b0c; cursor: pointer; font-size: 17px; display: flex; align-items: center; justify-content: center; flex: none; }
.composer .send:disabled { background: #3a3a40; color: #77777f; cursor: default; }
.composer .stop { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--bg-3); color: var(--text); cursor: pointer; flex: none; display: flex; align-items: center; justify-content: center; }
.composer .stop:hover { background: var(--bg-4); }
.composer-hint { max-width: 860px; margin: 6px auto 0; font-size: 11.5px; color: var(--muted); text-align: center; }

/* ------------------------------------------------------------ board */
.board-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.board-head b { font-size: 15px; }
.board-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px 14px 4px; }
.stat { background: var(--bg-3); border-radius: 10px; padding: 8px 10px; }
.stat .v { font-size: 18px; font-weight: 650; }
.stat .k { font-size: 11.5px; color: var(--muted); }
.board-list { flex: 1; overflow-y: auto; padding: 10px 12px 16px; min-height: 0; }
.bcard { border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; cursor: pointer; transition: border-color .15s; }
.bcard:hover { border-color: var(--line-2); }
.bcard.active { border-color: #3d4660; }
.bcard .b-top { display: flex; align-items: center; gap: 8px; }
.bcard .b-name { font-weight: 600; font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bcard .b-status { font-size: 12px; color: var(--muted); }
.bcard .b-text { font-size: 12.5px; color: var(--text-2); margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.bcard .b-meta { font-size: 11.5px; color: var(--muted); margin-top: 6px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ------------------------------------------------------------ modal / toast */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-start; justify-content: center; z-index: 50; padding: 6vh 16px 16px; overflow-y: auto; backdrop-filter: blur(2px); }
.modal { width: 100%; max-width: 560px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.modal.wide { max-width: 980px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head b { font-size: 16px; }
.modal-body { padding: 18px 20px 6px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; display: flex; gap: 8px; }
.tabs { display: flex; gap: 4px; padding: 10px 20px 0; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; padding: 8px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--text); border-bottom-color: var(--text); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px; font-size: 13.5px; margin-bottom: 14px; }
.kv > div:nth-child(odd) { color: var(--muted); }
.kv .mono { word-break: break-all; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid td { padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid input.input { height: 30px; padding: 0 8px; font-size: 13px; width: 76px; }
.table-wrap { overflow-x: auto; }
.section { margin: 4px 0 20px; }
.section h4 { margin: 0 0 10px; font-size: 14px; color: var(--text-2); }
.ok-text { color: var(--green); } .err-text { color: #fca5a5; }
.small-note { font-size: 13px; line-height: 1.6; margin: 0 0 10px; }
.qr-wrap { width: 200px; padding: 8px; margin: 4px 0 10px; background: #fff; border-radius: 10px; }
.qr-wrap .qr { display: block; width: 184px; height: 184px; }
.secret { font-size: 13px; padding: 8px 10px; margin-bottom: 12px; background: var(--bg-3); border-radius: 8px; word-break: break-all; user-select: all; }
.dirpick { border: 1px solid var(--line-2); border-radius: 10px; margin-top: 6px; max-height: 180px; overflow-y: auto; background: var(--bg); }
.dirpick div { padding: 5px 10px; cursor: pointer; font-family: var(--mono); font-size: 12.5px; }
.dirpick div:hover { background: var(--bg-3); }

.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--bg-4); border: 1px solid var(--line-2); padding: 9px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.5); font-size: 14px; max-width: 90vw; pointer-events: auto; }
.toast.err { border-color: #5b2323; background: #2a1517; color: #fecaca; }
.conn { position: fixed; bottom: 12px; right: 12px; font-size: 12px; background: #2a1517; border: 1px solid #5b2323; color: #fecaca; padding: 5px 10px; border-radius: 8px; z-index: 60; }

/* ------------------------------------------------------------ mobile */
.scrim { display: none; }
@media (max-width: 1180px) {
  .layout.with-board { grid-template-columns: 270px 1fr; }
  .layout.with-board .board { position: fixed; right: 0; top: 0; bottom: 0; width: min(360px, 92vw); z-index: 40; box-shadow: -10px 0 40px rgba(0,0,0,.5); }
}
@media (max-width: 820px) {
  .layout, .layout.with-board { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 10px 0 40px rgba(0,0,0,.5); }
  .layout.side-open .sidebar { transform: none; }
  .layout.side-open .scrim, .layout.with-board .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30; }
  .menu-btn { display: inline-flex; }
  .messages-inner { padding: 16px 14px 24px; }
  .composer-wrap { padding: 0 10px 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .chat-head { padding: 8px 10px; }
  .tag.cwd { display: none; }
  .msg.user .bubble { max-width: 90%; }
  .kv { grid-template-columns: 100px 1fr; }
  .composer-hint { display: none; }
}
