/* webigmodel — a calm, focused workspace. Light and dark share one set of
   tokens; only the values change. One accent, generous spacing, quiet borders. */
:root {
  color-scheme: light;
  --model-claude: #a34528;
  --model-codex: #08765b;
  --model-agy: #255fbe;
  --model-compatible: #7c3aed;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --raised: #ffffff;
  --line: #e6e8ec;
  --line-strong: #d4d8de;
  --text: #1a1d21;
  --text-soft: #4b5563;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent-weak: #eef0fe;
  --accent-text: #ffffff;
  --user-bubble: #4f46e5;
  --user-text: #ffffff;
  --ok: #17803d;
  --warn: #b4530a;
  --danger: #d02b2b;
  --danger-weak: #fdecec;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .18);
  --radius: 12px;
  --radius-sm: 8px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]), :root[data-theme="system"] {
    --bg: #0e1013;
    --surface: #16191e;
    --surface-2: #1b1f25;
    --raised: #1c2027;
    --line: #262b33;
    --line-strong: #333a44;
    --text: #e8eaed;
    --text-soft: #b3b9c2;
    --muted: #9aa6b5;
    --accent: #7c7cf0;
    --accent-weak: #1e2033;
    --accent-text: #000000;
    color-scheme: dark;
    --ok: #4ade80;
    --warn: #f0a35e;
    --danger: #f47171;
    --danger-weak: #2a1a1c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 34px rgba(0, 0, 0, .55);
  }
}
:root[data-theme="dark"] {    --bg: #0e1013;
    --surface: #16191e;
    --surface-2: #1b1f25;
    --raised: #1c2027;
    --line: #262b33;
    --line-strong: #333a44;
    --text: #e8eaed;
    --text-soft: #b3b9c2;
    --muted: #9aa6b5;
    --accent: #7c7cf0;
    --accent-weak: #1e2033;
    --accent-text: #000000;
    color-scheme: dark;
    --ok: #4ade80;
    --warn: #f0a35e;
    --danger: #f47171;
    --danger-weak: #2a1a1c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 34px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 15px/1.6 var(--sans); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px;
  border: 2px solid transparent; background-clip: content-box; }

button { font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 8px 14px; cursor: pointer; transition: background .12s, border-color .12s, opacity .12s; }
button:hover { background: var(--surface-2); border-color: var(--accent); }
button:active { transform: translateY(0.5px); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent);
  font-weight: 550; box-shadow: var(--shadow); }
button.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
button.danger:hover { background: var(--danger-weak); border-color: var(--danger); }
button.link { background: none; border: none; color: var(--muted); padding: 2px 4px; }
button.link:hover { background: none; color: var(--accent); }
button.icon { padding: 6px 9px; border-color: var(--line); }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 9px 11px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak); }
textarea { resize: vertical; min-height: 60px; max-height: 42vh; line-height: 1.55; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--danger); min-height: 1.2em; font-size: 13px; }

/* ---- login --------------------------------------------------------- */
.login { min-height: 100%; display: flex; padding: 40px clamp(24px, 6vw, 96px);
  background: radial-gradient(ellipse at 12% 45%, var(--accent-weak), transparent 65%), var(--bg); }
.login-shell { width: min(1120px, 100%); margin: auto; min-height: min(780px, calc(100svh - 80px));
  display: flex; flex-direction: column; }
.login-brand { display: flex; align-items: center; gap: 12px; font-weight: 650; font-size: 20px; letter-spacing: -.6px; }
.login-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px;
  background: var(--text); color: var(--bg); font-size: 23px; }
.login-layout { flex: 1; display: grid; grid-template-columns: 1.4fr 1fr; align-items: center; gap: 64px; padding: 80px 0; }
.login-eyebrow { color: var(--text-soft); font-size: 12px; letter-spacing: 4px; margin: 0 0 24px; }
.login-intro h1 { font-size: clamp(40px, 5vw, 66px); font-weight: 650; letter-spacing: -.04em; line-height: 1.22; margin: 0 0 28px; }
.login-intro h2 { font-size: 18px; font-weight: 550; margin: 0 0 14px; }
.login-description { color: var(--text-soft); font-size: 15px; line-height: 1.9; margin: 0; }
.login-capabilities { display: flex; flex-wrap: wrap; gap: 12px 20px; margin-top: 32px; font-size: 12px; color: var(--text-soft); }
.login-capabilities span { border-left: 2px solid var(--line-strong); padding-left: 10px; }
.login form { min-width: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; padding: 36px; display: grid; gap: 14px; box-shadow: 0 16px 48px rgba(0,0,0,.045); }
.login-card-symbol { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--line);
  border-radius: 13px; color: var(--text-soft); font-size: 24px; margin-bottom: 28px; }
.login-card-heading h2 { margin: 0 0 10px; font-size: 23px; font-weight: 600; letter-spacing: -.5px; }
#login-note { color: var(--text-soft); font-size: 13px; margin: 0 0 14px; }
.login .error { margin: 0; overflow-wrap: anywhere; }
.login .error:empty, #login-action:empty { display: none; }
.login-cta, .login button[type=submit] { display: flex; align-items: center; justify-content: center; min-height: 48px;
  width: 100%; border: 1px solid var(--text); border-radius: 10px; background: var(--text); color: var(--bg);
  text-decoration: none; font-size: 14px; font-weight: 550; padding: 12px 16px; }
.login-cta:hover, .login button[type=submit]:hover { opacity: .88; }
.login-cta:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
#login-local-fields { display: grid; gap: 14px; }
.login-divider { display: flex; align-items: center; gap: 12px; margin: 2px 0; color: var(--text-soft); font-size: 13px; }
.login-divider::before, .login-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.login-divider[hidden] { display: none !important; }
.login-cta-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); }
.login-cta-secondary:hover { background: var(--surface-2); border-color: var(--accent); }
.login-provider { margin: 2px 0 0; text-align: center; font-size: 12px; color: var(--text-soft); }
.login-footer { border-top: 1px solid var(--line); padding-top: 22px; display: flex; justify-content: space-between;
  gap: 16px; color: var(--text-soft); font-size: 12px; }
