/*
 * TAG Legal Desk v2.1: s929 UI and formatting sweep (7 Oct 2026). Layout only, loaded last; no colours of its own
 * (the design tokens only), no wording. Each block names what it fixes.
 */

/* 1. A "Your CM Task" card: the badge row (badge, due date) was the card grid's first child, so it took the 40px
 *    glyph column and pushed the glyph, the words and the counts one column along (the badge squeezed onto three
 *    lines, the title pushed right, "Nothing to send" cut off at the left). It now has its own full width row on top. */
#cards .card > .nst-task { grid-column: 1 / -1; grid-row: auto; min-width: 0; margin: 0 0 2px; padding-left: 0; }
#cards .card > .nst-task .nst-badge, #cards .card > .nst-task .nst-due { white-space: nowrap; }

/* 2. Phone header: the logo, the "to clear" count and the status chip ("Checking every 5 seconds") ran over each
 *    other. On a phone the chip shows its icon only (its words stay for screen readers) and the logo gives way. */
@media (max-width: 599px) {
  .hdr { grid-template-columns: minmax(40px, 1fr) auto auto; }
  .hdr-l { min-width: 0; overflow: hidden; }
  .hdr-l .logo, .hdr-l .logo-d { max-width: 100%; object-fit: contain; object-position: left center; }
  .hdr-r .hchip { font-size: 0; gap: 0; padding: 5px; flex: none; }
  .hdr-r .hchip svg { width: 14px; height: 14px; }
  .count { white-space: nowrap; }
}

/* 3. An email (and What came in) as wide as its longest unbroken string: a long link (the record's CRM address) or
 *    subject set the email's grid column to its own width, so on a phone and in narrow panels the whole email ran off
 *    the right edge (the subject cut, the second email and its Send this switch out of sight, the job scrolled
 *    sideways). The column now fits the panel and long strings wrap. */
