/* messages: the inbox, a conversation, a notice, and Write to us (DIRECTION-v6.md 6.4, over DIRECTION-v4.md
   1.4, 3.15, 4.19, 4.20). Markup: app/messages.js. No font-size inside a media or container query: phones
   change padding, gaps, columns, line clamps and the dock only. A sent bubble's entry is motion.js's list
   motion (data-flip); the subject's morph into the thread's title is its shared title (data-vt-title). */

/* =================================================================
   #/messages: two columns (2fr 1fr, 64 apart); one column under 1280, the cards after the list
   ================================================================= */
.mcols, .tcols, .ncols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--s-8); align-items: start; }
.mmain > .filters + * { margin-top: var(--s-4); }          /* the list box 16 under the chips */
.mnote { margin-top: var(--s-4); font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-2); }
.mnote .link { display: inline; }

/* The two boxes beside the list (padding 24, 16 apart), and the notice's side box: a 40 mint tile or a
   48 illustration, the title (Label), one Small gray line, then the action 16 under */
.mside-col, .mab-col { display: grid; gap: var(--s-4); align-content: start; }
.mside { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: var(--s-4); align-items: start; padding: var(--s-5); }
.mside.nside { grid-template-columns: 48px minmax(0, 1fr); }
.mside h2 { padding-top: 9px; }                             /* the title's first line centers on the 40 tile */
.mside.nside h2 { padding-top: 13px; }                      /* and on the 48 illustration */
.mside .txt { margin-top: 2px; font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-2); }
.mside .txt + .btn, .mside .acts { margin-top: var(--s-4); }
.mside .acts { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); }
/* A narrow box (the right column at 1280 to about 1300, where the text beside the tile would be under
   180 and the notice's button would stick out): the tile or illustration sits above the title, and the
   text and the action take the box's whole width */
.mside { container-type: inline-size; }
@container (max-width: 239px) {
  .mside > div { grid-column: 1 / -1; }
  .mside h2, .mside.nside h2 { padding-top: 0; }
}
@media (max-width: 639px) { .mside, .mab { padding: var(--pad-card); } }
@media (max-width: 1279px) {
  .mcols, .tcols, .ncols { grid-template-columns: minmax(0, 1fr); gap: var(--s-7); }
  .mside-col, .mab-col { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); align-items: start; }
  .ncols > .nside { max-width: 480px; }
}
/* push: also answers to the page area's width (branch ai-drawer README, the push layout) */
@container app (max-width: 1279px) {
  .mcols, .tcols, .ncols { grid-template-columns: minmax(0, 1fr); gap: var(--s-7); }
  .mside-col, .mab-col { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); align-items: start; }
  .ncols > .nside { max-width: 480px; }}

/* The list: a .box.flush list of rows, 1px --line between; the first and last rows take the box's
   corners through overflow: hidden. No preview pane: a row opens the thread or notice on its own page */
.mlist { list-style: none; margin: 0; padding: 0; }
.mlist > li + li { border-top: 1px solid var(--line); }
.mrow { position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; column-gap: var(--s-4); align-items: start; padding: var(--s-4) 20px; color: var(--ink); text-decoration: none; transition: background-color var(--t-hover); }
.mrow > .it { grid-row: 1 / span 3; }            /* a person: .it.round with initials; a notice: .it with the topic's icon. Shape, not color, tells them apart */
.mrow .subj { grid-column: 2; min-width: 0; line-height: var(--lh-ui); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.mrow .time { grid-column: 3; grid-row: 1; font-size: var(--fs-small); line-height: var(--lh-ui); color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mrow .prev { grid-column: 2 / -1; min-width: 0; margin-top: 2px; font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow .tags { grid-column: 2 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); margin-top: 10px; }
.mrow.unread .subj { font-weight: 700; }
.mrow.unread .subj::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: var(--s-2); border-radius: 50%; background: var(--green); vertical-align: 1px; }
.mrow.unread .time { font-weight: 700; color: var(--green-text); }
.mrow:hover { background: var(--hover); }
/* The row's cue at rest is "Read message" at the end of its last line (components.css), underlined on hover; the subject isn't */
.mrow:active { background: var(--pressed); --ink-2: var(--ink-2-press); }
.mrow:focus-visible { outline: var(--v8-focus); outline-offset: -2px; box-shadow: var(--v8-focus-glow-in); }
/* What a conversation is about ("Claim, liability insurance"), as quiet words with the topic's icon, like the file count:
   no outline (version 6), so the lime chip is the one shape in the row */
.ctx-tag { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-2); white-space: nowrap; }
.ctx-tag svg.i { width: 16px; height: 16px; }
.mfiles { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-2); }
.mfiles svg.i { width: 16px; height: 16px; }
/* A filter with nothing in it: in the list box, padding 32 */
.mlist-none { display: grid; justify-items: start; gap: var(--s-2); padding: var(--s-6); }
@media (max-width: 639px) {
  .mrow { column-gap: var(--s-3); padding: var(--s-4); }
  .mrow .prev { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; white-space: normal; }
  .mrow .tags:has(.chip, .ok, .badge) .ctx-tag { display: none; }
  .mlist-none { padding: var(--s-5); }
}
/* Under 360 the subject beside the time is about 150 wide: 3 lines, so "renews on 1 September" keeps its date */
@media (max-width: 359px) { .mrow .subj { -webkit-line-clamp: 3; } }

