/* A session's title on a wide window, and the view of sessions laid together (js/beside.js).
   One session is one stream (js/chat.js): its questions stand in its conversation. Here is only the
   head of its page on a wide window: a large mark, the name, a line with what it is at.
   Sessions laid together: one list of the questions of all of them (js/beside.js mounts it) in a wide
   column, their conversations narrow beside it, one above the other; below 1200px that list stands
   above the conversations. */

.pane-now { display: none; }

@media (min-width: 1200px) {
  body { --beside-col: 50.5rem; --talk-w: clamp(340px, 30vw, 440px); }

  /* ---- one session: the title is a head of its own: mark, name, a line; the modes at its right end ---- */
  body:not([data-pair]) .pane-title {
    display: grid; grid-template-rows: auto auto; align-items: center; gap: 0;
    min-height: 0; padding: 0;
  }
  body:not([data-pair]) .pane-who {
    grid-column: 1 / -1; grid-row: 1; gap: var(--s-4);
    margin: var(--s-6) max(var(--gutter), calc((100% - var(--beside-col)) / 2 + var(--gutter))) 0;
  }
  body:not([data-pair]) .pane-who .agent-avatar { width: 56px; height: 56px; border-radius: 16px; }
  body:not([data-pair]) .pane-who .crown-toggle { left: 12px; top: -17px; }
  body:not([data-pair]) .pane-who .crown-toggle .crown-mark { width: 26px; }
  body:not([data-pair]) .pane-title h2 { font-size: clamp(1.7rem, 2.6vw, 2.2rem); line-height: 1.1; letter-spacing: -.025em; }
  /* Under the name: what the session is at, its model and machine. */
  body:not([data-pair]) .pane-now {
    grid-column: 1 / -1; grid-row: 2; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--s-3); min-height: 1.5em;
    margin: -14px max(var(--gutter), calc((100% - var(--beside-col)) / 2 + var(--gutter))) var(--s-3);
    padding-left: calc(56px + var(--s-4)); color: var(--muted); font-size: var(--t-md);
  }
  .pane-now .caps { color: var(--faint); font-size: .66rem; white-space: nowrap; }
  .pane-now span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* The name's column, then the filters, then the two modes, on the title's lower line. (The longer
     selectors outweigh the lines in app.css that once took the old split back.) */
  body:not([data-pair]):not([data-scope="all"]) .pane-title { grid-template-columns: minmax(0, 1fr) auto auto; }
  /* (The name's box reaches under them and is positioned: they stand above it, so they can be pressed.) */
  body:not([data-pair]):not([data-scope="all"]) :is(.filters, .modes) { position: relative; z-index: 1; }
  body:not([data-pair]):not([data-scope="all"]) .filters { grid-column: 2; grid-row: 1 / -1; align-self: end; justify-self: end; margin: 0 var(--s-3) 10px 0; }
  body:not([data-pair]):not([data-scope="all"]) .modes { grid-column: 3; grid-row: 1 / -1; align-self: end; justify-self: end; margin: 0 var(--s-4) 6px 0; }

  /* ---- sessions laid together: one wide column with the questions of all of them, the conversations
     narrow beside it, one above the other, each with its own name and composer ---- */
  body[data-pair]:not([data-page]):not([data-scope="all"]) #session { display: grid; grid-template-columns: minmax(0, 1fr) var(--talk-w); grid-template-rows: auto minmax(0, 1fr); }
  body[data-pair] .pane-title { grid-column: 1 / -1; }
  body[data-pair][data-view="chat"] .group-questions { grid-column: 1; grid-row: 2; }
  body[data-pair] #chat { grid-column: 2; grid-row: 2; flex-direction: column; overflow: hidden; border-left: 1px solid var(--line); }
  body[data-pair] #scribble { grid-column: 1 / -1; grid-row: 2; }
  body[data-pair] #chat .chat-pane { min-width: 0 !important; --gutter: var(--s-4) !important; }
  body[data-pair] #chat .chat-pane + .chat-pane { border-left: 0; border-top: 1px solid var(--line-strong); }
  body[data-pair] #chat .log-inner { padding-block: var(--s-4) var(--s-4); }
  body[data-pair] #chat .msg { margin-top: var(--s-5); }
  body[data-pair] #chat .hint { display: none; }
}
/* The card a reference in a conversation pointed at, for a moment. */
.group-questions .inbox-row.is-pointed { outline: 3px solid var(--fg); outline-offset: 3px; }

