/* ChatAdmin: the conversation first (LAYOUT1, 2026-11-29; the owner: "the area of each is fixed ... a big part dialogue
   display in a very narrow space and scroll up and down only show 1-2 lines"; "make the solution robust as people may
   have different scales of screen, and size of text and display resolution"; "at least adjustable"). Loaded after
   style.css and next.css (index.html, the same line); layout.js adds the splitters, the reset and the collapse.

   THE RULE: a view opened from the top bar (Overview, Organization, Customers) or a page of its own (Subscription and
   every path other than the conversation) takes the WHOLE middle column; the conversation and the message box wait
   behind it until Close (or the Conversation button). A notice that shares the column with the conversation (the
   Marketplace welcome, the plans, the connect page, the locked preview) is capped at --lay-top of the column (25 %,
   a splitter moves it between 10 and 30 %) and scrolls itself, and the conversation keeps at least 60 % of it.

   Sizes are rem / em so the browser's text size moves them; the short-screen breakpoint is in em so zoom and the text
   size move it too. No fixed pixel height on a region: the rows are flex with min-height 0, the shares are percentages
   of the column.

   THE PHONE SWITCH - ONE VALUE: 720 px (``--lay-phone-max``; the owner, 2026-11-29: "users do not like" the rail moving
   to the top on a 200 % laptop, ~950 px wide). At 720 px or less the rail is a strip at the top and the Workings panel a
   bottom sheet; from 721 px the rail stays a left column (it narrows, its labels may wrap, the header may take two
   rows). A media query cannot read a custom property, so every phone query in style.css, next.css, panel.css,
   layout.css, commercial.js and app.js isPhone() is written as exactly (max-width: 720px) / (min-width: 721px) and
   tests/test_layout_ui.py fails on any other phone width - the value cannot drift. */

:root { --lay-rail: min(11.875rem, 24vw); --lay-work: clamp(min(16rem, 30vw), 26vw, 32rem); --lay-top: 25%;
  --lay-line: 62rem; --lay-composer-h: 6.25rem;
  --lay-phone-max: 720px; /* documentation of THE PHONE SWITCH above (media queries cannot read it) */ }

/* --- the columns: the rail and the Workings panel by layout.js (drag, keys) or these defaults; the conversation the rest */
@media (min-width: 721px) {
  .room { position: relative; grid-template-columns: var(--lay-rail) minmax(0, 1fr); }
  .room.with-workings { grid-template-columns: var(--lay-rail) minmax(0, 1fr) var(--lay-work); }
  body.lay-rail-collapsed { --lay-rail: 3.5rem; }
  body.lay-rail-collapsed .rail { padding: .5rem .375rem; align-items: center; }
  body.lay-rail-collapsed .rail .tile { width: auto; padding: .25rem; border-radius: 999px; align-items: center; }
  body.lay-rail-collapsed .rail .tile .name, body.lay-rail-collapsed .rail .tile > :not(.tile-head),
  body.lay-rail-collapsed .rail .rail-connect { display: none; }
  /* a long line is hard to read on a wide screen: the thread and the message box keep a readable measure, centred */
  .feed { padding-inline: max(1.25rem, calc((100% - var(--lay-line)) / 2)); }
  #composer { padding-inline: max(.75rem, calc((100% - var(--lay-line)) / 2)); }
  /* the top bar wraps instead of scrolling sideways (no horizontal scrollbar at 1280 px or at 1024 px) */
  header.top { flex-wrap: wrap; overflow: visible; row-gap: .25rem; justify-content: flex-end; }
}

