/* ===== Design tokens ===== */
:root, [data-theme="dark"] {
  --bg: #191919; --surface: #202020; --surface-2: #262626; --raised: #383836;
  --hover: rgba(255,255,255,.055); --active: rgba(255,255,255,.09);
  --text: #ffffff; --text-2: rgba(255,255,255,.65); --text-3: rgba(255,255,255,.46);
  --border: rgba(255,255,255,.11); --border-2: rgba(255,255,255,.2);
  --blue: #5E9FE8; --blue-soft: rgba(94,159,232,.12); --green: #72BC8F; --green-soft: rgba(114,188,143,.12);
  --orange: #DE9255; --orange-soft: rgba(222,146,85,.12); --red: #E97366; --red-soft: rgba(233,115,102,.12);
  --code-bg: #151515; --input-bg: #1c1c1c; --logo-ink: #191919;
  --shadow: 0 12px 40px rgba(0,0,0,.5); --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --btn-primary-bg: #f2f2f2; --btn-primary-fg: #191919;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #ffffff; --surface: #f9f8f7; --surface-2: #f0efed; --raised: #e8e7e4;
  --hover: rgba(0,0,0,.04); --active: rgba(0,0,0,.07);
  --text: #2c2c2b; --text-2: #6f6c67; --text-3: #9a9792;
  --border: #e6e5e3; --border-2: #d3d2cf;
  --blue: #2783DE; --blue-soft: #E5F2FC; --green: #46A171; --green-soft: #E8F1EC;
  --orange: #D5803B; --orange-soft: #FBEBDE; --red: #E56458; --red-soft: #FCE9E7;
  --code-bg: #f6f5f4; --input-bg: #ffffff; --logo-ink: #ffffff;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 12px 32px rgba(0,0,0,.1); --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
  --btn-primary-bg: #2c2c2b; --btn-primary-fg: #ffffff;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: ui-monospace, Menlo, Consolas, "DejaVu Sans Mono", monospace; }
[hidden] { display: none !important; }
.grow { flex: 1; }
.muted { color: var(--text-2); }
svg.i { flex: none; display: block; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
::selection { background: rgba(94,159,232,.35); }
* { scrollbar-width: thin; scrollbar-color: var(--raised) transparent; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ===== Buttons & inputs ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border-2); background: var(--surface); color: var(--text); cursor: pointer; font-weight: 500; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--hover); border-color: var(--border-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--btn-primary-bg); color: var(--btn-primary-fg); border-color: transparent; }
.btn.primary:hover { opacity: .9; }
.btn.danger { background: var(--red); color: #fff; border-color: transparent; }
.btn.danger-ghost { color: var(--red); }
.btn.danger-ghost:hover { background: var(--red-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 6px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.xs { width: 28px; height: 28px; border-radius: 6px; }
.icon-btn.danger:hover { color: var(--red); background: var(--red-soft); }
.input, .select, textarea.input { width: 100%; height: 38px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border-2); background: var(--input-bg); color: var(--text); outline: none; transition: border-color .12s, box-shadow .12s; }
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
textarea.input.code, .input.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.input:focus, .select:focus, textarea.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; cursor: pointer; }
.select.sm { height: 32px; font-size: 13px; padding-left: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span:first-child { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field .hint { font-size: 13px; color: var(--text-3); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.switch input { appearance: none; flex: none; width: 34px; height: 20px; margin: 1px 0 0; border-radius: 10px; background: var(--raised); position: relative; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked { background: var(--green); }
.switch input:checked::after { transform: translateX(14px); }
.switch b { display: block; font-weight: 500; }
.switch small { display: block; color: var(--text-2); font-size: 13px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.seg-btn { border: 0; background: transparent; color: var(--text-2); height: 30px; padding: 0 12px; border-radius: 6px; cursor: pointer; font-weight: 500; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--bg); color: var(--text); box-shadow: var(--shadow-sm); }
[data-theme="dark"] .seg-btn.active { background: var(--raised); }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.badge.blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.badge.green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.badge.orange { background: var(--orange-soft); color: var(--orange); border-color: transparent; }
.badge.red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid var(--border-2); background: transparent; color: var(--text-2); cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { color: var(--text); background: var(--hover); }
.chip.active { background: var(--text); color: var(--bg); border-color: transparent; }
.search-box { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: 1px solid var(--border-2); border-radius: 8px; background: var(--input-bg); color: var(--text-3); min-width: 0; }
.search-box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); height: 100%; }
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: 8px; background: var(--blue-soft); color: var(--text); font-size: 13px; line-height: 1.5; }
.callout svg { color: var(--blue); margin-top: 1px; }
.callout.warn { background: var(--orange-soft); } .callout.warn svg { color: var(--orange); }
.callout code { font-size: 12px; background: var(--active); padding: 1px 5px; border-radius: 4px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border-2); border-top-color: var(--blue); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== App shell ===== */
.app { display: flex; height: 100vh; height: 100dvh; }
.rail { width: 72px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 0 12px; background: var(--surface); border-right: 1px solid var(--border); z-index: 20; }
.rail-logo { color: var(--blue); margin-bottom: 14px; height: 28px; }
.rail-btn { width: 60px; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border-radius: 10px; color: var(--text-2); border: 0; background: transparent; cursor: pointer; text-decoration: none !important; }
.rail-btn:hover { background: var(--hover); color: var(--text); }
.rail-btn.active { background: var(--active); color: var(--text); }
.rail-btn.active svg { color: var(--blue); }
.rail-btn.small { min-height: 44px; }
.rail-label { font-size: 12px; font-weight: 500; line-height: 1; }
.main { flex: 1; min-width: 0; display: flex; }
.view { flex: 1; min-width: 0; display: none; height: 100%; position: relative; }
.view.active { display: flex; }

/* ===== Pages ===== */
.page { flex: 1; overflow-y: auto; min-width: 0; scrollbar-gutter: stable; }
.page-inner { max-width: 1160px; margin: 0 auto; padding: 32px 32px 64px; }
.page-head { display: flex; align-items: flex-end; gap: 24px; margin-bottom: 24px; }
.page-head > div:first-child { flex: 1; min-width: 0; }
.page-head h1 { margin: 0 0 4px; font-size: 24px; font-weight: 650; letter-spacing: -.01em; }
.page-head .sub { margin: 0; color: var(--text-2); max-width: 680px; }
.head-actions { display: flex; gap: 8px; flex: none; }
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar .search-box { max-width: 420px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; transition: border-color .12s; }
.card:hover { border-color: var(--border-2); }
.card-top { display: flex; gap: 12px; align-items: flex-start; }
.card-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub { color: var(--text-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-desc { color: var(--text-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 0; }
.card-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.card-actions { display: flex; gap: 8px; align-items: center; margin-top: auto; padding-top: 4px; }
.tile { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex: none; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.tile.blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.tile.green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.tile.orange { background: var(--orange-soft); color: var(--orange); border-color: transparent; }
.tile.red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; display: inline-block; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.dot.off { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.dot.wait { background: var(--orange); }
.empty-state { grid-column: 1 / -1; text-align: center; padding: 56px 24px; border: 1px dashed var(--border-2); border-radius: 12px; color: var(--text-2); }
.empty-state .tile { margin: 0 auto 16px; width: 48px; height: 48px; }
.empty-state h3 { margin: 0 0 6px; color: var(--text); font-size: 16px; }
.empty-state p { margin: 0 auto 20px; max-width: 460px; }
.empty-state .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ===== Chat ===== */
.sess-pane { width: 264px; flex: none; display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--surface); min-height: 0; }
.pane-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 12px; }
.pane-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.sess-pane .search-box { margin: 0 12px 8px; height: 34px; }
.sess-list { flex: 1; overflow-y: auto; padding: 4px 8px 16px; }
.sess-group { font-size: 12px; font-weight: 600; color: var(--text-3); padding: 12px 8px 4px; text-transform: uppercase; letter-spacing: .04em; }
.sess { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px 0 10px; border-radius: 8px; cursor: pointer; color: var(--text-2); }
.sess:hover { background: var(--hover); color: var(--text); }
.sess.active { background: var(--active); color: var(--text); }
.sess .t { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.sess .x { opacity: 0; }
.sess:hover .x, .sess.active .x { opacity: 1; }
.sess .run-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); animation: pulse 1.2s ease-in-out infinite; flex: none; }
@keyframes pulse { 50% { opacity: .35; } }
.scrim { display: none; }
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-top { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 16px; border-bottom: 1px solid var(--border); flex: none; }
.chat-title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-scroll { flex: 1; overflow-y: auto; position: relative; }
.messages { max-width: 820px; margin: 0 auto; padding: 24px 24px 16px; display: flex; flex-direction: column; gap: 14px; }
.msg-user { align-self: flex-end; max-width: 82%; background: var(--surface-2); border: 1px solid var(--border); padding: 10px 14px; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; word-break: break-word; font-size: 15px; }
.msg-ai { font-size: 15px; line-height: 1.6; word-break: break-word; }
.msg-ai .meta { font-size: 12px; color: var(--text-3); margin-top: 6px; display: flex; gap: 8px; align-items: center; }
.msg-ai .meta .badge { height: 20px; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md h1, .md h2, .md h3, .md h4 { margin: 18px 0 8px; line-height: 1.3; }
.md h1 { font-size: 20px; } .md h2 { font-size: 18px; } .md h3 { font-size: 16px; } .md h4 { font-size: 15px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; } .md li { margin: 3px 0; }
.md code { font-size: 13px; background: var(--active); padding: 1px 5px; border-radius: 4px; }
.md blockquote { margin: 0 0 10px; padding: 4px 14px; border-left: 3px solid var(--border-2); color: var(--text-2); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.table-wrap { overflow-x: auto; margin: 0 0 12px; border: 1px solid var(--border); border-radius: 8px; }
.md table { border-collapse: collapse; width: 100%; font-size: 14px; }
.md th, .md td { padding: 7px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.md th { background: var(--surface); font-weight: 600; }
.md tr:last-child td { border-bottom: 0; }
.codeblock { margin: 0 0 12px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--code-bg); }
.codebar { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 4px 12px; font-size: 12px; color: var(--text-3); border-bottom: 1px solid var(--border); }
.codebar .copy { border: 0; background: transparent; color: var(--text-2); cursor: pointer; font-size: 12px; padding: 3px 8px; border-radius: 5px; }
.codebar .copy:hover { background: var(--hover); color: var(--text); }
.codeblock pre { margin: 0; padding: 12px; overflow-x: auto; font-size: 13px; line-height: 1.5; }
.codeblock pre code { background: none; padding: 0; }
/* activity group: "Working for 12s" */
.run { display: flex; flex-direction: column; }
.run-head { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px 0 6px; margin-left: -6px; border: 0; border-radius: 7px; background: transparent; color: var(--text-2); font: inherit; font-size: 14px; cursor: pointer; }
.run-head:hover { background: var(--hover); color: var(--text); }
.run-ic { display: inline-flex; color: var(--text-3); }
.run.has-err .run-ic { color: var(--orange); }
.run-time { font-variant-numeric: tabular-nums; }
.run-steps { color: var(--text-3); }
.run-chev { color: var(--text-3); transition: transform .15s; }
.run.open .run-chev { transform: rotate(90deg); }
.run-body { display: none; flex-direction: column; gap: 2px; margin: 4px 0 2px 7px; padding-left: 16px; border-left: 1px solid var(--border-2); }
.run.open .run-body { display: flex; }
.step > summary { list-style: none; display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 4px 8px; margin-left: -8px; border-radius: 7px; cursor: pointer; user-select: none; color: var(--text-2); font-size: 14px; }
.step > summary::-webkit-details-marker { display: none; }
.step > summary:hover { background: var(--hover); color: var(--text); }
.step .step-ic { color: var(--text-3); flex: none; }
.step .step-title { flex: 0 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step .step-preview { flex: 1 1 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-3); font-size: 13px; font-style: italic; }
.step .chev { color: var(--text-3); flex: none; transition: transform .15s; opacity: .8; }
.step[open] > summary .chev { transform: rotate(90deg); }
.step .t-st { flex: none; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); margin-left: auto; }
.step .t-st.ok { display: none; }
.step .t-st.err { color: var(--red); } .step .t-st.wait { color: var(--orange); }
.step .t-st.warn { color: var(--orange); }
.step.tool.guarded .step-ic { color: var(--orange); }
.step.tool:has(.t-st.err) .step-ic { color: var(--red); }
.step-detail { margin: 2px 0 8px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); overflow: hidden; }
.step.think .step-detail { border: 0; background: none; padding: 2px 0 6px 22px; font-size: 13.5px; color: var(--text-2); white-space: pre-wrap; max-height: 420px; overflow-y: auto; }
.step-sub { display: flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 12px; color: var(--text-3); border-bottom: 1px solid var(--border); min-width: 0; }
.step-sub .sub-name { font-weight: 600; color: var(--text-2); flex: none; }
.step-sub .step-arg { font-family: ui-monospace, Menlo, Consolas, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.step-detail pre { margin: 0; padding: 10px 12px; font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow-y: auto; background: var(--code-bg); }
.step-detail pre + pre { border-top: 1px solid var(--border); }
.step-detail pre.in { color: var(--text-2); }
.step-detail pre.out.err { color: var(--red); }
.step-text { font-size: 14px; color: var(--text-2); padding: 4px 0 6px; line-height: 1.55; }
.step-text p { margin: 0 0 6px; }
.run-body .approval { margin: 2px 0 8px; }
.approval { border: 1px solid var(--orange); background: var(--orange-soft); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.approval .ap-head { display: flex; gap: 10px; align-items: center; }
.approval .ap-head svg { color: var(--orange); }
.approval .ap-head span { color: var(--text-2); font-size: 13px; }
.approval .ap-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.status-msg { align-self: center; font-size: 13px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); padding: 4px 12px; border-radius: 14px; }
.error-msg { display: flex; gap: 10px; border: 1px solid var(--red); background: var(--red-soft); color: var(--text); padding: 10px 14px; border-radius: 10px; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.error-msg svg { color: var(--red); margin-top: 2px; }
.empty-chat { max-width: 720px; margin: 0 auto; padding: 9vh 24px 24px; text-align: center; }
.empty-logo { color: var(--blue); display: flex; justify-content: center; margin-bottom: 18px; }
.empty-logo svg { width: 44px; height: 44px; }
.empty-chat h1 { font-size: 26px; margin: 0 0 8px; letter-spacing: -.01em; font-weight: 650; }
.empty-chat p { color: var(--text-2); margin: 0 auto 28px; max-width: 520px; }
.suggest { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; }
.sugg { display: grid; grid-template-columns: 20px 1fr; column-gap: 12px; row-gap: 2px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; text-align: left; }
.sugg:hover { border-color: var(--border-2); background: var(--surface-2); }
.sugg > span:first-child { grid-row: 1 / span 2; grid-column: 1; color: var(--blue); display: flex; padding-top: 1px; }
.sugg b { grid-column: 2; font-weight: 600; font-size: 14px; color: var(--text); }
.sugg > span:last-child { grid-column: 2; color: var(--text-2); font-size: 13px; line-height: 1.45; }
.composer-wrap { padding: 8px 24px 16px; flex: none; }
.composer { max-width: 820px; margin: 0 auto; border: 1px solid var(--border-2); border-radius: 14px; background: var(--input-bg); box-shadow: var(--shadow-sm); transition: border-color .12s, box-shadow .12s; }
.composer:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.composer textarea { display: block; width: 100%; border: 0; outline: 0; background: transparent; resize: none; padding: 14px 16px 4px; font-size: 15px; line-height: 1.5; max-height: 260px; }
.composer-bar { display: flex; align-items: center; gap: 8px; padding: 6px 8px 8px; }
.status-line { font-size: 13px; color: var(--text-2); display: inline-flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usage { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.send-btn { width: 36px; height: 36px; border-radius: 10px; border: 0; background: var(--btn-primary-bg); color: var(--btn-primary-fg); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }
.send-btn:hover { opacity: .88; }
.send-btn.stop { background: var(--red); color: #fff; }
.composer-hint { max-width: 820px; margin: 8px auto 0; font-size: 12px; color: var(--text-3); text-align: center; }
.composer-hint code { font-size: 11.5px; background: var(--hover); padding: 1px 5px; border-radius: 4px; }
.side-panel { width: 320px; flex: none; border-left: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 8px 0 12px; border-bottom: 1px solid var(--border); flex: none; }
.side-body { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.todo { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; font-size: 14px; }
.todo .tb { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-2); flex: none; margin-top: 2px; display: flex; align-items: center; justify-content: center; }
.todo.in_progress { background: var(--blue-soft); }
.todo.in_progress .tb { border-color: var(--blue); border-top-color: transparent; animation: spin 1s linear infinite; }
.todo.completed { color: var(--text-3); text-decoration: line-through; }
.todo.completed .tb { background: var(--green); border-color: var(--green); color: #fff; }
.side-empty { color: var(--text-2); font-size: 13px; padding: 8px; }
.path-bar { display: flex; align-items: center; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.path-bar code { flex: 1; min-width: 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }
.mini-files { display: flex; flex-direction: column; }
.fent { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.fent:hover { background: var(--hover); }
.fent svg { color: var(--text-3); } .fent.dir svg { color: var(--blue); }
.fent .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fent .s { color: var(--text-3); font-size: 12px; }
.file-preview { border: 1px solid var(--border); border-radius: 8px; background: var(--code-bg); overflow: hidden; display: flex; flex-direction: column; min-height: 120px; }
.file-preview .fp-bar { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--border); font-size: 12px; }
.file-preview .fp-bar b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-preview pre { margin: 0; padding: 10px 12px; font-size: 12px; overflow: auto; max-height: 420px; white-space: pre; }

/* ===== Servers: tabs, terminal, files ===== */
#view-servers { flex-direction: column; }
.tabstrip { display: flex; align-items: flex-end; gap: 2px; padding: 8px 12px 0; border-bottom: 1px solid var(--border); background: var(--surface); flex: none; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.tab { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 8px 0 12px; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; color: var(--text-2); cursor: pointer; font-size: 13px; font-weight: 500; white-space: nowrap; background: transparent; position: relative; top: 1px; }
.tab:hover { color: var(--text); background: var(--hover); }
.tab.active { background: var(--bg); color: var(--text); border-color: var(--border); }
.tab .tx { width: 22px; height: 22px; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-3); }
.tab .tx:hover { background: var(--active); color: var(--text); }
.tab.home { padding-right: 12px; }
.tab-pane { flex: 1; min-height: 0; }
.srv-panes { flex: 1; min-height: 0; display: flex; }
.srv-panes:empty { display: none; }
.srv-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.pane-bar { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 12px 0 16px; border-bottom: 1px solid var(--border); flex: none; }
.pane-bar .ttl { font-weight: 600; white-space: nowrap; }
.pane-bar .sub { color: var(--text-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.term-wrap { flex: 1; min-height: 0; background: #141414; transition: background .15s; padding: 8px 4px 4px 12px; }
.term-host { width: 100%; height: 100%; }
.term-host .xterm { height: 100%; }
.term-host .xterm-viewport { scrollbar-color: #444 transparent; }
.fm { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.fm-bar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.fm-bar .input { height: 34px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; flex: 1; min-width: 180px; }
.fm-list { flex: 1; overflow: auto; }
.fm table { width: 100%; border-collapse: collapse; font-size: 14px; }
.fm th { position: sticky; top: 0; background: var(--bg); text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding: 8px 12px; border-bottom: 1px solid var(--border); z-index: 1; }
.fm td { padding: 0 12px; height: 40px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.fm tr.row { cursor: pointer; }
.fm tr.row:hover td { background: var(--hover); }
.fm td.name { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.fm td.name svg { color: var(--text-3); } .fm tr.dir td.name svg { color: var(--blue); }
.fm td.name span { overflow: hidden; text-overflow: ellipsis; }
.fm td.num, .fm td.dim { color: var(--text-2); font-size: 13px; }
.fm td.acts { text-align: right; width: 1%; }
.fm td.acts .icon-btn { opacity: .0; }
.fm tr.row:hover td.acts .icon-btn, .fm tr.row:focus-within td.acts .icon-btn { opacity: 1; }
.fm-status { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-2); min-height: 38px; flex: none; }
.fm-drop { position: absolute; inset: 0; background: var(--blue-soft); border: 2px dashed var(--blue); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 600; color: var(--blue); pointer-events: none; z-index: 5; margin: 8px; }
.progress { flex: 1; max-width: 240px; height: 6px; border-radius: 3px; background: var(--raised); overflow: hidden; }
.progress > div { height: 100%; background: var(--blue); width: 0; transition: width .15s; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--text-2); } .kv dd { margin: 0; font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }
.auth-panel { display: flex; flex-direction: column; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.pubkey { display: flex; flex-direction: column; gap: 8px; }
.pubkey textarea { font-size: 12px; min-height: 64px; }

/* ===== Integrations ===== */
.int-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.int-opt { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; text-align: left; }
.int-opt:hover { border-color: var(--blue); background: var(--blue-soft); }
.int-opt b { display: block; font-weight: 600; }
.int-opt small { display: block; color: var(--text-2); font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.test-line { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); min-height: 20px; }
.test-line.ok { color: var(--green); } .test-line.err { color: var(--red); }
.console { display: flex; flex-direction: column; gap: 12px; }
.console-row { display: flex; gap: 8px; }
.console-row .select { width: 110px; flex: none; }
.console pre { margin: 0; padding: 12px; background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; max-height: 420px; overflow: auto; font-size: 12.5px; white-space: pre-wrap; word-break: break-word; }
.ptero-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.ptero-row { display: grid; grid-template-columns: 1fr auto auto; gap: 16px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.ptero-row:last-child { border-bottom: 0; }
.ptero-row .nm { font-weight: 600; } .ptero-row .ds { font-size: 13px; color: var(--text-2); }
.ptero-row .res { font-size: 12px; color: var(--text-2); text-align: right; white-space: nowrap; }
.ptero-row .pw { display: flex; gap: 4px; }

/* ===== Settings ===== */
.settings-layout { display: grid; grid-template-columns: 220px 1fr; gap: 32px; align-items: start; }
.sub-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; }
.sub-nav a { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px; border-radius: 8px; color: var(--text-2); text-decoration: none !important; font-weight: 500; }
.sub-nav a:hover { background: var(--hover); color: var(--text); }
.sub-nav a.active { background: var(--active); color: var(--text); }
.set-body { min-width: 0; max-width: 760px; display: flex; flex-direction: column; gap: 24px; }
.set-head h2 { margin: 0 0 4px; font-size: 20px; font-weight: 650; }
.set-head p { margin: 0; color: var(--text-2); }
.section { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.section > .sec-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.section > .sec-head h3 { margin: 0; font-size: 15px; font-weight: 600; flex: 1; }
.section > .sec-body { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.section > .sec-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-row .lr-main { flex: 1; min-width: 0; }
.list-row .lr-main b { display: block; font-weight: 600; }
.list-row .lr-main small { display: block; color: var(--text-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: var(--bg); }
.stat small { display: block; color: var(--text-2); font-size: 13px; margin-bottom: 4px; }
.stat b { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
.stat .bar { height: 6px; border-radius: 3px; background: var(--raised); margin-top: 10px; overflow: hidden; }
.stat .bar > div { height: 100%; background: var(--green); }

/* ===== Modal & toast ===== */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; z-index: 100; overflow-y: auto; animation: fade .12s ease-out; }
[data-theme="light"] .modal-back { background: rgba(15,15,15,.35); }
.modal { width: 100%; max-width: 560px; background: var(--bg); border: 1px solid var(--border-2); border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; animation: pop .14s ease-out; }
[data-theme="dark"] .modal { background: var(--surface); }
.modal.wide { max-width: 860px; } .modal.small { max-width: 420px; }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 14px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { display: flex; gap: 8px; align-items: center; padding: 12px 20px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.confirm-text { margin: 0; color: var(--text-2); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.99); } }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border-2); box-shadow: var(--shadow); font-size: 14px; animation: pop .15s ease-out; }
.toast.out { opacity: 0; transition: opacity .25s; }
.toast svg { margin-top: 2px; color: var(--blue); } .toast.error svg { color: var(--red); } .toast.success svg { color: var(--green); }
.toast span { word-break: break-word; }

/* ===== Responsive ===== */
.only-mobile { display: none; }
@media (max-width: 1100px) {
  .side-panel { position: absolute; right: 0; top: 0; bottom: 0; z-index: 15; box-shadow: var(--shadow); }
}
@media (max-width: 860px) {
  #modeSel { display: none; }
  .mpick-btn { max-width: 240px; }
}
@media (max-width: 760px) {
  body { font-size: 14px; }
  .app { flex-direction: column-reverse; }
  .rail { width: 100%; height: calc(60px + env(safe-area-inset-bottom)); flex-direction: row; justify-content: space-around; padding: 4px 4px env(safe-area-inset-bottom); border-right: 0; border-top: 1px solid var(--border); gap: 0; }
  .rail-logo, .rail .grow { display: none; }
  .rail-btn { width: auto; flex: 1; min-height: 52px; }
  .rail-btn.small { flex: 0 0 52px; }
  .main { min-height: 0; flex: 1; }
  .only-mobile { display: inline-flex; }
  .sess-pane { position: absolute; left: 0; top: 0; bottom: 0; z-index: 30; width: min(300px, 86vw); transform: translateX(-105%); transition: transform .18s ease-out; box-shadow: var(--shadow); }
  .sess-pane.open { transform: none; }
  .scrim.open { display: block; position: absolute; inset: 0; background: rgba(0,0,0,.45); z-index: 25; }
  .chat-top { padding: 0 8px; gap: 6px; height: 52px; }
  .chat-title { font-size: 14px; }
  .messages { padding: 16px 16px 8px; }
  .msg-user { max-width: 90%; }
  .composer-wrap { padding: 6px 12px 10px; }
  .composer-hint { display: none; }
  .empty-chat { padding-top: 32px; }
  .empty-chat h1 { font-size: 22px; }
  .suggest { grid-template-columns: 1fr; }
  .side-panel { width: 100%; }
  .page-inner { padding: 20px 16px 48px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 16px; }
  .head-actions { justify-content: flex-start; }
  .card-grid { grid-template-columns: 1fr; }
  .toolbar .search-box { max-width: none; flex-basis: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; gap: 16px; }
  .sub-nav { flex-direction: row; overflow-x: auto; position: static; gap: 4px; padding-bottom: 4px; }
  .sub-nav a { flex: none; }
  .stats { grid-template-columns: 1fr 1fr; }
  .modal-back { padding: 12px 8px; }
  .fm td.num.mt, .fm th.mt, .fm td.dim.pm, .fm th.pm { display: none; }
  .fm td.acts .icon-btn { opacity: 1; }
  .fm td.name { min-width: 0; max-width: 52vw; }
  .ptero-row { grid-template-columns: 1fr auto; }
  .ptero-row .res { display: none; }
  .tab { padding: 0 6px 0 10px; }
  .section > .sec-head { flex-wrap: wrap; row-gap: 10px; }
  .section > .sec-head h3 { flex: 1 0 100%; }
  .section > .sec-head .select { flex: 1; min-width: 0; }
  .list-row { flex-wrap: wrap; row-gap: 8px; }
  .list-row .lr-main { flex: 1 1 calc(100% - 60px); }
  .list-row .tile + .lr-main + .badge { margin-left: 52px; }
  .list-row .tile ~ .btn { margin-left: auto; }
  .pane-bar { padding: 0 8px 0 12px; gap: 6px; }
  .pane-bar .sub.mono { display: none; }
  .pane-bar .sub.st { flex: none; }
  .pane-bar .btn.sm { padding: 0 8px; }
}
.tabstrip:empty { display: none; }

/* model picker */
#modeSel { width: auto; flex: none; max-width: 190px; }
.mpick { position: relative; min-width: 0; flex: none; }
.mpick-btn { display: flex; align-items: center; gap: 8px; height: 34px; max-width: 340px; padding: 0 10px; border: 1px solid var(--border-2); border-radius: 8px; background: var(--input-bg); color: var(--text); cursor: pointer; font-size: 13px; transition: border-color .12s, background .12s; }
.mpick-btn:hover { background: var(--hover); }
.mpick-btn[aria-expanded="true"] { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.mpick-btn.empty { border-color: var(--blue); color: var(--blue); }
.mpick-btn .mp-ic, .mpick-btn .mp-chev { color: var(--text-3); display: flex; flex: none; }
.mpick-btn.empty .mp-ic { color: var(--blue); }
.mpick-txt { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.mpick-prov { color: var(--text-3); font-size: 12px; white-space: nowrap; flex: none; }
.mpick-model { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mpick-btn.empty .mpick-model { font-family: inherit; font-size: 13px; font-weight: 600; }
.mpick-pop { position: absolute; top: calc(100% + 6px); right: 0; z-index: 40; width: 380px; max-width: calc(100vw - 24px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border-2); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.mpick-pop[hidden] { display: none; }
.mpick-head { display: flex; align-items: center; gap: 6px; padding: 8px; border-bottom: 1px solid var(--border); }
.mpick-search { flex: 1; display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; border-radius: 8px; background: var(--input-bg); border: 1px solid var(--border-2); color: var(--text-3); }
.mpick-search:focus-within { border-color: var(--blue); }
.mpick-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13.5px; }
.mpick-provs { display: flex; gap: 6px; padding: 8px 8px 0; overflow-x: auto; scrollbar-width: none; }
.mpick-provs[hidden] { display: none; }
.mpick-provs .chip { height: 26px; padding: 0 10px; font-size: 12.5px; flex: none; }
.mpick-list { max-height: min(420px, 60vh); overflow-y: auto; padding: 4px 6px 6px; }
.mp-group { padding: 10px 8px 4px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.mp-item { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 34px; padding: 6px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--text); text-align: left; cursor: pointer; font-size: 13px; }
.mp-item .mono { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.mp-item:hover, .mp-item.active { background: var(--hover); }
.mp-item.sel { color: var(--blue); font-weight: 600; }
.mp-item.sel svg { color: var(--blue); flex: none; }
.mp-item > svg:first-child { color: var(--text-3); flex: none; }
.mp-note { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 10px; font-size: 13px; color: var(--text-2); }
.mp-note.warn { color: var(--orange); }
.mp-note a { color: var(--blue); }
.mpick-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); }
.mpick-foot a { color: var(--text-2); text-decoration: none; }
.mpick-foot a:hover { color: var(--blue); }
@media (max-width: 760px) {
  .mpick { flex: 0 1 auto; }
  .mpick-btn { max-width: 52vw; padding: 0 8px; gap: 6px; }
  .mpick-btn .mp-ic, .mpick-prov { display: none; }
  .mpick-pop { position: fixed; top: 58px; left: 8px; right: 8px; width: auto; max-width: none; }
  .mpick-list { max-height: 60vh; }
}
/* terminal appearance */
.modal.xl { max-width: 980px; }
.ta-modal .modal-body { max-height: min(78vh, 820px); overflow-y: auto; }
.ta { display: flex; flex-direction: column; gap: 16px; }
.ta-top { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(260px, 1fr); gap: 18px; align-items: start; }
.tp { border-radius: 8px; padding: 8px 10px; font: 11px/1.45 ui-monospace, Menlo, Consolas, monospace; white-space: pre; overflow: hidden; border: 1px solid rgba(128,128,128,.22); }
.tp.big { padding: 14px 16px; min-height: 200px; border-radius: 10px; }
.tp > div { overflow: hidden; text-overflow: clip; }
.tp-cur { display: inline-block; width: .6em; height: 1.1em; vertical-align: -0.2em; background: var(--cur); }
.tp-cur.bar { width: 2px; } .tp-cur.underline { height: 2px; vertical-align: -0.15em; width: .6em; }
.tp-cur.blink { animation: tpblink 1.05s steps(1) infinite; }
@keyframes tpblink { 50% { opacity: 0; } }
.ta-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.ta-side .field > span { display: flex; justify-content: space-between; }
.ta-val { font-style: normal; color: var(--text-3); font-variant-numeric: tabular-nums; }
.ta-side input[type=range] { width: 100%; accent-color: var(--blue); }
.ta-cur { display: flex; flex-direction: column; gap: 2px; }
.ta-k { font-size: 12px; color: var(--text-3); }
.ta-toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.ta-toggle input { accent-color: var(--blue); width: 16px; height: 16px; }
.ta-side .seg { align-self: flex-start; max-width: 100%; }
.ta-side .seg-btn { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; line-height: 30px; }
.ta-sec { display: flex; align-items: center; gap: 10px; }
.ta-sec h4 { margin: 0; font-size: 14px; flex: 1; }
.ta-sec h4 span { color: var(--text-3); font-weight: 400; margin-left: 4px; }
.ta-hint { font-size: 12px; color: var(--text-3); }
.ta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.ta-card { border: 1px solid var(--border); border-radius: 10px; padding: 6px; cursor: pointer; background: var(--bg); transition: border-color .12s, box-shadow .12s; outline: none; }
.ta-card:hover { border-color: var(--border-2); }
.ta-card:focus-visible { box-shadow: 0 0 0 3px var(--blue-soft, rgba(94,159,232,.3)); }
.ta-card.sel { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.ta-card .tp { pointer-events: none; }
.ta-card-foot { display: flex; align-items: center; gap: 4px; padding: 6px 2px 0 4px; min-height: 30px; }
.ta-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ta-card-foot .badge { height: 18px; font-size: 11px; padding: 0 6px; }
.ta-card-foot .icon-btn { opacity: 0; }
.ta-card:hover .icon-btn, .ta-card.sel .icon-btn, .ta-card:focus-within .icon-btn { opacity: 1; }
.ta-check { width: 20px; height: 20px; border-radius: 50%; background: var(--blue); color: #fff; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ta-colors { display: flex; flex-direction: column; gap: 8px; }
.ta-color { display: grid; grid-template-columns: 34px minmax(0, 1fr) 128px; align-items: center; gap: 10px; font-size: 13px; }
.ta-color input[type=color] { width: 34px; height: 28px; padding: 0; border: 1px solid var(--border-2); border-radius: 6px; background: none; cursor: pointer; }
.ta-color input[type=color]::-webkit-color-swatch-wrapper { padding: 2px; }
.ta-color input[type=color]::-webkit-color-swatch { border: 0; border-radius: 4px; }
.ta-color .input { height: 30px; font-size: 12px; padding: 0 8px; }
.ta-ansi { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.ta-ansi-col { display: flex; flex-direction: column; gap: 8px; }
.ta-ansi .ta-color { grid-template-columns: 34px 90px minmax(0, 150px); }
.ta-ansi-col > b { font-size: 12px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.ta-edit-foot { display: flex; gap: 8px; align-items: center; padding-top: 4px; }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 7px; }
@media (max-width: 760px) {
  .ta-top { grid-template-columns: 1fr; }
  .ta-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .ta-ansi { grid-template-columns: 1fr; gap: 12px; }
  .ta-color { grid-template-columns: 34px minmax(0, 1fr) 110px; }
  .tp.big { min-height: 0; font-size: 12px !important; }
  .ta:not([data-mode="edit"]) .ta-top { display: contents; }
  .ta:not([data-mode="edit"]) > .ta-sec { order: 2; }
  .ta:not([data-mode="edit"]) > .ta-grid { order: 3; }
  .ta:not([data-mode="edit"]) .ta-side { order: 4; border-top: 1px solid var(--border); padding-top: 14px; }
}
.tp-mini { width: 40px; height: 40px; border-radius: 9px; border: 1px solid; display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 8px; flex: none; }
.tp-mini i { border-radius: 2px; }
/* host system status */
.sys { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: 14px 16px; margin-bottom: 18px; display: flex; flex-direction: column; gap: 14px; }
.sys-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sys-id { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sys-id b { font-size: 15px; }
.sys-id span { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sys-live { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); flex: none; }
.sys-live .dot.on { animation: pulse 2s ease-in-out infinite; }
.sys-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.sys-m { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--bg); display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; min-width: 0; }
[data-theme="dark"] .sys-m { background: var(--surface-2); }
.sys-mh { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.sys-ml { font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.sys-mv { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sys-bar { height: 6px; border-radius: 3px; background: var(--active); overflow: hidden; }
.sys-bar i { display: block; height: 100%; border-radius: 3px; background: var(--green); transition: width .5s ease; }
.sys-m.warn .sys-bar i { background: var(--orange); } .sys-m.crit .sys-bar i { background: var(--red); }
.sys-m.crit .sys-mv { color: var(--red); }
.sys-ms { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 8px; min-width: 0; font-variant-numeric: tabular-nums; }
.sys-ms .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sys-spark { width: 100%; height: 28px; display: block; margin-top: 2px; }
.sys-spark .line { fill: none; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.sys-spark .fill { stroke: none; opacity: .14; }
.sys-spark.cpu .line { stroke: var(--blue); } .sys-spark.cpu .fill { fill: var(--blue); }
.sys-spark.load .line { stroke: var(--orange); } .sys-spark.load .fill { fill: var(--orange); }
.sys-spark.mem .line { stroke: var(--purple, #bf8eda); } .sys-spark.mem .fill { fill: var(--purple, #bf8eda); }
.sys-cores { display: flex; gap: 2px; height: 12px; width: 56px; flex: none; align-items: flex-end; }
.sys-cores i { flex: 1; height: var(--h); min-height: 2px; border-radius: 2px; background: var(--green); opacity: .75; transition: height .5s; }
.sys-cores i.warn { background: var(--orange); } .sys-cores i.crit { background: var(--red); }
.sys-ct-toggle { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 13px; font-weight: 500; padding: 4px 8px; margin: -6px 0 -4px -8px; border-radius: 7px; cursor: pointer; }
.sys-ct-toggle:hover { background: var(--hover); }
.sys-ct-toggle .muted { font-weight: 400; color: var(--text-3); }
.sys-ct-toggle .chev { color: var(--text-3); transition: transform .15s; }
.sys-ct-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
.sys-ct { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.sys-ct-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; font-size: 13px; min-width: 0; }
.sys-ct-row + .sys-ct-row { border-top: 1px solid var(--border); }
.sys-ct-row b { font-weight: 500; font-size: 12.5px; flex: none; }
.sys-ct-row .ell { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.sys-ct-row .num { flex: none; font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 12px; min-width: 64px; text-align: right; }
.sys-err { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; }
@media (max-width: 1000px) { .sys-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .sys { padding: 12px; gap: 12px; }
  .sys-grid { gap: 8px; }
  .sys-m { padding: 8px 10px; }
  .sys-mv { font-size: 17px; }
  .sys-ct-row .ell { display: none; }
  .sys-ms .t { white-space: normal; }
  .sys-live { display: none; }
}

/* activity log */
.audit-tools { display: flex; gap: 8px; margin-bottom: 12px; }
.audit-tools .input { flex: 1; min-width: 0; }
.audit-tools .select { width: auto; flex: none; }
.audit-list { display: flex; flex-direction: column; max-height: 560px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.au-row { padding: 9px 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.au-row:last-child { border-bottom: 0; }
.au-row.fail { background: var(--red-soft); }
.au-top { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); min-width: 0; flex-wrap: wrap; }
.au-time { color: var(--text-3); font-variant-numeric: tabular-nums; }
.au-tool { color: var(--text); font-weight: 600; }
.au-target { display: inline-flex; align-items: center; gap: 4px; }
.au-by { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--raised); color: var(--text-2); white-space: nowrap; }
.au-by.ok { background: var(--green-soft); color: var(--green); }
.au-by.auto { background: var(--blue-soft); color: var(--blue); }
.au-by.warn { background: var(--orange-soft); color: var(--orange); }
.au-by.err { background: var(--red-soft); color: var(--red); }
.au-cmd { font-size: 12.5px; color: var(--text); white-space: pre-wrap; word-break: break-word; max-height: 7.6em; overflow: hidden; cursor: pointer; }
.au-row.open .au-cmd { max-height: none; }
.au-chat { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-3); text-decoration: none; align-self: flex-start; }
.au-chat:hover { color: var(--text); text-decoration: underline; }
@media (max-width: 640px) { .audit-tools { flex-wrap: wrap; } .audit-tools .input { flex: 1 1 100%; } .audit-tools .select { flex: 1; } .au-cmd { font-size: 12px; } }

.wait-msg { display: flex; align-items: center; gap: 8px; color: var(--orange); }
.run-body .wait-msg { align-self: flex-start; }

/* role-based visibility */
body[data-role=member] [data-admin], body[data-sandbox=no] [data-sandbox], body[data-term=no] [data-term] { display: none !important; }

/* ---- users & account ---- */
.avatar { width: 36px; height: 36px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; background: var(--blue-soft); color: var(--blue); font-weight: 650; font-size: 15px; }
.avatar.lg { width: 44px; height: 44px; font-size: 18px; }
.user-row.disabled .avatar, .user-row.disabled .lr-main { opacity: .55; }
.user-row[data-edit] { cursor: pointer; }
.user-row[data-edit]:hover { background: var(--hover); }
.user-row .lr-main b { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.user-quota { width: 210px; flex: none; }
.quota { display: flex; flex-direction: column; gap: 6px; }
.quota-top { font-size: 14px; color: var(--text-2); }
.quota-top b { color: var(--text); font-size: 16px; font-weight: 650; }
.quota.compact .quota-top { font-size: 12.5px; } .quota.compact .quota-top b { font-size: 13px; }
.quota-bar { height: 6px; border-radius: 3px; background: var(--raised); overflow: hidden; }
.quota-bar > div { height: 100%; background: var(--green); border-radius: 3px; }
.quota-bar.orange > div { background: var(--orange); } .quota-bar.red > div { background: var(--red); }
.quota-sub { font-size: 12.5px; color: var(--text-3); }
.kv-list { display: flex; flex-direction: column; }
.kv-list > div { display: flex; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--border); align-items: baseline; }
.kv-list > div:last-child { border-bottom: 0; }
.kv-list > div > span { width: 170px; flex: none; color: var(--text-2); font-size: 13.5px; }
.kv-list > div > b { font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.user-modal .modal-body { max-height: min(78vh, 860px); overflow-y: auto; }
.user-form { display: flex; flex-direction: column; gap: 16px; }
.profile-row { display: flex; align-items: center; gap: 14px; }
.profile-row .lr-main b { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.profile-row .lr-main small { display: block; color: var(--text-2); font-size: 13px; margin-top: 2px; }
.uf-h { margin: 8px 0 -6px; font-size: 13.5px; font-weight: 600; display: flex; gap: 8px; align-items: baseline; }
.uf-h small { font-weight: 400; font-size: 12.5px; }
#accessBox { display: flex; flex-direction: column; gap: 16px; }
#accessBox[hidden] { display: none; }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; max-height: 230px; overflow-y: auto; }
.checklist.models { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.checklist > .muted { padding: 4px 2px; font-size: 13.5px; }
.ck { display: flex; align-items: flex-start; gap: 9px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; background: var(--surface); min-width: 0; }
.ck[hidden] { display: none; }
.ck:hover { background: var(--hover); }
.ck:has(input:checked) { border-color: var(--green); background: var(--green-soft); }
.ck input { margin: 2px 0 0; accent-color: var(--green); flex: none; }
.ck span { min-width: 0; }
.ck b { display: block; font-weight: 500; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ck small { display: block; color: var(--text-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quota-pill { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.quota-pill.orange { color: var(--orange); } .quota-pill.red { color: var(--red); font-weight: 600; }
@media (max-width: 760px) {
  .user-row { flex-wrap: wrap; }
  .user-row .lr-main { flex: 1 1 calc(100% - 110px); }
  .user-quota { order: 5; width: 100%; padding-left: 48px; }
  .kv-list > div { flex-direction: column; gap: 2px; }
  .kv-list > div > span { width: auto; }
}

/* ---- images (vision) ---- */
.attach-strip { display: flex; gap: 8px; padding: 10px 12px 0; overflow-x: auto; }
.attach-strip[hidden] { display: none; }
.att { position: relative; flex: none; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border-2); background: var(--surface-2); }
.att img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-x { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.att-x:hover { background: rgba(0,0,0,.85); }
.composer.drop { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); background: var(--blue-soft); }
.msg-user .msg-imgs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.msg-user .msg-imgs + .mu-text { margin-top: 8px; }
.msg-user.only-img { background: transparent; border-color: transparent; padding: 0; }
.msg-imgs img, .tool-imgs img { max-width: 240px; max-height: 180px; border-radius: 10px; border: 1px solid var(--border); cursor: zoom-in; display: block; object-fit: cover; background: var(--surface-2); }
.msg-imgs img:only-child { max-width: min(360px, 100%); max-height: 300px; }
.mu-note { margin-top: 6px; font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 5px; white-space: normal; }
.tool-imgs { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 6px 26px; }
.img-modal .modal-body { align-items: center; padding: 12px; max-height: 80vh; overflow: auto; }
.lightbox-img { max-width: 100%; max-height: 72vh; border-radius: 8px; display: block; }
@media (max-width: 760px) { .msg-imgs img { max-width: 160px; max-height: 140px; } .msg-imgs img:only-child { max-width: 100%; } .tool-imgs { margin-left: 0; } }

/* images shown by the agent inside answers */
.md img.ai-img { display: block; max-width: min(100%, 640px); max-height: 480px; height: auto; margin: 8px 0; border-radius: 8px; cursor: zoom-in; }
.md img.ai-img.pixel, .lightbox-img.pixel { image-rendering: pixelated; image-rendering: crisp-edges; border-radius: 2px; }
.md .ai-imgs { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; margin-top: 8px; }
.md .ai-imgs img.ai-img { margin: 0; }
@media (max-width: 760px) { .md img.ai-img { max-width: 100%; } }
