  :root {
    --dock-w: 360px;
    --dock-collapsed-w: 48px;
  }
  body.has-dock .app {
    display: grid;
    grid-template-columns: var(--rail) 1fr var(--dock-w);
    transition: grid-template-columns 240ms var(--ease-entrance);
    min-height: 100vh;
  }
  body.has-dock.dock-collapsed .app {
    grid-template-columns: var(--rail) 1fr var(--dock-collapsed-w);
  }
  body.has-dock.workspace-mode .app {
    grid-template-columns: var(--rail) 1fr;
  }
  body.has-dock.workspace-mode .dock-cf,
  body.has-dock.workspace-mode .dock-edge-handle { display: none; }

  /* Dock column */
  .dock-cf {
    background: var(--color-white);
    border-left: 1px solid var(--line-2);
    /* Sticky-pin the dock to the viewport (matches the rail's behavior) so
       the chat input + suggestions stay above the fold regardless of how
       tall .main grows. Without this, .dock-cf is a normal grid cell that
       stretches to row height and scrolls with the page. */
    position: sticky; top: 0;
    height: 100vh;
    min-width: 0; overflow: hidden;
    display: flex; flex-direction: column;
  }
  .dock-cf-content {
    display: flex; flex-direction: column; height: 100%;
    transition: opacity 180ms ease;
  }
  body.dock-collapsed .dock-cf-content { opacity: 0; pointer-events: none; }

  /* Collapsed sliver */
  .dock-cf-sliver {
    position: absolute; top: 0; left: 0; bottom: 0;
    width: var(--dock-collapsed-w);
    background: var(--color-purple-01);
    border: 0; cursor: pointer;
    display: grid; place-items: center;
    opacity: 0; pointer-events: none;
    transition: opacity 220ms ease, background 120ms;
    z-index: 1;
  }
  body.dock-collapsed .dock-cf-sliver { opacity: 1; pointer-events: auto; }
  .dock-cf-sliver:hover { background: var(--color-purple-02); }
  .dock-cf-sliver .stack {
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    color: var(--color-white);
  }
  .dock-cf-sliver .lbl {
    font-family: var(--font-mono); font-size: var(--text-app-2xs);
    letter-spacing: 0.16em; text-transform: uppercase;
    writing-mode: vertical-rl;
  }
  .dock-cf-sliver .arr {
    font-family: var(--font-mono); font-size: var(--text-app-lg);
    color: var(--color-cyan);
  }
  .dock-cf-sliver .dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--color-cyan);
  }

  /* Dock head */
  .dock-cf-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--color-white); position: relative; gap: 8px; flex-shrink: 0;
  }
  .dock-cf-head .t {
    font-family: var(--font-display); font-weight: 700;
    font-size: var(--text-app-md); text-transform: uppercase; letter-spacing: 0.02em;
    color: var(--color-purple-01);
    display: flex; align-items: center; gap: 6px;
    flex: 1; min-width: 0;
  }
  .dock-cf-head .t .num {
    font-family: var(--font-mono); font-size: var(--text-app-2xs);
    color: var(--color-muted-grey); letter-spacing: 0.06em;
  }
  .dock-cf-head .hist-btn {
    appearance: none;
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--color-purple-01);
    padding: 4px 8px;
    font-family: var(--font-mono); font-size: var(--text-app-2xs);
    letter-spacing: 0.06em; text-transform: uppercase;
    cursor: pointer;
    display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
  }
  .dock-cf-head .hist-btn:hover {
    border-color: var(--color-purple-03); color: var(--color-purple-03);
  }
  .dock-cf-head .hist-btn .hist-num {
    background: var(--color-purple-03); color: var(--color-white);
    padding: 1px 5px; font-weight: 700; line-height: 1.3;
  }

  /* Lifted .agent-panel adapts to the dock container.
     The original .agent-panel rule (from _inject_agent_panel) sets
     min-height: 500px / max-height: 640px — those caps were sized for the
     s6 detail page and must be lifted here so the panel can fill the dock
     column or the workspace screen. */
  .dock-cf .agent-panel,
  .ws-chat-host .agent-panel {
    background: transparent;
    padding: 0;
    height: auto;
    min-height: 0;
    max-height: none;
    flex: 1;
    display: flex; flex-direction: column; gap: 0;
  }
  .dock-cf .agent-panel > h5:first-child,
  .ws-chat-host .agent-panel > h5:first-child { display: none; }
  .dock-cf .agent-context-pill { margin: 8px 14px 0; }
  .dock-cf .agent-messages { padding: 10px 14px; flex: 1; min-height: 0; }
  .dock-cf .agent-suggestions { padding: 0 14px 8px; }
  .dock-cf .agent-form { padding: 0 14px 14px; }

  /* "Open in workspace" footer link */
  .dock-cf-openws {
    display: flex; align-items: center; justify-content: space-between;
    margin: 0 14px 14px;
    padding: 9px 12px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    cursor: pointer;
    font-family: var(--font-mono); font-size: var(--text-app-2xs);
    letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--color-purple-01);
    transition: border-color 120ms, background 120ms;
  }
  .dock-cf-openws:hover {
    border-color: var(--color-purple-03);
    background: color-mix(in srgb, var(--color-purple-03) 4%, transparent);
  }
  .dock-cf-openws .arr { color: var(--color-purple-03); }

  /* Edge handle (dock collapse on boundary) */
  .dock-edge-handle {
    position: fixed;
    top: 50%; transform: translateY(-50%);
    right: var(--dock-w);
    width: 22px; height: 56px;
    background: var(--color-purple-01);
    color: var(--color-white); border: 0; cursor: pointer;
    z-index: 25;
    display: grid; place-items: center;
    transition: right 240ms var(--ease-entrance), background 120ms;
    box-shadow: -2px 0 8px color-mix(in srgb, var(--color-purple-01) 18%, transparent);
  }
  .dock-edge-handle:hover { background: var(--color-purple-03); }
  .dock-edge-handle .chev {
    font-family: var(--font-mono); font-size: 18px; line-height: 1;
    transition: transform 200ms ease;
  }
  body.dock-collapsed .dock-edge-handle { display: none; }
  body.workspace-mode .dock-edge-handle { display: none; }

  /* s6 Per-Deal Explanation: the original .dual was a two-column grid
     (1fr 380px) where the agent panel filled the right column. The panel
     has been lifted into the dock, so the right column is now empty —
     collapse the grid to a single column and drop the orphaned divider
     between the (gone) columns. */
  #s6 .dual { grid-template-columns: 1fr; }
  #s6 .dual .left { border-right: 0; }

  /* History flyout */
  .hist-flyout {
    position: absolute;
    top: calc(100% + 4px); right: 14px;
    width: 300px;
    background: var(--color-white);
    border: 1px solid var(--line-2);
    box-shadow: 0 24px 60px color-mix(in srgb, var(--color-purple-01) 28%, transparent);
    z-index: 30;
    display: none; overflow: hidden;
    transform-origin: top right;
  }
  .hist-flyout.open {
    display: block;
    animation: hist-pop 200ms var(--ease-entrance);
  }
  @keyframes hist-pop {
    from { opacity: 0; transform: scale(.92) translateY(-6px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
  }
  .hist-flyout .head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 9px 14px;
    border-bottom: 1px solid var(--line);
  }
  .hist-flyout .head .meta {
    font-family: var(--font-mono); font-size: var(--text-app-2xs);
    letter-spacing: 0.10em; text-transform: uppercase;
    color: var(--color-purple-01); font-weight: 600;
  }
  .hist-flyout .head .meta .slash {
    color: var(--color-muted-grey); margin-right: 4px;
  }
  .hist-flyout .head .close {
    appearance: none; background: none; border: 0;
    font-family: var(--font-mono); font-size: var(--text-app-lg);
    color: var(--color-muted-grey); cursor: pointer;
    padding: 2px 6px; line-height: 1;
  }
  .hist-flyout .head .close:hover { color: var(--color-purple-03); }
  .hist-flyout .section-label {
    font-family: var(--font-mono); font-size: var(--text-app-2xs);
    letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--color-muted-grey);
    padding: 8px 14px 4px;
  }
  .hist-flyout .row {
    display: grid; grid-template-columns: 8px 1fr; gap: 10px;
    align-items: start; padding: 8px 14px;
    border-left: 2px solid transparent;
    cursor: pointer;
    transition: background 120ms;
  }
  .hist-flyout .row:hover { background: var(--panel-2); }
  .hist-flyout .row.active {
    background: color-mix(in srgb, var(--color-purple-03) 6%, transparent);
    border-left-color: var(--color-purple-03);
  }
  .hist-flyout .row.muted { opacity: 0.62; }
  .hist-flyout .row .dot {
    width: 8px; height: 8px; border-radius: 50%;
    margin-top: 5px; background: var(--color-purple-04);
  }
  .hist-flyout .row.active .dot { background: var(--color-cyan); }
  .hist-flyout .row.muted .dot { background: var(--color-muted-grey); }
  .hist-flyout .row .id {
    font-family: var(--font-mono); font-size: var(--text-app-xs);
    color: var(--color-purple-01); font-weight: 600;
  }
  .hist-flyout .row .snip {
    font-size: var(--text-app-sm); color: var(--ink-2);
    margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .hist-flyout .row .meta {
    font-family: var(--font-mono); font-size: var(--text-app-2xs);
    letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--color-muted-grey); margin-top: 4px;
  }
  .hist-flyout .foot {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px;
    background: var(--color-purple-01);
    color: var(--color-white); cursor: pointer;
    font-family: var(--font-mono); font-size: var(--text-app-2xs);
    letter-spacing: 0.08em; text-transform: uppercase;
    transition: background 120ms;
  }
  .hist-flyout .foot:hover { background: var(--color-purple-02); }
  .hist-flyout .foot .arr { color: var(--color-cyan); }

  /* Topbar keyboard hint */
  .topbar-kbd-hint {
    font-family: var(--font-mono); font-size: var(--text-app-2xs);
    letter-spacing: 0.04em; color: var(--color-muted-grey);
    display: flex; align-items: center; gap: 6px;
    margin-right: 12px;
  }
  .topbar-kbd-hint kbd {
    font-family: var(--font-mono); font-size: var(--text-app-2xs);
    background: var(--panel-2);
    border: 1px solid var(--line-2);
    padding: 2px 6px;
    color: var(--color-purple-01);
  }

  /* Analyst workspace screen (Concept F).
     .screen.on is display:block by default, so as a flex child of .main it
     only takes content height. Override just this screen to a flex column
     so the .pg-body → workspace → chat chain can flex-1 down to the viewport
     bottom (no whitespace below the input form). */
  #s-analyst.on {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }
  /* Lock .main to exactly one viewport while in workspace mode so the
     irreducible content (topbar + pg-head + pill + suggestions + form) can't
     push the page taller than 100vh. Internal scroll regions (thread list,
     agent messages) handle their own overflow. Scoped to .workspace-mode so
     normal screens (s1–s7) keep their natural scrolling behavior. */
  body.workspace-mode { overflow: hidden; }
  body.workspace-mode .main {
    height: 100vh;
    min-height: 0;
    overflow: hidden;
  }
  #s-analyst .pg-body {
    padding: 0; flex: 1; display: flex; flex-direction: column;
    min-height: 0;
  }
  .analyst-workspace {
    flex: 1;
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 0;
    background: var(--panel-2);
  }
  .ws-threads {
    background: var(--color-white); border-right: 1px solid var(--line);
    display: flex; flex-direction: column; min-height: 0;
  }
  .ws-threads-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 16px; border-bottom: 1px solid var(--line);
  }
  .ws-threads-head .t {
    font-family: var(--font-display); font-weight: 700;
    font-size: var(--text-app-md); text-transform: uppercase; letter-spacing: 0.02em;
    color: var(--color-purple-01);
  }
  .ws-threads-head .t .num {
    font-family: var(--font-mono); font-size: var(--text-app-2xs);
    color: var(--color-muted-grey); margin-right: 6px;
  }
  .ws-new-btn {
    appearance: none;
    background: var(--color-purple-03); color: var(--color-white);
    border: 0; padding: 5px 10px;
    font-family: var(--font-mono); font-size: var(--text-app-2xs);
    letter-spacing: 0.06em; cursor: pointer;
  }
  .ws-new-btn:hover { background: var(--color-purple-04); }
  .ws-thread-list { flex: 1; overflow-y: auto; padding: 6px 0; }
  .ws-thread {
    padding: 12px 16px;
    border-left: 2px solid transparent;
    cursor: pointer; transition: background 120ms;
  }
  .ws-thread:hover { background: var(--panel-2); }
  .ws-thread.active {
    background: color-mix(in srgb, var(--color-purple-03) 6%, transparent);
    border-left-color: var(--color-purple-03);
  }
  .ws-thread.muted { opacity: 0.55; }
  .ws-thread .id {
    font-family: var(--font-mono); font-size: var(--text-app-xs);
    color: var(--color-purple-01); font-weight: 600;
  }
  .ws-thread .snip {
    font-size: var(--text-app-md); color: var(--ink-2);
    margin-top: 3px;
    overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
  }
  .ws-thread .meta {
    font-family: var(--font-mono); font-size: var(--text-app-2xs);
    color: var(--color-muted-grey); letter-spacing: 0.04em;
    margin-top: 4px; text-transform: uppercase;
  }
  .ws-thread-divider {
    font-family: var(--font-mono); font-size: var(--text-app-2xs);
    letter-spacing: 0.10em; text-transform: uppercase;
    color: var(--color-muted-grey);
    padding: 14px 16px 6px;
  }
  .ws-thread-panel {
    background: var(--color-white);
    display: flex; flex-direction: column;
    min-height: 0; position: relative;
  }
  .ws-thread-head {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--line);
    background: var(--panel-2);
  }
  .ws-thread-head .ctx {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  }
  .ws-thread-head .ctx .meta {
    font-family: var(--font-mono); font-size: var(--text-app-2xs);
    letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--color-muted-grey); margin-right: 4px;
  }
  .ws-thread-head .ctx-pill {
    font-family: var(--font-mono); font-size: var(--text-app-2xs);
    background: var(--color-white); border: 1px solid var(--line-2);
    padding: 3px 8px; color: var(--color-purple-01);
  }
  .ws-thread-head .actions { display: flex; gap: 6px; }
  .ws-thread-head .actions button {
    appearance: none; background: var(--color-white);
    border: 1px solid var(--line-2);
    padding: 4px 12px;
    font-family: var(--font-mono); font-size: var(--text-app-2xs);
    letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--color-purple-01); cursor: pointer;
  }
  .ws-thread-head .actions button:hover {
    border-color: var(--color-purple-03); color: var(--color-purple-03);
  }
  .ws-thread-head .actions .ws-to-dock {
    background: var(--color-cyan); color: var(--color-purple-01);
    border-color: var(--color-cyan); font-weight: 700;
  }
  .ws-thread-head .actions .ws-to-dock:hover {
    background: var(--color-cyan); border-color: var(--color-cyan);
    color: var(--color-purple-01);
  }
  .ws-back {
    appearance: none; background: var(--color-white);
    border: 1px solid var(--line-2);
    padding: 4px 12px;
    font-family: var(--font-mono); font-size: var(--text-app-2xs);
    letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--color-purple-01); cursor: pointer;
  }
  .ws-back:hover { border-color: var(--color-purple-03); color: var(--color-purple-03); }
  .ws-chat-host {
    flex: 1;
    display: flex; flex-direction: column;
    min-height: 0; overflow: hidden;
  }
  .ws-chat-host .agent-context-pill { margin: 16px 24px 0; }
  .ws-chat-host .agent-messages {
    padding: 18px 24px; flex: 1; min-height: 0;
  }
  .ws-chat-host .agent-messages .agent-bubble {
    max-width: 760px; font-size: var(--text-app-xl); padding: 14px 16px;
  }
  .ws-chat-host .agent-messages .agent-bubble.user {
    max-width: 480px; font-size: var(--text-app-md); padding: 10px 14px;
  }
  .ws-chat-host .agent-suggestions { padding: 0 24px 12px; }
  .ws-chat-host .agent-form { padding: 14px 24px; border-top: 1px solid var(--line); }