@media (max-width: 760px) {
  .login { padding: 28px 24px; }
  .login-shell { min-height: calc(100svh - 56px); }
  .login-layout { grid-template-columns: 1fr; gap: 36px; padding: 48px 0; }
  .login-intro h1 { font-size: 44px; margin-bottom: 22px; }
  .login-intro h2 { font-size: 16px; }
  .login-description { font-size: 14px; }
  .login-desktop-break { display: none; }
  .login-capabilities { margin-top: 22px; gap: 12px; }
  .login form { padding: 28px; }
  .login-card-symbol { display: none; }
  .login-footer { flex-wrap: wrap; }
}

/* ---- app shell ----------------------------------------------------- */
.app { height: 100%; display: grid; grid-template-columns: 300px 1fr; }
.sidebar { border-right: 1px solid var(--line); background: var(--surface); display: flex;
  flex-direction: column; min-height: 0; }
.sidebar-head { display: flex; gap: 8px; padding: 14px; }
.sidebar-head .primary { flex: 1; }
.sidebar-head #reload-sessions { width: 40px; padding: 8px 0; color: var(--muted); }

.session-list { list-style: none; margin: 0; padding: 4px 8px; overflow-y: auto; flex: 1; }
.session-list li { position: relative; padding: 10px 10px 10px 30px; border-radius: 10px; cursor: pointer;
  display: flex; align-items: flex-start; gap: 8px; }
.session-list li:hover { background: var(--surface-2); }
.session-list li.active { background: var(--accent-weak); }
.session-list li.active::before { content: ""; position: absolute; left: 8px; top: 12px; bottom: 12px;
  width: 3px; border-radius: 3px; background: var(--accent); }
.session-list .dot { position: absolute; left: 13px; top: 15px; width: 8px; height: 8px; border-radius: 50%;
  flex: none; }