/* Filter chips (All, Claims, Policies, Invoices, Other): <button aria-pressed>, one row that stays on one line on phones */
.filters { display: flex; gap: var(--s-2); }
@media (max-width: 639px) {
  .filters { margin-inline: calc(-1 * var(--page-x)); padding-inline: var(--page-x); overflow-x: auto; scrollbar-width: none; }
}
.filters::-webkit-scrollbar { display: none; }
.filter { flex: none; display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: var(--r-pill); box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink); white-space: nowrap; transition: background-color var(--t-hover); }
.filter:hover { background: var(--hover); }
.filter:active { background: var(--pressed); }
.filter[aria-pressed="true"] { background: var(--g-10); box-shadow: inset 0 0 0 1px var(--green); color: var(--green-strong); font-weight: 700; }
.filter:focus-visible { outline-offset: -2px; }   /* the row scrolls on phones, so a ring outside the chip would be clipped */

/* =================================================================
   A conversation: the head, the phone's context row, the panel, then the thread and About (2fr 1fr)
   ================================================================= */
.page-in > .tpanel + .tcols, .page-in > .head + .ncols { margin-top: calc(var(--s-6) + var(--s-2)); }   /* 40 */
.tpanel > .mt-md { margin-top: var(--s-4); }

/* About this conversation: boxes 16 apart, padding 24 */
.mab { padding: var(--s-5); }
.mab-top { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: var(--s-4); align-items: start; }
.mab-top h3 { padding-top: 9px; }                           /* the name's first line centers on the tile */
.mab-s { margin-top: 2px; font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink); }
.mab .tracker { margin-top: var(--s-5); }
.mab-st { display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--s-1) var(--s-3); margin-top: var(--s-2); font-size: var(--fs-small); line-height: var(--lh-small); }
.mab-st span { color: var(--ink-2); }
.mab-a { margin-top: var(--s-4); }
.mab-hrs { margin-top: var(--s-3); font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-2); }
.mab > h3 + .mab-s + .btn { margin-top: var(--s-4); }

/* On a phone the About column's first card moves above the thread (components.css, "Messages fixer"); the phone's own context
   row is gone (the review, 17 October 2026: it named the same claim a second time in other words) */
@media (max-width: 639px) {
  .page-in > .tpanel + .tcols { margin-top: var(--s-6); }
}

/* A thread (threadHTML()): bubbles, oldest first, 24 apart. Each message is .tmsg.them or .tmsg.you
   holding (theirs) the 32 avatar, then a wrapper with the .sr "wrote" line, the bubble and the meta.
   Theirs white with the line, the avatar on the bubble's last line; yours mint, at the right.
   The meta sits under each bubble, never above */