/* ---- sessions laid together, at every width: the combined list of their questions ---- */
.group-questions { display: none; }
body[data-pair][data-view="chat"]:not([data-page]) .group-questions {
  display: block; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: var(--s-6) var(--gutter) var(--s-10); scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
body[data-pair] #filter-questions { display: none; }
body[data-pair][data-filter="questions"] .log { visibility: visible; }
.group-list { max-width: 50.5rem; margin-inline: auto; }
.group-list .inbox-title h2 { display: none; }
.group-list .inbox-head { margin-bottom: var(--s-4); }
.group-list .inbox-empty { margin-top: var(--s-2); }
.group-questions .rich { font-size: 1rem; line-height: 1.6; overflow-wrap: anywhere; min-width: 0; }
.group-questions .rich > * + * { margin-top: .8em; }
.group-questions .rich p { white-space: pre-wrap; }
.group-questions .rich ul { padding-left: 1.35em; }
.group-questions .rich a { color: var(--accent); text-underline-offset: 3px; }
.group-questions .rich :not(pre) > code { font: .86em/1.4 var(--mono); padding: .12em .4em; border-radius: 6px; background: var(--sunken); border: 1px solid var(--line); }
.group-questions .rich pre { margin: 0; padding: 12px 14px; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); font: .84rem/1.6 var(--mono); }
/* The two round buttons (memo, Scratchpad) stand at the top right of a session: the joined title's
   controls end before them. */
@media (min-width: 861px) {
  body[data-pair]:not([data-scope="all"]):not([data-page]) .pane-title { padding-right: 108px; }
}
/* Narrow, with nothing open: the list takes no room. */
@media (max-width: 1199px) {
  body[data-pair][data-view="chat"]:not([data-page]) .group-questions { flex: none; max-height: min(46dvh, 480px); padding: var(--s-4) var(--gutter) var(--s-5); border-bottom: 1px solid var(--line-strong); }
  body[data-pair][data-view="chat"]:not([data-page]) .group-questions:not(:has(.inbox-row, .inbox-pile)) { display: none; }
}
/* Wide: the first card of sessions laid together stands on the 80px line, like a single session's first line
   (the band ends at 64px; the list's empty head keeps its 16px below it, so the column needs no room of its own). */
@media (min-width: 861px) {
  body[data-pair][data-view="chat"]:not([data-page]) .group-questions { padding-top: 0; }
}

/* ---- an open question inside the conversation: a small reference to its card in the column ----
   Only its title is left, on one quiet line in the question's colour; a click brings the card into
   view beside (js/beside.js). */
body[data-pair] #chat .log .ask-open { container: none; margin-block: var(--s-4) 0; }
body[data-pair] #chat .log .ask-open .inbox-row {
    min-height: 0; display: block; padding: 0; border-radius: var(--r-sm); background: none; box-shadow: none; outline: 0; cursor: pointer;
  }
