/* Approved desktop/mobile layout. A shared reading column anchors the toolbar,
   answer and composer. The composer stays in the viewport grid, not over text. */
:root .app-shell { grid-template-columns:400px minmax(0,1fr); }
.main-column { --chat-side-gutter:max(16px,calc((100% - 800px) / 2)); }
.sidebar { padding-inline:16px; }
.chat-list .chat-open { white-space:normal; overflow-wrap:anywhere; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; line-clamp:2; font-size:16px; line-height:1.25; }
/* Half the 44px row and .22rem gap of 156. Longer titles retain two lines. */
.chat-section .chat-list {row-gap:.11rem}
.chat-list .chat-item {min-height:22px; padding:0 12px; align-items:center}
.chat-list .chat-open,.chat-list .chat-actions {min-height:22px}
.chat-list .chat-actions {margin:0; padding-block:0}
.sidebar-footer .settings-button { display:inline-flex; align-items:center; gap:12px; min-height:44px; padding:8px 12px; font-size:16px; }
.settings-button svg { flex-shrink:0; }
.sidebar-build { font-size:10px; opacity:.7; }
.project-list { display:grid; grid-template-columns:minmax(0,1fr); gap:6px; width:min(800px,100%); }
.project-list .project-item { padding:0; border:0; border-radius:12px; background:transparent; box-shadow:none; min-width:0; }
.project-title { display:flex; align-items:center; justify-content:space-between; gap:12px; list-style:none; cursor:pointer; padding:12px 16px; border-radius:12px; font-size:18px; line-height:1.5; }
.project-title::-webkit-details-marker { display:none; }
.project-title > span:first-child { min-width:0; overflow:hidden; overflow-wrap:anywhere; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; line-clamp:2; }
.project-title:hover,.project-item details[open] > .project-title { background:var(--sidebar); }
.project-title:focus-visible { outline:2px solid var(--ink); outline-offset:2px; }
.project-chevron { font-size:24px; flex-shrink:0; }
.project-item details[open] .project-chevron { transform:rotate(90deg); }
.project-body { padding:4px 16px 16px; }
.project-body > .row { flex-wrap:wrap; }
.project-body .stack-item { overflow-wrap:anywhere; display:flex; gap:8px; align-items:center; justify-content:space-between; }
.project-body button,#show-archived-projects { border:1px solid var(--line-strong); border-radius:9px; padding:7px 10px; min-height:36px; color:var(--ink); background:var(--panel); font-size:14px; }
.project-body button:hover,#show-archived-projects:hover { background:var(--sidebar); }
.project-body button:disabled { opacity:.5; cursor:default; }
@media (max-width:600px) {
  #projects-view .page-heading { display:block; }
  #projects-view .page-heading > .row { margin-top:12px; }
  .project-body button,#show-archived-projects { min-height:40px; }
}

:root .app-shell .topbar { position:relative; z-index:40; width:calc(min(800px,100% - 32px) - var(--chat-scrollbar-width,0px)); margin-inline:var(--chat-side-gutter) auto; padding:12px 0; min-height:80px; display:grid; grid-template-columns:minmax(0,1fr); align-items:center; gap:6px; border-bottom:0; }
/* The controls use the whole reading column, including in native mode.
   A protocol name owns a separate row and never reserves an empty column. */