.thread { display: grid; gap: var(--s-5); }
.bubble { max-width: 86%; padding: var(--s-3) var(--s-4); font-size: var(--fs-body); line-height: var(--lh-body); white-space: pre-line; overflow-wrap: anywhere; }
.tmsg > div { display: grid; min-width: 0; }
.tmsg.them { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: var(--s-3); align-items: end; }
.tmsg.them > div { justify-items: start; }
.tmsg.them:has(> div > .meta) > .it { margin-bottom: calc(6px + var(--lh-small)); }   /* the avatar sits on the bubble, not on the meta */
.tmsg.them .bubble { background: var(--canvas); box-shadow: inset 0 0 0 1px var(--line-2); border-radius: 16px 16px 16px 4px; }
.tmsg.you { display: grid; justify-items: end; }
.tmsg.you > div { justify-items: end; max-width: 86%; }
.tmsg.you > div > .bubble { max-width: 100%; }
.tmsg.you .bubble { background: var(--g-10); border-radius: 16px 16px 4px 16px; }   /* --ink on it 11.5:1 */
.bubble .file-chips { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-3); white-space: normal; }
.bubble .file-chips:first-child { margin-top: 0; }
.bubble .file-chip { background: var(--canvas); }          /* white, also inside a mint bubble */
.bubble .file-chip:hover { background: var(--hover); }
.bubble .file-chip:active { background: var(--pressed); }
.tmsg .meta { margin-top: 6px; font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-2); }
.tmsg.you .meta { text-align: right; }
.tmsg .meta.err { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: var(--s-1) var(--s-2); color: var(--error); }
.tmsg .meta.err svg.i { width: 16px; height: 16px; stroke-width: 1.5; }
.tmsg .meta.err .link { margin-left: var(--s-1); }
.tmsg-new { display: flex; align-items: center; gap: var(--s-3); font-size: var(--fs-small); line-height: var(--lh-small); font-weight: 700; color: var(--green-text); }
.tmsg-new::before, .tmsg-new::after { content: ""; flex: 1; height: 1px; background: var(--g-20); }
.tmsg-sys { padding-inline: var(--s-4); font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-2); text-align: center; text-wrap: balance; }
.tmsg-sys svg.i { display: inline-block; width: 16px; height: 16px; margin-right: var(--s-2); vertical-align: -3px; color: var(--green); }   /* inline, so a line that wraps keeps its check beside the first word */
@media (max-width: 639px) { .bubble { max-width: 92%; } .tmsg.you > div { max-width: 92%; } }

/* The reply box (replyBox()): the label (Label, 8 above), the box with a borderless textarea (2 rows
   growing to 8), the files she added, and the bar: secondary "Add a file" left, "Send" right
   (secondary while a primary is on the page). Under it one line on when the person answers.
   A closed thread has the closed box (an info box) in its place */
