@font-face { font-family: 'Tutou Sans'; src: url('/assets/noto-sans-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Tutou Sans'; src: url('/assets/noto-sans-bold.woff2') format('woff2'); font-weight: 600 700; font-display: swap; }

:root {
  --bg: #faf8f6; --panel: #ffffff; --side: #f4f0ed; --rail: #efe9e5; --line: #e7e0dc; --line-2: #d9d0cb;
  --text: #221f1f; --muted: #6b6264; --subtle: #8b8184; --accent: #cd2c39; --accent-2: #b3202d; --on-accent: #fff;
  --soft: #fbecee; --soft-line: #f0c6cc; --hover: #00000008; --active: #cd2c3914; --field: #fff;
  --code-bg: #f3eeeb; --code-line: #e6ddd8; --inline: #f1e8e6;
  --ok: #1f8a4c; --ok-bg: #e4f4ea; --warn: #9a6400; --warn-bg: #fff1cc; --err: #c42b3a; --err-bg: #fde8ea; --info: #3b5bab; --info-bg: #e8edfa;
  --diff-add: #e6f4ea; --diff-add-t: #1c6b3a; --diff-del: #fdecee; --diff-del-t: #a3212f;
  --shadow: 0 1px 2px #2a1d1f0d, 0 8px 28px #2a1d1f12; --shadow-lg: 0 20px 60px #2a1d1f2e;
  --fs: 17px; --radius: 14px; --side-w: 300px; --rail-w: 60px; --insp-w: 320px; --col: 820px;
  --font: 'Tutou Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans CJK SC', 'Noto Sans SC', sans-serif;
  --serif: ui-serif, 'Iowan Old Style', 'Palatino Linotype', Georgia, 'Songti SC', 'Noto Serif CJK SC', serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', 'Cascadia Code', Menlo, Consolas, 'Noto Sans Mono CJK SC', monospace;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #171415; --panel: #1f1b1c; --side: #1b1718; --rail: #141112; --line: #342d2f; --line-2: #473d40;
  --text: #f3eced; --muted: #b3a7aa; --subtle: #8f8386; --accent: #ff737d; --accent-2: #ff8e96; --on-accent: #2a0f13;
  --soft: #3a2027; --soft-line: #66343f; --hover: #ffffff0a; --active: #ff737d1f; --field: #1a1617;
  --code-bg: #120f10; --code-line: #2c2527; --inline: #33282b;
  --ok: #6fdc9d; --ok-bg: #173826; --warn: #f2c85c; --warn-bg: #3d3115; --err: #ff8f99; --err-bg: #46212a; --info: #9db4ff; --info-bg: #1f2944;
  --diff-add: #173822; --diff-add-t: #8fe0ab; --diff-del: #45202a; --diff-del-t: #ffa4ad;
  --shadow: 0 1px 2px #0006, 0 8px 28px #0005; --shadow-lg: 0 20px 60px #000a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; -webkit-text-size-adjust: 100%; }
body { overflow: hidden; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.ic { width: 20px; height: 20px; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--active); }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

/* ---------- buttons & fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-weight: 600; font-size: 14px; line-height: 1; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { background: var(--hover); border-color: var(--line-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-2); }
.btn.big { min-height: 50px; font-size: 16px; border-radius: 14px; width: 100%; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--err); }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; border: 0; background: transparent; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.soft { color: var(--muted); }
.icon-btn.on { color: var(--accent); background: var(--active); }
input[type=text], input[type=search], input[type=password], input:not([type]), textarea, select { background: var(--field); border: 1px solid var(--line); border-radius: 12px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--active); }
select { appearance: none; -webkit-appearance: none; padding: 0 30px 0 12px; min-height: 38px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }

/* ---------- login ---------- */
.login { position: fixed; inset: 0; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--bg); overflow: auto; }
.login-art { position: relative; overflow: hidden; background: linear-gradient(160deg, #2a0f14, #5b1520 55%, #cd2c39); display: flex; align-items: flex-end; padding: 56px; }
:root[data-theme="dark"] .login-art { background: linear-gradient(160deg, #0f0a0b, #3a1219 55%, #9e2330); }
.orb { position: absolute; border-radius: 50%; filter: blur(8px); opacity: .5; }
.o1 { width: 420px; height: 420px; right: -120px; top: -120px; background: radial-gradient(circle at 30% 30%, #ff8a93, transparent 70%); animation: float 12s ease-in-out infinite; }
.o2 { width: 300px; height: 300px; left: -80px; top: 30%; background: radial-gradient(circle at 50% 50%, #ffb0a0, transparent 70%); opacity: .25; animation: float 16s ease-in-out infinite reverse; }
@keyframes float { 50% { transform: translate(-30px, 30px) scale(1.05); } }
.login-quote { position: relative; color: #fff; max-width: 480px; }
.login-quote p { font-family: var(--serif); font-size: 28px; line-height: 1.35; margin: 16px 0 0; }
.spark { display: block; width: 36px; height: 36px; background: #fff; clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%); animation: spin 18s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.login-card { align-self: center; justify-self: center; width: min(420px, calc(100% - 40px)); padding: 40px 0; }
.login-brand { display: flex; gap: 14px; align-items: center; }
.login-brand img { border-radius: 14px; }
.login-brand b { display: block; font-size: 20px; }
.login-brand small { color: var(--muted); font-size: 13px; }
.login h1 { font-family: var(--serif); font-weight: 500; font-size: 34px; line-height: 1.2; margin: 34px 0 26px; letter-spacing: -.01em; }
.login label { display: grid; gap: 7px; margin-bottom: 16px; font-size: 13px; font-weight: 600; color: var(--muted); }
.login input { height: 50px; padding: 0 16px; font-size: 16px; color: var(--text); }
.form-error { color: var(--err); min-height: 22px; font-size: 14px; margin: 12px 0 0; }
.login-prefs { display: flex; gap: 10px; margin-top: 18px; }
.login-prefs select { min-height: 36px; font-size: 13px; }

/* ---------- app layout ---------- */
.app { position: fixed; left: 0; right: 0; top: var(--vv-top, 0px); height: var(--app-h, 100dvh); display: flex; }
.app > .main { flex: 1; }
.rail { width: var(--rail-w); flex: none; background: var(--rail); display: flex; flex-direction: column; align-items: center; padding: 12px 0 14px; gap: 6px; border-right: 1px solid var(--line); z-index: 5; }
.rail-logo img { border-radius: 10px; display: block; margin-bottom: 10px; }
.rail-nav { display: flex; flex-direction: column; gap: 6px; }
.rail-btn { position: relative; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 13px; background: transparent; color: var(--muted); }
.rail-btn:hover { background: var(--hover); color: var(--text); }
.rail-btn.on { background: var(--panel); color: var(--accent); box-shadow: var(--shadow); }
.rail-btn .ic { width: 22px; height: 22px; }
.rail-btn[data-tip]:hover::after { content: attr(data-tip); position: absolute; left: 52px; top: 50%; transform: translateY(-50%); background: var(--text); color: var(--bg); font-size: 12px; font-weight: 600; padding: 5px 9px; border-radius: 8px; white-space: nowrap; pointer-events: none; z-index: 30; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.conn-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--subtle); }
.conn-dot.ok { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-bg); }
.conn-dot.bad { background: var(--err); animation: blink 1s infinite; }
.badge-dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 2px var(--rail); }

.sessions { position: relative; width: var(--side-w); flex: none; background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; padding: 14px 12px 10px; gap: 10px; }
.app.side-collapsed .sessions { display: none; }
.app:not(.view-chat-on) .sessions { display: none; }
.sessions-head { display: flex; align-items: center; justify-content: space-between; min-height: 34px; padding: 0 4px; }
.brand-line { display: flex; align-items: center; gap: 9px; font-size: 16px; }
.brand-line img { border-radius: 7px; }
.brand-chip { font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--accent); background: var(--soft); border: 1px solid var(--soft-line); padding: 2px 7px; border-radius: 999px; }
.new-chat { justify-content: flex-start; background: var(--panel); box-shadow: var(--shadow); border-color: transparent; min-height: 44px; }
.new-chat .ic { color: var(--accent); }
.search-wrap { position: relative; }
.search-wrap .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--subtle); pointer-events: none; }
.search-wrap input { width: 100%; height: 38px; padding: 0 12px 0 36px; background: var(--panel); border-color: transparent; font-size: 14px; }
.session-list { flex: 1; overflow-y: auto; margin: 0 -6px; padding: 0 6px 12px; overscroll-behavior: contain; }
.group-label { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--subtle); padding: 14px 8px 6px; }
.srow { display: grid; grid-template-columns: 14px 1fr auto; gap: 4px 9px; align-items: start; padding: 9px 10px; border-radius: 11px; color: var(--text); text-decoration: none; cursor: pointer; border: 1px solid transparent; }
.srow:hover { background: var(--hover); }
.srow.on { background: var(--panel); border-color: var(--line); box-shadow: var(--shadow); }
.srow .sdot { margin-top: 7px; }
.srow .stitle { font-size: 14px; font-weight: 500; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.srow .smeta { grid-column: 2 / 4; display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--subtle); min-width: 0; }
.srow .smeta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow .stime { font-size: 11.5px; color: var(--subtle); white-space: nowrap; margin-top: 2px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--hover); color: var(--muted); white-space: nowrap; flex: none; }
.tag .ic { width: 12px; height: 12px; }
.tag.term { background: var(--info-bg); color: var(--info); }
.tag.web { background: var(--soft); color: var(--accent); }
.sdot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-2); flex: none; display: inline-block; }
.sdot.running { background: var(--ok); animation: pulse 1.6s ease-in-out infinite; }
.sdot.waiting { background: #e2a300; animation: pulse 1.2s ease-in-out infinite; }
.sdot.error { background: var(--err); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 0%, transparent); opacity: 1; } 50% { opacity: .45; } }
@keyframes blink { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .sdot.running, .sdot.waiting, .o1, .o2, .spark { animation: none; } }
.sessions-foot { font-size: 12px; color: var(--subtle); padding: 6px 6px 0; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; }
.resizer { position: absolute; top: 0; right: -4px; bottom: 0; width: 8px; cursor: col-resize; z-index: 4; }
.resizer:hover, .resizer.drag { background: linear-gradient(90deg, transparent 3px, var(--accent) 3px, var(--accent) 5px, transparent 5px); }
.scrim { position: fixed; inset: 0; background: #0006; z-index: 40; }

.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
.view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.topbar { position: relative; z-index: 20; display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 8px 16px; padding-top: calc(8px + var(--safe-t)); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); }
.title-block { min-width: 0; flex: 1; }
.title-block h2 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.005em; }
.subline { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); margin-top: 2px; min-width: 0; overflow: hidden; white-space: nowrap; }
.subline .sep { opacity: .4; }
.subline code { font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; padding: 5px 11px; border-radius: 999px; background: var(--hover); color: var(--muted); }
.status-pill.running { background: var(--ok-bg); color: var(--ok); }
.status-pill.waiting { background: var(--warn-bg); color: var(--warn); }
.status-pill.error { background: var(--err-bg); color: var(--err); }