:root .app-shell .chat-identity { display:contents; }
:root .app-shell .protocol-identity { grid-column:1 / -1; grid-row:2; min-width:0; max-width:none; width:100%; margin:0; text-align:left; gap:3px; }
.protocol-caption { font-size:11px; }
.protocol-name { font-size:15px; line-height:1.3; white-space:normal; overflow:hidden; overflow-wrap:anywhere; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; line-clamp:2; }
:root .app-shell .top-controls { grid-column:1; grid-row:1; min-width:0; max-width:none; width:100%; padding:0; display:grid; grid-template-columns:1.12fr 1.12fr .62fr 1.2fr .9fr; gap:8px; align-items:end; overflow:visible; }
:root .app-shell .top-controls > * { min-width:0; max-width:100%; }
:root .app-shell .topbar > .task-calendar { grid-column:1 / -1; grid-row:3; min-width:0; margin:0; font-size:14px; line-height:1.4; color:var(--muted); overflow-wrap:anywhere; }
:root .app-shell .topbar > .task-calendar:empty { display:none; }
:root .app-shell .top-controls label { display:flex; flex-direction:column; align-items:stretch; gap:3px; font-size:11px; min-width:0; }
:root .app-shell .top-controls .control-caption { display:block; min-width:0; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
:root .app-shell .top-controls select { width:100%; min-width:0; max-width:none; height:40px; padding:5px; font-size:12px; }
:root .app-shell .search-depth-control > span { max-width:none; white-space:nowrap; }
:root .app-shell #activity-toggle { height:40px; min-width:0; padding:6px 8px; background:var(--panel); color:var(--ink); border:1px solid var(--line-strong); font-size:13px; }
:root .app-shell #activity-toggle:hover { background:var(--sidebar); }
:root .app-shell #activity-toggle[aria-pressed="true"] { border-color:var(--ink); }

:root .app-shell .main-column { grid-template-rows:auto minmax(0,1fr); }
:root .app-shell #chat-view.active-view { height:100%; min-height:0; grid-template-columns:minmax(0,1fr); grid-template-rows:minmax(0,1fr) auto; }
.chat-footer { grid-row:2; min-width:0; display:flex; flex-direction:column; background:var(--panel); }
#chat-scroll160,#empty-chat { grid-area:1 / 1; }
#response-form-controls { grid-row:2; }
#inline-activity { grid-row:3; }
#composer { grid-row:4; }
.messages { padding:16px var(--chat-side-gutter) 12px; }
.messages::before { display:none; }
.message.user .message-body { width:100%; max-width:100%; }
.inline-activity,.response-form-controls { width:min(800px,calc(100% - 32px)); margin-inline:auto; }
.inline-activity { margin-bottom:8px; }
.composer-keyboard-hint { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; border:0; }
.answer-actions { gap:16px; margin-top:18px; }
.answer-action { min-height:40px; font-size:15px; }
.answer-branch { gap:10px; text-align:left; }

/* One visible text line and one action row: 94px at desktop, about 30% lower
   than the preceding 134px card. Content and touch controls may expand it. */
:root .app-shell .composer { container:composer / inline-size; width:min(800px,calc(100% - 32px)); margin:0 auto max(8px,env(safe-area-inset-bottom)); padding:8px 12px; border-radius:22px; border-color:var(--line-strong); box-shadow:none; }
:root .app-shell .composer #message-input { width:100%; height:32px; min-height:32px; max-height:min(30dvh,180px); padding:0 4px; font-size:20px; line-height:30px; }
:root .app-shell .composer-actions { display:grid; grid-template-columns:44px minmax(0,1fr) auto; gap:6px; align-items:center; min-height:44px; padding-top:4px; border:0; }
:root .app-shell .composer-left { min-width:0; position:relative; justify-self:start; }
:root .app-shell #request-state:empty { display:none; }
:root .app-shell #request-state:not(:empty) { font-size:12px; line-height:1.4; padding:0 4px 4px; overflow-wrap:anywhere; }
:root .app-shell .composer-center { display:flex; align-items:center; justify-content:center; gap:8px; width:auto; max-width:none; min-width:0; justify-self:stretch; }
:root .app-shell .continue-task-control { padding:2px 4px; min-height:40px; gap:6px; white-space:nowrap; font-size:13px; }
:root .app-shell #internet-toggle { flex-shrink:0; min-height:36px; padding:6px 8px; font-size:12px; }
:root .app-shell .composer-right { display:flex; gap:4px; justify-self:end; }
:root .app-shell .composer .model-picker { position:relative; right:auto; bottom:auto; }
:root .app-shell .composer #model-picker-toggle { padding:6px 8px; min-height:40px; font-size:13px; white-space:nowrap; }
:root .app-shell .composer .attach-button { width:40px; height:40px; min-height:40px; padding:0; }
:root .app-shell .microphone-button,:root .app-shell .send-button,:root .app-shell #stop-execution { width:40px; height:40px; min-width:40px; min-height:40px; }
:root .app-shell .send-button { background:#3881f7; color:#fff; }
:root .app-shell :is(.send-button,#stop-execution) svg { width:24px; height:24px; display:block; pointer-events:none; }
.composer #batch-note { max-height:60px; overflow:auto; margin-bottom:6px; font-size:12px; line-height:1.35; }
.composer #selected-file-strip:not(:empty) { max-height:90px; overflow:auto; margin-bottom:6px; }
.composer #upload-status:empty { display:none; }

@container composer (max-width:700px) {
  :root .app-shell .composer-actions { grid-template-columns:40px minmax(0,1fr); row-gap:2px; }
  :root .app-shell .composer-center { grid-column:2; grid-row:1; justify-content:flex-end; gap:6px; }
  :root .app-shell .composer-right { grid-column:1 / -1; grid-row:2; }
  :root .app-shell .continue-task-control { font-size:12px; min-height:36px; }
  :root .app-shell #internet-toggle { font-size:12px; min-height:36px; padding:4px 6px; }
}
@container composer (max-width:360px) {
  :root .app-shell .composer-actions { column-gap:2px; }
  :root .app-shell .composer-center { gap:2px; }
  :root .app-shell .continue-task-control { gap:4px; padding-inline:2px; font-size:11px; }
  :root .app-shell #internet-toggle { padding-inline:4px; font-size:11px; }
}

@media (min-width:821px) and (max-width:1180px) and (min-height:601px) {
  :root .app-shell { grid-template-columns:320px minmax(0,1fr); }
}

/* The same controls remain visible in both phone orientations. The Internet
   setting is deliberately part of the composer, never duplicated in header. */
@media (max-width:820px), (max-width:1100px) and (max-height:600px) {
  :root .app-shell { grid-template-columns:minmax(0,1fr); }
  :root .app-shell .sidebar { width:min(400px,calc(100vw - 44px)); }
  .main-column { --chat-side-gutter:max(8px,calc((100% - 800px) / 2)); }
  :root .app-shell .topbar { width:calc(min(800px,100% - 16px) - var(--chat-scrollbar-width,0px)); display:grid; grid-template-columns:28px minmax(0,1fr); gap:4px; padding:6px 0; min-height:0; align-items:end; }
  :root .app-shell .chat-identity,:root .app-shell .chat-identity:has(.protocol-identity.hidden) { display:contents; }
  :root .app-shell #mobile-menu { grid-column:1; grid-row:1; }
  :root .app-shell #mobile-menu { width:28px; min-width:28px; height:36px; min-height:36px; padding:0; justify-self:start; }
  :root .app-shell .protocol-identity { grid-column:1 / -1; grid-row:2; text-align:left; width:100%; max-width:none; }
  :root .app-shell .top-controls { grid-column:2; grid-row:1; grid-template-columns:var(--header-fit-columns,minmax(32px,.8fr) minmax(66px,1.3fr) minmax(49px,.8fr) minmax(46px,1fr) max-content); gap:4px; width:100%; text-size-adjust:100%; -webkit-text-size-adjust:100%; }
  :root .app-shell .top-controls > .uploads-control { grid-column:auto; }
  :root .app-shell .top-controls label { font-size:10px; gap:2px; }
  :root .app-shell .top-controls .control-caption { font-size:var(--header-fit-size,10px); }
  :root .app-shell .top-controls select { height:36px; padding:3px 13px 3px 2px; font-size:var(--header-fit-size,11px); appearance:none; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='m3 4.5 3 3 3-3' fill='none' stroke='%23707788' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-size:10px 10px; background-position:right 2px center; }
  :root .app-shell .top-controls select option { font-size:14px; }
  :root .app-shell .top-controls #activity-toggle { height:36px; padding:3px 1px; font-size:var(--header-fit-size,11px); white-space:nowrap; }
  :root .app-shell .top-controls .search-depth-control > span { font-size:0; }
  :root .app-shell .search-depth-control > span::after { content:'Глубина'; font-size:var(--header-fit-size,10px); }
  .message .message-content,.message .answer-tail160,.message.user .message-body,.message-content .response-neutral,
  .message-content .response,.live-output-text,.inline-activity,.inline-activity-current.is-thinking { font-size:16px; line-height:1.5; }
  /* Two 29px rows, 5px padding and a 2px border: 65px at rest. Additional
     files/status/voice content owns separate rows and is never clipped. */
  :root .app-shell .composer { width:min(800px,calc(100% - 16px)); display:flex; flex-direction:column; gap:0; padding:2px 8px 3px; margin-bottom:0; border-radius:18px; text-size-adjust:100%; -webkit-text-size-adjust:100%; }
  :root .app-shell .composer > * { flex-shrink:0; }
  :root .app-shell .composer #selected-file-strip:empty { display:none; }
  :root .app-shell .composer #voice-chat-feedback { order:1; }
  :root .app-shell .composer #voice-chat-feedback:has(> .hidden) { display:none; }
  :root .app-shell .composer #message-input { order:2; height:29px; min-height:29px; padding:2px 4px; font-size:16px; line-height:24px; }
  :root .app-shell .composer-actions { order:3; display:flex; flex-wrap:nowrap; align-items:center; justify-content:flex-end; gap:2px; min-height:29px; margin-top:auto; padding:0; }
  :root .app-shell .composer-actions > .composer-left { flex:0 0 29px; }
  :root .app-shell .composer-center,:root .app-shell .composer-right { display:contents; }
  :root .app-shell .composer .model-picker { flex:0 0 auto; min-width:0; max-width:150px; margin-left:auto; }
  :root .app-shell .composer #model-picker-toggle { width:100%; overflow:hidden; text-overflow:ellipsis; }
  :root .app-shell .continue-task-control { flex:0 0 auto; min-height:29px; height:29px; padding:0 2px; gap:4px; font-size:12px; line-height:18px; }
  :root .app-shell .continue-task-control > span { font-size:inherit; }
  :root .app-shell .continue-task-control > span::after { content:none; }
  :root .app-shell #internet-toggle { display:flex; align-items:center; justify-content:center; gap:0; min-height:29px; height:29px; width:52px; padding:2px 4px; line-height:0; }
  :root .app-shell #internet-toggle { font-size:0; }
  :root .app-shell #internet-toggle::after { content:'Интернет\A' attr(data-mode); white-space:pre; display:block; font-size:9px; line-height:11px; }
  :root .app-shell .composer #model-picker-toggle { min-height:29px; height:29px; padding:2px 4px; font-size:12px; line-height:18px; }
  :root .app-shell #model-picker-label { font-size:0; }
  :root .app-shell #model-picker-label::after { content:attr(data-model-name); font-size:12px; }
  :root .app-shell .composer .attach-button { width:29px; height:29px; min-height:29px; line-height:29px; font-size:26px; }
  :root .app-shell .microphone-button,:root .app-shell .send-button,:root .app-shell #stop-execution { width:29px; height:29px; min-width:29px; min-height:29px; padding:0; }
  :root .app-shell .microphone-button svg { width:20px; height:20px; }
  :root .app-shell :is(.send-button,#stop-execution) svg { width:19px; height:19px; }
  :root .app-shell #chat-view.active-view { padding-bottom:var(--chat-footer-height,150px); grid-template-rows:minmax(0,1fr); }
  :root .app-shell #chat-view.active-view .chat-footer { position:fixed; left:0; right:0; bottom:var(--app-bottom,0px); z-index:30; max-height:max(100px,calc(var(--app-height,100dvh) - var(--topbar-height,80px) - 44px)); overflow-y:auto; overscroll-behavior:contain; }
  :root .app-shell .chat-footer > * { flex-shrink:0; }
  /* The OS inset belongs outside the card. Keep its action row against the
     card's lower edge, including when content or browser sizing adds height. */
  :root .app-shell .chat-footer { padding-bottom:var(--mobile-safe-bottom,env(safe-area-inset-bottom,0px)); }
  .inline-activity,.response-form-controls { width:min(800px,calc(100% - 16px)); }
  :root .app-shell .composer .voice-controls { position:static; }
  .answer-actions { gap:10px; }
  .answer-branch { font-size:14px; }
}
@media (min-width:740px) and (max-width:820px), (min-width:740px) and (max-width:1100px) and (max-height:600px) {
  :root .app-shell .top-controls { grid-template-columns:var(--header-fit-columns,1.1fr 1.1fr .65fr 1.2fr .9fr); }
  :root .app-shell .top-controls > .uploads-control { grid-column:auto; }
}
@media (max-width:360px) {
  :root .app-shell .continue-task-control { font-size:11px; gap:4px; padding-inline:0; }
  :root .app-shell .composer-actions { gap:1px; }
  :root .app-shell #internet-toggle { width:48px; padding-inline:2px; }
  :root .app-shell .composer #model-picker-toggle { padding-inline:1px; font-size:11px; }
  :root .app-shell #model-picker-label::after { font-size:11px; }
}
/* The full label stays visible even at 315 CSS px. Only its two words wrap
   inside the existing 29px control; the action row and the card do not grow. */
@media (max-width:399px) {
  :root .app-shell .continue-task-control > span { width:min-content; white-space:normal; overflow-wrap:normal; word-break:normal; line-height:13px; }
}

/* Build 43: public actions and explanations follow the chat text width. */
.work-action{display:flex;align-items:flex-start;gap:10px;margin:12px 0;color:var(--muted);font-size:14px;line-height:1.5;font-weight:400;overflow-wrap:anywhere;}
.work-action svg{width:18px;height:18px;flex:0 0 18px;margin-top:2px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;}
.work-action-title,.work-action-detail{display:block;}
.work-action-detail{font-size:inherit;opacity:.9;margin-top:2px;}
.work-note{font-family:var(--chat-font);font-size:20px;line-height:1.5;font-weight:400;margin:18px 0;overflow-wrap:anywhere;}
.work-history>summary{cursor:pointer;color:var(--muted);font-size:14px;margin:14px 0;}
.work-progress-history{margin-bottom:24px;}
.work-progress-history .work-note{font-size:14px;}
.work-progress-history h3{font-size:15px;font-weight:500;}
.inline-activity-current:empty{display:none;}
@media (max-width:820px), (max-width:1100px) and (max-height:600px){.work-note{font-size:16px;}.work-action{font-size:13px;gap:8px;}.work-history>summary{font-size:13px;}}

/* Header controls are bold on every screen. Composer controls are bold
   only in the existing phone portrait/landscape layout. */
:root .app-shell .top-controls :is(select,#activity-toggle,.depth-display176) { font-weight:700; color:var(--muted); }
:root .app-shell .top-controls select option { font-weight:inherit; }
@media (max-width:820px), (max-width:1100px) and (max-height:600px) {
  :root .app-shell .composer-actions :is(button,.continue-task-control) { font-weight:700; }
}

/* Build 51: desktop geometry follows the former 80% browser view, with the
   shared answer/header/composer column widened a further 25% (800 -> 1000).
   Typography
   is independent: 20 * .8 = 16px body, 17.5 * .8 = 14px controls. Touch and
   the existing phone portrait/landscape layouts do not enter this block. */
@supports (zoom:1) {
  @media screen and (hover:hover) and (pointer:fine) and (min-width:821px) and (min-height:601px),
         screen and (hover:hover) and (pointer:fine) and (min-width:1101px) {
    :root { --desktop-ui-scale:.8; zoom:var(--desktop-ui-scale); }
    :root .app-shell { height:var(--app-height,100%); }
    :root .app-shell .main-column { --desktop-chat-width:1000px; --chat-side-gutter:max(16px,calc((100% - var(--desktop-chat-width)) / 2)); }
    :root .app-shell .topbar { width:calc(min(var(--desktop-chat-width),100% - 32px) - var(--chat-scrollbar-width,0px)); }
    :root .app-shell .top-controls label { font-size:15px; }
    :root .app-shell .top-controls { grid-template-columns:var(--desktop-header-columns,1.12fr 1.12fr .62fr 1.2fr .9fr); }
    :root .app-shell .top-controls.desktop-header-wrapped { grid-template-columns:repeat(3,minmax(0,1fr)); row-gap:10px; }
    :root .app-shell .desktop-header-wrapped > .uploads-control { grid-column:1 / 3; }
    :root .app-shell .desktop-header-wrapped #activity-toggle { grid-column:3; }
    :root .app-shell .top-controls select,
    :root .app-shell .top-controls #activity-toggle { font-size:17.5px; }
    :root .app-shell .top-controls select {
      padding-left:5px; padding-right:18px; appearance:none;
      background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='m3 4.5 3 3 3-3' fill='none' stroke='%236b7484' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
      background-repeat:no-repeat; background-size:12px 12px; background-position:right 3px center;
    }
    :root .app-shell .section-nav .sidebar-shortcut,
    :root .app-shell .chat-list .chat-open,
    :root .app-shell .sidebar-footer .settings-button,
    :root .app-shell .sidebar .section-caption,
    :root .app-shell .sidebar .search-box input { font-size:17.5px; }

    /* Use the very same edges as the answer and header, including a classic
       scrollbar. Automatic centering used to shift/widen the bottom card. */
    :root .app-shell .chat-footer > :is(.composer,.inline-activity,.response-form-controls) {
      width:calc(min(var(--desktop-chat-width),100% - 32px) - var(--chat-scrollbar-width,0px));
      margin-left:var(--chat-side-gutter); margin-right:auto;
    }
    :root .app-shell .composer-center { justify-content:center; align-items:center; gap:12.5px; }
    :root .app-shell .continue-task-control,
    :root .app-shell #internet-toggle {
      display:inline-flex; align-items:center; justify-content:center;
      height:40px; min-height:40px; padding:5px 7.5px;
      font-size:17.5px; line-height:25px; white-space:nowrap;
    }
    :root .app-shell .continue-task-control { gap:7.5px; }
    :root .app-shell .continue-task-control > span { font-size:inherit; }
    :root .app-shell .composer #model-picker-toggle { font-size:17.5px; line-height:25px; }
  }
  /* At 80% page zoom the former 1180px compact-sidebar threshold is 944px.
     Preserve that geometry on resized desktop windows as well. */
  @media screen and (hover:hover) and (pointer:fine) and (min-width:945px) and (min-height:601px),
         screen and (hover:hover) and (pointer:fine) and (min-width:1101px) {
    :root .app-shell { grid-template-columns:400px minmax(0,1fr); }
  }
}

/* Build 122: menu body text shares the navigation font on desktop and phones.
   Titles, code editors, semantic link/error colours and disabled states retain
   their own roles; this does not scale the application or the input card. */
:root { --menu-body-size:16px; }
@media (max-height:660px) { :root { --menu-body-size:15px; } }
@media screen and (hover:hover) and (pointer:fine) and (min-width:821px) and (min-height:601px),
       screen and (hover:hover) and (pointer:fine) and (min-width:1101px) {
  :root { --menu-body-size:17.5px; }
}
:root .app-shell :is(.view:not(#chat-view),.model-picker-panel,.attach-menu,.chat-menu),
:root dialog { font-size:var(--menu-body-size); }
:root .app-shell .view:not(#chat-view) :is(p,label,small,.help,.card-meta,.toolbar,.file-name span,.key-values,.stack-item,.setting-row,.settings-nav button,.file-actions button,.file-actions a,.project-body button,#show-archived-projects),
:root .app-shell :is(.model-picker-panel,.attach-menu,.chat-menu) :is(label,small,.help,select,input,button),
:root dialog :is(p,label,small,.help,input,select,button) {
  font-size:var(--menu-body-size); line-height:1.4;
}
:root .app-shell .view:not(#chat-view) :is(p,label,small,.help,.card-meta,.toolbar,.file-name span,.key-values),
:root .app-shell :is(.model-picker-panel,.attach-menu) :is(label,small,.help),
:root dialog :is(label,small,.help) { color:var(--ink); }
:root .app-shell .view:not(#chat-view) :is(.help,.page-heading p) { font-weight:400; }
.view:not(#chat-view) .card-grid > p.help { grid-column:1 / -1; max-width:760px; }
/* Match the enlarged labels without squeezing the phone's form fields. */
@media (max-width:600px) {
  .view:not(#chat-view) .page-heading { flex-wrap:wrap; }
  .view:not(#chat-view) .setting-row { flex-wrap:wrap; gap:10px; }
  .view:not(#chat-view) .setting-row > span { flex:1 1 100%; }
  .view:not(#chat-view) .setting-row > :is(select,input) { max-width:100%; width:100%; }
  .view:not(#chat-view) .form-grid { grid-template-columns:minmax(0,1fr); }
}
@media screen and (hover:hover) and (pointer:fine) and (min-width:821px) and (min-height:601px),
       screen and (hover:hover) and (pointer:fine) and (min-width:1101px) {
  :root .app-shell .continue-task-control { color:var(--ink); font-weight:400; }
  :root .app-shell .continue-task-control:has(input:checked) { background:transparent; }
  :root .app-shell .continue-task-control:has(input:disabled) { opacity:1; }
  :root .app-shell .continue-task-control input {
    appearance:none; display:grid; place-content:center; border:1.5px solid var(--ink);
    border-radius:3px; background:var(--panel); color:var(--ink); opacity:1;
  }
  :root .app-shell .continue-task-control input:checked::after {
    content:""; width:8px; height:5px; border-left:2px solid currentColor;
    border-bottom:2px solid currentColor; transform:rotate(-45deg) translateY(-1px);
  }
  /* Build 123: spacing follows the approved second mockup, not fractions of
     the old centred layout. Sizes and mobile placement stay independent. */
  :root .app-shell .composer-actions {
    --composer-plus-gap:8px;
    --composer-model-gap:12px;
    --composer-control-gap:16px;
    --composer-stop-space:24px;
  }
  :root .app-shell .desktop-composer-spaced {
    grid-template-columns:40px var(--composer-plus-gap) max-content minmax(8px,1fr) max-content var(--composer-model-gap) max-content;
    column-gap:0;
  }
  :root .app-shell .desktop-composer-spaced .composer-center { display:contents; }
  :root .app-shell .desktop-composer-spaced .composer-left { grid-column:1; grid-row:1; }
  :root .app-shell .desktop-composer-spaced .continue-task-control { grid-column:3; grid-row:1; }
  :root .app-shell .desktop-composer-spaced #internet-toggle { grid-column:5; grid-row:1; }
  :root .app-shell .desktop-composer-spaced .composer-right { grid-column:7; grid-row:1; gap:var(--composer-control-gap); }
  :root .app-shell .desktop-composer-spaced #stop-execution { margin-right:var(--composer-stop-space); }
  :root .app-shell .desktop-composer-wrapped { grid-template-columns:40px minmax(0,1fr); row-gap:2px; }
  :root .app-shell .desktop-composer-wrapped .composer-center { grid-column:2; grid-row:1; justify-content:flex-end; gap:6px; }
  :root .app-shell .desktop-composer-wrapped .composer-right { grid-column:1 / -1; grid-row:2; }
}


/* The first cell is always reserved for the protocol identity, even in native mode. */
:root .app-shell .top-controls { grid-template-columns:var(--fit-columns-154,1.2fr 1fr 1.45fr .75fr 1.15fr 1fr); }
:root .app-shell .top-controls .protocol-identity { grid-column:1; grid-row:1; align-self:end; justify-content:center; height:40px; margin:0; }
:root .app-shell .top-controls .protocol-name { white-space:normal; overflow-wrap:anywhere; }
:root .app-shell .topbar > .task-calendar { grid-row:2; }
:root .app-shell .top-controls.desktop-header-wrapped { grid-template-columns:repeat(3,minmax(0,1fr)); }
:root .app-shell .desktop-header-wrapped > .uploads-control, :root .app-shell .desktop-header-wrapped #activity-toggle { grid-column:auto; }
@media (max-width:820px), (max-width:1100px) and (max-height:600px) {
  :root .app-shell .topbar { width:calc(100% - max(4px,env(safe-area-inset-left)) - max(4px,env(safe-area-inset-right))); margin-inline:max(4px,env(safe-area-inset-left)) 0; grid-template-columns:20px minmax(0,1fr); gap:2px; }
  :root .app-shell #mobile-menu { width:20px; min-width:20px; }
  :root .app-shell .top-controls { gap:2px; }
  :root .app-shell .top-controls .protocol-identity { height:36px; }
  :root .app-shell .top-controls .protocol-name { font-size:8.5px; line-height:1.05; -webkit-line-clamp:4; line-clamp:4; }
  :root .app-shell .top-controls select { padding:3px 10px 3px 2px; background-size:7px; background-position:right 1px center; }
  :root .app-shell .top-controls select, :root .app-shell .top-controls #activity-toggle { font-size:var(--fit-controls-154,10px); white-space:nowrap; }
  :root .app-shell .top-controls .control-caption { font-size:var(--fit-caption-154,9px); }
  :root .app-shell .top-controls .search-depth-control > span { font-size:0; }
  :root .app-shell .search-depth-control > span::after { font-size:var(--fit-caption-154,9px); }
}
@media(max-width:360px) {
  :root .app-shell .top-controls {gap:1px;}
  :root .app-shell .top-controls select {padding-inline:1px 8px;}
  :root .app-shell .top-controls .protocol-name {font-size:8px;}
}

/*155. Sidebar area and reading column share one measured rail, including root zoom. */
:root .app-shell { --canvas155:#fcfcfc; --navrail155:#f9f9f9; --sidebar155:260px; --rail155:39px; --leading155:117px; --column155:min(1080px,100%); }
@media(prefers-color-scheme:dark){:root .app-shell{--canvas155:var(--panel);--navrail155:var(--sidebar);}}
:root .app-shell .sidebar { display:grid; grid-template-columns:var(--rail155) minmax(0,1fr); grid-template-rows:minmax(0,1fr); gap:0; padding:0; overflow:hidden; background:var(--canvas155); }
:root .app-shell .nav-rail155 { display:flex; align-items:flex-end; justify-content:center; padding-bottom:max(8px,env(safe-area-inset-bottom)); background:var(--navrail155); }
:root .app-shell .nav-rail155 .settings-button { display:grid; place-items:center; width:100%; min-width:0; min-height:42px; margin:0; padding:3px; border:0; background:transparent; color:var(--ink); }
:root .app-shell .nav-body155 { display:grid; grid-template-rows:auto auto auto minmax(0,1fr) auto; gap:8px; min-width:0; min-height:0; overflow-y:auto; padding:12px 8px 6px; background:var(--canvas155); border-left:1px solid var(--line); }
:root .app-shell .nav-body155 .brand, :root .app-shell .nav-body155 .section-nav, :root .app-shell .nav-body155 .sidebar-heading, :root .app-shell .nav-body155 .chat-section, :root .app-shell .nav-body155 .section-caption { background:transparent; }
:root .app-shell .nav-body155 .sidebar-shortcut, :root .app-shell .nav-body155 .chat-item, :root .app-shell .nav-body155 .chat-open { min-width:0; background:transparent; box-shadow:none; }
:root .app-shell .nav-body155 .sidebar-shortcut:hover, :root .app-shell .nav-body155 .chat-open:hover { text-decoration:underline; }
:root .app-shell .nav-body155 .chat-open { font-weight:400; }
:root .app-shell #chat-list-heading { margin:0; padding:0; border:0; background:transparent; font:inherit; font-weight:400; }
:root .app-shell .nav-body155 .shortcut-label { display:inline; }
:root .app-shell .nav-body155 .sidebar-shortcut { justify-content:flex-start; width:100%; }
:root .app-shell .nav-body155 .chat-list { min-height:0; }
:root .app-shell .nav-body155 .sidebar-footer { display:block; margin:0; padding:0 6px; }
:root .app-shell .nav-body155 .sidebar-build { display:block; }
:root .app-shell .nav-body155 .chat-item { grid-template-columns:minmax(0,1fr) auto; }
:root .app-shell .main-column, :root .app-shell #chat-view, :root .app-shell .topbar, :root .app-shell #messages, :root .app-shell .chat-footer { background:var(--canvas155); }
:root .app-shell .message.user .message-body { background:transparent; padding-inline:0; }
:root .app-shell .top-controls { position:relative; }
:root .app-shell .top-controls .task-calendar { grid-column:2 / -1; grid-row:2; margin:4px 0 0; min-width:0; color:var(--muted); font-size:13px; overflow-wrap:anywhere; }
:root .app-shell .top-controls .task-calendar:empty { display:none; }
:root .app-shell .top-controls.compact155 select, :root .app-shell .top-controls.compact155 #activity-toggle { font-size:var(--fit-controls-154,11px); }
:root .app-shell[data-nav155="wide"] { grid-template-columns:var(--sidebar155) minmax(0,1fr); }
:root .app-shell[data-nav155="wide"] .sidebar { position:relative; inset:auto; transform:none; width:100%; height:100%; box-shadow:none; z-index:auto; }
:root .app-shell[data-nav155="wide"] :is(#mobile-menu,#mobile-menu-close,.sidebar-backdrop) { display:none; }
:root .app-shell[data-nav155="wide"] {
  --chat-pane-width:calc(var(--column155) + 2 * var(--leading155) + var(--chat-scrollbar-width,0px));
  /* Startup fallback; viewport.js supplies screen-centred measured values. */
  --reading-width:calc((var(--chat-pane-width) + var(--sidebar155)) * .515625);
  --reading-inset:max(24px,calc((var(--chat-pane-width) - var(--reading-width) - var(--sidebar155)) / 2));
}
:root .app-shell[data-nav155="wide"] .main-column { --chat-side-gutter:var(--reading-inset); }
:root .app-shell[data-nav155="wide"] .topbar {
  grid-template-columns:minmax(0,1fr); width:var(--reading-width); padding-inline:0; margin-inline:var(--reading-inset) 0;
}
:root .app-shell[data-nav155="wide"] .top-controls { grid-area:1 / 1; grid-template-columns:var(--fit-columns-154,repeat(5,minmax(0,1fr))); }
:root .app-shell[data-nav155="wide"] .top-controls .task-calendar { grid-column:1 / -1; }
:root .app-shell[data-nav155="wide"] .top-controls .protocol-identity {
  position:absolute; grid-column:1 / -1; grid-row:1 / 2; inset-inline-end:calc(100% + 8px); inset-block-end:0;
  width:calc(var(--leading155) - 16px); min-width:0; max-width:none; text-align:left; margin:0;
}
:root .app-shell[data-nav155="wide"] .top-controls .protocol-name { display:block; overflow-wrap:anywhere; white-space:normal; }
:root .app-shell[data-nav155="wide"] #messages { padding-inline:0; align-items:flex-start; }
:root .app-shell[data-nav155="wide"] #messages > .message,
:root .app-shell[data-nav155="wide"] .chat-footer > :is(.composer,.response-form-controls),
:root .app-shell[data-nav155="wide"] #chat-scroll160 > #inline-activity {
  width:var(--reading-width); max-width:none; margin-inline:var(--reading-inset) 0;
}
:root .app-shell[data-nav155="drawer"] .sidebar { width:var(--sidebar155); }
:root .app-shell[data-nav155="drawer"] .chat-footer > :is(.composer,.inline-activity,.response-form-controls) { width:var(--column155); max-width:none; margin-inline:var(--leading155) 0; }
:root .app-shell[data-nav155="drawer"] #messages { padding-inline:var(--leading155); }
@media(max-height:570px){:root .app-shell .nav-body155{grid-template-rows:auto auto auto minmax(90px,1fr) auto;}}
:root .app-shell[data-nav155="wide"] .sidebar { transition:none; }
:root .app-shell[data-nav155="wide"] #chat-view.active-view { padding-bottom:0; grid-template-rows:minmax(0,1fr) auto; }
:root .app-shell[data-nav155="wide"] #chat-view.active-view .chat-footer { position:static; max-height:none; overflow:visible; padding:0; }
:root .app-shell[data-nav155="wide"] .top-controls { min-width:0; justify-content:start; padding:0; }
:root .app-shell[data-nav155="wide"] .top-controls .protocol-identity { align-self:end; justify-content:center; }
:root .app-shell[data-nav155="wide"] .top-controls.compact155 label, :root .app-shell[data-nav155="wide"] .top-controls.compact155 .control-caption { font-size:var(--fit-caption-154,10px); }

/* Release 156, the same navigation switch stays reachable above the drawer. */
.mobile-switch156 {display:none}
:root .app-shell[data-nav155="drawer"] {--leading155:11px;--column155:calc(100% - 22px);--sidebar155:min(320px,calc(100vw - 30px));position:fixed;top:var(--app-top,0px);inset-inline:0;height:var(--app-height,100dvh);grid-template-rows:minmax(0,1fr);overflow:hidden;isolation:isolate}
:root .app-shell[data-nav155="drawer"] .mobile-switch156 {position:absolute;z-index:85;top:0;inset-inline:0;display:flex;align-items:center;height:28px;background:var(--canvas155);border-bottom:1px solid var(--line)}
:root .app-shell[data-nav155="drawer"] .mobile-switch156 #mobile-menu {position:relative;display:flex;align-items:center;gap:10px;justify-content:flex-start;width:100%;height:100%;min-height:0;max-height:none;border:0;border-radius:0;padding:0 12px;font:700 15px/1.2 var(--chat-font,system-ui);background:transparent;color:var(--ink);box-shadow:none;transform:none}
:root .app-shell .mobile-switch156 #mobile-menu svg {width:18px;height:18px;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;fill:none}
:root .app-shell[data-nav155="drawer"] .main-column {--switch-height:28px;padding-top:var(--switch-height)}
:root .app-shell[data-nav155="drawer"] .sidebar,
:root .app-shell[data-nav155="drawer"] .sidebar.open + .sidebar-backdrop {position:absolute;top:28px;bottom:0;height:auto;min-height:0}
:root .app-shell[data-nav155="drawer"] .nav-body155 {
  grid-template-columns:minmax(0,1fr);
  padding-top:16px;
}
:root .app-shell[data-nav155="drawer"] .nav-body155 .shortcut-label {white-space:normal;overflow-wrap:anywhere}
:root .app-shell[data-nav155="drawer"] .search-box input {min-width:0}
@media(max-width:360px) {
  :root .app-shell[data-nav155="drawer"] .nav-body155 .brand {padding-inline:4px 0}
  :root .app-shell[data-nav155="drawer"] .nav-body155 .sidebar-shortcut {gap:6px;padding-inline:4px 0}
}
:root .app-shell[data-nav155="drawer"] .topbar {display:block;margin:0 var(--leading155);padding:0;width:var(--column155);min-height:0}
:root .app-shell[data-nav155="drawer"] .top-controls {display:grid;grid-template-columns:var(--fit-columns-154,repeat(5,minmax(0,1fr)));grid-template-rows:auto auto auto;align-items:end;gap:1px 2px;min-width:0;padding:0}
:root .app-shell[data-nav155="drawer"] .top-controls > .protocol-identity {position:static;grid-column:1/-1;grid-row:1;height:auto;min-height:0;max-width:100%;width:auto;margin:0;pointer-events:none}
:root .app-shell[data-nav155="drawer"] .protocol-name {display:block;font-size:11px;line-height:1.15;-webkit-line-clamp:unset;line-clamp:unset;overflow-wrap:anywhere}
:root .app-shell[data-nav155="drawer"] .protocol-identity:has(.protocol-name:empty) {display:none}
:root .app-shell[data-nav155="drawer"] .top-controls > :is(label,.uploads-control) {grid-column:auto;grid-row:2;min-width:0;margin:0;width:100%}
:root .app-shell[data-nav155="drawer"] .top-controls > .test-field156 {grid-column:5;grid-row:2;min-width:0;margin:0}
:root .app-shell[data-nav155="drawer"] .test-field156 > label {display:none}
:root .app-shell[data-nav155="drawer"] .top-controls .task-calendar {grid-column:1/-1;grid-row:3;margin:2px 0 4px;font-size:clamp(12px,3.3vw,13px)}
:root .app-shell[data-nav155="drawer"] .top-controls label > .control-caption {display:none}
:root .app-shell[data-nav155="drawer"] .top-controls :is(select,#activity-toggle){height:auto;min-height:29px;padding:2px 1px;white-space:normal}
:root .app-shell[data-nav155="drawer"] .top-controls select {appearance:none;background-image:none;text-align:center}
:root .app-shell[data-nav155="wide"] .top-controls .protocol-identity {width:var(--leading155);inset-inline-end:100%;padding:0 5px}
:root .app-shell .sidebar-build {display:block;white-space:nowrap;line-height:1.3;font-size:12px;color:var(--muted);opacity:1}
:root .app-shell .nav-body155 .sidebar-footer {min-height:38px;display:flex;align-items:center}
:root .app-shell .test-field156 {position:relative;min-width:0;align-self:end;display:grid;gap:2px}
:root .app-shell .test-field156>label {font-weight:400;color:var(--muted);margin:0}
:root .app-shell .test-field156 #activity-toggle {width:100%;min-width:0;line-height:1.16}
#test-modes156 {position:absolute;top:100%;right:0;z-index:60;width:max-content;max-width:min(260px,88vw);background:var(--panel);border:1px solid var(--line-strong);border-radius:8px;padding:4px;box-shadow:var(--shadow)}
:root .app-shell #test-modes156 button {display:block;width:100%;text-align:left;white-space:normal;padding:8px;border:0;background:transparent;color:var(--ink);font-size:13px;font-weight:400}
:root .app-shell #test-modes156 button:is(:hover,:focus-visible) {background:var(--sidebar)}
:root .app-shell :is(#activity-drawer,#sources-drawer,#replay-drawer) {position:fixed;z-index:62;inset:auto;top:var(--report-top156,70px);left:var(--report-left156,50%);width:var(--report-width156,48%);height:auto;max-height:var(--report-height156,70dvh);min-width:0;overflow:auto;overflow-wrap:anywhere;background:var(--panel);border:1px solid var(--line-strong);border-radius:10px;padding:10px;box-shadow:var(--shadow)}
:root .app-shell .activity-drawer header {display:flex;gap:4px;align-items:flex-start;justify-content:space-between}
:root .app-shell #replay-drawer {left:auto;right:12px;width:min(520px,calc(100vw - 24px))}
:root .app-shell .activity-drawer h2 {min-width:0;font-size:16px}
:root .app-shell .activity-drawer :is(.activity-actions,dl) {min-width:0;flex-wrap:wrap}
:root .app-shell .activity-drawer :is(dd,textarea,button) {min-width:0;max-width:100%;white-space:normal;overflow-wrap:anywhere}
:root .app-shell #sources-drawer .answer-sources {display:block;margin:0;border:0;padding:0}
:root .app-shell .source-copy,.activity-actions {position:sticky;top:0;z-index:1;background:var(--panel)}
:root .app-shell .message.user .message-body {box-sizing:border-box;align-self:flex-end;width:66.666667%;max-width:66.666667%;background:#e9f3fd;color:#102b4d;border-radius:18px;padding:10px 14px;white-space:pre-wrap;overflow-wrap:anywhere}
:root .app-shell .message.user .user-actions {align-self:flex-end}
@media(prefers-color-scheme:dark){:root .app-shell .message.user .message-body{background:#233a53;color:#e6f1ff}}
:root .app-shell .answer-tail160 .answer-actions {order:initial;justify-content:flex-start;border:0;margin:4px 0 9px;padding:0}
.answer-mode156 {color:var(--muted);font-size:.88em;margin-top:10px}
:root .app-shell #inline-activity:not(.hidden) {margin-bottom:8px;background:transparent}
.visible-work156 {min-width:0}
.visible-work156:empty {display:none}
:root .app-shell .work-action-title {font-weight:400;color:var(--progress-ink156)}
:root .app-shell {--progress-ink156:#747474;--progress-symbol156:#5d5d5d;--progress-band156:#4e4e4e}
:root .app-shell .work-action svg {color:var(--progress-symbol156)}
:root .app-shell .work-action-detail {color:var(--ink);opacity:1}
:root .app-shell #inline-activity-current {display:flex;align-items:center;gap:.55em;margin:4px 0;color:var(--progress-ink156);font-weight:400;background:none;-webkit-text-fill-color:currentColor;animation:none}
:root .app-shell #inline-activity-current::before {display:none}
:root .app-shell #inline-activity-current.has-stage.is-thinking::before {content:"";display:block;width:14px;height:14px;border-radius:50%;border:2px solid var(--line);border-top-color:var(--progress-symbol156);animation:work-stage-spin 1s linear infinite}
:root .app-shell #inline-activity-current.is-thinking span,:root .app-shell .action-wave156 {width:fit-content;color:var(--progress-ink156);font-weight:400}
@media(prefers-color-scheme:dark){:root .app-shell {--progress-ink156:#adadad;--progress-symbol156:#bdbdbd;--progress-band156:#cbcbcb}}
@media(prefers-reduced-motion:no-preference) and (forced-colors:none){
  :root .app-shell :is(#inline-activity-current.is-thinking span,.action-wave156) {background:linear-gradient(105deg,var(--progress-ink156) 38%,var(--progress-band156) 49%,var(--progress-ink156) 60%) 100% 50% / 240% 100%;background-clip:text;-webkit-background-clip:text;color:transparent;-webkit-text-fill-color:transparent;animation:public-wave156 1.8s linear infinite}
}
@keyframes public-wave156{to{background-position:-80% 50%}}
@media(prefers-reduced-motion:reduce){:root .app-shell #inline-activity-current.has-stage.is-thinking::before{animation:none}}
:root .app-shell[data-nav155="drawer"] #composer :is(#internet-toggle,#model-picker-toggle)::before {display:block;width:15px;height:15px;margin:0 auto 1px}
:root .app-shell[data-nav155="drawer"] #composer :is(#internet-toggle,#model-picker-toggle) {display:flex;flex-direction:column;align-items:center;justify-content:center;gap:0;height:auto;min-height:29px;padding:1px}
:root .app-shell[data-nav155="drawer"] #internet-toggle::after {content:attr(data-mode);font-size:10px;line-height:12px}
:root .app-shell[data-nav155="drawer"] #model-picker-toggle>span[aria-hidden] {display:none}
:root .app-shell[data-nav155="drawer"] #message-input {font-weight:400}
:root .app-shell[data-nav155="drawer"] {--mobile-answer-ink194:#111}
:root .app-shell[data-nav155="drawer"] .message.assistant .message-content,
:root .app-shell[data-nav155="drawer"] .message.assistant .message-content :is(.response,.response-neutral) {font-weight:400;color:var(--mobile-answer-ink194)}
:root .app-shell[data-nav155="drawer"] .top-controls :is(select,#activity-toggle,.depth-display176) {color:var(--mobile-answer-ink194)}
@media(prefers-color-scheme:dark){:root .app-shell[data-nav155="drawer"] {--mobile-answer-ink194:#f5f5f5}}
/* One frame for the drawer, backdrop and composer when browser chrome or the keyboard resizes. */
:root .app-shell[data-nav155="drawer"] #chat-view.active-view {grid-template-rows:minmax(0,1fr) auto;padding-bottom:0}
:root .app-shell[data-nav155="drawer"] #chat-view.active-view .chat-footer {position:relative;inset:auto;grid-row:2;width:100%;min-height:0;max-height:max(80px,calc(var(--app-height,100dvh) - var(--topbar-height,72px) - 72px));overflow:auto;padding-bottom:env(safe-area-inset-bottom,0px)}
@media(max-width:620px){:root .app-shell .activity-summary{display:block}.activity-summary dd{margin:0 0 6px}}
/* The open report can occupy the same area as the mode menu. */
:root .app-shell:has(#test-modes156:not(.hidden)) :is(#activity-drawer,#sources-drawer,#replay-drawer) {visibility:hidden;pointer-events:none}
:root .app-shell[data-nav155="drawer"] .answer-tail160 .answer-actions {display:flex;flex-wrap:nowrap;align-items:center;gap:2px}
:root .app-shell[data-nav155="drawer"] .answer-actions .answer-action {min-width:0;min-height:40px;padding-inline:3px;font-size:12px;line-height:1.25}
:root .app-shell[data-nav155="drawer"] .answer-actions :is(.answer-copy,.answer-speak) {flex:0 0 33px}
:root .app-shell[data-nav155="drawer"] .answer-actions .answer-branch {flex:0 1 auto;white-space:normal;text-align:left}
:root .app-shell[data-nav155="drawer"] .answer-branch>span {min-width:0;white-space:normal;overflow-wrap:anywhere}
:root .app-shell[data-nav155="drawer"] .answer-projects {flex:0 0 auto}

/* The transcript and active work share a single scrollport. The composer is its sibling. */
#chat-scroll160 {grid-area:1 / 1;min-height:0;min-width:0;display:flex;flex-direction:column;overflow:auto;overscroll-behavior:contain}
#chat-scroll160 > #messages {flex:0 0 auto;overflow:visible}
:root .app-shell #chat-scroll160 > #inline-activity {
  flex:0 0 auto;width:var(--column155);max-width:calc(100% - var(--leading155));
  margin:auto 0 8px var(--leading155);
}
/* Keep four lines of chat text between the desktop progress line and the composer. */
:root .app-shell[data-nav155="wide"] #chat-scroll160 > #inline-activity:not(.hidden) {margin-block-end:0;padding-block-end:4lh}
:root .app-shell[data-nav155="wide"] #activity-stages160 #inline-activity-current {margin-block-end:0}
#inline-activity .inline-activity-time {border-bottom:0}
#inline-activity .visible-work156,#inline-activity ol,#inline-activity .inline-activity-current {max-height:none;overflow:visible}
#activity-stages160.has-actions {border-top:1px solid var(--line);margin-top:12px;padding-top:8px}
#completed-stages160 {display:grid;gap:.25em;list-style:none;padding:0;margin:0}
#completed-stages160:empty {display:none}
#completed-stages160 li {display:flex;align-items:center;gap:.55em;margin:0;padding:0;color:var(--progress-ink156);line-height:1.5}
#completed-stages160 svg {width:14px;height:14px;flex:none;fill:none;stroke:var(--progress-symbol156);stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round}
:root .app-shell #activity-stages160 #inline-activity-current {padding:0;min-height:0;max-height:none;overflow:visible}
:root .app-shell #activity-stages160 #inline-activity-current::before {position:static;flex:0 0 14px}


/* The footer keeps its DOM position. Only the empty state's grid tracks change. */
:root .app-shell[data-nav155] #chat-view.active-view:has(> #empty-chat:not(.hidden)) {
  --welcome-space:max(0px,calc(50% - (var(--topbar-height,80px) + var(--switch-height,0px) + var(--chat-footer-height,90px)) / 2));
  grid-template-rows:minmax(max-content,var(--welcome-space)) max-content minmax(0,1fr);
  align-content:start;
  padding-block:0;
  overflow-y:auto;
}
:root .app-shell #chat-view:has(> #empty-chat:not(.hidden)) > #chat-scroll160 {display:none}
:root .app-shell #empty-chat:not(.hidden) {
  align-self:end; justify-self:center; width:auto; max-width:100%;
  margin:0 12px 24px; padding:0; text-align:center;
}
:root .app-shell #empty-chat h2 {margin:0;font:500 29px/1.25 var(--chat-font,system-ui,sans-serif);letter-spacing:-.025em}
:root .app-shell #empty-chat:not(.hidden) + #chat-footer > #composer {
  margin-block:0; border-radius:24px; box-shadow:0 3px 15px rgba(26,42,59,.055);
}
:root .app-shell[data-nav155="wide"] #empty-chat:not(.hidden) + #chat-footer #message-input {height:72px}
:root .app-shell[data-nav155="drawer"] #empty-chat:not(.hidden) {
  margin-block-end:16px;
}
:root .app-shell[data-nav155="drawer"] #empty-chat h2 {font-size:22px}
:root .app-shell[data-nav155="drawer"] #empty-chat:not(.hidden) + #chat-footer {
  padding-bottom:0;
}
/* Keep the welcome heading on the same desktop column as the input card. */
:root .app-shell[data-nav155="wide"] #empty-chat:not(.hidden) {
  justify-self:start;width:var(--reading-width);max-width:none;
  margin-inline:var(--reading-inset) 0;
}
/* The narrower left gap cannot hold a protocol name. Its own row keeps the
   complete name readable without pushing the shared text column sideways. */
:root .app-shell[data-nav155="wide"] .top-controls .protocol-identity {
  position:static;inset:auto;grid-column:1 / -1;grid-row:1;
  width:auto;height:auto;min-height:0;padding:0;text-align:left;
}
:root .app-shell[data-nav155="wide"] .top-controls .protocol-identity:has(.protocol-name:empty) {display:none}
:root .app-shell[data-nav155="wide"] .top-controls:has(.protocol-name:not(:empty)) > :is(label,.uploads-control,.test-field156) {grid-row:2}
:root .app-shell[data-nav155="wide"] .top-controls:has(.protocol-name:not(:empty)) > #task-calendar {grid-row:3}
:root .app-shell[data-nav155="wide"] .top-controls.tight-header168 :is(select,#activity-toggle) {padding-inline:2px}
:root .app-shell[data-nav155="wide"] .top-controls.desktop-header-wrapped > label {grid-row:1}
:root .app-shell[data-nav155="wide"] .top-controls.desktop-header-wrapped > .uploads-control {grid-row:2;grid-column:1}
:root .app-shell[data-nav155="wide"] .top-controls.desktop-header-wrapped > .test-field156 {grid-row:2;grid-column:2 / -1}
:root .app-shell[data-nav155="wide"] .top-controls.desktop-header-wrapped > #task-calendar {grid-row:3}
:root .app-shell[data-nav155="wide"] .top-controls.desktop-header-wrapped:has(.protocol-name:not(:empty)) > label {grid-row:2}
:root .app-shell[data-nav155="wide"] .top-controls.desktop-header-wrapped:has(.protocol-name:not(:empty)) > :is(.uploads-control,.test-field156) {grid-row:3}
:root .app-shell[data-nav155="wide"] .top-controls.desktop-header-wrapped:has(.protocol-name:not(:empty)) > #task-calendar {grid-row:4}
@media (hover:hover) and (pointer:fine) and (min-width:1101px) and (max-width:1600px) {
  :root .app-shell .composer-actions {
    --composer-plus-gap:5px; --composer-model-gap:6px; --composer-control-gap:6px; --composer-stop-space:0px;
  }
  :root .app-shell #composer :is(#internet-toggle,#model-picker-toggle) {padding-inline:5px}
}

/* Lower Luna to the existing globe line without moving the internet control. */
:root .app-shell[data-nav155="drawer"] #composer #model-picker-toggle::before {
  transform:translateY(var(--mobile-model-icon-offset,0px));
}

/* The mobile toolbar uses the same slot and checkbox as the original two-word label.
   Its current caption wraps on word boundaries without changing the widths of adjacent controls. */
@media (max-width: 820px), (max-width: 1100px) and (max-height: 600px) {
  :root .app-shell[data-nav155="drawer"] #continue-task-control[data-quick-action="replay"] .task-caption {
    display: grid;
    align-items: center;
    width: max-content;
    min-width: 0;
    line-height: normal;
  }
  :root .app-shell[data-nav155="drawer"] #continue-task-control[data-quick-action="replay"] .task-caption::before {
    content: "Продолжение задачи";
    grid-area: 1 / 1;
    visibility: hidden;
    white-space: nowrap;
  }
  :root .app-shell[data-nav155="drawer"] #continue-task-control[data-quick-action="replay"] .task-caption-text {
    grid-area: 1 / 1;
    inline-size: 0;
    min-inline-size: 100%;
    white-space: normal;
    overflow-wrap: normal;
    word-break: normal;
    font-size: min(1em, 10.5px);
    line-height: 9px;
  }
}
@media (max-width: 399px) {
  :root .app-shell[data-nav155="drawer"] #continue-task-control[data-quick-action="replay"] .task-caption::before {
    width: min-content;
    white-space: normal;
  }
}
