* { box-sizing: border-box; }
[hidden] { display: none !important; }
.app { margin: 0; background: var(--bg-canvas); color: var(--text); font: 400 13px/1.45 var(--font-sans); -webkit-font-smoothing: antialiased; scrollbar-width: thin; scrollbar-color: var(--sb-show) transparent; }
.app * { scrollbar-width: thin; scrollbar-color: var(--sb-show) transparent; }
.app h1, .app h2, .app h3, .app p, .app dl, .app dd { margin: 0; }
.app b, .app strong { font-weight: 500; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
.app :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.mono { font-family: var(--font-mono); letter-spacing: 0; font-variant-ligatures: none; }
.muted { color: var(--muted); }
.field label { font-size: 12px; font-weight: 500; color: var(--muted); }
.spacer { flex: 1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-3); height: var(--control-md); padding: 0 14px; border-radius: var(--radius-md); border: 1px solid transparent; font-weight: 500; white-space: nowrap; transition: background var(--duration-fast) var(--easing-standard); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--focus); }
.btn-secondary { background: var(--bg-raised); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; }
.btn:disabled { background: var(--bg-raised); border-color: var(--border); color: var(--subtle); }
.icon-btn { width: var(--control-sm); height: var(--control-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; border-radius: var(--radius-md); border: 1px solid transparent; background: transparent; color: var(--muted); }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.badge { display: inline-flex; align-items: center; gap: var(--space-3); height: 22px; padding: 0 8px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); font-size: 12px; white-space: nowrap; flex-shrink: 0; }
.field { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.input { height: var(--control-md); padding: 0 10px; border-radius: var(--radius-md); border: 1px solid var(--border-control); background: var(--bg-raised); color: var(--text); font: inherit; }
.textarea { padding: var(--space-4) 10px; border-radius: var(--radius-md); border: 1px solid var(--border-control); background: var(--bg-raised); color: var(--text); font: 14px/1.45 var(--font-sans); resize: vertical; min-height: 64px; }
.textarea::placeholder { color: var(--subtle); }
.card { border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--bg-surface); }
.agent-mark { width: 18px; height: 18px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 5px; font: 700 10px/1 var(--font-mono); color: var(--bg-canvas); }

.name-tag { all: unset; box-sizing: border-box; position: absolute; transform: translate(-50%, -100%); display: flex; align-items: center; gap: var(--space-3); max-width: var(--tag-max-width, 104px); padding: 2px 8px 3px 7px; background: var(--bg-overlay); border: 1px solid var(--border-strong); border-radius: var(--radius-md); box-shadow: var(--shadow-tag); color: var(--text); font: 500 11px/1.3 var(--font-sans); white-space: nowrap; cursor: pointer; pointer-events: auto; }
.name-tag:hover { max-width: none; z-index: 2; border-color: var(--border-control); }
.name-tag:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.name-tag span { display: grid; min-width: 0; }
.name-tag b, .name-tag small { overflow: hidden; text-overflow: ellipsis; }
.name-tag b { font-weight: 600; }
.name-tag small { font-size: 10px; font-weight: 400; color: var(--muted); }
.name-tag i { flex: none; width: 6px; height: 6px; border-radius: var(--radius-full); background: var(--muted); }
.name-tag[data-status="working"] i { background: var(--accent); }
.name-tag[data-status="reviewing"] i, .name-tag[data-status="waiting"] i { background: var(--info); }
.name-tag[data-status="break"] i { background: var(--success); }
.name-tag[data-status="needs_you"] i { background: var(--warning); animation: blink 1s steps(2) infinite; }
.name-tag[data-status="needs_you"] { border-color: var(--warning); animation: hop 0.8s steps(2) infinite; }
.name-tag[data-status="blocked"] i { background: var(--danger); animation: blink 1s steps(2) infinite; }