/* ---------- chat ---------- */
.chat-body { flex: 1; display: flex; min-height: 0; }
.chat-col { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.scroller { flex: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scroll-behavior: auto; }
.thread { width: min(var(--col), calc(100% - 32px)); margin: 0 auto; padding: 22px 0 28px; font-size: var(--fs); line-height: 1.65; }
.load-earlier { display: flex; justify-content: center; margin: 4px 0 18px; }
.msg { margin: 0 0 18px; position: relative; }
.msg-user { display: flex; justify-content: flex-end; }
.bubble { max-width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 18px 18px 6px 18px; padding: 11px 16px; box-shadow: var(--shadow); white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
.bubble.clip { max-height: 320px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 75%, transparent); mask-image: linear-gradient(#000 75%, transparent); }
.bubble-imgs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.bubble-imgs img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; }
.user-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 4px; font-size: 12px; color: var(--subtle); min-height: 22px; }
.user-foot .state { display: inline-flex; align-items: center; gap: 5px; }
.user-foot .state.failed { color: var(--err); }
/* The width limit sits on the column, a share of the thread: a percentage on the bubble would be a
   share of the column, which takes its width from the bubble, and short messages would wrap. */
.msg-user .col { display: flex; flex-direction: column; align-items: flex-end; max-width: min(88%, 680px); min-width: 0; }
.msg-actions { display: inline-flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions { opacity: 1; }
@media (hover: none) { .msg-actions { opacity: .75; } }
.mini-btn { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--subtle); }
.mini-btn:hover { background: var(--hover); color: var(--text); }
.mini-btn .ic { width: 16px; height: 16px; }

.msg-assistant { display: grid; grid-template-columns: 30px 1fr; gap: 12px; }
.avatar { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--soft); color: var(--accent); margin-top: 2px; }
.avatar .ic { width: 18px; height: 18px; }
.a-body { min-width: 0; }
.a-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--subtle); margin-bottom: 2px; min-height: 22px; }
.a-head b { color: var(--text); font-size: 13px; }
.md { word-break: break-word; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .8em; }
.md h1, .md h2, .md h3, .md h4 { font-family: var(--serif); font-weight: 600; line-height: 1.3; margin: 1.2em 0 .5em; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.28em; } .md h3 { font-size: 1.12em; } .md h4 { font-size: 1em; }
.md ul, .md ol { padding-left: 1.4em; margin: .4em 0 .9em; }
.md li { margin: .2em 0; }
.md li > p { margin: 0; }
.md blockquote { margin: .6em 0; padding: .2em 1em; border-left: 3px solid var(--soft-line); color: var(--muted); }
.md code { font-family: var(--mono); font-size: .86em; background: var(--inline); padding: .12em .4em; border-radius: 6px; }
.md pre { position: relative; background: var(--code-bg); border: 1px solid var(--code-line); border-radius: 12px; padding: 12px 14px; overflow-x: auto; font-size: 13.5px; line-height: 1.55; margin: .6em 0 1em; }
.md pre code { background: none; padding: 0; font-size: inherit; white-space: pre; }
.md pre .copy-code { position: absolute; top: 6px; right: 6px; opacity: 0; }
.md pre:hover .copy-code { opacity: 1; }
@media (hover: none) { .md pre .copy-code { opacity: .8; } }
.md table { border-collapse: collapse; margin: .6em 0 1em; font-size: .92em; display: block; overflow-x: auto; max-width: 100%; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--code-bg); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
.md a { word-break: break-all; }
.md img { max-width: 100%; }
.streaming-caret::after { content: ''; display: inline-block; width: .5em; height: 1em; margin-left: 2px; vertical-align: -2px; background: var(--accent); border-radius: 2px; animation: blink .9s steps(2) infinite; }