body[data-pair] #chat .log .ask-open .inbox-row > :not(.inbox-content),
body[data-pair] #chat .log .ask-open .inbox-content > :not(.inbox-text),
body[data-pair] #chat .log .ask-open .inbox-text > :not(.inbox-question) { display: none; }
body[data-pair] #chat .log .ask-open .inbox-content { display: block; padding: 0; overflow: visible; }
body[data-pair] #chat .log .ask-open .inbox-text { display: flex; align-items: baseline; gap: var(--s-2); width: 100%; padding: 6px 10px 6px 8px; border-radius: var(--r-sm); border-left: 3px solid var(--tone-pen); background: var(--card-bg); }
body[data-pair] #chat .log .ask-open .inbox-text::before { content: "Question"; flex: none; font: 600 var(--t-xs)/1 var(--font); letter-spacing: .07em; text-transform: uppercase; color: var(--tone-pen); }
body[data-pair] #chat .log .ask-open .inbox-text::after { content: "←"; flex: none; margin-left: auto; color: var(--tone-pen); }
body[data-pair] #chat .log .ask-open .inbox-question { display: block; font: 600 var(--t-sm)/1.35 var(--font); letter-spacing: 0; text-wrap: wrap; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1199px) { body[data-pair] #chat .log .ask-open .inbox-text::after { content: "↑"; } }
@media (any-hover: hover) { body[data-pair] #chat .log .ask-open .inbox-text:hover { background: var(--tone-wash); } }

/* ---- sessions laid together on a phone: the list is one line above the conversation, or the whole view ---- */
.group-bar { display: none; }
@media (max-width: 860px) {
  body[data-pair][data-view="chat"]:not([data-page]) .group-bar:not([hidden]) {
    flex: none; display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: 44px; padding: 0 var(--gutter);
    border: 0; border-bottom: 1px solid var(--line); background: var(--surface-2); color: var(--fg); font: 600 var(--t-sm)/1.2 var(--font); text-align: left;
  }
  .group-bar b { flex: none; padding: 6px 12px; border-radius: var(--r-pill); background: var(--fg); color: var(--bg); font-weight: 600; }
  body[data-pair][data-view="chat"]:not([data-page]) .group-questions { display: none; }
  body[data-pair][data-joined-list][data-view="chat"]:not([data-page]) .group-questions { display: block; flex: 1; max-height: none; border-bottom: 0; }
  body[data-pair][data-joined-list][data-view="chat"]:not([data-page]) #chat { display: none; }
}

/* ---- sessions laid together, wide window: the edge that drags the conversations' column, and its fold ----
   (js/beside.js; width and fold are kept per browser). Folded, the column is a strip at the right edge. */
.talk-edge, .talk-fold, .talk-strip { display: none; }
@media (min-width: 1200px) {
  body[data-pair][data-view="chat"]:not([data-page]):not([data-scope="all"]) #session { position: relative; }
  body[data-pair][data-view="chat"]:not([data-page]):not([data-scope="all"]) .talk-edge {
    display: block; position: absolute; z-index: 5; grid-column: 2; grid-row: 2; top: 0; bottom: 0; left: -6px; width: 12px;
    cursor: col-resize; touch-action: none;
  }
  .talk-edge::after { content: ""; position: absolute; left: 5px; top: 0; bottom: 0; width: 2px; border-radius: 2px; background: transparent; transition: background 120ms; }
  .talk-edge:hover::after, body[data-talk-drag] .talk-edge::after { background: var(--line-strong); }
  .talk-edge[data-will-fold]::after { background: var(--fg); }
  body[data-talk-drag] { cursor: col-resize; user-select: none; -webkit-user-select: none; }
  body[data-talk-drag] #session :is(iframe, .rh-frame) { pointer-events: none; }
  /* Fold: a small round button on the edge, at the top of the column. */
  body[data-pair][data-view="chat"]:not([data-talk-folded]):not([data-page]):not([data-scope="all"]) .talk-fold {
    display: grid; place-items: center; position: absolute; z-index: 6; grid-column: 2; grid-row: 2; top: 10px; left: -14px;
    width: 28px; height: 28px; padding: 0; border: 1px solid var(--line-strong); border-radius: 50%;
    background: var(--surface); color: var(--muted); font: 600 .9rem/1 var(--font); box-shadow: var(--shadow-sm, 0 1px 2px rgb(0 0 0 / .08));
  }
  .talk-fold:hover { color: var(--fg); border-color: var(--fg); }
  /* Folded: the column is a strip; the list of questions takes the rest. */
  body[data-pair][data-talk-folded] { --talk-w: 44px !important; }
  body[data-pair][data-talk-folded] #chat { display: none !important; }
  body[data-pair][data-talk-folded] .talk-edge { display: none !important; }
  body[data-pair][data-talk-folded][data-view="chat"]:not([data-page]):not([data-scope="all"]) .talk-strip {
    display: flex; flex-direction: column; align-items: center; gap: var(--s-3); grid-column: 2; grid-row: 2; min-height: 0;
    padding: var(--s-3) 0; border: 0; border-left: 1px solid var(--line); background: var(--surface-2); color: var(--muted); cursor: pointer;
  }
  .talk-strip b { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg); font: 600 .9rem/1 var(--font); }
  .talk-strip-words { writing-mode: vertical-rl; min-height: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 var(--t-xs)/1 var(--font); letter-spacing: .08em; text-transform: uppercase; }
  .talk-strip:hover { color: var(--fg); background: var(--surface); }
}