.thought { position: absolute; z-index: 1; width: max-content; max-width: 150px; transform: translate(-50%, calc(-100% - var(--thought-lift))); padding: 3px 9px 4px; background: var(--thought-paper); border: 2px solid var(--thought-ink); border-radius: 12px; color: var(--thought-ink); font: italic 500 11px/1.25 var(--font-sans); text-align: center; pointer-events: none; opacity: 0; translate: 0 4px; transition: opacity 240ms ease, translate 240ms ease; }
.thought.is-visible { opacity: 1; translate: 0 0; }
.thought::before, .thought::after { content: ""; position: absolute; left: 50%; background: var(--thought-paper); border: 2px solid var(--thought-ink); border-radius: var(--radius-full); }
.thought::before { width: 7px; height: 7px; bottom: -11px; translate: -60% 0; }
.thought::after { width: 4px; height: 4px; bottom: -18px; translate: -120% 0; }
.thought.is-speech { border-radius: 6px; font-style: normal; font-weight: 600; }
.thought.is-speech::before { width: 0; height: 0; bottom: -9px; translate: -50% 0; background: none; border: 7px solid transparent; border-top-color: var(--thought-ink); border-bottom: 0; border-radius: 0; }
.thought.is-speech::after { display: none; }

.side-resizer { position: absolute; top: 0; bottom: 0; left: calc(var(--space-6) * -1); z-index: 1; width: var(--space-6); cursor: col-resize; touch-action: none; }
.side-resizer::after { content: ""; position: absolute; top: var(--space-4); bottom: var(--space-4); left: 50%; width: 2px; translate: -50% 0; border-radius: var(--radius-full); background: var(--accent); opacity: 0; transition: opacity var(--duration-fast) var(--easing-standard); }
.side-resizer:hover::after, .side-resizer:focus-visible::after, .is-resizing-panel .side-resizer::after { opacity: 1; }
.side-resizer:focus-visible { outline: none; }
.is-resizing-panel, .is-resizing-panel * { cursor: col-resize !important; user-select: none; }
.sheet { display: flex; flex-direction: column; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: 40px; padding: 0 var(--space-5); border-bottom: 1px solid var(--border); flex-shrink: 0; }