/* tool timeline */
.steps { margin: 6px 0 12px; border-left: 2px solid var(--line); padding-left: 0; }
.steps-head { width: 100%; max-width: 100%; min-width: 0; text-align: left; display: flex; align-items: center; gap: 8px; margin: 0 0 4px -2px; padding: 4px 8px; border: 0; background: none; color: var(--muted); font-size: 13px; font-weight: 600; border-radius: 8px; }
.steps-head:hover { color: var(--text); background: var(--hover); }
.steps-head .ic { width: 15px; height: 15px; transition: transform .15s; }
.steps.open > .steps-head .chev { transform: rotate(90deg); }
.steps:not(.open) > .steps-body { display: none; }
.tool { margin: 2px 0 2px 12px; }
.tool-head { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 34px; padding: 5px 10px; border: 1px solid transparent; border-radius: 10px; background: none; text-align: left; font-size: 13.5px; color: var(--text); min-width: 0; }
.tool-head:hover { background: var(--hover); }
.tool.open > .tool-head { background: var(--panel); border-color: var(--line); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.tool-ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--code-bg); color: var(--muted); flex: none; }
.tool-ic .ic { width: 15px; height: 15px; }
.tool-name { font-weight: 600; flex: none; }
.tool-sum { font-family: var(--mono); font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.tool-state { flex: none; display: inline-flex; align-items: center; }
.tool-state .spin { width: 14px; height: 14px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.tool-state .ok { color: var(--ok); } .tool-state .err { color: var(--err); }
.tool-state .ic { width: 16px; height: 16px; }
.tool-body { border: 1px solid var(--line); border-top: 0; border-radius: 0 0 10px 10px; background: var(--panel); padding: 10px 12px; font-size: 13px; }
.tool:not(.open) > .tool-body { display: none; }
.tool-body .label { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--subtle); margin: 6px 0 4px; }
.tool-body .label:first-child { margin-top: 0; }
.pre { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; background: var(--code-bg); border: 1px solid var(--code-line); border-radius: 9px; padding: 9px 11px; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; max-height: 420px; overflow: auto; margin: 0; }
.pre.err { color: var(--err); }
.diff { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; border: 1px solid var(--code-line); border-radius: 9px; overflow: auto; max-height: 460px; background: var(--code-bg); }
.diff div { padding: 0 10px; white-space: pre-wrap; word-break: break-word; }
.diff .add { background: var(--diff-add); color: var(--diff-add-t); }
.diff .del { background: var(--diff-del); color: var(--diff-del-t); }
.diff .ctx-sep { color: var(--subtle); background: var(--hover); }
.todo-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.todo-list li { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; line-height: 1.45; }
.todo-list .box { width: 16px; height: 16px; border-radius: 5px; border: 1.5px solid var(--line-2); flex: none; margin-top: 2px; display: grid; place-items: center; }
.todo-list .completed .box { background: var(--ok); border-color: var(--ok); color: #fff; }
.todo-list .completed .txt { text-decoration: line-through; color: var(--subtle); }
.todo-list .in_progress .box { border-color: var(--accent); box-shadow: inset 0 0 0 3px var(--panel), inset 0 0 0 8px var(--accent); }
.todo-list .in_progress .txt { font-weight: 600; }
.todo-list .box .ic { width: 12px; height: 12px; }
.thinking { margin: 4px 0 10px; }
.thinking > button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--subtle); font-size: 13px; padding: 3px 6px; border-radius: 7px; font-style: italic; }
.thinking > button:hover { background: var(--hover); color: var(--muted); }
.thinking .ic { width: 15px; height: 15px; }
.thinking .th-body { display: none; margin: 4px 0 0 6px; padding: 4px 0 4px 14px; border-left: 2px solid var(--line); color: var(--muted); font-size: .9em; white-space: pre-wrap; }
.thinking.open .th-body { display: block; }
.sysline { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--subtle); font-size: 12.5px; }
.sysline::before, .sysline::after { content: ''; flex: 1; border-top: 1px dashed var(--line-2); }
.sysline.plain::before, .sysline.plain::after { display: none; }
.sysline .ic { width: 15px; height: 15px; }
.card-note { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: var(--panel); font-size: 14px; margin: 0 0 16px; }
.card-note.recap { background: var(--info-bg); border-color: transparent; color: var(--info); }
.card-note.error { background: var(--err-bg); border-color: transparent; color: var(--err); white-space: pre-wrap; }
.card-note.notice summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.card-note .pre { margin-top: 8px; }
.card-note.continued { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--info-bg); border-color: transparent; color: var(--info); }
.card-note.continued .ic { width: 16px; height: 16px; flex: none; }
.card-note.continued a { margin-left: auto; font-weight: 600; color: var(--accent); text-decoration: none; }
.handoff-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 8px; padding: 10px 12px; border-radius: 14px; background: var(--soft); border: 1px solid var(--soft-line); color: var(--text); font-size: 13.5px; line-height: 1.45; }
.handoff-bar > .ic { width: 18px; height: 18px; flex: none; color: var(--accent); }
.handoff-bar > span { flex: 1; min-width: 180px; }
.handoff-cmd { user-select: all; white-space: pre-wrap; word-break: break-all; }
.req-release { margin-top: 8px; }
.contract-details { margin-top: 6px; font-size: 12px; } .contract-details pre { max-height: 180px; overflow: auto; white-space: pre-wrap; }
.turn-end { font-size: 12px; color: var(--subtle); margin: -8px 0 18px 42px; display: flex; gap: 6px; align-items: center; }
.turn-end .ic { width: 13px; height: 13px; }

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; min-height: 60vh; padding: 20px 0; }
.empty .spark-lg { width: 54px; height: 54px; background: var(--accent); clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%); margin-bottom: 18px; }
.empty h1 { font-family: var(--serif); font-weight: 500; font-size: 32px; margin: 0 0 10px; }
.empty p { color: var(--muted); max-width: 560px; margin: 0 0 26px; line-height: 1.6; font-size: 15.5px; }
.sugg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; max-width: 640px; }
.sugg button { text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 13px 15px; font-size: 14px; line-height: 1.45; color: var(--text); box-shadow: var(--shadow); }
.sugg button:hover { border-color: var(--soft-line); background: var(--soft); }

.jump { position: absolute; right: 22px; top: -52px; z-index: 6; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); }
.jump .ic { width: 16px; height: 16px; }

