/* Look and layout follow the T3 Code mobile app (Android). Colours come from themes.css (--color-*). */
@font-face { font-family: "DM Sans"; font-style: normal; font-weight: 100 1000; font-display: swap;
  src: url(/fonts/dm-sans-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "DM Sans"; font-style: normal; font-weight: 100 1000; font-display: swap;
  src: url(/fonts/dm-sans-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  /* app chrome around the rounded content card, slightly off the card colour in every theme */
  --chrome: color-mix(in srgb, var(--color-foreground) 5%, var(--color-screen));
  --bg: var(--color-screen); --panel: var(--color-card); --panel2: var(--color-grouped-card);
  --border: var(--color-border); --sep: var(--color-separator);
  --text: var(--color-foreground); --muted: var(--color-foreground-muted); --faint: var(--color-chevron);
  --accent: var(--color-primary); --accent-text: var(--color-primary-text); --on-accent: var(--color-primary-foreground);
  --user: var(--color-user-bubble); --danger: var(--color-danger-foreground); --warn: var(--color-warning-foreground);
  --ok: #138a5b; --info: #1a73e8;
  --mono: ui-monospace, "SF Mono", Menlo, "Roboto Mono", monospace;
  --safe-top: env(safe-area-inset-top); --safe-bot: env(safe-area-inset-bottom);
}
:root[data-theme$="-dark"] { --ok: #34d399; --info: #6aa8ff; }
#clientError { color: var(--danger); font-size: 12px; overflow-wrap: anywhere; margin-top: 6px; max-height: 100px; overflow-y: auto; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--chrome); color: var(--text);
  font: 16px/1.45 "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font-family: inherit; color: var(--text); }
::placeholder { color: var(--color-placeholder); opacity: 1; }
.hidden { display: none !important; }
svg { flex-shrink: 0; }

.logo { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  background: var(--color-prominent-action); color: var(--color-prominent-action-foreground); font-weight: 800; font-size: 22px; }
.logo.sm { width: 26px; height: 26px; font-size: 14px; border-radius: 7px; }
.logo.lg { width: 64px; height: 64px; font-size: 32px; border-radius: 18px; }

/* ---------- layout: chat list screen + chat screen (side by side on wide screens) ---------- */
.app { display: flex; height: 100dvh; overflow: hidden; }
.sidebar { position: relative; width: 340px; flex-shrink: 0; background: var(--chrome); display: flex; flex-direction: column;
  padding-top: var(--safe-top); }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 10px 12px 20px; min-height: 64px; }
.brand { display: flex; gap: 10px; align-items: center; min-width: 0; }
.wordmark { font-size: 26px; letter-spacing: -.02em; color: var(--color-wordmark); font-weight: 400; line-height: 1; }
.wordmark b { font-weight: 800; letter-spacing: -.04em; }
.alpha { font-size: 10px; font-weight: 600; letter-spacing: .14em; color: var(--muted); background: var(--panel2); border-radius: 6px; padding: 3px 6px; }
.head-actions { display: flex; align-items: center; gap: 2px; }
.icon-btn { background: none; border: none; padding: 0; width: 42px; height: 44px; border-radius: 50%; color: var(--color-icon);
  display: inline-grid; place-items: center; font-size: 20px; }
.icon-btn:active, .icon-btn:hover { background: var(--color-row-hover); }
.side-card { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--bg); border-radius: 28px 28px 0 0; overflow: hidden; margin: 0 4px; }
.side-tools { display: flex; align-items: center; gap: 8px; padding: 10px 12px 2px; }
.chat-list { flex: 1; overflow-y: auto; padding: 4px 0 96px; -webkit-overflow-scrolling: touch; }
/* left of the floating "new chat" button, below the list */
.side-foot { flex-shrink: 0; min-height: 98px; padding: 8px 200px calc(12px + var(--safe-bot)) 20px; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; gap: 2px; border-top: 1px solid var(--sep); }
.link-btn { background: none; border: none; color: var(--accent-text); padding: 4px 0; font-size: 13px; }
.conn { font-size: 12px; color: var(--muted); }
.conn.ok { color: var(--ok); }
.conn.bad { color: var(--danger); }
.backdrop { display: none; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--chrome); }
.top { display: flex; align-items: center; gap: 2px; padding: calc(8px + var(--safe-top)) 8px 10px; min-height: 64px; }
.top .menu { display: none; }
.top-title { flex: 1; min-width: 0; padding: 0 6px; }
#title { font-size: 21px; line-height: 28px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--color-header-foreground); }
.sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-card { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--color-thread-canvas); border-radius: 28px 28px 0 0; overflow: hidden; margin: 0 4px; }

@media (max-width: 760px) {
  /* phones: the chat list is its own full screen; the back arrow returns to it */
  .sidebar { position: fixed; z-index: 20; inset: 0; width: 100%; transform: translateX(-100%); transition: transform .24s cubic-bezier(.2,.8,.2,1); }
  .app.open .sidebar { transform: none; }
  .top .menu { display: inline-grid; }
  .side-card, .chat-card { margin: 0; }
  .chat-item .del { opacity: 1; }
}