.pending-what { font-weight: 500; }
.pending-card pre { display: block; margin: 0; padding: var(--space-3) var(--space-4); max-height: 160px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--term); font-size: 12px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.pending-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-4); flex-wrap: wrap; }
.pending-card { display: grid; gap: var(--space-5); padding: 14px; border-color: var(--warning-border); background: var(--bg-raised); }
.pending-flag { font-size: 12px; color: var(--warning); }
.card-title { font-size: 14px; font-weight: 600; line-height: 1.25; }
.pending-error, .composer-status[data-error="true"] { font-size: 12px; color: var(--danger); }
.question { margin: 0; padding: 0; border: 0; display: grid; gap: var(--space-4); min-width: 0; }
.question legend { display: flex; align-items: center; gap: var(--space-4); padding: 0; margin-bottom: var(--space-4); font-weight: 500; }
.choices { display: grid; gap: var(--space-3); }
.choice { all: unset; box-sizing: border-box; display: grid; gap: var(--space-1); padding: var(--space-4) 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--bg-surface); cursor: pointer; }
.choice:hover { background: var(--bg-hover); }
.choice span { font-size: 12px; color: var(--muted); }
.choice[aria-pressed="true"] { background: var(--bg-selected); border-color: var(--accent); }
.choice:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.sheet-head { justify-content: flex-start; gap: var(--space-4); padding: var(--space-4) var(--space-5) var(--space-4) var(--space-4); }
.sheet-identity { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.identity { flex: 1; min-width: 0; }
.identity p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-title { font-size: 16px; font-weight: 600; line-height: 1.25; }
.sheet-body { display: flex; flex-direction: column; gap: 14px; padding: 14px; overflow: auto; min-height: 0; }
.composer { display: grid; gap: var(--space-4); }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.composer-hint { font-size: 12px; }
.composer-status { font-size: 12px; color: var(--muted); }
.composer-status:empty { display: none; }

.pane { position: relative; display: flex; flex-direction: column; min-width: 0; flex-shrink: 0; background: var(--term); border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.pane.is-expanded { position: fixed; inset: var(--space-8); z-index: 20; box-shadow: var(--shadow-dialog), 0 0 0 100vmax var(--scrim); }
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: 34px; padding: 0 var(--space-4) 0 10px; border-bottom: 1px solid var(--border); background: var(--bg-surface); }
.pane-title { display: inline-flex; align-items: center; gap: var(--space-3); font-size: 12px; font-weight: 600; white-space: nowrap; }
.pane-tools { display: flex; align-items: center; gap: var(--space-2); }
.live-dot { width: 7px; height: 7px; border-radius: var(--radius-full); background: var(--success); animation: blink 1.6s steps(2) infinite; }
.pane-body { display: flex; flex-direction: column; gap: var(--space-5); min-height: 120px; max-height: 46vh; overflow: auto; padding: 10px var(--space-5); font: 12px/1.6 var(--font-mono); font-variant-ligatures: none; overflow-wrap: anywhere; scrollbar-width: thin; }
.pane.is-expanded .pane-body { flex: 1; max-height: none; font-size: 13px; }
.pane-body:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.pane-foot { display: flex; align-items: center; height: 26px; padding: 0 var(--space-5); border-top: 1px solid var(--border); font: 11px/1 var(--font-mono); color: var(--muted); }
.pane-jump { position: absolute; right: var(--space-6); bottom: 36px; box-shadow: var(--shadow-popover); }

.entry { min-width: 0; }
.entry-head { display: flex; align-items: baseline; gap: var(--space-3); min-width: 0; }
.entry-head b { flex: none; font-weight: 600; }
.stamp { flex: none; margin-left: auto; padding-left: var(--space-4); font-size: 10px; color: var(--subtle); }
.entry.prompt { display: flex; align-items: baseline; gap: var(--space-3); margin: 0 calc(var(--space-5) * -1); padding: var(--space-3) var(--space-5); background: var(--prompt); border-left: 2px solid var(--accent); white-space: pre-wrap; }
.prompt-text { min-width: 0; }
.busy { color: var(--accent); }
.tool-glyph { flex: none; width: 14px; text-align: center; color: var(--muted); }
.tool-summary { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.entry.tool[data-kind="shell"] .tool-glyph { color: var(--success); }
.entry.tool[data-kind="edit"] .tool-glyph, .entry.tool[data-kind="write"] .tool-glyph { color: var(--accent); }
.entry.tool[data-kind="read"] .tool-glyph, .entry.tool[data-kind="web"] .tool-glyph { color: var(--info); }
.entry.tool[data-kind="delegate"] .tool-glyph, .entry.tool[data-kind="plan"] .tool-glyph, .entry.tool[data-kind="ask"] .tool-glyph { color: var(--warning); }
.entry.error, .entry.error .tool-glyph { color: var(--danger); }
.entry.note, .when { color: var(--muted); }
.detail { margin: var(--space-2) 0 0 20px; }
.detail summary { cursor: pointer; font-size: 11px; color: var(--muted); }
.detail summary:hover { color: var(--text); }
.detail pre { margin: 0; }

.diff { padding: var(--space-2) 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow-x: auto; }
.diff-line { display: block; padding: 0 var(--space-4); white-space: pre; }
.diff-line.add { background: var(--diff-add-bg); color: var(--success); }
.diff-line.del { background: var(--diff-del-bg); color: var(--danger); }
.diff-sign { display: inline-block; width: 14px; color: var(--subtle); user-select: none; }
.plain { white-space: pre-wrap; color: var(--muted); }

.code-block { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-canvas); }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 2px var(--space-2) 2px var(--space-4); border-bottom: 1px solid var(--border); background: var(--bg-surface); font-size: 10px; color: var(--muted); }
.code-block pre { margin: 0; padding: var(--space-4); overflow-x: auto; white-space: pre; }
.copy-btn { all: unset; padding: 1px 6px; border-radius: var(--radius-sm); cursor: pointer; color: var(--muted); }
.copy-btn:hover { background: var(--bg-hover); color: var(--text); }
.copy-btn:focus-visible { outline: 2px solid var(--focus); }
.no-clipboard .copy-btn { display: none; }
.prompt-sign { color: var(--success); user-select: none; }