/* composer */
.composer-wrap { position: relative; padding: 0 16px calc(12px + var(--safe-b)); }
.composer, .requests, .activity { width: min(var(--col), 100%); margin: 0 auto; }
.activity { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); padding: 0 6px 8px; }
.activity .spark-sm { width: 14px; height: 14px; background: var(--accent); clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%); animation: spin 2.4s linear infinite; }
.composer { position: relative; background: var(--panel); border: 1px solid var(--line-2); border-radius: 20px; box-shadow: var(--shadow); padding: 10px 10px 8px 14px; transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--active), var(--shadow); }
.composer textarea { display: block; width: 100%; border: 0; outline: none; background: transparent; box-shadow: none !important; resize: none; font-size: 16px; line-height: 1.5; padding: 4px 2px; min-height: 30px; max-height: 40vh; color: var(--text); }
.composer-bar { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.chips { display: flex; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.chips::-webkit-scrollbar { display: none; }
.chip-select { position: relative; display: inline-flex; align-items: center; flex: none; }
.chip-select .chip-ic { position: absolute; left: 9px; pointer-events: none; color: var(--muted); display: grid; }
.chip-select .ic { width: 15px; height: 15px; }
.chip-select select { min-height: 32px; border-radius: 999px; font-size: 12.5px; font-weight: 600; padding-left: 29px; padding-right: 26px; background-color: var(--bg); border-color: var(--line); color: var(--muted); max-width: 190px; background-position: calc(100% - 14px) 52%, calc(100% - 9px) 52%; }
.chip-select.hot select { color: var(--accent); border-color: var(--soft-line); background-color: var(--soft); }
.send { width: 40px; height: 40px; border-radius: 13px; border: 0; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; flex: none; transition: transform .1s, background .15s; }
.send:hover { background: var(--accent-2); }
.send:disabled { background: var(--line-2); color: var(--panel); cursor: default; }
.send.stop { background: var(--text); color: var(--bg); }
.send .ic { width: 20px; height: 20px; }
.attachments { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; }
.att { position: relative; flex: none; display: flex; align-items: center; gap: 8px; height: 58px; padding: 0 30px 0 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); max-width: 220px; }
.att img { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; }
.att .att-name { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att .att-size { font-size: 11px; color: var(--subtle); }
.att .file-ic { width: 40px; height: 40px; border-radius: 8px; background: var(--code-bg); display: grid; place-items: center; color: var(--muted); }
.att .x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border: 0; border-radius: 50%; background: var(--text); color: var(--bg); display: grid; place-items: center; }
.att .x .ic { width: 12px; height: 12px; }
.att.busy::after { content: ''; position: absolute; inset: 0; border-radius: 12px; background: color-mix(in srgb, var(--panel) 60%, transparent); }
.slash-menu { position: absolute; left: 8px; right: 8px; bottom: calc(100% + 8px); max-height: 340px; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 20; }
.slash-item { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: baseline; padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.slash-item.on, .slash-item:hover { background: var(--active); }
.slash-item b { font-family: var(--mono); font-size: 13.5px; color: var(--accent); }
.slash-item span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slash-item small { grid-column: 1 / 3; font-size: 11px; color: var(--subtle); }
/* Long questions scroll inside their own box; the chat column has a fixed height (phones). */
.requests { display: grid; gap: 10px; margin-bottom: 10px; max-height: calc(var(--app-h, 100dvh) * .6); overflow-y: auto; overscroll-behavior: contain; border-radius: 16px; }
.req { background: var(--panel); border: 1px solid var(--soft-line); border-radius: 16px; box-shadow: var(--shadow); padding: 14px 16px; }
.req h4 { margin: 0 0 8px; display: flex; gap: 8px; align-items: center; font-size: 14px; }
.req h4 .ic { color: var(--warn); }
.req .q { font-size: 15px; margin: 10px 0 8px; font-weight: 600; }
.req .opts { display: grid; gap: 6px; }
.req .opt { text-align: left; border: 1px solid var(--line); background: var(--bg); border-radius: 11px; padding: 9px 12px; font-size: 14px; }
.req .opt small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.req .opt.on { border-color: var(--accent); background: var(--soft); }
.req .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.req input { width: 100%; height: 40px; padding: 0 12px; margin-top: 6px; }
.req .md { font-size: 14.5px; max-height: 45vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg); }

/* inspector */
.inspector { width: var(--insp-w); flex: none; border-left: 1px solid var(--line); background: var(--side); overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.insp-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.insp-card h5 { margin: 0 0 10px; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--subtle); display: flex; align-items: center; gap: 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.kv dd code { font-family: var(--mono); font-size: 12px; font-weight: 400; }
.insp-actions { display: grid; grid-template-columns: 1fr; gap: 6px; }
.insp-actions .btn { font-size: 13px; min-height: 38px; padding: 0 12px; justify-content: flex-start; min-width: 0; }
.insp-actions .btn .ic { width: 16px; height: 16px; }
.meter { height: 6px; border-radius: 999px; background: var(--hover); overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }

/* ---------- terminal ---------- */
.view-terminal { background: var(--bg); }
.term-tabs { display: flex; gap: 6px; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; }
.term-tabs::-webkit-scrollbar { display: none; }
.term-tab { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 6px 0 12px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; flex: none; }
.term-tab:hover { background: var(--hover); }
.term-tab.on { background: var(--panel); border-color: var(--line); color: var(--text); box-shadow: var(--shadow); }
.term-tab .ic { width: 16px; height: 16px; }
.term-tab .x { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: var(--subtle); }
.term-tab .x:hover { background: var(--hover); color: var(--err); }
.term-tab .x .ic { width: 13px; height: 13px; }
.term-tab .dead { color: var(--err); }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 30; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 9px; font-size: 14px; }
.menu button:hover { background: var(--hover); }
.menu button small { display: block; color: var(--subtle); font-size: 12px; }
.term-stage { flex: 1; min-height: 0; position: relative; background: #141112; overflow: hidden; }
.term-pane { position: absolute; inset: 0; padding: 8px 0 0 10px; }
.term-pane .xterm { height: 100%; }
.term-pane .xterm-viewport { overscroll-behavior: contain; }
.term-over { position: absolute; inset: 0; display: grid; place-items: center; background: #141112cc; color: #eee; z-index: 3; }
.term-over .box { text-align: center; display: grid; gap: 12px; justify-items: center; }
.term-keys { display: flex; gap: 6px; padding: 8px 10px; overflow-x: auto; background: var(--side); border-top: 1px solid var(--line); scrollbar-width: none; }
.term-keys::-webkit-scrollbar { display: none; }
.term-keys button { flex: none; min-width: 42px; height: 36px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--text); }
.term-keys button.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.term-cmd { display: flex; gap: 8px; padding: 8px 10px calc(8px + var(--safe-b)); background: var(--side); }
.term-cmd input { flex: 1; min-width: 0; height: 42px; padding: 0 14px; font-family: var(--mono); font-size: 15px; }

/* ---------- files ---------- */
.path-bar { flex: 1; display: flex; align-items: center; gap: 4px; min-width: 0; }
.path-bar input { flex: 1; min-width: 0; height: 38px; padding: 0 12px; font-family: var(--mono); font-size: 13.5px; }
.files-body { flex: 1; display: flex; min-height: 0; }
.file-list { flex: 1; overflow-y: auto; padding: 8px 12px calc(20px + var(--safe-b)); min-width: 0; }
.frow { display: grid; grid-template-columns: 34px 1fr auto auto 32px; gap: 12px; align-items: center; padding: 7px 10px; border-radius: 10px; cursor: pointer; font-size: 14px; }
.frow:hover { background: var(--hover); }
.frow.on { background: var(--active); }
.frow .fic { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--code-bg); color: var(--muted); }
.frow.dir .fic { background: var(--soft); color: var(--accent); }
.frow .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frow .fsize, .frow .fdate { font-size: 12px; color: var(--subtle); white-space: nowrap; }
.file-preview { width: min(56%, 760px); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; background: var(--panel); }
.fp-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.fp-head b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.fp-body { flex: 1; min-height: 0; overflow: auto; }
.fp-body textarea { width: 100%; height: 100%; border: 0; border-radius: 0; resize: none; padding: 12px 14px; font-family: var(--mono); font-size: 13px; line-height: 1.55; background: var(--panel); box-shadow: none !important; white-space: pre; }
.fp-body textarea[wrap=soft] { white-space: pre-wrap; overflow-wrap: anywhere; }
.fp-body img, .fp-body video { max-width: 100%; display: block; margin: 12px auto; }
.fp-empty { padding: 30px; color: var(--muted); text-align: center; }

/* ---------- system & settings ---------- */
.page { flex: 1; overflow-y: auto; padding: 20px 16px calc(30px + var(--safe-b)); }
.page-inner { width: min(980px, 100%); margin: 0 auto; display: grid; gap: 14px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.stat small { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.stat small .ic { width: 15px; height: 15px; }
.stat b { display: block; font-size: 22px; margin-top: 6px; font-family: var(--serif); font-weight: 600; }
.stat span { font-size: 12.5px; color: var(--subtle); }
.panel-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.panel-card h3 { margin: 0 0 10px; font-size: 14px; }
.plain-list { display: grid; gap: 8px; }
.plain-list a.li { color: inherit; text-decoration: none; }
.plain-list a.li:hover { background: var(--hover); }
.plain-list .li { display: flex; gap: 10px; align-items: center; font-size: 13.5px; padding: 8px 10px; border-radius: 10px; background: var(--bg); min-width: 0; }
.plain-list .li .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plain-list .li code { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row label { font-weight: 600; font-size: 14px; }
.set-row small { display: block; color: var(--muted); font-weight: 400; font-size: 12.5px; margin-top: 2px; }
.set-row select, .set-row input[type=text] { min-width: 160px; height: 38px; padding-left: 12px; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--accent); box-shadow: var(--shadow); }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line-2); border-radius: 999px; transition: .2s; cursor: pointer; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px #0003; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }

/* ---------- toasts & modal ---------- */
.toast-host { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-b)); z-index: 100; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow-lg); max-width: min(92vw, 520px); animation: tin .2s ease-out; }
.toast.err { background: var(--err); color: #fff; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }
.modal-host { position: fixed; inset: 0; z-index: 90; background: #0007; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--panel); border-radius: 18px; box-shadow: var(--shadow-lg); width: min(460px, 100%); padding: 20px; max-height: 90vh; overflow: auto; }
.modal h3 { margin: 0 0 12px; font-family: var(--serif); font-weight: 600; font-size: 19px; }
.modal input { width: 100%; height: 44px; padding: 0 12px; font-size: 15px; }
.modal .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal.img { width: auto; max-width: 95vw; padding: 8px; background: transparent; box-shadow: none; }
.modal.img img { max-width: 92vw; max-height: 86vh; border-radius: 12px; display: block; }
.drop-hint { position: fixed; inset: 12px; border: 3px dashed var(--accent); border-radius: 24px; background: color-mix(in srgb, var(--soft) 80%, transparent); z-index: 95; display: grid; place-items: center; font-size: 20px; font-weight: 600; color: var(--accent); pointer-events: none; }

/* ---------- tabbar (mobile) ---------- */
.tabbar { display: none; }
.only-mobile { display: none; }

@media (max-width: 1180px) {
  .inspector { position: fixed; right: 0; top: 0; bottom: 0; z-index: 45; box-shadow: var(--shadow-lg); width: min(360px, 92vw); padding-top: calc(16px + var(--safe-t)); }
}
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .rail { display: none; }
  .sessions { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; width: min(340px, 88vw); box-shadow: var(--shadow-lg); padding-top: calc(14px + var(--safe-t)); transform: translateX(-102%); transition: transform .22s ease; display: flex !important; }
  .app.side-open .sessions { transform: none; }
  .resizer { display: none; }
  .only-mobile { display: inline-grid; }
  .main { min-height: 0; }
  .tabbar { flex: none; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--panel); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); z-index: 10; }
  .app.kb-open .tabbar { display: none; }
  .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 56px; border: 0; background: none; color: var(--subtle); font-size: 11px; font-weight: 600; position: relative; }
  .tabbar button.on { color: var(--accent); }
  .tabbar .ic { width: 22px; height: 22px; }
  .tabbar .badge-dot { top: 8px; right: calc(50% - 18px); box-shadow: 0 0 0 2px var(--panel); }
  .topbar { min-height: 54px; padding: 6px 8px; padding-top: calc(6px + var(--safe-t)); gap: 6px; }
  .title-block h2 { font-size: 17px; }
  .thread { width: calc(100% - 24px); padding-top: 14px; }
  .msg-assistant { grid-template-columns: 1fr; gap: 4px; }
  .msg-assistant .avatar { display: none; }
  .turn-end { margin-left: 0; }
  .tool { margin-left: 8px; }
  .msg-user .col { max-width: 92%; }
  .composer-wrap { padding: 0 8px 8px; }
  .composer { border-radius: 18px; padding: 8px 8px 6px 12px; }
  .composer-bar { gap: 2px; }
  .composer .icon-btn { width: 34px; height: 34px; }
  .chip-select select { max-width: 150px; }
  .jump { right: 14px; }
  .sugg { grid-template-columns: 1fr; }
  .empty h1 { font-size: 26px; }
  .empty { min-height: 50vh; }
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .login h1 { font-size: 28px; margin: 26px 0 20px; }
  .file-preview { position: fixed; inset: 0; width: auto; z-index: 60; padding-top: var(--safe-t); padding-bottom: var(--safe-b); }
  .frow { grid-template-columns: 34px 1fr auto 32px; }
  .frow .fdate { display: none; }
  .status-pill .txt { display: none; }
  .term-cmd { padding-bottom: 8px; }
  .toast-host { bottom: calc(130px + var(--safe-b)); }
}
@media (min-width: 901px) {
  #sessions-close { display: none; }
}

