/* The dock on a phone: a one-row composer over one status line, at one
   height whatever runs.  What a wider window stacks above the composer --
   background work, queued prompts, schedules, the goal -- opens from the
   status line as the Activity sheet. */

/* A wider window keeps the dock it has: the sheet's wrappers dissolve and
   leave the background work a dock row. */
.activity-sheet, .activity-panel { display:contents; }
.activity-scrim, .activity-head, .activity-panel .activity-label, .activity-note, #activity-queue, #activity-later,
.status-half, .composer-more, .composer-menu { display:none; }

@media (max-width:640px) {
  /* This sheet loads before viewer-room.css, hence the weightier selectors. */
  body > .dock { padding:8px 12px var(--safe-bottom, env(safe-area-inset-bottom, 0px)); gap:8px; border-top:1px solid var(--line); }
  /* An empty region would still cost the dock a gap. */
  #own-queue, #assistant-working, .queue-state, #requests:empty { display:none; }
  body[data-lobby] > .dock { border-top:0; }

  /* Composer at rest: more, the field, Interrupt while busy, Send. */
  .composer { position:relative; }
  .composer.compact:not(.composing) { flex-direction:row; flex-wrap:wrap; align-items:center; gap:6px; padding:4px; }
  .composer.compact:not(.composing) :is(.composer-field, .composer-row) { display:contents; }
  .composer.compact:not(.composing) :is(#attach-button, #skills-button, .composer-spacer, .input-expand) { display:none; }
  .composer.compact:not(.composing) :is(.composer-scope, .attachments) { flex:0 0 100%; margin:0; padding:4px 8px 0; }
  .composer.compact:not(.composing) .composer-more { display:grid; place-items:center; flex:none; order:1; width:44px; height:44px; padding:0; border:0; border-radius:4px; background:none; color:var(--muted); cursor:pointer; }
  .composer-more svg { width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:1.6; stroke-linecap:round; }
  .composer-more[aria-expanded="true"] { color:var(--accent); background:var(--accent-soft); }
  .composer-more:focus-visible, .status-half:focus-visible, .activity-row:focus-visible, #activity-close:focus-visible { outline:2px solid var(--accent); outline-offset:-2px; }
  .composer.compact:not(.composing) .expandable-input { order:2; flex:1; }
  .composer.compact:not(.composing) textarea::placeholder { overflow:hidden; text-overflow:ellipsis; }
  .composer.compact:not(.composing) textarea { height:44px; min-height:44px; max-height:44px; padding:9px 4px; line-height:26px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .composer.compact:not(.composing) #stop-button:not([hidden]) { display:inline-flex; align-items:center; justify-content:center; order:3; width:44px; height:44px; padding:0; font-size:0; }
  .composer.compact:not(.composing) #stop-button::before { content:''; display:block; width:12px; height:12px; border-radius:2px; background:var(--failed); }
  .composer.compact:not(.composing) #send-button { order:4; min-width:64px; min-height:44px; font-size:14px; font-weight:600; }
  .composer-menu:not([hidden]) { display:block; position:absolute; left:-1px; bottom:calc(100% + 8px); z-index:2; width:min(260px, calc(100vw - 24px)); padding:4px 0; background:var(--surface); border:1px solid var(--line); border-radius:6px; box-shadow:var(--shadow); }
  .composer-menu button { display:flex; align-items:center; gap:10px; width:100%; min-height:44px; padding:0 14px; border:0; background:none; color:var(--ink); font:inherit; font-size:14px; text-align:left; white-space:nowrap; cursor:pointer; }
  .composer-menu span { min-width:0; overflow:hidden; text-overflow:ellipsis; }
  .composer-menu button + button { border-top:1px solid var(--line); }
  .composer-menu small { flex:none; margin-left:auto; color:var(--muted); font-size:12px; }
  /* Reading folds the row to the field and Interrupt, at the same height:
     a dock that resized while the page scrolls would move the page. */
  body[data-reading] .dock:is(:not(:focus-within), :has(#background-work:focus-within)) { padding-top:8px; }
  body[data-reading] .dock:is(:not(:focus-within), :has(#background-work:focus-within)) .composer-more { display:none; }
  body[data-reading] .dock:is(:not(:focus-within), :has(#background-work:focus-within)) .composer.compact { padding:4px; }
  body[data-reading] .dock:is(:not(:focus-within), :has(#background-work:focus-within)) .composer.compact textarea { height:44px; padding:9px 8px; }

  /* The status line: session and settings left, activity right. */
  .dock .modeline { justify-content:space-between; align-items:stretch; flex-wrap:nowrap; gap:8px; width:calc(100% + 8px); max-width:none; margin:0 -4px; padding:0; font-size:13px; }
  .dock .modeline > #modeline, #pending-schedules-button { display:none; }
  .status-half { display:flex; align-items:center; gap:6px; min-width:0; min-height:44px; padding:0 4px; border:0; background:none; color:var(--muted); font:inherit; cursor:pointer; }
  .status-half[hidden] { display:none; }
  .status-half:disabled { cursor:default; }
  .status-half > span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .status-half > span:empty::before { content:attr(data-state); }
  .status-half > b, .status-half > .status-chev { flex:none; }
  .status-activity { flex:none; max-width:64%; color:var(--ink); font-weight:500; }
  .status-activity.quiet { color:var(--muted); font-weight:400; }
  .status-chev { color:var(--muted); }
  .status-dot { flex:none; width:8px; height:8px; border-radius:50%; background:var(--muted); }
  .status-dot.ok { background:var(--ok); }
  .status-spin { flex:none; width:12px; height:12px; border:2px solid var(--accent); border-right-color:transparent; border-radius:50%; animation:assistant-spin 1s linear infinite; }
  .status-half.attention, .status-half.ended { color:var(--failed); }
  .status-half:is(.attention, .ended) .status-dot { background:var(--failed); }
  .status-half.attention { font-weight:600; }

  /* The Activity sheet. */
  .activity-sheet:not([data-open]) { display:none; }
  .activity-scrim { display:block; position:fixed; inset:0; z-index:40; background:rgb(10 14 22 / 38%); touch-action:none; }
  .activity-panel { display:block; position:fixed; left:0; right:0; bottom:0; z-index:41; max-height:88dvh; overflow-y:auto; overscroll-behavior:contain; padding:0 16px calc(12px + var(--safe-bottom, env(safe-area-inset-bottom, 0px))); background:var(--surface); border-top:1px solid var(--line); border-radius:12px 12px 0 0; box-shadow:0 -6px 24px rgb(10 14 22 / 18%); text-align:left; }
  .activity-panel::before { content:''; display:block; width:36px; height:4px; margin:6px auto 0; border-radius:2px; background:var(--line); }
  .activity-head { display:flex; align-items:center; min-height:44px; margin:2px -10px 0 0; }
  .activity-head h2 { flex:1; margin:0; font-size:17px; font-weight:650; letter-spacing:-.01em; }
  #activity-close { width:44px; height:44px; border:0; background:none; color:var(--muted); font:20px/1 var(--font-ui); cursor:pointer; }
  .activity-panel .activity-label { display:block; margin:12px 0 2px; font-size:11px; font-weight:700; letter-spacing:.07em; text-transform:uppercase; color:var(--muted); }
  .activity-panel:not(:has(> #background-work:not([hidden]))) > .activity-running { display:none; }
  #activity-queue:not([hidden]), #activity-later:not([hidden]) { display:block; }
  .activity-note:not([hidden]) { display:block; margin:6px 0; font-size:13px; color:var(--muted); }
  .activity-list { list-style:none; margin:0; padding:0; }
  .activity-list li[hidden] { display:none; }
  .activity-list li:not([hidden]), .activity-row { display:flex; align-items:center; gap:10px; min-width:0; min-height:44px; font-size:14px; }
  .activity-list li, .activity-panel .background-row { border-top:1px solid var(--line); }
  .activity-row { flex:1; margin:0; padding:0; border:0; background:none; color:var(--ink); font:inherit; font-size:14px; text-align:left; cursor:pointer; }
  .activity-glyph { flex:none; width:16px; text-align:center; color:var(--accent); }
  .activity-row small { flex:none; color:var(--muted); font-size:13px; }
  .activity-row small:empty { display:none; }
  .activity-text { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .activity-list .btn { flex:none; min-height:40px; padding:0 10px; font-size:13px; }
  /* Background work wears the sheet's rows; its details keep their shape. */
  .activity-panel .background-work { max-height:none; overflow:visible; border:0; border-radius:0; background:none; }
  /* The label above already names the list; its heading stays to say work was left out. */
  .activity-panel .background-work > header { position:static; min-height:0; padding:4px 0 8px; background:none; font-size:13px; color:var(--muted); }
  .activity-panel .background-work:not([data-omitted="true"]) > header, .activity-panel #background-collapse { display:none; }
  .activity-panel #background-list { padding:0; }
  /* Clipped: the turned chevron must not widen the row. */
  .activity-panel .background-toggle { align-items:center; gap:10px; min-height:44px; padding-top:0; padding-bottom:0; overflow:hidden; font-size:14px; }
  .activity-panel .background-toggle::before { content:none; }
  .activity-panel .background-toggle::after { content:'›'; flex:none; color:var(--muted); }
  .activity-panel .background-toggle[aria-expanded="true"]::after { transform:rotate(90deg); }
  .activity-panel .background-mark { width:16px; text-align:center; color:var(--accent); }
  .activity-panel .background-kind { margin-right:-4px; color:var(--muted); font-size:13px; }
  .activity-panel :is(.background-meta, .background-preview-label, .background-preview) { font-size:12px; }
  .activity-panel .background-controls { gap:8px; padding:6px 0 10px; }
  .activity-panel :is(.background-controls .btn, #background-more) { min-height:40px; padding:0 12px; font-size:13px; }
  .activity-panel #background-more { margin:6px 0; }
}
@media (prefers-reduced-motion:reduce) { .status-spin { animation:none; } }