.md { font: 13px/1.55 var(--font-sans); color: var(--text); }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md table, .md .code-block { margin: 0 0 var(--space-4); }
.md h1, .md h2, .md h3, .md h4 { margin: var(--space-5) 0 var(--space-3); font-size: 13px; font-weight: 700; }
.md h1, .md h2 { font-size: 14px; }
.md ul, .md ol { padding-left: 20px; }
.md li + li { margin-top: var(--space-1); }
.md a { color: var(--info); }
.md strong { font-weight: 600; }
.md :not(pre) > code { padding: 0 4px; border-radius: var(--radius-sm); background: var(--bg-raised); font: 12px var(--font-mono); color: var(--accent); }
.md blockquote { padding-left: var(--space-5); border-left: 2px solid var(--border-control); color: var(--muted); }
.md table { border-collapse: collapse; font-size: 12px; }
.md th, .md td { padding: var(--space-2) var(--space-4); border: 1px solid var(--border-strong); text-align: left; }
.md hr { border: 0; border-top: 1px solid var(--border-strong); }
.md .code-block pre { font: 12px/1.5 var(--font-mono); }
.streaming:empty { display: none; }
.streaming .md > :last-child::after { content: "\258D"; color: var(--accent); animation: blink 1s steps(2) infinite; }

.hljs-keyword, .hljs-selector-tag, .hljs-built_in { color: var(--accent); }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-template-tag { color: var(--success); }
.hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet { color: var(--warning); }
.hljs-title, .hljs-section, .hljs-attr, .hljs-attribute, .hljs-name, .hljs-property { color: var(--info); }
.hljs-comment, .hljs-quote, .hljs-meta { color: var(--subtle); font-style: italic; }
.hljs-deletion { color: var(--danger); }
.hljs-variable, .hljs-params, .hljs-type { color: var(--text); }

@keyframes blink { 50% { opacity: 0; } }
@keyframes hop { 50% { translate: 0 -4px; } }
@media (prefers-reduced-motion: reduce) { .app * { animation: none !important; transition: none !important; } }

.dialog { width: min(520px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--bg-overlay); color: var(--text); box-shadow: var(--shadow-dialog); }
.dialog::backdrop { background: var(--scrim); }
.dialog-title { padding: var(--space-6) var(--space-6) var(--space-5); font-size: 16px; font-weight: 600; line-height: 1.25; }
.dialog-body { display: flex; flex-direction: column; gap: var(--space-5); padding: 0 var(--space-6); }
.dialog-foot { display: flex; justify-content: flex-end; gap: var(--space-4); padding: 14px var(--space-6) var(--space-6); }
.name-tag.reserved { padding: 1px 6px; background: var(--bg-surface); border-style: dashed; border-color: var(--border-control); box-shadow: none; color: var(--muted); font-weight: 400; font-size: 10px; cursor: default; pointer-events: auto; overflow: hidden; text-overflow: ellipsis; }

.notices:empty { display: none; }
.notice { margin: 0; padding: var(--space-4) var(--space-6); background: var(--bg-surface); border-bottom: 1px solid var(--warning); color: var(--text); font-size: 12px; }
.notice code, .pairing-needed code { padding: 0 4px; border-radius: var(--radius-sm); background: var(--bg-hover); }
.mode[data-mode="unpaired"]::before { background: var(--warning); }
.command { margin: 0; padding: var(--space-4) var(--space-5); border-radius: var(--radius-md); background: var(--bg-raised); border: 1px solid var(--border-strong); user-select: all; }
.devices { display: grid; gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
.device { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.device-id { display: grid; gap: var(--space-1); min-width: 0; }
.device-id .mono { font-size: 11px; overflow-wrap: anywhere; }
.pairing-code { display: grid; gap: var(--space-4); justify-items: center; text-align: center; }
.qr { width: min(240px, 70vw); height: auto; border-radius: var(--radius-sm); }
.pairing-link { font-size: 11px; overflow-wrap: anywhere; user-select: all; }
.device-name { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