.session-list .dot.busy { box-shadow: 0 0 0 0 currentColor; animation: pulse 1.6s infinite; color: var(--ok); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(23,128,61,.5); } 70% { box-shadow: 0 0 0 6px rgba(23,128,61,0); } 100% { box-shadow: 0 0 0 0 rgba(23,128,61,0); } }
.row-body { flex: 1; min-width: 0; }
.session-list .t { font-weight: 550; font-size: 14px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; color: var(--text); }
.session-list .t .star { color: #e6a817; margin-right: 4px; }
.session-list .m { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; gap: 5px;
  flex-wrap: wrap; align-items: center; white-space: nowrap; overflow: hidden; }
.session-list .m .sep { opacity: .5; }
.session-list .m .owner { color: var(--accent); }
.row-acts { display: none; gap: 2px; flex: none; }
.session-list li:hover .row-acts, .session-list li.active .row-acts { display: flex; }
.row-act { border: none; background: none; padding: 3px 5px; font-size: 13px; line-height: 1; color: var(--muted);
  border-radius: 6px; }
.row-act:hover { background: var(--line); color: var(--text); }

.sidebar-foot { padding: 12px 14px; border-top: 1px solid var(--line); display: flex; align-items: center;
  gap: 10px; flex-wrap: wrap; font-size: 12.5px; }
.sidebar-foot .conn { color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.sidebar-foot .conn::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.sidebar-foot .conn.on::before { background: var(--ok); }
.sidebar-foot .conn.off::before { background: var(--warn); }
.sidebar-foot .conn.busy { color: var(--accent); }
.sidebar-foot .conn.busy::before { background: var(--accent); animation: pulse 1.4s infinite; }
.sidebar-foot #whoami { font-weight: 550; color: var(--text-soft); margin-right: auto; }


.session-list li.group { position: sticky; top: 0; background: var(--surface); cursor: default;
  padding: 8px 10px 4px; display: flex; align-items: center; gap: 6px; z-index: 1; }
.session-list li.group:hover { background: var(--surface); }
.session-list li.group > span:first-child { font-size: 11px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-list li.group .gcount { font-size: 11px; color: var(--muted); background: var(--surface);
  border-radius: 20px; padding: 0 7px; min-width: 18px; text-align: center; }

/* tool tag pills — every session, colored by tool */
.session-list .m { align-items: center; }
.tag { font-size: 10.5px; font-weight: 650; padding: 1px 7px; border-radius: 20px; line-height: 1.5;
  color: #fff; letter-spacing: .02em; }
.tag-claude { background: var(--model-claude); }
.tag-codex { background: var(--model-codex); }
.tag-agy { background: var(--model-agy); }
.tag-compatible { background: var(--model-compatible); }
.session-list .run { color: var(--ok); font-weight: 600; }
.session-list .run::before { content: "● "; }
.session-list li { padding-left: 12px; }
.session-list li.active::before { top: 12px; bottom: 12px; }

/* ---- main / chat --------------------------------------------------- */
.main { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg); }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 22px;
  border-bottom: 1px solid var(--line); background: var(--surface); }
.chat-title { flex: 1; min-width: 0; }
.chat-title .title { font-weight: 650; font-size: 16px; letter-spacing: -.01em; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.chat-title .small { color: var(--muted); margin-top: 1px; }
#toggle-sidebar { display: none; }
.notice { padding: 10px 22px; background: color-mix(in srgb, var(--warn) 12%, var(--surface));
  color: var(--warn); border-bottom: 1px solid var(--line); font-size: 13px; }

.timeline { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: min(760px, 92%); padding: 12px 16px; border-radius: 16px; white-space: pre-wrap;
  word-break: break-word; line-height: 1.6; box-shadow: var(--shadow); }
.msg.user { align-self: flex-end; background: var(--user-bubble); color: var(--user-text);
  border-bottom-right-radius: 5px; }
.msg.user .who { display: block; font-size: 11px; opacity: .8; margin-bottom: 3px; }
.msg.user .state { display: block; font-size: 11px; opacity: .8; margin-top: 5px; text-align: right; }
.msg.user.failed { background: var(--danger-weak); color: var(--danger); border:1px solid var(--danger); }
.msg.assistant { align-self: flex-start; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.assistant.live::after { content: "▍"; color: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { to { opacity: 0; } }
.msg.note { align-self: flex-start; max-width: min(760px, 92%); color: var(--muted); font-size: 13px;
  background: transparent; border: none; box-shadow: none; padding: 0 4px; font-style: italic; }

.tool { align-self: flex-start; max-width: min(760px, 92%); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; font-size: 13px; box-shadow: var(--shadow); }
.tool summary { cursor: pointer; color: var(--text-soft); list-style: none; display: flex; gap: 8px; align-items: baseline; }
.tool summary::-webkit-details-marker { display: none; }
.tool summary::before { content: "▸"; color: var(--muted); font-size: 11px; }
.tool[open] summary::before { content: "▾"; }
.tool summary b { color: var(--accent); font-weight: 600; }
.tool summary span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool pre { margin: 8px 0 0; font: 12px/1.5 var(--mono); white-space: pre-wrap; word-break: break-all;
  max-height: 320px; overflow: auto; color: var(--text-soft);
  background: var(--bg); padding: 8px 10px; border-radius: 8px; }
.status { align-self: center; font-size: 12px; color: var(--muted); background: var(--surface);
  border: 1px solid var(--line); border-radius: 20px; padding: 3px 12px; }
.status.error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.retry { margin-left: 8px; font-size: 11px; padding: 1px 9px; border-radius: 12px; }

/* ---- composer ---------------------------------------------------- */

/* ---- collapsed status: one light + a popover ---------------------- */
.status-wrap { position: relative; }
.status-light { padding: 6px; border-radius: 50%; border: 1px solid var(--line-strong); line-height: 0;
  background: var(--surface); }
.status-light .lamp { display: block; width: 12px; height: 12px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 0 0 rgba(23,128,61,.5); }
.status-light.bad .lamp { background: var(--danger); animation: lamp 1.8s infinite; }
@keyframes lamp { 0% { box-shadow: 0 0 0 0 rgba(208,43,43,.55); } 70% { box-shadow: 0 0 0 7px rgba(208,43,43,0); } 100% { box-shadow: 0 0 0 0 rgba(208,43,43,0); } }
.status-panel { position: absolute; right: 0; top: calc(100% + 8px); width: min(420px, 78vw); z-index: 30;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg);
  padding: 12px 14px; display: grid; gap: 10px; font-size: 12.5px; }
.sp-row { display: grid; grid-template-columns: 40px 1fr; gap: 10px; align-items: baseline; }
.sp-label { color: var(--muted); font-weight: 600; }
.sp-row .ib { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; color: var(--text-soft); }
.ib-quota b { color: var(--text); font-weight: 600; }
.ib-quota .q.low { color: var(--warn); font-weight: 600; }
.ib-quota .q.out { color: var(--danger); font-weight: 600; }
.ib-sys .sys-warn { color: var(--warn); font-weight: 600; }
.ib-sys.alert { color: var(--warn); font-weight: 600; }
.ib-presence.alert { color: var(--danger); font-weight: 650; }

.composer { display: flex; gap: 12px; padding: 14px 22px; border-top: 1px solid var(--line);
  background: var(--surface); padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.composer textarea { flex: 1; box-shadow: var(--shadow); }
.composer-side { display: flex; flex-direction: column; gap: 6px; align-items: stretch; width: 96px; }
.composer-side .primary { padding: 10px; }
.composer-side .queue-info, #queue-info { text-align: center; color: var(--muted); }
#stop { padding: 6px 14px; }

/* ---- dialogs ------------------------------------------------------- */
.dialog { position: fixed; inset: 0; background: rgba(10, 12, 16, .5); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.dialog-box { width: min(480px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 24px; display: grid; gap: 14px; box-shadow: var(--shadow-lg); }
.dialog-box.wide { width: min(720px, 100%); }
.dialog-box h2 { margin: 0 0 2px; font-size: 19px; letter-spacing: -.01em; }
.dialog-box label { display: grid; gap: 5px; font-size: 13px; color: var(--text-soft); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* ---- user management (cards) -------------------------------------- */
.users-list { display: grid; gap: 12px; max-height: 56vh; overflow-y: auto; padding-right: 4px; }
.ucard { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--surface-2);
  display: grid; gap: 10px; }
.ucard.disabled { opacity: .62; }
.uc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.uc-name { font-weight: 650; font-size: 15px; }
.uc-badge { font-size: 11px; padding: 1px 8px; border-radius: 20px; background: var(--line);
  color: var(--text-soft); font-weight: 600; }
.uc-badge.admin { background: var(--accent-weak); color: var(--accent); }
.uc-status { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.uc-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.uc-status.on { color: var(--ok); }
.uc-status.busy { color: var(--accent); font-weight: 700; }
.uc-status.off { color: var(--muted); }
.uc-status.dis { color: var(--danger); }
.uc-when { font-size: 12px; color: var(--muted); margin-left: auto; }
.uc-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.uc-label { color: var(--muted); min-width: 62px; }
.chips { display: inline-flex; gap: 7px; flex-wrap: wrap; }
.chip { padding: 3px 12px; border-radius: 20px; font-size: 12.5px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text-soft); font-weight: 550; }
.chip:hover { border-color: var(--accent); background: var(--surface); }
.chip.on { color: #fff; border-color: transparent; }
.chip.on.tag-claude { background: var(--model-claude); }
.chip.on.tag-codex { background: var(--model-codex); }
.chip.on.tag-agy { background: var(--model-agy); }
.chip.persist.on { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.uc-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 2px; }
.uc-actions button { padding: 5px 12px; font-size: 12.5px; }
.user-add { margin-top: 6px; padding: 16px; border: 1px dashed var(--line-strong); border-radius: 12px;
  display: grid; gap: 12px; }
.ua-title { font-weight: 650; font-size: 14px; }
.ua-fields { display: flex; gap: 10px; flex-wrap: wrap; }
.ua-fields input { flex: 1; min-width: 150px; width: auto; }
.ua-opts { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.ua-legend { color: var(--muted); font-size: 13px; }
.tool-checks { display: inline-flex; gap: 12px; flex-wrap: wrap; }
.tool-checks label, label.inline { font-size: 13px; display: inline-flex; gap: 5px; align-items: center; }
.tool-checks input, label.inline input { width: auto; }
.ua-opts .primary { margin-left: auto; }


/* disk row: a real sliding toggle, a labeled quota field, right-aligned usage */
.uc-row .uc-used { margin-left: auto; color: var(--muted); font-size: 12px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--text-soft); flex: none; white-space: nowrap; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .slider { position: relative; width: 38px; height: 22px; border-radius: 22px; background: var(--line-strong);
  transition: background .15s; flex: none; }
.toggle-txt { flex: none; }
.toggle .slider::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow); transition: transform .15s; }
.toggle input:checked + .slider { background: var(--accent); }
.toggle input:checked + .slider::after { transform: translateX(16px); }
.toggle input:focus-visible + .slider { box-shadow: 0 0 0 3px var(--accent-weak); }
.quota-field { display: inline-flex; align-items: center; gap: 6px; }
.uc-sub { color: var(--muted); font-size: 13px; }
.quota-field .disk-mb { width: 84px; padding: 6px 9px; }

/* ---- responsive ---------------------------------------------------- */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 22% 0 0; z-index: 40; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  #toggle-sidebar { display: inline-flex; }
  .row-acts { display: flex; }
  .msg { max-width: 90%; }
  .composer-side { width: 74px; }
  .chat-head, .timeline, .quota, .presence, .mydisk, .composer { padding-left: 16px; padding-right: 16px; }
}

.feishu-qr { display: flex; justify-content: center; padding: 8px; }
.feishu-qr img { width: 200px; height: 200px; background: #fff; border-radius: 10px; padding: 6px; }
.feishu-code { text-align: center; font-size: 15px; }
.feishu-code b { font: 700 22px var(--mono); letter-spacing: 3px; color: var(--accent);
  background: var(--accent-weak); padding: 2px 10px; border-radius: 8px; }
.perm-tag { font-size: 10.5px; padding: 1px 6px; border-radius: 20px; margin-left: 6px; border: 1px solid var(--warn); color: var(--warn); }
.approval { align-self: stretch; max-width: min(760px,100%); border: 1.5px solid var(--warn); border-radius: 12px;
  padding: 12px 14px; background: color-mix(in srgb, var(--warn) 8%, var(--surface)); display: grid; gap: 8px; }
.approval.done { border-color: var(--line); background: var(--surface-2); opacity: .8; }
.ap-head { font-weight: 650; color: var(--warn); }
.approval pre { margin: 0; font: 12px/1.4 var(--mono); white-space: pre-wrap; word-break: break-all; max-height: 200px; overflow: auto; background: var(--bg); padding: 8px; border-radius: 8px; }
.ap-acts { display: flex; gap: 10px; }
.ap-acts button { padding: 6px 18px; }
.ap-result { font-weight: 600; color: var(--text-soft); }

/* Workbench identity stays visible above the session controls. */
.workbench-title { padding: 16px 14px 0; font-size: 17px; font-weight: 650;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
#settings-form { width: min(480px, calc(100vw - 32px)); }
#settings-form label { font-weight: 550; }
#settings-form p { margin: 0; }

#settings-form { max-height: calc(100dvh - 40px); overflow-y: auto; }
.settings-section { border-top: 1px solid var(--line); padding-top: 14px; }
.settings-section h3 { margin: 0 0 10px; font-size: 14px; }
.settings-links { display: grid; gap: 8px; }
.settings-links button { display: flex; justify-content: space-between; align-items: center; text-align: left; }
.settings-links button span { color: var(--muted); }

/* Bounded historical reader, independent of the live timeline. */
.history-box { width: min(900px, 96vw); max-width: 96vw; max-height: 92dvh; display: flex; flex-direction: column; overflow: hidden; }
.history-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.history-head h2 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-records { overflow: auto; min-height: 100px; flex: 1; border-block: 1px solid var(--line, #ddd); }
.history-record { padding: 12px 0; border-bottom: 1px solid var(--line, #ddd); }
.history-record pre { font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0; }
.history-record summary { cursor: pointer; overflow-wrap: anywhere; }
.history-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
#history-error { margin: 4px 0; }
@media (max-width: 600px) { .history-box { padding: 14px; } .history-head h2 { font-size: 16px; } }

/* Durable message references and topic navigation. */
.message-actions { display:flex; gap:8px; margin-top:8px; white-space:normal; }
.message-actions button { font-size:12px; padding:3px 8px; opacity:.8; }
.quote-card { display:block; max-width:100%; width:100%; text-align:left; white-space:pre-wrap; overflow:hidden; max-height:100px; border-left:3px solid #7695dd; margin-bottom:10px; font-size:12px; }
#reply-preview { display:flex; align-items:center; gap:12px; padding:10px 18px; border-top:1px solid #5555; }
#reply-preview[hidden] { display:none; }
#reply-preview-text { flex:1; white-space:pre-wrap; max-height:90px; overflow:auto; font-size:13px; min-width:0; }
#reply-cancel { flex-shrink:0; }
#topic-select { max-width:180px; min-width:70px; }
.reference-highlight { outline:2px solid #7695dd; }
#reference-dialog { z-index:60; }
#reference-text { white-space:pre-wrap; overflow-wrap:anywhere; }
@media(max-width:600px) { #topic-select { max-width:110px; } .message-actions button { min-height:32px; } }

#topic-origin:not([hidden]) { padding:8px 18px 0; }

.task-box { width:min(820px,94vw); max-height:92dvh; overflow:auto; }
.task-box label { display:block; margin:10px 0; }
.task-box textarea,.task-box input:not([type=checkbox]) { width:100%; box-sizing:border-box; }
.task-limits { display:flex; gap:16px; }
.task-limits label { flex:1; min-width:0; }
.task-list { display:flex; flex-direction:column; gap:8px; margin:16px 0; }
.task-row,.task-card { text-align:left; white-space:normal; overflow-wrap:anywhere; }
.task-card { display:block; margin:12px 0; padding:12px; border-left:3px solid #82a7df; }
#task-logs,#task-result,.task-source { white-space:pre-wrap; overflow-wrap:anywhere; max-height:35vh; overflow:auto; font-size:12px; }
#task-create-dialog { z-index:70; }
#tasks-dialog { z-index:65; }
@media(max-width:600px) { .message-actions { flex-wrap:wrap; } .task-box { padding:14px; } }

#model-accounts-cards section { display:flex; flex-wrap:wrap; gap:8px; }
#model-accounts-cards h3, #model-accounts-cards p, #model-accounts-cards pre { width:100%; margin:4px 0; }
#model-accounts-cards pre { white-space:pre-wrap; overflow-wrap:anywhere; }
#model-accounts-cards input { width:100%; }

#model-accounts-dialog .dialog-box { max-height:calc(100dvh - 40px); overflow-y:auto; min-height:0; }

.session-list .wait { color:var(--warn); font-weight:600; }
.session-list .wait::before { content:'◷ '; }
.sidebar-foot .conn.waiting { color:var(--warn); }
.sidebar-foot .conn.waiting::before { background:var(--warn); animation:none; }

#project-status {padding:6px 16px;overflow-wrap:anywhere;flex-shrink:0;max-height:90px;overflow:auto} #project-status button{margin-left:8px} #new-project-path{overflow-wrap:anywhere} @media(max-width:600px){.chat-head{flex-wrap:wrap} #project-model{font-size:12px;padding:4px 8px}}

/* Composer size is user-controlled and retained after sending. */
.composer-options { display:flex; align-items:center; flex-wrap:wrap; gap:8px; padding:6px 16px; }
#input { min-height:80px; max-height:50dvh; resize:vertical; }
#attachment-status { overflow-wrap:anywhere; flex-basis:100%; }

#operations-dialog .dialog-box { max-height:90dvh; overflow:auto; }

/* Compact project workbench, phase one. */
:root { --user-bubble:color-mix(in srgb, var(--surface) 80%, var(--accent-weak)); --user-text:var(--text); }
.app { grid-template-columns:var(--sidebar-width,240px) minmax(0,1fr); position:relative; }
.sidebar { position:relative; background:var(--surface-2); }
.workbench-title { padding:14px 16px 0; font-size:16px; }
.sidebar-head { padding:12px 12px 8px; gap:6px; }
.project-search { padding:0 12px 10px; }
.project-search input { padding:7px 10px; font-size:13px; }
#search-empty { padding:0 16px; }
.sidebar-foot { gap:8px 12px; padding:12px; }
#whoami { width:100%; overflow-wrap:anywhere; }
#sidebar-resizer { position:absolute; left:calc(var(--sidebar-width,240px) - 3px); top:0; bottom:0; width:6px; z-index:5; cursor:col-resize; touch-action:none; }
#sidebar-resizer:hover, #sidebar-resizer:focus-visible { background:var(--accent); }
.app.sidebar-collapsed { grid-template-columns:minmax(0,1fr); }
.app.sidebar-collapsed .sidebar, .app.sidebar-collapsed #sidebar-resizer { display:none; }
#toggle-sidebar { display:inline-flex; flex:none; }
.chat-head { min-height:56px; gap:8px; padding:8px 16px; }
.chat-head button, .chat-head select { font-size:13px; padding:5px 9px; }
.chat-title .title { font-size:15px; }
#chat-cwd { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:100%; font-size:11px; }
#topic-select { width:auto; max-width:140px; }
.timeline { padding:20px clamp(16px,3vw,48px); gap:18px; }
.msg { max-width:min(1100px,100%); border-radius:8px; box-shadow:none; }
.msg.assistant { width:100%; align-self:center; border:0; background:transparent; padding:4px 0; line-height:1.7; }
.msg.user { max-width:min(900px,90%); padding:10px 14px; }
.msg.note, .tool, .approval { max-width:min(1100px,100%); }
.tool { box-shadow:none; padding:7px 10px; border-radius:6px; }
.message-actions { margin-top:6px; }
.message-actions button { background:transparent; border-color:transparent; padding:2px 6px; }
@media (hover:hover) { .msg .message-actions { opacity:0; } .msg:hover .message-actions,.msg:focus-within .message-actions { opacity:1; } }
.tag { color:#fff; font-size:10px; padding:0 5px; border-radius:4px; }
.compose-area { margin:0 16px 12px; border:1px solid var(--line-strong); border-radius:10px; background:var(--surface); flex-shrink:0; overflow:hidden; padding-bottom:env(safe-area-inset-bottom); }
.compose-area:focus-within { border-color:var(--accent); }
.composer { display:flex; flex-direction:column; gap:4px; padding:8px 10px; border:0; background:transparent; }
.composer textarea { width:100%; flex:none; box-shadow:none; border:0; border-radius:4px; padding:6px; background:transparent; }
.composer textarea:focus { box-shadow:none; }
#input { min-height:72px; max-height:40dvh; }
.composer-side { width:100%; flex-direction:row; flex-wrap:wrap; align-items:center; gap:8px; }
#attachment-upload { font-size:13px; padding:4px 8px; background:transparent; border-color:transparent; }
#send { margin-left:auto; padding:5px 18px; font-size:13px; order:3; }
#queue-info { order:2; font-size:12px; }
#attachment-status { flex-basis:auto; flex:1; min-width:0; max-height:44px; overflow:auto; font-size:12px; }
#attachment-status:empty { display:none; }
#reply-preview { padding:6px 12px; border-top:0; border-bottom:1px solid var(--line); }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.dialog-box { max-height:calc(100dvh - 32px); overflow-y:auto; }
@media(max-width:820px) {
  .app, .app.sidebar-collapsed { grid-template-columns:minmax(0,1fr); }
  .sidebar, .app.sidebar-collapsed .sidebar { display:flex; position:fixed; inset:0 auto 0 0; width:min(300px,85vw); z-index:40; }
  #sidebar-resizer { display:none; }
  .chat-head { flex-wrap:wrap; padding:8px 10px; gap:6px; }
  .chat-title { flex-basis:calc(100% - 48px); }
  .status-wrap { margin-left:auto; }
  .timeline { padding:14px 12px; gap:14px; }
  .compose-area { margin:0 8px 8px; }
  .msg.user { max-width:94%; }
  .dialog { padding:10px; }
  .dialog-box { padding:16px; min-width:0; }
  .dialog-actions { flex-wrap:wrap; }
  .chat-head button { min-height:32px; }
}
@media(prefers-reduced-motion:reduce) { *, *::before, *::after { animation:none !important; transition:none !important; } }

#sidebar-close { display:none; }

@media(max-width:820px) { #sidebar-close { display:block; padding:4px 10px; } }
@media(max-width:820px) {
  .sidebar:not(.open) { visibility:hidden; }
  .sidebar.open { visibility:visible; }
}

/* Named for user preference; no claim that a hue prevents eye disease. */
:root[data-theme="eye-care"] {
  color-scheme:light;
  --bg:#e8f0e8; --surface:#f3f7ef; --surface-2:#e1ebe0; --raised:#f3f7ef;
  --line:#c7d6c6; --line-strong:#829581;
  --text:#243529; --text-soft:#405743; --muted:#506650;
  --accent:#326344; --accent-weak:#dcebd9; --accent-text:#fff;
  --ok:#27623a; --warn:#805211; --danger:#a82c32; --danger-weak:#f7e6e4;
  --shadow:none; --shadow-lg:0 10px 30px #24352922;
}
.withdraw-message { margin-left:8px; padding:2px 8px; font-size:12px; }
.msg.user[data-state="withdrawn"] { border:1px dashed var(--line-strong); }

/* User bubbles fit their text; actions share a compact, visible footer. */
.msg.user { width:fit-content; padding:8px 12px; white-space:normal; }
.message-text { white-space:pre-wrap; overflow-wrap:anywhere; }
.msg.user .who { margin-bottom:2px; color:var(--muted); opacity:1; }
.message-footer { display:flex; flex-wrap:wrap; align-items:center; justify-content:flex-end; gap:4px 8px; margin-top:4px; white-space:normal; }
.msg.user .message-footer .state { margin:0; opacity:1; color:var(--muted); }
.msg.user.failed .who, .msg.user.failed .message-footer .state { color:var(--danger); }
.msg.user .message-actions { margin:0; opacity:1; gap:4px; }
.msg.user .message-actions button { opacity:1; font-size:11px; padding:1px 4px; }
.msg.user .withdraw-message { margin:0; }

#feishu-config-form, #compatible-model-form { display:grid; gap:12px; }
#compatible-model-list { display:grid; gap:12px; }
#compatible-model-list .ucard { overflow-wrap:anywhere; }

/* Version info block in workbench settings. */
.version-info { display: flex; align-items: baseline; gap: 10px; }
.version-number { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 15px; font-weight: 600; }
#version-date { margin: 4px 0 0; }

/* ---- Assistant Markdown rendering (whitelist, no innerHTML) ---- */
.msg.assistant.md { white-space: normal; }
.msg.assistant.md .md-p { margin: 0 0 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.assistant.md .md-p:last-child { margin-bottom: 0; }
.msg.assistant.md .md-h { margin: 12px 0 6px; line-height: 1.3; font-weight: 700; }
.msg.assistant.md .md-h:first-child { margin-top: 0; }
.msg.assistant.md h2.md-h { font-size: 19px; }
.msg.assistant.md h3.md-h { font-size: 16px; }
.msg.assistant.md h4.md-h { font-size: 14px; }
.msg.assistant.md .md-list { margin: 0 0 8px; padding-left: 22px; }
.msg.assistant.md .md-list li { margin: 3px 0; overflow-wrap: anywhere; }
.msg.assistant.md .md-quote { margin: 0 0 8px; padding: 2px 12px; border-left: 3px solid var(--line-strong); color: var(--text-soft); }
.inline-code { font-family: var(--mono); font-size: .88em; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 5px; padding: 0 4px; overflow-wrap: anywhere; }
.msg.assistant.md .codeblock { margin: 0 0 10px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.msg.assistant.md .codeblock:last-child { margin-bottom: 0; }
.codeblock-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--surface-2); padding: 4px 8px; border-bottom: 1px solid var(--line); }
.codeblock-lang { font: 11px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.codeblock-copy { border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font-size: 11px; padding: 2px 10px; border-radius: 6px; cursor: pointer; }
.codeblock-copy:hover { background: var(--accent-weak); border-color: var(--accent); }
.codeblock-pre { margin: 0; padding: 10px 12px; background: var(--bg); overflow-x: auto;
  font: 12.5px/1.55 var(--mono); white-space: pre; color: var(--text); }
.codeblock-pre code { font: inherit; white-space: pre; }

/* ---- Sidebar content-search results ---- */
.search-results { padding: 4px 8px 8px; border-bottom: 1px solid var(--line); }
.search-hint { margin: 4px 2px; }
.search-result { display: block; width: 100%; text-align: left; border: 1px solid var(--line);
  background: var(--surface-2); border-radius: 8px; padding: 6px 8px; margin: 0 0 6px; cursor: pointer; }
.search-result:hover { border-color: var(--accent); background: var(--accent-weak); }
.search-result .sr-title { display: block; font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 2px; }
.search-result .sr-snip { display: block; font-size: 12px; color: var(--muted); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
#archive-view.on { color: var(--accent); font-weight: 600; }
#metrics-rows .ib { font-size: 12px; color: var(--text-soft); }
.history-md { padding: 4px 0; box-shadow: none; border: 0; background: transparent; max-width: 100%; }

/* Mobile layout: original controls move into the menu, preserving their state. */
.message-more, .row-menu { display:none; }
.message-action-items { display:contents; }
#sidebar-backdrop { display:none; }
.mobile-more { position:absolute; z-index:35; top:100%; right:12px; width:min(360px,calc(100vw - 24px));
  padding:12px; border:1px solid var(--line-strong); border-radius:12px; background:var(--surface);
  box-shadow:var(--shadow-lg); max-height:calc(var(--mobile-height,100dvh) - 72px); overflow:auto; }
#mobile-session-info { margin:0 0 8px; font-size:13px; overflow-wrap:anywhere; }
@media(max-width:820px) {
  html, body { min-width:0; }
  .app { height:var(--mobile-height,100dvh); overflow:hidden; }
  .main, .timeline, .compose-area, .dialog-box, .history-records, .task-list { min-width:0; min-height:0; }
  .chat-head { position:relative; flex-wrap:wrap; padding:8px max(12px,env(safe-area-inset-right)) 8px max(12px,env(safe-area-inset-left));
    padding-top:max(8px,env(safe-area-inset-top)); gap:6px; flex-shrink:0; }
  .chat-title { flex:1 1 0; min-width:0; }
  .chat-title .title { font-size:16px; }
  #chat-cwd { display:none; }
  #toggle-sidebar, #mobile-more-toggle, #stop { width:44px; min-width:44px; height:44px; padding:0; flex:none; }
  #stop { font-size:12px; }
  #mobile-more-toggle { font-size:24px; }
  .mobile-context { order:10; flex:1 0 100%; display:grid; grid-template-columns:minmax(0,1fr) minmax(70px,1fr); gap:8px; align-items:center; }
  .mobile-model-label { min-width:0; font-size:12px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--muted); }
  .mobile-context #topic-select { max-width:100%; width:100%; height:44px; }
  .codeblock-pre { font-size:13px; }
  .mobile-more { display:flex; flex-direction:column; gap:8px; }
  .mobile-more > button, .mobile-more > select { width:100%; max-width:100%; text-align:left; }
  .mobile-more .status-wrap { margin:0; }
  .mobile-more #status-light { width:100%; border-radius:8px; justify-content:flex-start; }
  .mobile-more #status-light::after { content:'系统状态'; margin-left:8px; }
  .mobile-more .status-panel { position:static; width:100%; margin-top:8px; box-shadow:none; }
  #sidebar-backdrop { display:block; position:fixed; inset:0; z-index:39; border:0; border-radius:0; background:#0007; }
  .sidebar { padding-top:env(safe-area-inset-top); padding-left:env(safe-area-inset-left);
    padding-bottom:env(safe-area-inset-bottom); height:var(--mobile-height,100dvh); overflow:auto; overscroll-behavior:contain; }
  .sidebar-foot { flex-shrink:0; }
  .session-list li { flex-wrap:wrap; }
  .row-menu { display:inline-flex; justify-content:center; align-items:center; font-size:22px; padding:0; }
  .session-list li .row-acts { display:none; }
  .session-list li.row-acts-open .row-acts { display:flex; flex-basis:100%; justify-content:flex-end; }
  .mobile-drawer-open { overflow:hidden; }
  button, button.link, button.icon, .row-act, .message-actions button, .msg.user .message-actions button,
  .withdraw-message, .codeblock-copy, #attachment-upload, #send, #reply-cancel, #sidebar-close,
  .chat-head button { min-height:44px; min-width:44px; }
  input, textarea, select, .chat-head select, .composer textarea { font-size:16px; }
  .timeline { font-size:16px; line-height:1.6; overscroll-behavior:contain; padding-left:max(12px,env(safe-area-inset-left));
    padding-right:max(12px,env(safe-area-inset-right)); }
  .msg, .tool, .approval, .notice, #topic-origin { overflow-wrap:anywhere; min-width:0; max-width:100%; }
  .tool pre, #task-result, #task-logs, .history-records pre, .codeblock-pre { max-width:100%; overflow-x:auto; }
  .compose-area { margin-left:max(8px,env(safe-area-inset-left)); margin-right:max(8px,env(safe-area-inset-right)); }
  #input { min-height:48px; height:56px; max-height:min(120px,25dvh); resize:none; }
  .composer-side { gap:6px; }
  #send { padding:8px 16px; }
  #attachment-status { flex:1 1 100%; max-height:64px; order:4; overflow-wrap:anywhere; }
  #queue-info { overflow-wrap:anywhere; flex:1; }
  #reply-preview { display:flex; align-items:center; gap:8px; }
  #reply-preview-text { min-width:0; flex:1; max-height:64px; overflow:auto; overflow-wrap:anywhere; }
  .message-actions { opacity:1; flex-wrap:wrap; }
  .message-more { display:inline-flex; align-items:center; justify-content:center; }
  .message-action-items { display:none; flex-wrap:wrap; gap:4px; }
  .actions-open .message-action-items { display:flex; }
  .dialog { padding:max(8px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left)); }
  .dialog-box, #model-accounts-dialog .dialog-box, #operations-dialog .dialog-box {
    max-width:100%; max-height:calc(var(--mobile-height,100dvh) - 24px); overflow:auto; padding:16px; overscroll-behavior:contain; }
  .dialog-box h2 { overflow-wrap:anywhere; }
  .history-head, .dialog-actions, .history-actions { flex-wrap:wrap; }
  .history-head { gap:8px; }
  .dialog-box label, .dialog-box form, .dialog-box pre, .ucard { min-width:0; overflow-wrap:anywhere; }
  .dialog-box input:not([type=checkbox]):not([type=radio]) { min-height:48px; }
  .tool-checks label, label.inline, .toggle { min-height:44px; }
  .login { padding:20px max(16px,env(safe-area-inset-left)); }
  .login-shell { min-height:calc(100svh - 40px); }
  .login-layout { grid-template-columns:1fr; gap:24px; padding:28px 0; }
  .login-intro h1 { font-size:36px; }
  .login form { padding:20px; }
  .login input { min-height:48px; }
  .app.mobile-compact .sidebar, .app.mobile-compact.sidebar-collapsed .sidebar { display:block; }
  .mobile-compact .session-list { height:auto; max-height:none; min-height:120px; overflow:visible; }
  .mobile-compact .compose-area { padding-bottom:0; margin-bottom:4px; }
  .mobile-compact .chat-head { padding-top:4px; padding-bottom:4px; }
  .mobile-compact #input { height:48px; max-height:80px; }
  .mobile-compact .timeline { padding-top:8px; padding-bottom:8px; }
  .mobile-compact #attachment-status, .mobile-compact #reply-preview-text { max-height:44px; }
}
@media(max-width:820px) {
  .app.mobile-tiny { overflow-y:auto; }
  .mobile-tiny .main { min-height:100%; overflow:visible; }
  .mobile-tiny .timeline { flex:1 0 48px; max-height:100px; }
  .mobile-tiny .compose-area { flex-shrink:0; }
}

/* Independent SSH terminal: safe areas and keyboard-aware, touch-sized controls. */
.terminal-box {width:min(1000px,calc(100vw - 24px));max-width:100%;height:min(780px,calc(100dvh - 24px));display:flex;flex-direction:column;gap:8px;overflow:hidden;padding:16px;}
.terminal-header,.terminal-controls {display:flex;align-items:center;gap:8px;flex-wrap:wrap;}
.terminal-header {justify-content:space-between;}
.terminal-header h2,.terminal-box p {margin:0;}
.terminal-controls button,.terminal-controls select,.terminal-header button {min-height:44px;font-size:16px;}
.terminal-controls select {min-width:0;max-width:100%;flex:1;}
#terminal-screen {flex:1;min-height:100px;min-width:0;overflow:hidden;background:#10141c;padding:6px;border-radius:8px;}
#terminal-screen .xterm {height:100%;}
#terminal-screen .xterm-helper-textarea {font-size:16px!important;}
#terminal-identity {overflow-wrap:anywhere;}
#terminal-error:empty {display:none;}
#terminal-keys button[aria-pressed="true"] {background:var(--accent);color:white;}
@media(max-width:600px) {
 .terminal-box {width:100%;height:100dvh;max-height:100dvh;border-radius:0;padding:calc(8px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));}
 #terminal-keys {gap:4px;}
 #terminal-keys button {padding:4px 9px;}
}

.main.attachment-dragging {outline:3px dashed var(--accent);outline-offset:-6px;}
.main.attachment-dragging .composer {background:rgba(54,93,232,.12);}

/* Product home: readable on phones, with the same light/dark tokens as chat. */
.workbench-home { flex:1; min-height:0; overflow:auto; padding:clamp(18px,4vw,46px); }
.main.is-home > :not(.chat-head):not(.workbench-home) { display:none !important; }
.main.is-home #topic-select,.main.is-home #project-model,.main.is-home #history-open,.main.is-home #stop,.main.is-home #mobile-more-toggle { display:none !important; }
.home-intro { max-width:900px; margin:0 auto 24px; }
.home-intro h1 { font-size:clamp(26px,4vw,36px); margin:4px 0 8px; line-height:1.3; }
.home-eyebrow { color:var(--accent); font-size:13px; letter-spacing:.08em; margin:0; }
.home-actions { display:flex; flex-wrap:wrap; gap:10px; margin-top:16px; }
.home-columns { display:grid; grid-template-columns:minmax(0,1.3fr) minmax(0,1fr); gap:18px; }
.home-card,.home-stats { max-width:1100px; margin:0 auto 18px; }
.home-card { background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:20px; width:100%; min-width:0; }
.home-card h2 { font-size:18px; margin:0 0 10px; }
.home-stats { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; }
.home-stat { padding:16px; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface); }
.home-stat strong { display:block; font-size:26px; line-height:1.3; }
.home-row { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 0; border-bottom:1px solid var(--line); overflow-wrap:anywhere; }
.home-row:last-child { border-bottom:0; }
.home-row > div { min-width:0; }
.home-row button { flex-shrink:0; }
.home-columns { max-width:1100px; margin:auto; }
.help-diagnostics { white-space:pre-wrap; overflow-wrap:anywhere; padding:14px; background:var(--surface-2); border-radius:var(--radius-sm); font-size:12px; }
@media(max-width:650px) { .home-columns { grid-template-columns:minmax(0,1fr); gap:0; } .home-card{padding:16px;} .home-stats{gap:8px;} .home-stat{padding:12px 8px;font-size:12px;} .home-stat strong{font-size:23px;} .home-row button{padding:8px 10px;} }

.main.is-home .mobile-context { display:none !important; }
#home-error:empty { display:none; }
.home-intro { max-width:1100px; }
#home-heading:focus { outline:none; }

#operations-config-form { display:grid; gap:12px; margin:16px 0; }
#operations-config-form label { display:grid; gap:4px; }
#management-password-form { display:grid; gap:12px; margin:16px 0; }

/* Project files are shared; each conversation has its own model context. */
/* Project names lead the hierarchy; conversation names remain secondary. */
.session-list li.project-heading { cursor:default; padding:16px 10px 8px; display:flex; align-items:baseline; gap:8px; flex-wrap:wrap; }
.session-list li.project-heading:hover { background:transparent; }
.session-list .project-name { min-width:0; font-size:15px; line-height:1.5; font-weight:650; color:var(--text); overflow-wrap:anywhere; }
.session-list .project-count { flex-shrink:0; font-size:11px; font-weight:400; color:var(--muted); }
.session-list li.project-session-row { margin-left:14px; border-left:2px solid var(--line); flex-wrap:wrap; }
.session-list .project-session-row .t { font-size:13px; line-height:1.5; font-weight:400; color:var(--text-soft); }
.session-list .project-session-row.active .t { font-weight:500; color:var(--text); }
.session-list li.project-session-row .row-acts { flex-basis:100%; justify-content:flex-end; margin-top:4px; }
.session-list li.project-session-row .row-act { white-space:nowrap; flex-shrink:0; }
