/* The selected agent (or the computer): a surface plane tucked against the right edge; a full sheet on narrow screens. */
.panel {
  position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 36px 0 0 0; margin-top: 4px;
}
.panel-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 22px calc(24px + var(--safe-r)) 16px 28px; }
.sheet-close { display: none; }

.panel-head { display: flex; align-items: flex-start; gap: 16px; padding-bottom: 14px; }
.head-main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.panel-head h2 { font-size: clamp(28px, 2.6vw, 40px); font-weight: 700; font-stretch: 80%; line-height: 1.05; letter-spacing: -.01em; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; color: var(--dim); max-width: 62ch; }
.meta .queued { color: var(--ink); }
.activity { display: flex; align-items: center; gap: 10px; min-height: 24px; font-size: 15px; }
#a-activity-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#panel-agent[data-state="error"] #a-activity-text { white-space: normal; color: var(--error); }
#panel-agent[data-state="permission"] #a-activity-text { color: var(--attention); }
.head-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 2px; flex: none; }
.head-actions select { width: auto; min-height: 40px; padding: 6px 12px; border-radius: 999px; font-size: 14px; margin-right: 6px; }

/* ---- permission request ---- */
.perm { display: grid; gap: 8px; padding: 16px 18px; margin-bottom: 12px; border-radius: 22px; border: 2px solid var(--attention); background: color-mix(in srgb, var(--attention) 9%, var(--surface)); }
.perm-title { font-weight: 700; font-size: 18px; color: var(--attention); }
.perm-summary { font-size: 15px; overflow-wrap: anywhere; }
.perm summary { cursor: pointer; color: var(--dim); font-size: 14px; min-height: 28px; }
.perm pre { margin: 6px 0 0; max-height: 160px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--dim); font-size: 13px; }
.perm-actions { display: flex; gap: 10px; }
.perm-actions .btn { flex: 1; }

/* ---- tabs ---- */
.tabs { display: flex; gap: 22px; border-bottom: 1.5px solid var(--line); margin-bottom: 4px; }
.tabs [role="tab"] {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 2px; border: 0; background: none; cursor: pointer;
  font-weight: 600; color: var(--dim); border-bottom: 3px solid transparent; margin-bottom: -1.5px;
}
.tabs [aria-selected="true"] { color: var(--ink); border-bottom-color: var(--arc); }
.tabs i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.tabs [data-preview="running"] i { background: var(--arc); }
.tabs [data-preview="starting"] i { background: var(--attention); }
.tabs [data-preview="error"] i { background: var(--error); }

/* ---- transcript ---- */
.transcript, .conversation { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 6px 12px 0; overscroll-behavior: contain; }
.transcript { display: flex; flex-direction: column; gap: 12px; }
.transcript > .empty { padding-left: 0; }
.t-line { max-width: 72ch; overflow-wrap: anywhere; }
.t-user {
  align-self: flex-end; max-width: min(60ch, 86%); padding: 10px 16px; border-radius: 20px 20px 4px 20px;
  background: color-mix(in srgb, var(--arc) 18%, var(--surface)); white-space: pre-wrap;
}
.t-assistant { font-size: 16px; line-height: 1.5; }
.md > * + * { margin-top: .6em; }
.md ul, .md ol { padding-left: 1.3em; display: grid; gap: .25em; }
.md ul { list-style: disc; }
.md ol { list-style: decimal; }
.md li::marker { color: var(--dim); }
.md code { font: 400 .875em var(--mono); padding: 1px 6px; border-radius: 6px; background: var(--ground); }
.md pre { margin: .6em 0 0; padding: 12px 14px; border-radius: 14px; background: var(--ground); overflow-x: auto; }
.md pre code { padding: 0; background: none; white-space: pre; }
.md .md-h { font-weight: 700; font-size: 1.05em; }
.t-step, .t-steps summary, .t-steps li { font: 400 13.5px/1.45 var(--mono); color: var(--dim); }
.t-step, .t-steps { padding-left: 14px; border-left: 2px solid var(--line); }
.t-steps summary { display: flex; flex-wrap: wrap; gap: 2px 12px; cursor: pointer; min-height: 28px; align-items: center; list-style: none; }
.t-steps summary::-webkit-details-marker { display: none; }
.t-steps summary::before { content: "+"; width: 1ch; color: var(--arc); }
.t-steps[open] summary::before { content: "\2212"; }
.t-count { color: var(--ink); }
.t-steps ol { display: grid; gap: 2px; padding: 4px 0 2px 2ch; }
.t-done { font-size: 14px; color: var(--arc); font-weight: 600; }
.t-result { padding-left: 14px; border-left: 2px solid var(--arc); }
.t-note { display: flex; gap: 10px; font-size: 14px; color: var(--dim); }
.t-tag { flex: none; font-weight: 600; }
.t-stderr .t-tag { color: var(--error); }
.t-permission .t-tag { color: var(--attention); }
.atts { display: flex; flex-wrap: wrap; gap: 8px; }
.atts { margin-top: 8px; }
.att { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 10px; border-radius: 10px; background: var(--ground); font-size: 14px; text-decoration: none; }
.att.img { padding: 0; overflow: hidden; }
.att img { display: block; max-height: 110px; max-width: 200px; object-fit: cover; }