/* goal card & status line */
.goal-card { width: min(var(--col), calc(100% - 32px)); margin: 8px auto 0; display: grid; grid-template-columns: auto 1fr auto; gap: 0 8px; align-items: center; padding: 2px 4px 2px 12px; border-radius: 12px; background: var(--soft); border: 1px solid var(--soft-line); }
.goal-card .g-text { border: 0; background: none; text-align: left; padding: 6px 0; min-width: 0; color: var(--text); font-size: 13px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-card.open .g-text { white-space: pre-wrap; word-break: break-word; max-height: 40vh; overflow: auto; }
.goal-card .g-more { display: none; grid-column: 1 / 4; gap: 8px; padding: 2px 0 8px 26px; }
.goal-card.open .g-more { display: flex; flex-wrap: wrap; }
.goal-card .g-ic .ic { width: 16px; height: 16px; }
.steps.single { border-left: 0; }
.steps.single > .steps-head { display: none; }
.steps.single > .steps-body > .tool { margin-left: 0; }
.goal-card .g-ic { color: var(--accent); margin-top: 2px; }
.goal-card .g-head { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--accent); display: flex; gap: 8px; align-items: center; }
.goal-card .g-head .met { color: var(--ok); }

.statusline { width: min(var(--col), 100%); margin: 6px auto 0; padding: 2px 4px; background: transparent; color: var(--muted); font-family: var(--mono); font-size: 11.5px; line-height: 1.5; white-space: nowrap; overflow-x: auto; scrollbar-width: none; text-align: center; }
.statusline::-webkit-scrollbar { display: none; }
@media (max-width: 900px) { .goal-card { width: calc(100% - 16px); } .statusline { margin-left: 0; max-width: 100%; } }

/* connection state & mobile drawer tools */
.head-tools { display: none; align-items: center; gap: 2px; }
.conn-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 3px 9px; border-radius: 999px; background: var(--hover); margin-right: 4px; white-space: nowrap; }
.conn-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--subtle); }
.conn-pill.ok { color: var(--ok); background: var(--ok-bg); }
.conn-pill.ok::before { background: var(--ok); }
.conn-pill.bad { color: var(--err); background: var(--err-bg); }
.conn-pill.bad::before { background: var(--err); animation: blink 1s infinite; }
.conn-banner { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 6px 12px; padding-top: calc(6px + var(--safe-t)); background: var(--err-bg); color: var(--err); font-size: 13px; font-weight: 600; }
.conn-banner::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--err); animation: blink 1s infinite; }
@media (max-width: 900px) {
  .head-tools.only-mobile-flex { display: flex; }
  .sessions-head { gap: 6px; }
  .brand-line .brand-chip { display: none; }
  .main:has(.conn-banner:not([hidden])) .topbar { padding-top: 6px; }
}