.thread + .reply-box, .thread + * > .reply-box, .thread + .infobox, .thread + .msg-closed { margin-top: var(--s-6); }   /* the claim page wraps its reply box */
.reply-box .rb-l { display: block; margin-bottom: var(--s-2); font-weight: 700; line-height: var(--lh-ui); }
.reply-box .rb-box { display: grid; gap: var(--s-2); padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4); border-radius: var(--r-lg); background: var(--canvas); box-shadow: inset 0 0 0 1px var(--field); cursor: text; transition: box-shadow var(--t-hover); }
.reply-box .rb-box:hover { box-shadow: var(--edge-hover); }
.reply-box .rb-box:focus-within { box-shadow: inset 0 0 0 2px var(--green); }
.reply-box .rb-box:has(textarea[aria-invalid="true"]) { box-shadow: inset 0 0 0 2px var(--error); }
.reply-box textarea { display: block; width: 100%; min-height: calc(2 * var(--lh-body)); max-height: calc(8 * var(--lh-body)); padding: 0; border: 0; outline: 0; background: none; resize: none; field-sizing: content; font-size: var(--fs-body); line-height: var(--lh-body); color: var(--ink); }
.reply-box .rb-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.reply-box .rb-note { margin-top: var(--s-2); font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-2); }
.rb-files { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* A file she added and hasn't sent: the file chip with a 32 round remove button in place of the download icon */
.file-chip.added { grid-template-columns: 40px minmax(0, 1fr) 32px; padding-right: var(--s-2); }
.file-chip.added:hover { background: var(--canvas); }
.file-chip.added:hover .fc-n { text-decoration: none; }
.file-chip .x { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: var(--ink); }
.file-chip .x:hover { background: var(--hover); }
.file-chip .x:active { background: var(--pressed); }
.file-chip .x svg.i { width: 16px; height: 16px; }

/* The phone dock (under 640, on an open conversation's page; shell() puts it right after main and sets
   .shell.has-dock): it replaces the tab bar and the reply box. A 40 paperclip button, a pill field
   (1 to 5 lines), a 40 round send button: ink outline while empty, green with a white icon after.
   Its height (--dock-h, set by messages.js) is the page's bottom padding, so the last bubble clears it */
.dock { display: none; }
@media (max-width: 639px) {
  .dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; gap: var(--s-2); padding: var(--s-2) var(--s-3) calc(var(--s-3) + env(safe-area-inset-bottom)); background: var(--canvas); border-top: 1px solid var(--line); }
  .shell.has-dock .tabbar, .shell.has-dock .reply-box { display: none; }
  .shell.has-dock .col { padding-bottom: calc(var(--dock-h, var(--tabbar-h)) + var(--s-4)); }
}
.dock .err { margin: 0 var(--s-1); }
.dock-row { display: flex; align-items: flex-end; gap: var(--s-2); }
.dock .icon-btn { flex: none; }
.dock .dock-field { flex: 1; min-width: 0; min-height: 40px; max-height: calc(5 * var(--lh-body) + var(--s-4)); padding: var(--s-2) var(--s-4); border: 0; border-radius: calc(var(--btn-h) / 2); background: var(--canvas); box-shadow: inset 0 0 0 1px var(--field); resize: none; field-sizing: content; font-size: var(--fs-body); line-height: var(--lh-body); color: var(--ink); }
.dock .dock-field::placeholder { color: var(--ink-2); opacity: 1; }
.dock .dock-field:hover { box-shadow: var(--edge-hover); }
.dock .dock-field:focus { outline: none; box-shadow: inset 0 0 0 2px var(--green); }
.dock .dock-field[aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--error); }
.dock .send { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--ink); color: var(--ink); transition: background-color var(--t-hover); }
.dock .send.ready { background: var(--green); box-shadow: none; color: var(--inverse-ink); }
.dock .send.ready:hover { background: var(--green-strong); }

/* =================================================================
   A notice: the illustration (64, on white), the text (62ch), the facts, the files, the action; the side box
   ================================================================= */
.nmain > img.art { width: 64px; height: 64px; }
.ntext { margin-top: var(--s-5); max-width: 62ch; }
.ntext p + p { margin-top: var(--s-3); }
.nfacts { display: flex; flex-wrap: wrap; gap: var(--s-4); margin-top: var(--s-5); }
.nfact { display: grid; min-width: 180px; padding: var(--s-4) 20px; }
.nfact .fig { font-size: var(--fs-title); line-height: var(--lh-title); letter-spacing: var(--track-tight); font-variant-numeric: tabular-nums; }
.nfact .lbl { font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-2); }
.nfiles { margin-top: var(--s-5); }
.nacts { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-3) var(--s-5); margin-top: var(--s-6); }
.ndone { display: flex; align-items: flex-start; gap: var(--s-2); margin-top: var(--s-6); }
.ndone > svg.i { width: 20px; height: 20px; margin-top: 2px; color: var(--green); }
.nlink { margin-top: var(--s-4); }
.nacts .ok, .nlink .ok { font-size: var(--fs-body); line-height: var(--lh-ui); }
.nacts .ok:focus, .nlink .ok:focus { outline: none; }
@media (max-width: 639px) { .nfact { flex: 1 1 140px; min-width: 0; } }

/* =================================================================
   #/messages/new: Write to us, one column of questions
   ================================================================= */
.wr { max-width: 720px; }
.wr > * + * { margin-top: var(--s-6); }
.wr .choices + .err { margin-top: var(--s-3); }
.wr-tip { margin-bottom: var(--s-3); font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-2); }
.wr-tip .link { display: inline; }
.wr-fl { display: block; margin-bottom: var(--s-2); font-weight: 700; line-height: var(--lh-ui); }
.wr-files .file-chips { margin-bottom: var(--s-3); }
.wr-hint { margin-top: var(--s-2); font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-2); }
.wr > .wr-foot { margin-top: var(--s-7); }