/* --- the splitters (layout.js): a 12 px hit area, a visible grip, keyboard focusable; none on a phone */
.lay-split, .lay-fold { display: none; }
@media (min-width: 721px) {
  .lay-split { position: absolute; z-index: 6; touch-action: none; background: transparent; border: 0; padding: 0; }
  .lay-split::before { content: ""; position: absolute; background: transparent; transition: background-color .15s; }
  .lay-split::after { content: ""; position: absolute; border-radius: 3px; background: var(--border); }
  .lay-split:hover::before, .lay-split:focus-visible::before, .lay-split.dragging::before { background: var(--teal); }
  .lay-split:hover::after, .lay-split:focus-visible::after, .lay-split.dragging::after { background: var(--teal); }
  .lay-split:focus-visible { outline: none; }
  .lay-split-v { display: block; top: 0; bottom: 0; width: 12px; margin-left: -6px; cursor: col-resize; }
  .lay-split-v::before { left: 5px; top: 0; bottom: 0; width: 2px; }
  .lay-split-v::after { left: 3px; top: 50%; width: 6px; height: 2.5rem; margin-top: -1.25rem; }
  #laySplitRail { left: var(--lay-rail); }
  #laySplitWork { left: calc(100% - var(--lay-work)); }
  .room:not(.with-workings) > #laySplitWork, .room:not(.with-workings) > #layFoldWork { display: none; }
  body.lay-rail-collapsed #laySplitRail { cursor: default; }
  .lay-fold { display: inline-flex; position: absolute; z-index: 7; bottom: calc(var(--lay-composer-h) + .5rem); align-items: center; justify-content: center;
    width: 1.5rem; height: 1.5rem; margin-left: -.75rem; padding: 0; border: 1px solid var(--border); border-radius: 50%;
    background: var(--panel); color: var(--muted); font-size: .875rem; line-height: 1; cursor: pointer; }
  .lay-fold:hover { color: var(--text); border-color: var(--teal); }
  #layFoldRail { left: var(--lay-rail); }
  #layFoldWork { left: calc(100% - var(--lay-work)); }
  .lay-split-h { display: none; flex: none; position: relative; height: 12px; margin: -4px 0; cursor: row-resize; }
  .lay-split-h::before { left: 0; right: 0; top: 5px; height: 2px; }
  .lay-split-h::after { top: 3px; left: 50%; height: 6px; width: 2.5rem; margin-left: -1.25rem; }
}
#layResetBtn { padding-inline: .5rem; }
@media (max-width: 720px) { #layResetBtn { display: none; } }
/* no rail, no Workings, no conversation (the signed-out page, /start, a visitor's sample): no layout control at all;
   layout.js also hides each control whose region is not on the page */
body.visitor :is(.lay-split, .lay-fold, #layResetBtn), body.plan-page :is(.lay-split, .lay-fold, #layResetBtn) { display: none !important; }

/* --- a notice that shares the column: capped, scrolls itself; the conversation keeps the rest (at least 60 %) */
.chat > :is(#marketplacePanel, #visitorPanel, #commercialPanel, #mspConnectPanel, #cxoPreview):not([hidden]) {
  flex: 0 1 auto; min-height: 0; max-height: var(--lay-top); overflow: auto; }
.chat > #feed { flex: 1 1 0; min-height: 40%; }
.chat:has(> :is(#marketplacePanel, #visitorPanel, #commercialPanel, #mspConnectPanel, #cxoPreview):not([hidden])) > #feed { min-height: 60%; }
@media (min-width: 721px) {
  .chat:has(> :is(#marketplacePanel, #visitorPanel, #commercialPanel, #mspConnectPanel, #cxoPreview):not([hidden])) > #laySplitTop { display: block; }
}
/* no conversation on the page (visitor, plan page): the notice is the page */
body.visitor .chat > :is(#marketplacePanel, #visitorPanel, #commercialPanel, #mspConnectPanel):not([hidden]),
body.plan-page .chat > #commercialPanel:not([hidden]) { max-height: none; }
body.visitor #laySplitTop, body.plan-page #laySplitTop, body.lay-page #laySplitTop { display: none !important; }

/* --- a view takes the whole column (THE RULE): Organization open, Customers open, a page of its own; Overview already
   does it (panel.css .cxo-open). The column scrolls as one page: no box inside a box. */
.chat:has(> #organization[open]:not([hidden])), .chat:has(> #mspPanel:not([hidden])),
body.lay-page .chat:has(> :is(#commercialPanel, #mspConnectPanel, #marketplacePanel, #visitorPanel):not([hidden])) { overflow: hidden auto; }
.chat:has(> #organization[open]:not([hidden])) :is(#feed, #cardStrip, #llmBanner, #laySplitTop, #cxoPreview, #marketplacePanel, #visitorPanel, #commercialPanel, #mspConnectPanel),
.chat:has(> #mspPanel:not([hidden])) :is(#feed, #cardStrip, #llmBanner, #laySplitTop, #cxoPreview, #marketplacePanel, #visitorPanel, #commercialPanel, #mspConnectPanel),
body.lay-page .chat:has(> :is(#commercialPanel, #mspConnectPanel, #marketplacePanel, #visitorPanel):not([hidden])) :is(#feed, #cardStrip, #llmBanner, #laySplitTop, #cxoPreview),
/* the message box waits too; its one small line (the AI notice, the access mode) stays at the foot of the column */
.chat:has(> #organization[open]:not([hidden])) > #composer > :not(.lay-meta):not(#aiNotice),
.chat:has(> #mspPanel:not([hidden])) > #composer > :not(.lay-meta):not(#aiNotice),
body.lay-page .chat:has(> :is(#commercialPanel, #mspConnectPanel, #marketplacePanel, #visitorPanel):not([hidden])) > #composer > :not(.lay-meta):not(#aiNotice),
body .chat.cxo-open > form#composer > :not(.lay-meta):not(#aiNotice) {
  display: none !important; }
body .chat.cxo-open > form#composer { display: flex !important; }
.chat:has(> #organization[open]:not([hidden])) > #composer, .chat:has(> #mspPanel:not([hidden])) > #composer,
body.lay-page .chat:has(> :is(#commercialPanel, #mspConnectPanel, #marketplacePanel, #visitorPanel):not([hidden])) > #composer {
  position: sticky; bottom: 0; z-index: 2; margin-top: auto; }
.chat > #organization[open]:not([hidden]), .chat > #mspPanel:not([hidden]), .chat > #mspWorkOrders:not([hidden]),
body.lay-page .chat > :is(#commercialPanel, #mspConnectPanel, #marketplacePanel, #visitorPanel):not([hidden]) {
  flex: none; max-height: none; min-height: 0; overflow: visible; overflow-x: auto; margin: .75rem; }
#mspPanel[hidden] ~ #mspWorkOrders { display: none !important; }

/* --- no tiny scroll box inside the conversation: a tool's JSON, a preview, a plan grow with the thread (they stay folded
   in their "result" / "Details" disclosure until opened); a wide table or line scrolls sideways only */
.feed pre, .w-body pre, .feed .tool pre, .w-body .tool pre, .feed .preview pre, .w-body .preview pre {
  max-height: none; overflow-x: auto; overflow-y: visible; }
.feed .md-table-wrap { overflow-y: visible; }

/* --- the message box: grows as you type (layout.js), the native resize up to a sensible maximum; the AI line and the
   access-mode line share one small line (layout.js moves #orgModeLine next to #aiNotice) */
#input { max-height: min(15em, 30vh); max-height: min(15em, 30dvh); }
/* while the box is empty its hint is one line ending in an ellipsis (a 1-line box cut the second line in half); typing
   wraps and grows as before */
#input:placeholder-shown { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#input::placeholder { display: block; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lay-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .75rem; min-width: 0; }
.lay-meta > .ai-notice { margin: 0; }
.lay-meta > #orgModeLine { order: 0; margin: 0; text-align: left; font-size: .75rem; color: var(--dim); min-width: 0; }
.card-strip { bottom: calc(var(--lay-composer-h) + .5rem); }

/* --- a short screen (a laptop at 125-150 %, a zoomed page, a large text size): everything around the thread smaller.
   THE RULE (the owner's report of 2026-11-29: 1920x1080 at 150 %, Edge at 100 %, about 1280x620 CSS px): a SHORT
   screen only compresses vertical spacing (padding, the message box, the rail's cards, the header's rows) - the
   columns stay. Only the WIDTH decides the layout: the rail goes to a strip at the top, and the Workings panel to a
   sheet, at 720 px or less (THE PHONE SWITCH above) and never because of the height
   (tests/test_layout_ui.py pins it). */
@media (max-height: 50em), (max-width: 720px) {
  #composer { flex-flow: row wrap; align-items: center; column-gap: .5rem; row-gap: .25rem; padding-top: .375rem; padding-bottom: .25rem; }
  #composer > .row { order: 0; flex: 1 1 100%; }
  #composer > #specialists { order: 1; flex: none; }
  #composer > #specialists[open] { flex: 1 1 100%; }
  #composer > .tools-row { order: 2; flex: 1 1 auto; min-width: 0; }
  #composer > .lay-meta { order: 3; flex: 1 1 100%; flex-wrap: nowrap; }
  .lay-meta > .ai-notice { flex: 0 1 auto; }
  .lay-meta > #orgModeLine { flex: 1 1 0; min-width: 4em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #input { min-height: 2.5em; height: 2.5em; padding: .375rem .625rem; }
  #sendBtn, #stopBtn { padding: .375rem .875rem; }
  .tools-row .btn { padding: 1px .5rem; }
  .feed { padding-top: .5rem; padding-bottom: .5rem; gap: .5rem; }
  .chair { padding: .375rem .75rem; }
  .msg { padding: .5rem .75rem; }
  footer { padding-top: 0; padding-bottom: 0; }
}
@media (max-height: 50em) and (min-width: 721px) {
  header.top { padding-top: 2px; padding-bottom: 2px; column-gap: .375rem; }
  /* the header's controls a little smaller, so a short laptop screen keeps them on fewer rows */
  header.top button, header.top .btn, header.top .pill { padding: 2px .5rem; font-size: .8125rem; }
  header.top .signin { gap: .375rem; }
  .rail { gap: .25rem; padding: .375rem; }
  .rail .tile { flex-flow: row wrap; align-items: center; gap: 2px .375rem; padding: .25rem .5rem; }
  .rail .tile .pills { margin-left: auto; }
  .rail .tile .pill:not(.state) { display: none; }
  .rail .tile .pill { font-size: .6875rem; padding: 0 .375rem; }
  .rail .tile .name { font-size: .8125rem; line-height: 1.25; }
  .rail .avatar { width: 1.375rem; height: 1.375rem; font-size: .625rem; }
  .rail-connect { padding: .375rem .5rem; font-size: .8125rem; margin-bottom: .25rem; }
}
@media (max-height: 50em), (max-width: 720px) {
  .msp-band { padding: .25rem .625rem; gap: .25rem .5rem; font-size: .8125rem; }
  .msp-band select.msp-switch { padding: 1px .375rem; max-width: 45%; }
}
/* a phone: the rail is one scrolling row - its guidance line is a short card in that row, never a tall column */
@media (max-width: 720px) {
  .rail { align-items: center; }
  .rail-connect { flex: none; width: min(22rem, 80vw); margin: 0; padding: .25rem .5rem; font-size: .75rem; line-height: 1.3; }
  #composer > .lay-meta { flex-wrap: wrap; }
  .lay-meta > #orgModeLine { flex: 1 1 100%; white-space: normal; }
}
@media (max-height: 30em) {
  #composer > #specialists:not([open]) > summary { font-size: .75rem; }
}