/* terminal: touch scrolling, text view */
.term-pane { touch-action: none; }
.term-text-view { position: fixed; inset: 0; z-index: 85; display: flex; flex-direction: column; background: var(--bg); padding-top: var(--safe-t); padding-bottom: var(--safe-b); }
.term-text-view .tt-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--panel); }
.term-text-view .tt-head b { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.term-text-view .tt-hint { font-size: 12px; color: var(--muted); padding: 6px 12px; background: var(--side); border-bottom: 1px solid var(--line); }
.term-text-view pre { flex: 1; margin: 0; overflow: auto; padding: 10px 12px 24px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; -webkit-touch-callout: default; background: #141112; color: #ece6e7; overscroll-behavior: contain; }
.term-text-view.nowrap pre { white-space: pre; word-break: normal; overflow-wrap: normal; }
@media (max-width: 900px) { #term-new span { display: none; } #term-new { padding: 0 9px; } }

.act-elapsed { font-family: var(--mono); font-size: 12px; color: var(--subtle); }
.activity .btn { margin-left: auto; min-height: 30px; }

/* terminal key bar and shortcut sheet — same for every terminal */
.term-keys button.kb-mod { min-width: 48px; }
.term-keys .kb-sheet-btn { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font); color: var(--accent); border-color: var(--soft-line); background: var(--soft); }
.term-keys .kb-sheet-btn.on { background: var(--accent); color: var(--on-accent); }
.term-keys .kb-sheet-btn .ic { width: 16px; height: 16px; }
.kb-sheet { flex: none; position: relative; z-index: 2; border-top: 1px solid var(--line); background: var(--panel); max-height: min(46vh, 360px); display: flex; flex-direction: column; }
.kb-tabs { display: flex; gap: 4px; padding: 6px 8px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); flex: none; }
.kb-tabs::-webkit-scrollbar { display: none; }
.kb-tabs button { flex: none; border: 0; background: none; padding: 6px 12px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); }
.kb-tabs button.on { background: var(--active); color: var(--accent); }
.kb-tabs .kb-close { margin-left: auto; display: grid; place-items: center; padding: 6px; position: sticky; right: 0; background: var(--panel); box-shadow: -10px 0 10px var(--panel); }
.kb-tabs .kb-close .ic { width: 16px; height: 16px; }
.kb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; padding: 8px; overflow-y: auto; }
.kb-grid button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 7px 10px; min-height: 44px; }
.kb-grid button:active { background: var(--active); }
.kb-grid b { font-family: var(--mono); font-size: 12.5px; color: var(--accent); }
.kb-grid span { font-size: 12px; color: var(--muted); }
.kb-custom { display: flex; gap: 8px; padding: 8px 8px 0; }
.kb-custom input { flex: 1; min-width: 0; height: 40px; padding: 0 12px; font-family: var(--mono); font-size: 14px; }
.kb-help { font-size: 12px; color: var(--muted); padding: 6px 10px 0; line-height: 1.45; }
@media (max-width: 900px) { .kb-grid { grid-template-columns: repeat(2, 1fr); } }

/* phones: no focus zoom, fast taps */
button, a, .srow, .tool-head, .steps-head { touch-action: manipulation; }
@media (max-width: 900px) {
  input:not([type=checkbox]), textarea { font-size: 16px !important; }
  .app.kb-open .statusline { display: none; }
}

/* session list tools & row menu */
.list-tools { display: flex; gap: 6px; }
.list-tools select { flex: 1; min-width: 0; min-height: 32px; font-size: 12.5px; border-radius: 10px; background-color: var(--panel); border-color: transparent; color: var(--muted); }
.srow { position: relative; }
.srow .row-menu { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border: 0; border-radius: 8px; background: var(--panel); color: var(--muted); display: grid; place-items: center; opacity: 0; box-shadow: var(--shadow); }
.srow:hover .row-menu, .srow.on .row-menu, .srow .row-menu:focus-visible { opacity: 1; }
@media (hover: none) { .srow .row-menu { opacity: .9; background: transparent; box-shadow: none; } .srow .stime { margin-right: 26px; } }
.srow .row-menu .ic { width: 17px; height: 17px; }
.pop-menu { position: fixed; z-index: 70; min-width: 210px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; }
.pop-menu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 9px; font-size: 14px; color: var(--text); }
.pop-menu button:hover { background: var(--hover); }
.pop-menu button.danger { color: var(--err); }
.pop-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }

/* fast toggle, suggestion, tips */
.fast-btn { position: relative; }
.fast-btn.on { color: var(--text); background: var(--hover); }
.fast-btn.on::after { content: ''; position: absolute; right: 7px; top: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }
.suggestion { display: flex; align-items: center; gap: 8px; width: min(var(--col), 100%); margin: 0 auto 8px; padding: 7px 12px; border: 1px dashed var(--line-2); border-radius: 12px; background: transparent; color: var(--muted); font-size: 13.5px; text-align: left; }
.suggestion .ic { width: 15px; height: 15px; flex: none; }
.suggestion span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.suggestion kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line-2); border-radius: 5px; padding: 0 5px; color: var(--subtle); }
.activity .tip { color: var(--subtle); font-size: 12.5px; overflow-x: auto; overflow-y: hidden; white-space: nowrap; min-width: 0; flex: 1; scrollbar-width: none; overscroll-behavior-x: contain; touch-action: pan-x; }
.activity .tip::-webkit-scrollbar { display: none; }
.empty .tip-line { margin-top: 18px; font-size: 13px; color: var(--subtle); }
.slash-item .at-ic { display: inline-grid; vertical-align: -3px; margin-right: 4px; }
.slash-item .at-ic .ic { width: 15px; height: 15px; }
@media (hover: none) { .suggestion kbd { display: none; } }

.term-pane .xterm, .term-pane .xterm-viewport, .term-pane .xterm-screen { background-color: #141112 !important; }

.composer-bar .fast-btn { margin-left: auto; }
.chip-select select { field-sizing: content; max-width: 170px; }

.inspector.no-session { display: none !important; }

.act-verb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; max-width: 55%; }
.act-tokens { font-family: var(--mono); font-size: 12px; color: var(--subtle); }
@media (max-width: 900px) { .activity { flex-wrap: wrap; row-gap: 2px; } .activity .tip { flex-basis: 100%; padding-left: 23px; font-size: 12px; } .act-verb { max-width: none; flex: 1; } }

@media (max-width: 900px) {
  .empty { min-height: 0; padding-top: 18px; }
  .empty .spark-lg { width: 40px; height: 40px; margin-bottom: 12px; }
  .empty h1 { font-size: 24px; }
  .empty p { font-size: 14.5px; margin-bottom: 16px; }
  .sugg button { padding: 10px 13px; font-size: 14px; }
}

.frow .fmenu { width: 32px; height: 32px; opacity: .6; }
.frow:hover .fmenu { opacity: 1; }

.kb-foot { padding: 6px 10px 8px; border-top: 1px solid var(--line); flex: none; }

/* iOS: no automatic zoom when a field gets focus (fields must be >= 16px). */
@supports (-webkit-touch-callout: none) { input, textarea, select, .xterm-helper-textarea { font-size: 16px !important; } }