.email, .email-body-wrap, .came, .came-extra { grid-template-columns: minmax(0, 1fr); }
.email > *, .email-body-wrap > *, .came > *, .came-extra > * { min-width: 0; }
.files { min-width: 0; }
.file { min-width: 0; }
.file > .link, .file > button.link { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email .ed-region, .email .paper, .came-subj, .came-text, .came-from { overflow-wrap: break-word; }
.email .subj input { min-width: 0; text-overflow: ellipsis; }  /* a subject longer than the box ends in an ellipsis */

/* 4. An open job whose top bar carries heads up lines (a lead before its status is chosen, an email to fix): the
 *    list took the bar's spare room and the client's name shrank to nothing (the lead's name was missing). The bar
 *    now wraps, so the lines sit on their own row under the name and the buttons. (The lines' own look is s928's.) */
.job-top:has(> .nst-heads-job) { flex-wrap: wrap; row-gap: 6px; }

/* 5. "Fred checked N things before writing": a long "Not reached: ..." flag would not shrink, so on the folded line it
 *    ran past the card and out of the job panel. It now ends in an ellipsis on the folded line and wraps when opened. */
.rl-flag { flex: 0 1 auto; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
details.rl[open] .rl-flag { white-space: normal; overflow-wrap: anywhere; }

/* 6. What came in, for a job with no email behind it (a timer or reminder): an empty name, an empty subject, an empty
 *    white text box and a "Read in full" of nothing showed. Empty parts are no longer drawn. */
.came-from > b:empty, .came-subj:empty, .came-text:empty { display: none; }
.came:has(> .came-text.full:empty) > .dl-row { display: none; }

/* 7. A lead's job on a phone or narrow window: the stamp and the gauge ("Bad lead 52, Estimate A$0 ...") sat in the
 *    top bar beside the name, so the name was cut to a few letters, the stamp lay over the gauge and the estimate ran
 *    off the screen under the file button. Narrow, the stamp and gauge take their own row under the name. */
@media (max-width: 760px) {
  .job-top:has(> .l418-bar) { flex-wrap: wrap; row-gap: 6px; }
  .job-top > .l418-bar { order: 5; flex: 1 1 100%; min-width: 0; margin: 0; }
  .job-top .l418g-btn { width: auto; flex: 0 1 auto; white-space: normal; height: auto; min-height: 36px; padding: 4px 10px; text-align: start; min-width: 0; }
}

/* 8. An email's head on a phone: with "Edited", "Undo my changes" and the Send this switch on the right, the left
 *    part ("Email 1 of 2, to the Director and the GM") was squeezed to one word a line. The left part now keeps a
 *    readable width and the right part wraps under it when there is no room. */
.email-h .t { flex: 1 1 12rem; }

/* ---------- round 2 (7 Oct 2026, evening) ---------- */

/* 9. The subject is now a one line box that wraps (js/job.js makes it a textarea that takes no line breaks), so a long
 *    subject reads in full, on a phone too. Same look as the old one line box. */
.subj textarea { flex: 1; min-width: 0; min-height: 40px; padding: 9px 10px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: inherit; font: inherit; font-weight: 700; font-size: .9375rem; line-height: 1.35rem;
  resize: none; overflow: hidden; field-sizing: content; overflow-wrap: anywhere; white-space: pre-wrap; box-sizing: border-box; }
.subj textarea:hover { border-color: var(--glass-rim); background: var(--glass-1); }
.subj textarea:focus-visible { background: var(--solid); border-color: var(--edge-strong); outline-offset: 0; }
.subj textarea:disabled { cursor: default; }
.subj textarea:disabled:hover { border-color: transparent; background: transparent; }
@media (max-width: 599px) { .subj textarea { flex-basis: 100%; } }

/* 10. Dark themes: an email already sent was dimmed to 72% as a whole, so its white paper went grey and its words grey
 *     on grey. In every dark theme the sent email keeps full strength; the paper takes the light "locked" grey the page
 *     already uses for fixed wording, and the green "Already sent" chip says the rest. */
:root[data-theme="dark"] .email.sent .email-body-wrap { opacity: 1; }
:root[data-theme="dark"] .email.sent .paper { background: #EFF1EE; }

/* 11. The Ask orb sits at the bottom right. Where a panel reaches that corner (an open job on a laptop, History and the
 *     other side sheets) the panel now leaves the orb its own lane, so it no longer sits over times and corners. The
 *     orb can still be dragged anywhere. Phones keep the full width. */
@media (min-width: 600px) {
  :root:has(#v21ao-layer:not([hidden])) .job-layer { padding-right: 88px; }
  :root:has(#v21ao-layer:not([hidden])) .sheet-b { padding-right: 88px; }
}

/* 12. A card someone has open: the "Gary has this" pill sat under the card's menu button and was cut off. The pill now
 *     ends left of the button. */
@media (min-width: 600px) {
  .card:has(> .hld-menu) .holder { right: 60px; }
}

/* 13. A lead's Call back box: the service chips ("Enlisted post 2004 ...") sat straight under the call back buttons as
 *     if they were more buttons. They now have a little room and a hairline above them. */
.l418-box .l418-svcs { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--glass-rim); }

/* 14. Laptop header: "Checking every 5 seconds" took two lines, the name chip was cut to "Jo..." and "+256 today" took
 *     two lines. Up to 1366px the chip stays on one line and the "+N today" note gives way (as it does on a phone). */
@media (min-width: 600px) and (max-width: 1366px) {
  .hdr-r .hchip { white-space: nowrap; flex: none; }
  .hdr-r .you .pts .pts-today { display: none; }
}

/* 15. The For you sheet: the answer box had no inner space (the words sat on its edge) and a plain browser border, and
 *     "Send to Fred" was a bare text link. The box now matches the desk's other write boxes, and Send is a button. */
.fy-sheet .fy-text { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--edge-strong); background: var(--solid);
  color: var(--ink); line-height: 1.4; }
.fy-sheet .fy-text:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.fy-sheet .fy-send { min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--glass-edge);
  background: var(--glass-1); box-shadow: inset 0 1px 0 var(--glass-hi), 0 0 0 1px var(--glass-rim); }