/* ---- computer conversation ---- */
.conversation { display: flex; flex-direction: column; gap: 14px; }
.c-msg { display: grid; gap: 1px; max-width: 64ch; }
.c-who { font-size: 13px; font-weight: 600; color: var(--dim); }
.c-assistant .c-body { font-size: 20px; line-height: 1.3; font-weight: 500; }
.c-user .c-body { color: var(--dim); font-size: 18px; }
.c-system .c-body { font-size: 14px; color: var(--dim); }
.c-system .c-who { color: var(--glow); }
.techlog { flex: none; border-top: 1.5px solid var(--line); }
.techlog summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; color: var(--dim); font-size: 14px; font-weight: 600; }
.techlog #log { max-height: 140px; overflow: auto; font-size: 12.5px; color: var(--dim); padding-bottom: 8px; overflow-wrap: anywhere; }

/* ---- composer ---- */
.composer-wrap { flex: none; display: grid; gap: 8px; padding-top: 8px; }
.composer { flex: none; display: flex; align-items: flex-end; gap: 6px; padding: 5px; border-radius: 26px; background: var(--ground); border: 1.5px solid var(--line); }
.composer:focus-within { border-color: var(--glow); }
.composer textarea, .composer input[type="text"] { flex: 1; min-height: 44px; border: 0; background: none; padding: 10px 8px; resize: none; border-radius: 12px; }
.composer textarea:focus-visible, .composer input:focus-visible { outline: none; }
.composer textarea { scrollbar-width: none; }
.composer textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- preview ---- */
.preview { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding-top: 10px; }
.pv-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pv-status { flex: 1; min-width: 12ch; font-weight: 600; }
.preview[data-status="error"] .pv-status { color: var(--error); }
.seg { display: flex; padding: 3px; border-radius: 999px; background: var(--ground); }
.seg button { display: grid; place-items: center; width: 44px; height: 38px; border: 0; border-radius: 999px; background: none; color: var(--dim); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); }
.pv-stage { flex: 1; min-height: 0; display: grid; justify-items: center; border-radius: 18px; background: var(--ground); overflow: auto; }
.pv-stage iframe { width: 100%; height: 100%; border: 0; background: #fff; border-radius: 18px; }
.pv-stage[data-size="phone"] iframe { width: 390px; max-width: 100%; }
.pv-stage[data-size="tablet"] iframe { width: 820px; max-width: 100%; }
.pv-note { width: 100%; padding: 20px; color: var(--dim); display: grid; gap: 12px; align-content: start; }
.pv-note p { max-width: 60ch; }
.pv-note pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }

/* ---- narrow screens: the deck scrolls, the panel is a sheet ---- */
@media (max-width: 899px) {
  body { overflow: auto; grid-template-rows: auto auto auto auto; min-height: 100%; height: auto; }
  .top { position: sticky; top: 0; z-index: 20; background: var(--ground); gap: 10px; padding-left: calc(14px + var(--safe-l)); padding-right: calc(14px + var(--safe-r)); }
  .wordmark { font-size: 20px; }
  .ws-switch button { padding: 0 12px; font-size: 15px; }
  .top-right .btn span, .conn span, #install, .top-help { display: none; }
  .top-right .btn { padding: 0; width: 44px; min-height: 44px; border-color: transparent; }
  .top-right { gap: 0; }
  .deck { grid-template-columns: 1fr; }
  .stage { padding: 0 calc(12px + var(--safe-r)) 96px calc(12px + var(--safe-l)); }
  .ring { width: min(70vw, 52vh); }
  .agents { overflow: visible; padding-right: 0; }
  .dock { position: fixed; z-index: 15; left: 0; right: 0; bottom: 0; background: var(--ground); padding-top: 8px; }
  .dock-actions .btn.quiet { display: none; }
  .dock-actions .btn { padding: 0 14px; }
  .panel {
    position: fixed; inset: 0; z-index: 40; margin: 0; border-radius: 0; padding-top: var(--safe-t);
    transform: translateY(102%); visibility: hidden; transition: transform .28s cubic-bezier(.2, .8, .2, 1), visibility 0s .28s;
  }
  :root[data-sheet="open"] .panel { transform: none; visibility: visible; transition-delay: 0s; }
  :root[data-sheet="open"] body { overflow: hidden; }
  .panel-body { padding: 8px calc(14px + var(--safe-r)) calc(10px + var(--safe-b)) calc(14px + var(--safe-l)); }
  .sheet-close { display: inline-grid; align-self: center; margin-top: 4px; width: 64px; }
  .panel-head { flex-direction: column; gap: 6px; }
  .head-actions { justify-content: flex-start; }
  :root[data-drive="on"] body { overflow: hidden; height: 100%; }
  :root[data-drive="on"] .stage { padding-bottom: calc(16px + var(--safe-b)); }
  :root[data-mini="on"] body { overflow: hidden; height: 100%; grid-template-rows: minmax(0, 1fr); }
  :root[data-mini="on"] .stage { padding: 10px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .panel { transition: none; }
}