/* CLI-style commands and their output */
.cli-cmd { display: flex; align-items: baseline; gap: 8px; font-family: var(--mono); font-size: 13.5px; line-height: 1.5; color: var(--muted); margin: 10px 0 4px; word-break: break-word; }
.cli-cmd .p { color: var(--accent); font-weight: 700; flex: none; }
.cli-cmd b { color: var(--text); font-weight: 600; }
.cli-cmd .a { color: var(--muted); white-space: pre-wrap; }
.cli-cmd .c { min-width: 0; overflow-wrap: anywhere; }
.cli-cmd .a.clip { display: block; max-height: 13.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.cli-cmd .cmd-more { display: block; margin-top: 4px; font-family: var(--font); }
.cli-cmd.pending { opacity: .75; }
.cli-cmd .state { margin-left: auto; font-family: var(--font); font-size: 12px; color: var(--subtle); display: inline-flex; gap: 5px; align-items: center; white-space: nowrap; }
.cli-cmd .state .ic { width: 13px; height: 13px; }
.cli-out { position: relative; margin: 0 0 14px 6px; padding-left: 18px; color: var(--muted); font-size: 13.5px; }
.cli-out::before { content: '⎿'; position: absolute; left: 0; top: 0; color: var(--subtle); font-family: var(--mono); }
.cli-out-text { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; white-space: pre; max-height: 420px; overflow: auto; overscroll-behavior-x: contain; }
.cli-out .md { font-size: 14px; color: var(--text); }

.tool-body .label.with-copy { display: flex; align-items: center; justify-content: space-between; }
.tool-body .label .mini-btn, .out-foot .mini-btn { width: 24px; height: 24px; }
.out-foot { display: flex; justify-content: flex-end; margin-top: 2px; }
/* todo panel above the composer, like the CLI's task list under the spinner */
.todo-bar { width: min(var(--col), 100%); margin: 0 auto 8px; border: 1px solid var(--line); background: var(--panel); border-radius: 12px; font-size: 13px; }
.todo-bar > button { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; padding: 7px 12px; color: var(--muted); font-weight: 600; text-align: left; }
.todo-bar > button .ic { width: 15px; height: 15px; }
.todo-bar > button .cur { font-weight: 400; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.todo-bar .todo-list { padding: 0 12px 10px; max-height: 30vh; overflow: auto; }
.todo-bar:not(.open) .todo-list { display: none; }
.att { cursor: pointer; }

.md pre .copy-code.bottom { top: auto; bottom: 6px; }

/* short screens (phone in landscape): give the space to the conversation / terminal */
@media (max-height: 520px) and (max-width: 1100px) {
  .tabbar button { height: 40px; }
  .tabbar button span { display: none; }
  .tabbar .badge-dot { top: 6px; }
  .topbar { min-height: 44px; padding-top: calc(4px + var(--safe-t)); padding-bottom: 4px; }
  .topbar .subline { display: none; }
  .title-block h2 { font-size: 15.5px; }
  .statusline, .activity .tip, .goal-card { display: none !important; }
  .activity { padding-bottom: 4px; }
  .composer { padding: 6px 8px 4px 10px; }
  .composer textarea { max-height: 22vh; min-height: 26px; }
  .composer-bar { margin-top: 2px; }
  .composer .icon-btn, .send { width: 34px; height: 34px; }
  .chip-select select { min-height: 30px; }
  .composer-wrap { padding-bottom: 4px; }
  .term-keys { padding: 4px 8px; }
  .term-keys button { height: 30px; }
  .term-cmd { padding: 4px 8px; }
  .term-cmd input { height: 34px; }
  .kb-sheet { max-height: 45vh; }
  .jump { top: -44px; }
}

/* working folders */
.folders-box { margin-top: 18px; display: grid; gap: 8px; width: 100%; max-width: 640px; }
.fb-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fb-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); min-width: 150px; }
.fb-label .ic { width: 16px; height: 16px; }
.fb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.folder-chip { display: inline-flex; flex-direction: row; flex-wrap: nowrap; white-space: nowrap; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--text); font-size: 13px; max-width: 100%; }
.folder-chip code { font-family: var(--mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: min(60vw, 360px); min-width: 0; }
.folder-chip .ic { flex: none; }
.folder-chip.main { border-color: var(--soft-line); background: var(--soft); }
.folder-chip.add { border-style: dashed; color: var(--muted); background: transparent; }
.folder-chip button { border: 0; background: none; padding: 0; display: inline-flex; align-items: center; gap: 6px; color: inherit; }
.folder-chip .ic { width: 14px; height: 14px; }
.folder-chip.fav .ic { color: var(--accent); }
.folder-picker { width: min(560px, 100%); padding: 0; display: flex; flex-direction: column; max-height: min(86vh, 720px); }
.folder-picker .fp-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 6px 18px; }
.folder-picker .fp-top h3 { margin: 0; }
.folder-picker .fp-path { display: flex; gap: 4px; align-items: center; padding: 4px 12px 8px; }
.folder-picker .fp-path input { flex: 1; min-width: 0; height: 38px; padding: 0 12px; font-family: var(--mono); font-size: 13px; }
.folder-picker .fp-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; }
.folder-picker .fp-list { flex: 1; overflow-y: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px 6px; min-height: 160px; }
.fp-dir { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 9px 10px; border-radius: 9px; text-align: left; font-size: 14px; color: var(--text); }
.fp-dir:hover { background: var(--hover); }
.fp-dir .ic { width: 18px; height: 18px; color: var(--accent); }
.fp-dir .ic:last-child { color: var(--subtle); margin-left: auto; }
.fp-dir span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-picker .row { padding: 10px 12px 12px; margin: 0; }
.insp-folders { display: flex; flex-wrap: wrap; gap: 6px; }
.insp-note { display: block; margin-top: 8px; font-size: 11.5px; color: var(--subtle); line-height: 1.45; }
@media (max-width: 900px) { .fb-label { min-width: 0; width: 100%; } .folder-picker { max-height: 88vh; } }
.folder-picker .fp-newname { flex: 1; min-width: 0; height: 40px; padding: 0 12px; }


/* composer tools: one family of soft, framed controls */
.composer-bar .icon-btn.soft { width: 32px; height: 32px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.composer-bar .icon-btn.soft:hover { background: var(--hover); border-color: var(--line-2); color: var(--text); }
.composer-bar .icon-btn.soft .ic { width: 17px; height: 17px; }
.composer-bar .fast-btn.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.composer-bar .fast-btn.on::after { display: none; }
.composer-bar { gap: 6px; }
/* summary chip (phones) */
.opt-chip { display: none; align-items: center; gap: 6px; flex: 1; min-width: 0; height: 32px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--muted); font-size: 12.5px; font-weight: 600; }
.opt-chip span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.opt-chip .ic { width: 15px; height: 15px; flex: none; }
.opt-chip.hot { border-color: var(--soft-line); background: var(--soft); color: var(--accent); }
@media (max-width: 900px) {
  .composer-bar .chips { display: none; }
  .opt-chip { display: inline-flex; }
  .composer .icon-btn.soft { width: 32px; height: 32px; }
}
/* bottom sheet */
.opt-scrim { position: fixed; inset: 0; z-index: 92; background: #0006; display: flex; align-items: flex-end; justify-content: center; animation: fadein .15s ease-out; }
@keyframes fadein { from { opacity: 0; } }
.opt-sheet { width: min(560px, 100%); max-height: 82vh; background: var(--panel); border-radius: 20px 20px 0 0; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; padding-bottom: var(--safe-b); animation: sheetin .2s ease-out; }
@keyframes sheetin { from { transform: translateY(24px); opacity: .6; } }
.opt-grip { width: 38px; height: 4px; border-radius: 4px; background: var(--line-2); margin: 8px auto 2px; flex: none; }
.opt-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 10px 6px 18px; flex: none; }
.opt-head b { font-family: var(--serif); font-size: 17px; }
.opt-body { overflow-y: auto; padding: 0 12px; overscroll-behavior: contain; }
.opt-sec { padding: 8px 0 10px; border-top: 1px solid var(--line); }
.opt-sec h6 { display: flex; align-items: center; gap: 6px; margin: 4px 6px 8px; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--subtle); }
.opt-sec h6 .ic { width: 15px; height: 15px; }
.opt-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; background: none; padding: 9px 8px; border-radius: 12px; color: var(--text); }
.opt-row:hover { background: var(--hover); }
.opt-row .opt-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-2); flex: none; }
.opt-row.on .opt-dot { border-color: var(--accent); box-shadow: inset 0 0 0 4px var(--panel), inset 0 0 0 9px var(--accent); }
.opt-row.on { background: var(--active); }
.opt-text { display: flex; flex-direction: column; min-width: 0; }
.opt-text b { font-size: 14.5px; font-weight: 600; }
.opt-text small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt-seg { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px; }
.opt-seg button { flex: 1 1 auto; min-width: 64px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-size: 13px; font-weight: 600; color: var(--muted); }
.opt-seg button.on { border-color: var(--accent); background: var(--soft); color: var(--accent); }
.opt-foot { padding: 10px 14px 12px; border-top: 1px solid var(--line); flex: none; }