/* ---------- chat list rows ---------- */
.search { margin: 12px 12px 4px; padding: 11px 16px; border-radius: 999px; border: none; background: var(--color-sidebar-search); font-size: 16px; outline: none; }
.chat-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 20px; cursor: pointer; border-radius: 0; }
.chat-item:hover { background: var(--color-row-hover); }
.chat-item.active { background: var(--color-thread-selected); color: var(--color-thread-selected-foreground); }
@media (min-width: 761px) { .chat-item { margin: 0 6px; padding: 12px 14px; border-radius: 22px; } .chat-item.active { background: var(--color-card); box-shadow: 0 1px 3px rgba(0,0,0,.06); } }
.chat-item .tw { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.chat-item .r1 { display: flex; align-items: center; gap: 8px; min-height: 20px; }
.chat-item .sub2 { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; font-size: 14.5px; color: var(--muted); }
.chat-item .sub2 span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .t { font-size: 16.5px; line-height: 1.3; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.chat-item.unseen .t { font-weight: 700; }
.chat-item .r3 { display: flex; align-items: center; gap: 8px; min-height: 20px; font-size: 13.5px; color: var(--muted); }
.chat-item .dir { flex: 1; min-width: 0; font-family: var(--mono); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .rc { flex-shrink: 0; display: flex; align-items: center; }
.chat-item .ago { font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.chat-item .term { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 0 4px; }
.chat-item .del { opacity: 0; flex-shrink: 0; background: none; border: none; color: var(--faint); padding: 0 2px; font-size: 13px; }
.chat-item:hover .del, .chat-item.active .del { opacity: 1; }
.chat-item .del:hover { color: var(--danger); }
.chat-item .cb { width: 22px; height: 22px; margin-top: 22px; border-radius: 7px; border: 2px solid var(--faint); flex-shrink: 0; display: grid; place-items: center; font-size: 13px; color: var(--on-accent); }
.chat-item.sel { background: var(--color-update); }
.chat-item.sel .cb { background: var(--accent); border-color: var(--accent); }
.selecting .chat-item .del { display: none; }
.group-label { color: var(--muted); font-size: 14px; padding: 16px 20px 6px; }
.sec-head { display: flex; align-items: center; gap: 12px; width: 100%; background: none; border: none; color: var(--muted);
  font-size: 14.5px; padding: 18px 20px 8px; text-align: left; }
.sec-head i { flex: 1; height: 1px; background: var(--border); }
.sec-head svg { transition: transform .2s; color: var(--faint); }
.sec-head.closed svg { transform: rotate(180deg); }
.sec-head.pinned { cursor: default; } .sec-head.pinned svg { display: none; }

.badge { flex-shrink: 0; font-size: 13.5px; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.badge.working { color: var(--info); }
.badge.working::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--info); animation: pulse 1.2s infinite; }
/* Waiting: the turn ended, subagents still run (T3 Code style); a slower pulse in the warning colour */
.badge.waiting { color: var(--warn); }
.badge.waiting::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); animation: pulse 2s infinite; }
.badge.complete { color: var(--ok); }
.badge.error { color: var(--danger); }
.badge.stopped { color: var(--muted); }

/* floating actions, bottom right like T3's "New thread" */
.fabs { position: absolute; right: 16px; bottom: calc(18px + var(--safe-bot)); display: flex; flex-direction: column; align-items: flex-end; gap: 14px; z-index: 3; }
.fab-sq { width: 58px; height: 58px; border-radius: 18px; border: none; background: var(--panel); color: var(--color-icon);
  display: grid; place-items: center; box-shadow: 0 3px 10px rgba(0,0,0,.14), 0 1px 3px rgba(0,0,0,.08); }
.fab-thread { display: inline-flex; align-items: center; gap: 12px; height: 62px; padding: 0 26px 0 22px; border: none; border-radius: 20px;
  background: var(--accent); color: var(--on-accent); font-size: 17px; font-weight: 500; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.fab-sq:active, .fab-thread:active { transform: scale(.95); }
.fab-sq:disabled, .fab-thread:disabled { opacity: .55; }

.head-actions .text-btn { padding: 8px 10px; }
.text-btn { background: none; border: none; color: var(--accent-text); font-size: 15px; padding: 6px 8px; border-radius: 999px; }
.text-btn:hover { background: var(--color-row-hover); }
.danger-btn { background: var(--color-danger); color: var(--danger); border: 1px solid var(--color-danger-border); border-radius: 999px; padding: 9px 16px; font-weight: 600; }
.danger-btn:disabled { opacity: .4; }
.bulk-bar { display: flex; align-items: center; gap: 8px; padding: 10px 16px calc(10px + var(--safe-bot)); border-top: 1px solid var(--border); background: var(--bg); }
.bulk-bar span { flex: 1; font-size: 14px; color: var(--muted); }
.sidebar.selecting .fabs, .sidebar.selecting .side-foot { display: none; }

/* servers / project / view switches at the top of the list */
.srv-chip { display: flex; align-items: center; gap: 8px; margin: 12px 12px 0; padding: 10px 14px; border-radius: 16px; border: none;
  background: var(--panel2); font-size: 14.5px; text-align: left; }
.srv-chip span { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.srv-chip svg { color: var(--muted); }
.srv-chip.hidden { display: none; }
.project-chip { flex: 1; min-width: 0; padding: 8px 14px; min-height: 40px; display: flex; align-items: center; gap: 6px;
  text-align: left; border: 1px solid var(--border); border-radius: 999px; background: transparent; font-size: 12.5px; color: var(--muted); }
.project-chip b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-size: 14px; font-weight: 600; }
.project-chip.unavailable b { color: var(--danger); }
.chat-views { display: flex; padding: 3px; gap: 2px; background: var(--panel2); border-radius: 999px; flex-shrink: 0; }
.chat-views button { min-height: 34px; padding: 0 12px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 13px; }
.chat-views button[aria-pressed="true"] { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; vertical-align: middle; }
.dot.online, .srv-chip[data-state="online"] .dot { background: var(--ok); }
.dot.offline, .srv-chip[data-state="offline"] .dot { background: var(--danger); }
.dot.auth { background: var(--warn); }
.dot.checking, .srv-chip[data-state="checking"] .dot { background: var(--muted); animation: pulse 1s infinite; }

/* projects view */
.project-group-head { display: flex; align-items: center; gap: 4px; margin-top: 6px; padding: 0 12px 0 20px; }
.project-group-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 0; text-align: left; background: none; border: 0; font-size: 13px; color: var(--muted); }
.project-group-toggle b { color: var(--text); font-size: 15.5px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-group-toggle small { margin-left: auto; flex-shrink: 0; font-size: 12px; }
.project-chevron { flex-shrink: 0; color: var(--faint); }
.project-group-add { flex-shrink: 0; border: none; border-radius: 50%; background: var(--panel2); color: var(--text); width: 38px; height: 38px; font-size: 20px; line-height: 1; }
.project-group-add:disabled { opacity: .4; }
.project-empty { padding: 2px 20px 10px; font-size: 13px; color: var(--muted); }

/* ---------- chat screen ---------- */
.chat-project { flex-shrink: 0; padding: 12px max(20px, calc((100% - 820px)/2)) 0; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.messages { flex: 1; overflow-y: auto; padding: 12px max(16px, calc((100% - 820px)/2)) 20px; -webkit-overflow-scrolling: touch; }
.empty { height: 100%; display: grid; place-content: center; text-align: center; color: var(--muted); gap: 8px; justify-items: center; }
.msg { margin: 14px 0; max-width: 100%; overflow-wrap: anywhere; }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.msg.user .bubble { background: var(--user); color: var(--color-user-bubble-foreground); padding: 12px 18px; border-radius: 22px; max-width: 86%; white-space: pre-wrap; font-size: 16.5px; line-height: 1.45; }
.msg.assistant .bubble { padding: 0 4px; font-size: 16.5px; line-height: 1.5; color: var(--color-md-body); }
.bubble p { margin: .55em 0; }
.bubble strong { color: var(--color-md-strong); }
.bubble ul, .bubble ol { padding-left: 1.3em; }
.bubble blockquote { margin: .6em 0; padding: 6px 12px; border-left: 3px solid var(--color-md-blockquote-border); background: var(--color-md-blockquote-bg); border-radius: 0 10px 10px 0; }
.bubble hr { border: none; border-top: 1px solid var(--color-md-hr); }
.bubble pre { background: var(--color-md-code-bg); border: 1px solid var(--border); border-radius: 14px; padding: 12px; overflow-x: auto; font-size: 13px; }
.bubble code { font-family: var(--mono); font-size: .88em; }
.bubble :not(pre) > code { background: var(--panel2); color: var(--color-md-code-text); padding: 1px 5px; border-radius: 6px; }
.msg.user .bubble :not(pre) > code { background: var(--color-md-user-code-bg); color: var(--color-md-user-code-text); }
.bubble a { color: var(--color-md-link); }
.bubble table { border-collapse: collapse; display: block; overflow-x: auto; }
.bubble td, .bubble th { border: 1px solid var(--border); padding: 5px 9px; }

/* agent work: muted, collapsed rows, like T3's "Worked for 2m >" */
.reasoning { color: var(--muted); font-size: 14px; margin: 6px 4px; }
.reasoning summary { cursor: pointer; list-style: none; }
.reasoning summary::-webkit-details-marker { display: none; }
.reasoning summary::after { content: " ›"; color: var(--faint); }
.reasoning div { white-space: pre-wrap; padding: 6px 0 6px 12px; border-left: 2px solid var(--border); margin-top: 6px; }
.tool { margin: 2px 0; font-size: 14px; color: var(--muted); }
.tool summary { padding: 7px 4px; cursor: pointer; display: flex; gap: 8px; align-items: center; list-style: none; border-radius: 10px; }
.tool summary:hover { background: var(--color-row-hover); }
.tool summary::-webkit-details-marker { display: none; }
.tool summary::after { content: "›"; color: var(--faint); font-size: 17px; line-height: 1; transition: transform .15s; }
.tool[open] summary::after { transform: rotate(90deg); }
.tool .st { width: 16px; text-align: center; font-size: 12px; }
.tool .st.run { color: var(--info); animation: pulse 1s infinite; }
.tool .st.ok { color: var(--ok); }
.tool .st.err { color: var(--danger); }
.tool .nm { font-weight: 600; color: var(--text); }
.tool .pv { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 1; font-family: var(--mono); font-size: 12.5px; }
.tool pre { margin: 4px 0 8px 28px; padding: 10px 12px; background: var(--panel2); border-radius: 12px; max-height: 320px; overflow: auto; white-space: pre-wrap; font: 12px/1.5 var(--mono); color: var(--text); }
.status-line { color: var(--muted); font-size: 14px; margin: 10px 4px; display: flex; gap: 8px; align-items: center; }
.spinner { width: 13px; height: 13px; border: 2px solid var(--border); border-top-color: var(--info); border-radius: 50%; animation: spin .8s linear infinite; }
.err-line { color: var(--danger); background: var(--color-danger); border: 1px solid var(--color-danger-border); border-radius: 14px; padding: 9px 12px; font-size: 14px; margin: 10px 0; }
.notice { color: var(--ok); font-size: 14px; margin: 10px 4px; }
.meta { color: var(--muted); font-size: 12px; margin: 2px 4px 0; }
.hint { color: var(--muted); font-size: 13.5px; margin-top: -4px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- composer: one rounded field with + , text, mic and a round send ---------- */
.composer { position: relative; padding: 8px max(10px, calc((100% - 820px)/2)) calc(10px + var(--safe-bot)); background: transparent; }
.cmp-box { display: flex; gap: 2px; align-items: flex-end; padding: 6px; border-radius: 30px; background: var(--color-composer-surface);
  border: 1px solid var(--color-composer-border); }
.cmp-box:focus-within { border-color: var(--color-focus); }
.composer textarea { flex: 1; min-width: 0; resize: none; max-height: 40vh; background: transparent; border: none;
  padding: 11px 6px; font-size: 16.5px; line-height: 1.4; outline: none; }
.attach, .mic, .send, .stop { flex-shrink: 0; height: 46px; border: none; display: grid; place-items: center; }
.attach { width: 46px; border-radius: 50%; background: transparent; color: var(--color-icon); }
.attach:active, .mic:active { background: var(--color-row-hover); }
.send, .stop { width: 46px; border-radius: 50%; }
.send { background: var(--accent); color: var(--on-accent); }
#input:placeholder-shown ~ .send { opacity: .3; }
#input:placeholder-shown { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* one-line hint, like T3 */
.send:disabled { opacity: .3; }
.stop { background: var(--text); color: var(--bg); }
.mic { min-width: 46px; border-radius: 23px; background: transparent; color: var(--color-icon); display: flex; align-items: center; justify-content: center;
  gap: 4px; padding: 0 10px; font-size: 14px; font-variant-numeric: tabular-nums; }
.mic[data-state="rec"] { background: var(--color-danger); color: var(--danger); }
.mic[data-state="rec"] .mic-ic { animation: pulse 1s infinite; }
.mic[data-state="busy"] { color: var(--info); }
.mic[data-state="busy"] .mic-ic { animation: pulse .7s infinite; }
.mic[data-state="retry"] { color: var(--danger); }
.mic-cancel { width: 36px; height: 46px; border: none; background: transparent; color: var(--muted); font-size: 16px; flex-shrink: 0; }

.status-pill { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font: 12px var(--mono); color: var(--muted);
  padding: 6px max(20px, calc((100% - 820px)/2 + 8px)) 0; }
.status-pill > span { display: inline-flex; align-items: center; gap: 6px; }
.sp-ctx .bar { width: 54px; height: 6px; border-radius: 3px; background: var(--panel2); overflow: hidden; }
.sp-ctx .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.sp-ctx.warn .bar i { background: var(--warn); } .sp-ctx.crit .bar i { background: var(--danger); }
.sp-live { color: var(--info); gap: 10px !important; }
.sp-live span + span::before { content: "·"; margin-right: 10px; color: var(--muted); }
.sp-model { margin-left: auto; opacity: .85; }
.sp-limits { display: inline-flex; gap: 8px; align-items: center; background: var(--panel2); border: none; border-radius: 999px;
  padding: 3px 10px; color: var(--muted); font: inherit; cursor: pointer; }
.sp-limits .warn { color: var(--warn); } .sp-limits .crit { color: var(--danger); }

.slash-menu { position: absolute; left: max(10px, calc((100% - 820px)/2)); right: max(10px, calc((100% - 820px)/2)); bottom: calc(100% - 2px);
  max-height: min(46vh, 380px); overflow-y: auto; background: var(--color-sheet-solid); border: 1px solid var(--border); border-radius: 22px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18); z-index: 30; padding: 6px 0; -webkit-overflow-scrolling: touch; }
.slash-menu .sm-h { font-size: 12px; letter-spacing: .06em; color: var(--muted); padding: 10px 18px 4px; text-transform: uppercase; font-weight: 600; }
.slash-menu .sm-i { display: flex; align-items: baseline; gap: 10px; padding: 10px 18px; cursor: pointer; }
.slash-menu .sm-i.on, .slash-menu .sm-i:hover { background: var(--color-row-hover); }
.slash-menu .sm-n { font: 15px var(--mono); color: var(--text); white-space: nowrap; }
.slash-menu .sm-n b { color: var(--accent-text); font-weight: 600; }
.slash-menu .sm-d { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.slash-menu .sm-tag { margin-left: auto; font-size: 10.5px; color: var(--muted); background: var(--panel2); border-radius: 6px; padding: 1px 6px; flex-shrink: 0; }
.slash-menu .sm-i.with-star { align-items: center; padding-right: 8px; }
.slash-menu .sm-star { margin-left: auto; flex: none; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%;
  display: inline-grid; place-items: center; background: none; color: var(--faint); }
.slash-menu .sm-star.on { color: #f5b301; }
.slash-menu .sm-star:active, .slash-menu .sm-star:hover { background: var(--color-row-hover); }

/* rich markdown: code blocks, file chips, tap-to-copy */
.bubble .cblock { background: var(--color-md-code-bg); border: 1px solid var(--border); border-radius: 16px; margin: .7em 0; overflow: hidden; }
.cblock .cb-head { display: flex; align-items: center; gap: 2px; padding: 3px 6px 3px 14px; border-bottom: 1px solid var(--border); min-height: 38px; background: var(--panel2); }
.cblock .cb-lang { flex: 1; font: 12px var(--mono); color: var(--muted); }
.cblock .cb-btn { background: none; border: none; color: var(--muted); padding: 7px 9px; border-radius: 10px; display: inline-grid; place-items: center; }
.cblock .cb-btn:active, .cblock .cb-btn:hover { background: var(--color-row-hover); color: var(--text); }
.cblock .cb-btn.ok { color: var(--ok); }
.bubble .cblock pre { background: none; border: none; border-radius: 0; margin: 0; padding: 12px 14px; font-size: 13.5px; line-height: 1.55;
  overflow-x: auto; white-space: pre; -webkit-overflow-scrolling: touch; }
.bubble .cblock.wrap pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble :not(pre) > code.copyable { cursor: pointer; transition: background .15s, color .15s; -webkit-user-select: text; user-select: text; }
.bubble :not(pre) > code.copyable:active { background: var(--color-row-hover); }
.bubble .inline-code { display: inline-flex; align-items: center; vertical-align: middle; max-width: 100%; min-width: 0;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.bubble .inline-code > code { background: none; padding: 3px 7px; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .inline-code.command-code { display: flex; margin: .5em 0; }
.bubble .command-code > code { flex: 1; padding: 10px 12px; }
.ic-copy { display: inline-grid; place-items: center; flex: 0 0 44px; min-width: 44px; min-height: 44px; align-self: stretch;
  border: 0; border-left: 1px solid var(--border); background: none; color: var(--muted); padding: 8px; cursor: pointer; }
.ic-copy:hover, .ic-copy:active { background: var(--color-row-hover); color: var(--text); }
.ic-copy.ok { color: var(--ok); }
.ic-copy:focus-visible, .cb-btn:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -3px; }
.fchip { display: inline-flex; align-items: baseline; gap: 5px; vertical-align: baseline; cursor: pointer; padding: 0 2px; border-radius: 5px;
  color: var(--color-md-link); transition: background .15s; white-space: nowrap; max-width: 100%;
  text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
.fchip .fi { font: 700 .72em var(--mono); letter-spacing: -.02em; }
.fchip .fn { overflow: hidden; text-overflow: ellipsis; }
.fchip:active, .fchip:hover { background: var(--panel2); }
.copyable.flash { background: color-mix(in srgb, var(--ok) 22%, transparent) !important; color: var(--ok) !important; }
#toast { position: fixed; left: 50%; bottom: calc(110px + var(--safe-bot)); transform: translate(-50%, 10px); background: var(--color-prominent-action); color: var(--color-prominent-action-foreground);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 100; max-width: 86vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#inappBanner { position: fixed; inset: auto; margin: 0; left: 50%; top: calc(10px + env(safe-area-inset-top, 0px)); transform: translate(-50%, -140%);
  display: flex; align-items: center; gap: 12px; width: min(440px, calc(100vw - 24px)); padding: 12px 16px; border: 1px solid var(--border);
  border-radius: 20px; background: var(--panel); color: var(--text); box-shadow: 0 10px 30px rgba(0,0,0,.25); cursor: pointer;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 200; }
#inappBanner.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#inappBanner .ib-ic { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
#inappBanner.err .ib-ic { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
#inappBanner .ib-tx { display: flex; flex-direction: column; min-width: 0; }
#inappBanner .ib-tx b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#inappBanner .ib-tx span { color: var(--muted); font-size: 13px; }
.push-box + .push-box { margin-top: 10px; }
#inappBox .push-row + .push-row { margin-top: 8px; }
.fab-new.busy { opacity: .55; pointer-events: none; }
.fab-new.busy svg { animation: spin 1s linear infinite; }

/* ---------- attachments ---------- */
.attach-bar { display: flex; gap: 8px; overflow-x: auto; padding: 8px max(12px, calc((100% - 820px)/2)) 0; -webkit-overflow-scrolling: touch; }
.att { position: relative; display: flex; align-items: center; gap: 8px; background: var(--panel2); border-radius: 16px; padding: 6px 30px 6px 6px; max-width: 220px; flex-shrink: 0; overflow: hidden; }
.att img { width: 40px; height: 40px; object-fit: cover; border-radius: 10px; }
.att .att-ic { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: var(--panel); font: 700 12px var(--mono); }
.att .att-t { display: flex; flex-direction: column; min-width: 0; }
.att .att-n { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att .att-s { font-size: 11px; color: var(--muted); }
.att.err { outline: 1px solid var(--danger); }
.att.err .att-s { color: var(--danger); }
.att .att-x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: none; background: var(--panel); color: var(--muted); font-size: 11px; display: grid; place-items: center; }
.att .att-bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); transition: width .2s; }
.u-imgs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 86%; }
.u-img { max-width: 180px; max-height: 180px; border-radius: 16px; cursor: pointer; object-fit: cover; }
.u-files { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin-top: 6px; white-space: normal; }
.u-files .fchip { background: var(--color-md-user-code-bg); padding: 3px 8px; }

/* ---------- dialogs and bottom sheets ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; }
.login-card { width: min(340px, 90vw); text-align: center; display: grid; gap: 12px; justify-items: center; }
.login-card h1 { font-weight: 500; margin: 4px 0 0; }
.login-card input, .login-card button { width: 100%; padding: 14px 18px; border-radius: 999px; border: 1px solid var(--color-input-border); background: var(--color-input); font-size: 16px; }
.login-card button { background: var(--accent); color: var(--on-accent); font-weight: 600; border: none; }
.login-card .link-btn { background: none; color: var(--accent-text); }

dialog { background: var(--color-sheet-solid); color: var(--text); border: none; border-radius: 28px; width: min(520px, 92vw); max-height: 80vh; padding: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: var(--color-backdrop); }
dialog h3 { font-size: 21px; font-weight: 500; margin: 0 0 10px; }
dialog button { padding: 10px 16px; border-radius: 999px; border: none; background: var(--panel2); }
.dlg-actions { display: flex; justify-content: space-between; gap: 8px; }
.import-list { max-height: 55vh; overflow-y: auto; margin-bottom: 12px; border-radius: 20px; background: var(--panel2); }
.import-item { padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--sep); }
.import-item:last-child { border-bottom: none; }
.import-item:hover { background: var(--color-row-hover); }
.import-item small { color: var(--muted); display: block; }

.file-dlg, .sheet { margin: auto auto 0; width: min(560px, 100vw); max-width: 100vw; border-radius: 28px 28px 0 0;
  padding: 14px 18px calc(18px + var(--safe-bot)); }
.file-dlg[open], .sheet[open] { animation: sheetUp .24s cubic-bezier(.2,.8,.2,1); }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } }
.sheet-grip { width: 36px; height: 4px; border-radius: 2px; background: var(--faint); margin: 0 auto 14px; }
.sheet h3 { text-align: left; margin: 0 4px 8px; }
.sheet.tall { max-height: 90vh; overflow-y: auto; }
.set-sec { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 20px 4px 8px; font-weight: 600; }
.fd-preview { margin: 0 0 12px; border-radius: 18px; overflow: hidden; background: var(--panel2); display: grid; place-items: center; max-height: 46vh; }
.fd-preview img { max-width: 100%; max-height: 46vh; object-fit: contain; }
.fd-head { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.fd-icon { width: 48px; height: 48px; border-radius: 14px; background: var(--panel2); display: grid; place-items: center; flex-shrink: 0; font: 700 14px var(--mono); }
.fd-meta { min-width: 0; }
.fd-name { font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.fd-info { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; margin-top: 2px; }
.fd-actions { display: flex; flex-direction: column; gap: 8px; }
.fd-btn { display: block; text-align: center; padding: 14px; border-radius: 999px; border: none; background: var(--panel2);
  color: var(--text); text-decoration: none; font-size: 15.5px; }
.fd-btn.primary { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.fd-btn.ghost { background: none; color: var(--accent-text); }
.fd-btn.danger { color: var(--danger); }
.fd-btn.disabled { opacity: .4; pointer-events: none; }
.sheet .fd-btn { display: block; width: 100%; margin-top: 8px; }

/* message queue */
.queue-pill { align-self: center; display: inline-flex; align-items: center; gap: 7px; margin: 6px auto 0; padding: 8px 16px;
  border-radius: 999px; border: none; background: var(--panel2); color: var(--text); font-size: 14px; }
.queue-pill svg { color: var(--muted); }
.queue-pill:active { transform: scale(.96); }
.q-list { display: flex; flex-direction: column; margin-top: 8px; }
.q-item { display: flex; flex-direction: column; gap: 10px; padding: 14px 4px; border-bottom: 1px solid var(--sep); }
.q-t { font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 7.5em; overflow: hidden; }
.q-f { margin-left: 8px; color: var(--muted); font-size: 12px; }
.q-actions { display: flex; gap: 8px; justify-content: flex-end; }
.q-actions .q-send { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.q-actions .q-del { background: var(--panel2); color: var(--muted); }

/* subscription limits */
.u-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.u-head .hint { margin: 0; flex: 1; }
.u-head .fd-btn { flex: none; width: auto; margin: 0; }
.u-list { display: flex; flex-direction: column; gap: 10px; margin: 10px 0 14px; }
.u-prov { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-radius: 20px; background: var(--panel2); }
.u-name { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.u-plan { font-weight: 500; font-size: 12px; color: var(--muted); background: var(--panel); border-radius: 6px; padding: 1px 6px; margin-left: 4px; }
.u-row { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.u-bar { height: 8px; border-radius: 4px; background: var(--panel); overflow: hidden; margin: 6px 0 4px; }
.u-bar i { display: block; height: 100%; background: var(--accent); }
.u-lim.warn .u-bar i { background: var(--warn); } .u-lim.crit .u-bar i { background: var(--danger); }
.u-lim.warn b { color: var(--warn); } .u-lim.crit b { color: var(--danger); }
.u-sub { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.u-err { color: var(--danger); font-size: 13px; }

/* settings: grouped rounded cards like T3's settings lists */
.srv-list { display: flex; flex-direction: column; margin: 8px 0 12px; border-radius: 22px; overflow: hidden; background: var(--panel2); }
.srv-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--sep); cursor: pointer; }
.srv-row:last-child { border-bottom: none; }
.srv-row.active { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.srv-main { flex: 1; min-width: 0; }
.srv-name { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srv-tag { font-weight: 500; font-size: 11px; color: var(--accent-text); background: var(--color-update); border-radius: 6px; padding: 1px 6px; margin-left: 4px; }
.srv-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.srv-url { font-size: 12.5px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
dialog .srv-act { background: none; border: none; color: var(--muted); padding: 8px; border-radius: 50%; font-size: 18px; line-height: 1; display: grid; place-items: center; }
dialog .srv-act:active { background: var(--color-row-hover); color: var(--text); }
.srv-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.srv-form.hidden { display: none; }
.srv-form input, .voice-key input, .folder-go input { padding: 13px 16px; border-radius: 16px; border: 1px solid var(--color-input-border); background: var(--color-input); font-size: 16px; outline: none; }
.srv-form input:focus, .voice-key input:focus, .folder-go input:focus { border-color: var(--color-focus); }
.srv-form-act { display: flex; gap: 8px; }
.srv-form-act .fd-btn { flex: 1; }
#srvAddBtn.hidden { display: none; }
.push-box { border-radius: 22px; padding: 14px 16px; background: var(--panel2); }
.push-row { display: flex; align-items: center; gap: 10px; }
.push-state { flex: 1; font-size: 15px; }
.push-state.on { color: var(--ok); }
.push-state.bad { color: var(--danger); }
.push-box .fd-btn, .sheet .push-box .fd-btn { background: var(--panel); }
.push-box .fd-btn.primary { background: var(--accent); }
.push-btn, .sheet .push-btn { width: auto; margin: 0; padding: 9px 16px; min-height: 40px; }
.push-box .hint { margin: 10px 0 0; }
.push-box #pushTest { margin-top: 8px; padding: 10px; }
.voice-key { display: flex; align-items: stretch; gap: 8px; margin-top: 10px; }
.voice-key input { flex: 1 1 0; width: 0; min-width: 0; min-height: 44px; }
.voice-key .fd-btn, .sheet .voice-key .fd-btn { flex: 0 0 auto; width: auto; margin: 0; padding: 8px 16px; min-height: 44px; white-space: nowrap; }

/* theme picker */
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-opt { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-radius: 18px; border: 2px solid transparent; background: var(--panel); font-size: 13px; }
.theme-opt[aria-pressed="true"] { border-color: var(--accent); }
.theme-sw { display: flex; width: 44px; height: 26px; border-radius: 13px; overflow: hidden; border: 1px solid var(--border); }
.theme-sw i { flex: 1; }
.theme-modes { display: flex; padding: 3px; gap: 2px; background: var(--panel); border-radius: 999px; margin-top: 10px; }
.sheet .theme-modes button { flex: 1; margin: 0; min-height: 38px; padding: 0 8px; border-radius: 999px; background: transparent; color: var(--muted); font-size: 14px; }
.sheet .theme-modes button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

/* server summary */
.mx-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.mx-card { padding: 12px 14px; border-radius: 20px; background: var(--panel2); min-width: 0; }
.mx-h { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: 13px; color: var(--muted); }
.mx-h b { color: var(--text); font-size: 19px; white-space: nowrap; }
.mx-card.warn .mx-h b { color: var(--warn); } .mx-card.crit .mx-h b { color: var(--danger); }
.mx-card.warn .u-bar i { background: var(--warn); } .mx-card.crit .u-bar i { background: var(--danger); }
.spark { width: 100%; height: 28px; display: block; margin: 4px 0 2px; }
.spark .line { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark .area { fill: color-mix(in srgb, var(--accent) 12%, transparent); stroke: none; }
.mx-top { display: flex; flex-direction: column; font-size: 13px; }
.mx-p { display: grid; grid-template-columns: 1fr 56px 64px; gap: 8px; padding: 7px 4px; border-bottom: 1px solid var(--sep); }
.mx-p span:not(.mx-pn) { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.mx-pn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#mxSub .dot { margin-right: 4px; }
@media (max-width: 360px) { .mx-grid { grid-template-columns: 1fr; } }

/* "to the end" button */
.jump-wrap { position: relative; height: 0; z-index: 5; }
.jump-btn { position: absolute; left: 50%; bottom: 10px; transform: translate(-50%, 12px) scale(.92); opacity: 0; pointer-events: none;
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 999px; border: none;
  background: var(--color-glass-fallback); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); color: var(--text); font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.18); transition: opacity .18s, transform .18s; white-space: nowrap; }
.jump-btn.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0) scale(1); }
.jump-btn:active { transform: translate(-50%, 0) scale(.95); }
.jump-btn svg { color: var(--accent-text); }
.jump-dot { display: none; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.jump-btn.new .jump-dot { display: inline-block; }

/* projects sheet */
.project-list { display: flex; flex-direction: column; margin: 12px 0; border-radius: 22px; overflow: hidden; background: var(--panel2); }
.project-row { display: flex; align-items: center; gap: 2px; border-bottom: 1px solid var(--sep); padding-right: 6px; }
.project-row:last-child { border-bottom: none; }
dialog .project-pick { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 10px 16px; text-align: left; border: 0; border-radius: 0; background: transparent; }
.project-pick > span:last-child { min-width: 0; }
.project-pick b, .project-pick small { display: block; overflow-wrap: anywhere; }
.project-pick b { font-weight: 600; }
.project-pick small { color: var(--muted); font-size: 12px; line-height: 1.4; margin-top: 3px; }
.project-pick[aria-pressed="true"] { color: var(--accent-text); }
.project-tick { width: 16px; flex-shrink: 0; }
dialog .project-act { padding: 8px; min-width: 40px; min-height: 44px; border: 0; background: transparent; color: var(--muted); font-size: 18px; }
dialog .project-act.danger { color: var(--danger); }
#projectForm label { font-size: 13px; color: var(--muted); margin: 6px 4px 0; }
#projectMsg:not(:empty) { padding: 10px 14px; border-radius: 16px; background: var(--color-warning); color: var(--warn); overflow-wrap: anywhere; }
.project-safety { font-size: 12px; }
#projectsDlg button:disabled { opacity: .55; cursor: wait; }

/* folder tree: independent expansion and selection, not drill-down navigation */
#folderDlg { width: min(680px, calc(100% - 24px)); height: min(760px, 92vh); height: min(760px, 92dvh); max-height: 92vh; max-height: 92dvh; box-sizing: border-box; margin: auto; border-radius: 28px; overflow: hidden; }
#folderDlg[open] { display: flex; flex-direction: column; }
#folderDlg > :not(.folder-tree) { flex-shrink: 0; }
#folderDlg .hint { margin: 6px 4px; }
.folder-toolbar, .folder-go { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
#folderDlg .folder-toolbar .fd-btn, #folderDlg .folder-go .fd-btn { width: auto; margin: 0; flex-shrink: 0; }
.folder-toolbar label { display: flex; align-items: center; gap: 5px; font-size: 13.5px; color: var(--muted); margin-left: auto; }
.folder-go input { min-width: 0; width: 100%; }
.folder-tree { flex: 1 1 auto; min-height: 80px; overflow: auto; border-radius: 20px; background: var(--panel2); padding: 6px; }
.folder-children { margin-left: 18px; padding-left: 6px; border-left: 1px solid var(--border); }
.folder-row { display: flex; align-items: center; gap: 4px; min-height: 44px; border-radius: 12px; }
.folder-node[aria-selected="true"] > .folder-row { background: var(--color-update); }
dialog .folder-toggle { flex: 0 0 36px; width: 36px; height: 36px; padding: 0; border-radius: 50%; background: var(--panel); color: var(--accent-text); font-size: 22px; }
dialog .folder-toggle:disabled { background: none; color: var(--faint); }
dialog .folder-pick { flex: 1; min-width: 120px; padding: 10px 8px; text-align: left; white-space: nowrap; border: 0; background: transparent; color: var(--text); font-size: 15px; }
.folder-node[aria-selected="true"] > .folder-row .folder-pick { color: var(--accent-text); font-weight: 600; }
.folder-note { margin: 4px 8px 8px; }
.folder-selected { overflow-wrap: anywhere; margin: 4px 0 10px; padding: 10px 14px; border-radius: 16px; background: var(--color-update); font-size: 13.5px; color: var(--accent-text); }
#folderDlg button:disabled { opacity: .5; }

/* quick new chat sheet: default project button + recent project chips */
.sheet .fd-btn.quick-go { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 60px; margin-top: 12px; border-radius: 22px; }
.quick-go b { font-weight: 700; overflow-wrap: anywhere; }
.quick-go small { font-weight: 400; font-size: 12.5px; opacity: .8; overflow-wrap: anywhere; }
.quick-go:disabled { opacity: .5; }
.quick-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
dialog .quick-chip { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; max-width: 100%; min-height: 44px; padding: 9px 14px;
  border-radius: 18px; background: var(--panel2); color: var(--text); text-align: left; font-size: 14.5px; }
.quick-chip b { font-weight: 600; overflow-wrap: anywhere; }
.quick-chip small { color: var(--muted); font-size: 12px; }
dialog .quick-chip.none { background: transparent; border: 1px dashed var(--border); }
.quick-chip:active { transform: scale(.96); }

/* context handoff */
.handoff-btn.busy { opacity: .5; pointer-events: none; }
.handoff-btn.busy svg { animation: spin 1s linear infinite; }
.msg.user.handoff-card { display: block; margin-left: auto; max-width: min(88%, 640px); background: var(--user); border-radius: 22px; padding: 12px 16px; }
.handoff-card summary { cursor: pointer; list-style: none; display: flex; flex-direction: column; gap: 3px; }
.handoff-card summary::-webkit-details-marker { display: none; }
.handoff-card small { color: var(--muted); font-size: 12.5px; }
.handoff-card pre { white-space: pre-wrap; word-break: break-word; max-height: 50vh; overflow: auto; font-size: 12px; margin: 10px 0 0; }

/* Agent choice wraps on phones when all five CLIs are installed. */
.quick-agents { display: flex; flex-wrap: wrap; padding: 3px; gap: 2px; background: var(--panel2); border-radius: 22px; margin: 6px 0 4px; }
.sheet .quick-agents button { flex: 1 0 auto; margin: 0; padding: 8px 12px; min-height: 40px; border-radius: 999px; background: transparent; color: var(--muted); font-size: 15px; }
.sheet .quick-agents button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.agent-tag { flex-shrink: 0; font-style: normal; font-size: 11px; font-weight: 600; letter-spacing: .02em; color: var(--accent-text); background: var(--color-update); border-radius: 6px; padding: 1px 6px; }

/* Remote browser (browser.js): full-screen window over the app. */
dialog.browser-dlg { position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0;
  border-radius: 0; box-shadow: none; overflow: hidden; background: var(--bg); }
dialog.browser-dlg[open] { display: flex; flex-direction: column; }
.br-bar { display: flex; align-items: center; gap: 4px; padding: calc(6px + env(safe-area-inset-top)) calc(6px + env(safe-area-inset-right)) 6px calc(6px + env(safe-area-inset-left)); }
dialog .br-btn { flex: 0 0 auto; width: 40px; height: 40px; padding: 0; display: grid; place-items: center; font-size: 20px; line-height: 1;
  background: transparent; color: var(--text); }
dialog .br-btn:disabled { opacity: .35; }
dialog .br-btn.hint { background: var(--accent); color: var(--on-accent); }
.br-url { flex: 1; min-width: 0; height: 40px; padding: 0 14px; border-radius: 999px; border: none; background: var(--panel2); color: var(--text); font-size: 16px; }
.br-title { padding: 0 16px 4px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 4px; }
.br-title:empty { padding-bottom: 0; }
.br-view { position: relative; flex: 1; min-height: 0; background: #fff; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  margin-bottom: env(safe-area-inset-bottom); }
.br-view img { display: block; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.br-view.loading::before { content: ""; position: absolute; left: 0; top: 0; height: 2px; width: 40%; background: var(--accent); animation: brLoad 1s linear infinite; z-index: 1; }
@keyframes brLoad { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.br-note { position: absolute; left: 50%; top: 40%; transform: translateX(-50%); max-width: 80%; padding: 10px 16px; border-radius: 16px;
  background: rgba(0,0,0,.75); color: #fff; font-size: 14px; text-align: center; }
.br-keys { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; font-size: 16px; }
.br-share { margin: 0 8px 6px; padding: 12px; border-radius: 20px; background: var(--panel2); font-size: 14px; }
.br-share p { margin: 0 0 8px; color: var(--muted); }
.br-share .br-url { width: 100%; box-sizing: border-box; background: var(--bg); font-size: 14px; }
.br-share-act { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
dialog .br-pill, .br-pill { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px; border: none; background: var(--bg); color: var(--text); font-size: 14px; text-decoration: none; }
.br-pill.primary { background: var(--accent); color: var(--on-accent); }

/* Terminal view of a chat (terminal.js): the agent's real TUI, dark like a terminal app whatever the theme. */
@font-face { font-family: "Symbols Nerd Font Mono"; font-style: normal; font-weight: 400; font-display: block;
  src: url(/fonts/symbols-nerd-font-mono.woff2) format("woff2"); unicode-range: U+23FB-23FE, U+2665, U+26A1, U+2B58, U+E000-F8FF, U+F0000-FFFFD; }
.chat-card.term-mode { background: #1a1b26; }
.chat-card.term-mode > :not(.term-pane) { display: none !important; }
.term-btn[aria-pressed="true"] { color: var(--accent-text); }
.term-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #1a1b26; color: #c0caf5; position: relative; }
.term-view { flex: 1; min-height: 0; overflow: hidden; }
.term-view .xterm { height: 100%; padding: 8px 4px 2px 8px; } /* FitAddon subtracts this element's padding, not the parent's */
.term-view .xterm-viewport { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.term-note { position: absolute; left: 12px; right: 12px; top: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-radius: 14px; background: #24283b; border: 1px solid #414868; font-size: 14px; z-index: 5; }
.term-note span { flex: 1; min-width: 160px; }
.term-pill { min-height: 36px; padding: 0 14px; border-radius: 999px; border: none; background: #7aa2f7; color: #1a1b26; font-weight: 600; font-size: 14px; }
.term-keys { display: flex; gap: 8px; overflow-x: auto; padding: 10px 10px 6px; scrollbar-width: none; background: #16161e; }
.term-keys::-webkit-scrollbar { display: none; }
.term-key { flex-shrink: 0; min-width: 44px; height: 42px; padding: 0 14px; border-radius: 14px; border: none; background: #24283b; color: #c0caf5;
  font: 15px var(--mono); white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; touch-action: manipulation; }
.term-key.ic { padding: 0 10px; }
.term-key.danger { color: #f7768e; }
.term-key:active { background: #33467c; }
.term-input { display: flex; gap: 8px; align-items: flex-end; padding: 6px 10px calc(10px + var(--safe-bot)); background: #16161e; }
.term-input textarea { flex: 1; min-width: 0; resize: none; max-height: 120px; padding: 11px 14px; border-radius: 16px; border: 1px solid #414868;
  background: #1a1b26; color: #c0caf5; font: 16px var(--mono); line-height: 1.35; outline: none; }
.term-input textarea:focus { border-color: #7aa2f7; }
.term-input .send { background: #7aa2f7; color: #1a1b26; }
.term-kbd { flex-shrink: 0; width: 46px; height: 46px; border-radius: 16px; border: 1px solid #414868; background: #1a1b26; color: #c0caf5; display: grid; place-items: center; }
.term-kbd:active { background: #33467c; }
.term-input .mic, .term-input .mic-cancel { color: #c0caf5; }
.term-input .mic:active { background: #33467c; }
.term-view { position: relative; }
.term-jump { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 6; display: inline-flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid #414868; background: #24283b; color: #c0caf5; font-size: 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,.45); touch-action: manipulation; }
.term-jump:active { background: #33467c; }
.term-kbd.busy { opacity: .5; animation: pulse 1s infinite; }
.term-info { height: 24px; line-height: 24px; padding: 0 12px; background: #16161e; color: #9aa5ce; font: 12.5px var(--mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-top: 1px solid #24283b; }
/* The row keeps a fixed height (no terminal resize); the field inside is anchored to its bottom and grows upward
   over the terminal while focused (height set in terminal.js). */
.term-line { flex: 1; min-width: 0; position: relative; height: 46px; }
.term-line textarea { position: absolute; left: 0; right: 0; bottom: 0; z-index: 7; width: 100%; box-sizing: border-box;
  height: 46px; max-height: none; overflow-y: auto; }
.term-line textarea:focus { box-shadow: 0 -6px 18px rgba(0,0,0,.5); }
.term-key.cmd { color: #7dcfff; border: 1px solid #2a3a5c; }
.term-path { flex: none; height: 24px; line-height: 24px; padding: 0 12px; background: #16161e; color: #7aa2f7; font: 12.5px var(--mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-bottom: 1px solid #24283b; } /* fixed height: no terminal resize */
.term-host { height: 100%; } /* one per open terminal chat; hidden ones keep their screen */