.folder-picker .fp-warn { display: flex; gap: 8px; align-items: flex-start; margin: 8px 12px 0; padding: 8px 10px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: 12.5px; line-height: 1.45; }
.folder-picker .fp-warn .ic { width: 16px; height: 16px; flex: none; margin-top: 1px; }
/* attachment names stay inside their frame */
.att > span { min-width: 0; overflow: hidden; }
.att .att-name, .att .att-size { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }

/* message typed while Claude is busy: waiting in the CLI queue */
.msg-user.queued .bubble { opacity: .8; border-style: dashed; }
.q-state { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--warn); }
.q-state .ic { width: 13px; height: 13px; }

/* ---------- media viewer ---------- */
.mv-scrim { position: fixed; inset: 0; z-index: 94; background: #000a; display: flex; align-items: center; justify-content: center; padding: 16px; padding-top: calc(16px + var(--safe-t)); padding-bottom: calc(16px + var(--safe-b)); animation: fadein .15s ease-out; }
.mv { width: min(980px, 100%); max-height: 100%; display: flex; flex-direction: column; background: var(--panel); border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden; }
.mv-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.mv-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mv-title b { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-title small { font-family: var(--mono); font-size: 11.5px; color: var(--subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.mv-body { position: relative; flex: 1; min-height: 160px; overflow: auto; background: #141112; display: flex; flex-direction: column; }
.mv-img { flex: 1; display: grid; place-items: center; overflow: auto; }
.mv-img img { max-width: 100%; max-height: 72vh; object-fit: contain; cursor: zoom-in; display: block; }
.mv-img.zoom { place-items: start; }
.mv-img.zoom img { max-width: none; max-height: none; cursor: zoom-out; }
.mv-video { width: 100%; max-height: 62vh; background: #000; display: block; }
.mv-audio { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 36px 16px; color: #ece6e7; }
.mv-audio .ic { width: 54px; height: 54px; opacity: .7; }
.mv-audio audio { width: min(520px, 100%); }
.mv-pdf { width: 100%; height: 70vh; border: 0; background: #fff; }
.mv-open { position: absolute; right: 10px; bottom: 10px; }
.mv-text { flex: 1; width: 100%; min-height: 55vh; border: 0; border-radius: 0; padding: 12px 14px; font-family: var(--mono); font-size: 13px; line-height: 1.55; background: var(--panel); color: var(--text); resize: none; box-shadow: none !important; }
.mv-foot { padding: 7px 12px; font-size: 12px; color: var(--subtle); border-top: 1px solid var(--line); min-height: 18px; }
.mv-md { flex: 1; min-height: 55vh; padding: 16px 18px 32px; background: var(--panel); color: var(--text); font-size: 15px; line-height: 1.6; overflow: auto; }
.mv-md table { display: block; overflow-x: auto; }
.mv-textbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mv-textbar span:first-child { flex: 1; min-width: 160px; }
/* video / audio editor */
.me { background: var(--panel); color: var(--text); padding: 10px 12px 12px; display: grid; gap: 10px; border-top: 1px solid var(--line); }
.me-bar { position: relative; height: 26px; border-radius: 8px; background: var(--code-bg); border: 1px solid var(--line); cursor: pointer; overflow: hidden; }
.me-sel { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--accent) 30%, transparent); border-left: 2px solid var(--accent); border-right: 2px solid var(--accent); }
.me-head { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text); }
.me-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.me-row label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.me-row input.me-t { width: 84px; height: 34px; padding: 0 8px; font-family: var(--mono); font-size: 13px; }
.me-row select { min-height: 34px; font-size: 13px; }
.me-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.me-go .btn { min-height: 38px; }
.me-progress { position: relative; height: 26px; border-radius: 8px; background: var(--code-bg); overflow: hidden; }
.me-progress i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); opacity: .35; transition: width .3s; }
.me-progress span { position: relative; display: block; text-align: center; line-height: 26px; font-size: 12.5px; }
/* image editor */
.ie { position: fixed; inset: 0; z-index: 96; background: #141112; color: #ece6e7; display: flex; flex-direction: column; padding-top: var(--safe-t); padding-bottom: var(--safe-b); }
.ie-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.ie-head b { flex: 1; font-size: 15px; }
.ie-head .icon-btn { color: #ece6e7; }
.ie-stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; padding: 8px; }
.ie-canvas { max-width: 100%; max-height: 100%; touch-action: none; background: repeating-conic-gradient(#2a2425 0 25%, #1f1b1c 0 50%) 0 0 / 16px 16px; }
.ie-crop { position: absolute; border: 2px dashed #fff; box-shadow: 0 0 0 9999px #0008; pointer-events: none; }
.ie-textin { position: absolute; min-width: 140px; height: 36px; padding: 0 10px; font-size: 16px; background: #fff; color: #111; border-radius: 8px; border: 2px solid var(--accent); z-index: 2; }
.ie-panel { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 12px; min-height: 44px; font-size: 13px; }
.ie-panel label { display: inline-flex; align-items: center; gap: 6px; }
.ie-panel input[type=range] { width: 120px; accent-color: #ff737d; }
.ie-hint { color: #b9aeb1; font-size: 12.5px; }
.ie-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.ie-chips button { border: 1px solid #473d40; background: #1f1b1c; color: #ece6e7; border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.ie-chips button.on { border-color: #ff737d; color: #ff737d; }
.ie-colors { display: flex; gap: 8px; }
.ie-colors button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #473d40; }
.ie-colors button.on { border-color: #fff; box-shadow: 0 0 0 2px #ff737d; }
.ie-tools { display: flex; gap: 4px; overflow-x: auto; padding: 8px; border-top: 1px solid #342d2f; scrollbar-width: none; }
.ie-tools::-webkit-scrollbar { display: none; }
.ie-tools button { flex: 1 0 auto; min-width: 62px; display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: none; color: #b9aeb1; padding: 6px 8px; border-radius: 10px; font-size: 11.5px; }
.ie-tools button .ic { width: 20px; height: 20px; }
.ie-tools button.on { color: #ff737d; background: #ff737d1f; }
/* attachment cards: video frame + play mark */
.att .att-media { position: relative; width: 46px; height: 46px; border-radius: 8px; overflow: hidden; background: #141112; display: grid; place-items: center; flex: none; }
.att .att-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
.att .att-media .ic { position: relative; width: 18px; height: 18px; color: #fff; filter: drop-shadow(0 1px 2px #000); }
/* clickable file paths in chat */
.path-link { cursor: pointer; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; color: inherit; }
.md code.path-link:hover, a.path-link:hover { color: var(--accent); }
.tool-open { margin-bottom: 8px; }
@media (max-width: 900px) { .mv-scrim { padding: 0; } .mv { border-radius: 0; height: 100%; } .mv-img img { max-height: 70vh; } }

/* The company owner's chat-only panel (tutoukeji.cn/boss): no folders, terminals or permission modes. */
[data-role=boss] .boss-hide, [data-role=boss] #mode-chip, [data-role=boss] #session-dir, [data-role=boss] #handoff-bar,
[data-role=boss] #statusline, [data-role=boss] #inspector-toggle, [data-role=boss] #inspector { display: none !important; }
