/* The Record workspace: the staff ticket page as a fixed workspace (docs/adr/0387-record-workspace-ticket-page.md;
   public/js/app/ticket-record.js). A header band of four short rows that never scrolls away; one line for a live
   situation; the conversation (its filters pinned, the reply box docked at the bottom) beside a 360 px side panel with
   Overview, Related and Details. While the window is wide and tall enough the conversation and the panel scroll on their
   own; at 200% zoom, or in a short or narrow window, the page scrolls as one (WCAG 1.4.10). Below 1200 px the panel is a
   drawer; on a phone it is tabs (ticket-phone.css). Colors are the palette's tokens, so the dark theme follows; the SLA
   value in the header is the only red thing on the page. */

/* ---------- The page ---------- */
.ticket-detail.tw.tp.rw, [data-theme="dark"] .ticket-detail.tw.tp.rw { --tp-width:none; --rw-pad:var(--space-250); max-width:none; margin:0; border:1px solid var(--line); border-radius:var(--radius-lg); background:var(--surface); overflow:clip; }
.tp.rw #twSla, .tp.rw #tpStateChip, .tp.rw #twDates, .tp.rw .page-time-zone { display:none !important; }
.tp.rw > #tpMissing:not([hidden]) { padding:var(--space-300) var(--rw-pad); }

/* ---------- The header band ---------- */
.tp.rw .rw-band { position:relative; z-index:2; padding:0 var(--rw-pad); border-bottom:1px solid var(--line-strong); background:var(--surface); }
/* Row 1: the way back and the navigator, muted. */
.tp.rw .rw-band > .tw-nav { display:flex; align-items:center; flex-wrap:wrap; gap:var(--space-50) var(--space-150); min-height:32px; max-width:none; margin:0; padding:var(--space-25) 0 0; color:var(--muted); font-size:var(--text-xs); }
.tp.rw .rw-band > .tw-nav > .page-breadcrumb { flex:1 1 auto; min-width:0; font-size:var(--text-xs); }
/* "IT Service Desk / Tickets": the number is said one line below, in the title. */
.tp.rw #ticketBreadcrumb li:last-child { display:none; }
.tp.rw #ticketBreadcrumb li:nth-last-child(2)::after { content:none; }
.tp.rw .rw-band .tw-pager { margin-left:auto; color:var(--ink-2); font-size:var(--text-xs); }
.tp.rw .rw-band .tw-pager[hidden] + .rt { margin-left:auto; }
/* Row 2: what the ticket is, and only the actions that apply. */
.tp.rw .rw-band > .detail-header { position:static; display:flex; flex-direction:row; flex-wrap:wrap; justify-content:flex-start; align-items:center; gap:var(--space-100) var(--space-150); max-width:none; min-height:52px; margin:0; padding:var(--space-75) 0; border:0; background:transparent; }
/* The title takes what it needs and wraps when it must (at least 14rem); the actions take the rest, the toolbar's buttons
   at its right end, and what doesn't fit goes into More (ticket-toolbar.js tbFit measures the bar's own box). */
.tp.rw .rw-band > .detail-header > .tp-title-column { flex:0 1 auto; min-width:min(14rem, 100%); }
.tp.rw .rw-band .tp-title-line { display:flex; flex-wrap:wrap; align-items:baseline; gap:var(--space-25) var(--space-100); }
.tp.rw .rw-band .tp-number { margin:0; color:var(--muted); font-size:var(--text-sm); font-weight:var(--weight-medium); cursor:pointer; border-radius:var(--radius-sm); }
.tp.rw .rw-band .tp-number:hover { color:var(--ink-2); text-decoration:underline; }
.tp.rw .rw-band .tp-number:focus-visible { outline:2px solid var(--spruce); outline-offset:2px; }
.tp.rw .rw-band .tp-title-line #detailTitle { display:inline; margin:0; padding:0; font-size:var(--text-xl); font-weight:var(--weight-semibold); line-height:var(--leading-tight); letter-spacing:-0.01em; }
.tp.rw .rw-band .tp-title-line .tw-meta { display:inline-flex; align-items:center; gap:var(--space-75); }
.tp.rw .rw-band > .detail-header .detail-actions { display:flex; flex:1 1 18rem; flex-wrap:nowrap; align-items:center; justify-content:flex-end; gap:var(--space-75); min-width:0; max-width:100%; margin-left:auto; }
/* The bar is as wide as its buttons while they fit, and shrinks when they don't (tbFit then moves the last into More). */
.tp.rw .rw-band > .detail-header .detail-actions > .tb-wrap { flex:0 1 auto; min-width:0; }
.tp.rw .rw-band .detail-save-status { flex:0 0 auto; order:-1; color:var(--muted); font-size:var(--text-xs); white-space:nowrap; transition:opacity .3s; }
.tp.rw .rw-band .detail-save-status.rw-gone:not(.refused):not(.saving) { opacity:0; pointer-events:none; }
.tp.rw .rw-band .detail-save-status.refused { color:var(--warn-ink); white-space:normal; max-width:22rem; }
.tp.rw .rw-panel-button { display:none; }
/* Row 3: who it is for (ticket-requester-line.js). */
.tp.rw .rw-band > #rqLine { margin:0; padding:0 0 var(--space-75); }
/* Row 4: the values, one quiet row of label-over-value pairs (ticket-strip.js). */
.tp.rw .rw-band > .tf-strip, .ticket-detail.tw.ts-compact.rw .rw-band > .tf-strip { display:flex; flex-wrap:wrap; align-items:stretch; max-width:none; margin:0; padding:var(--space-50) 0; border:0; border-top:1px solid var(--line); border-radius:0; background:transparent; }
.ticket-detail.tw.ts-compact.rw .tf-strip > .ts-row { flex:0 1 auto; min-width:7rem; max-width:20rem; padding:var(--space-25) var(--space-150); border-left:1px solid var(--line); }
.ticket-detail.tw.ts-compact.rw .tf-strip > .ts-row:first-child { padding-left:0; border-left:0; }
.ticket-detail.tw.ts-compact.rw .tf-strip .ts-label { padding:0 var(--space-100); color:var(--muted); font-size:var(--text-xs); }
.ticket-detail.tw.ts-compact.rw .tf-strip .ts-row .custom-select-trigger, .ticket-detail.tw.ts-compact.rw .tf-strip .ts-row .state-dropdown-trigger { padding-right:var(--space-200); }
/* Read as answers: the arrow shows only when the value is pointed at, focused or open. */
.ticket-detail.tw.ts-compact.rw .tf-strip .ts-row:not(:hover):not(:focus-within) .custom-select-wrapper:not(.open) .custom-select-trigger::after,
.ticket-detail.tw.ts-compact.rw .tf-strip .ts-row:not(:hover):not(:focus-within) .custom-state-dropdown:not(.open) .state-dropdown-trigger::after { opacity:0; }
/* A required field that is empty says "Required" in red; a filled one no longer shows the star. */
.ticket-detail.tw.ts-compact.rw .tf-strip .ts-label .required { display:none; }
/* The SLA: the page's one home for it, and its only red. */
.ticket-detail.tw.ts-compact.rw .tf-strip .tf-sla-value { display:inline-flex; align-items:center; gap:var(--space-50); margin:0; padding:var(--space-25) var(--space-100); border:1px solid transparent; border-radius:var(--radius-md); background:none; color:var(--ink); font:inherit; font-size:var(--text-sm); font-weight:var(--weight-semibold); line-height:18px; text-align:left; cursor:pointer; overflow-wrap:anywhere; }
.ticket-detail.tw.ts-compact.rw .tf-strip .tf-sla-value:hover { border-color:var(--control-border); background:var(--hover-bg); }
.ticket-detail.tw.ts-compact.rw .tf-strip .tf-sla-value:focus-visible { outline:2px solid var(--spruce); outline-offset:0; }
.ticket-detail.tw.ts-compact.rw .tf-strip .tf-sla-value[data-tone="bad"] { color:var(--bad); }
.ticket-detail.tw.ts-compact.rw .tf-strip .tf-sla-value[data-tone="warn"] { color:var(--warn-ink); }
.tf-icon { flex:0 0 auto; width:14px; height:14px; fill:none; stroke:currentColor; stroke-width:1.5; stroke-linecap:round; stroke-linejoin:round; }
/* Assignment: the group and the person as one value, and its picker. */
.ticket-detail.tw.ts-compact.rw .tf-strip .tf-assign { position:relative; }
.ticket-detail.tw.ts-compact.rw .tf-assign-value { display:block; width:100%; margin:0; padding:var(--space-25) var(--space-200) var(--space-25) var(--space-100); border:1px solid transparent; border-radius:var(--radius-md); background:none; color:var(--ink); font:inherit; font-size:var(--text-sm); font-weight:var(--weight-semibold); line-height:18px; text-align:left; cursor:pointer; overflow-wrap:anywhere; }
.ticket-detail.tw.ts-compact.rw .tf-assign-value:hover:not([aria-disabled="true"]), .ticket-detail.tw.ts-compact.rw .tf-assign-value[aria-expanded="true"] { border-color:var(--control-border); background:var(--hover-bg); }
.ticket-detail.tw.ts-compact.rw .tf-assign-value:focus-visible { outline:2px solid var(--spruce); outline-offset:0; }
.ticket-detail.tw.ts-compact.rw .tf-assign-value[aria-disabled="true"] { color:var(--ink-2); cursor:default; }
.tf-assign-pick { position:absolute; top:calc(100% + var(--space-25)); left:0; z-index:var(--z-menu); width:min(20rem, 90vw); max-height:22rem; overflow:auto; padding:var(--space-75); border:1px solid var(--line-strong); border-radius:var(--radius-lg); background:var(--surface); box-shadow:var(--shadow); }
.tf-assign-pick[hidden] { display:none; }
.tf-pick-search { width:100%; box-sizing:border-box; margin:0 0 var(--space-50); }
.tf-pick-head { display:flex; flex-wrap:wrap; align-items:center; gap:var(--space-50); margin:var(--space-50) var(--space-75) var(--space-25); color:var(--muted); font-size:var(--text-xs); }
.tf-pick-note { margin:var(--space-50) var(--space-75); color:var(--muted); font-size:var(--text-xs); }
.tf-pick-list { display:grid; gap:var(--space-25); margin:0; padding:0; list-style:none; }
.tf-pick-item { display:flex; align-items:center; gap:var(--space-75); width:100%; min-height:32px; padding:var(--space-50) var(--space-75); border:0; border-radius:var(--radius-md); background:none; color:var(--ink); font:inherit; font-size:var(--text-sm); text-align:left; cursor:pointer; }
.tf-pick-item:hover, .tf-pick-item:focus-visible { background:var(--hover-bg); outline:none; }
.tf-pick-item:focus-visible { box-shadow:inset 0 0 0 2px var(--spruce); }
.tf-pick-item.is-chosen { background:var(--spruce-pale); color:var(--spruce-dark); font-weight:var(--weight-semibold); }
.tf-pick-item[aria-disabled="true"] { color:var(--muted); cursor:default; }
.tf-pick-words { flex:1 1 auto; min-width:0; overflow-wrap:anywhere; }
.tf-pick-you { color:var(--muted); font-weight:var(--weight-regular); }
.tf-pick-next, .tf-pick-check { flex:0 0 auto; color:var(--muted); }
.tf-pick-item.is-chosen .tf-pick-check { color:var(--spruce-dark); }

/* ---------- One line for a live situation ---------- */
.tp.rw > .rw-banners { display:grid; gap:0; }
.tp.rw > .rw-banners:not(:has(> :not([hidden]))) { display:none; }
.tp.rw > .rw-banners > :not([hidden]) { margin:0 !important; border-radius:0 !important; border-left:0 !important; border-right:0 !important; border-top:0 !important; padding-inline:var(--rw-pad) !important; }

/* ---------- The panes ---------- */
.tp.rw > .detail-body { display:grid; grid-template-columns:minmax(0, 1fr) var(--rw-panel-w, 360px); gap:0; max-width:none; margin:0; padding:0; }
.tp.rw .detail-main { display:flex; flex-direction:column; min-width:0; min-height:0; background:var(--paper); }
.tp.rw .detail-main > .comments-panel { display:flex; flex:1 1 auto; flex-direction:column; min-height:0; margin:0 !important; padding:0; border:0; border-radius:0; background:transparent; box-shadow:none; }
.tp.rw .detail-main > .comments-panel > .detail-tabs { display:none; }
.tp.rw .tp-conversation { display:flex; flex:1 1 auto; flex-direction:column; gap:0; min-height:0; margin:0; }
/* The conversation's filters, pinned at its top. */
.tp.rw .tp-conversation > .cv-bar { position:sticky; top:0; z-index:1; flex:0 0 auto; min-height:40px; margin:0; padding:var(--space-50) var(--rw-pad); border-bottom:1px solid var(--line); background:var(--surface); }
/* The stream: the original request first, the messages, changes as gray lines. */
.tp.rw .rw-stream { position:relative; display:flex; flex:1 1 auto; flex-direction:column; gap:var(--space-150); min-height:0; padding:var(--space-200) var(--rw-pad); }
.tp.rw .rw-stream > [hidden] { display:none !important; }
.tp.rw .rw-stream > .comment-history { display:grid; gap:var(--space-150); margin:0; padding:0; }
.tp.rw .rw-new-reply { position:sticky; bottom:var(--space-100); align-self:center; z-index:1; margin-top:auto; padding:var(--space-50) var(--space-150); border:1px solid var(--line-strong); border-radius:var(--radius-pill); background:var(--surface); color:var(--spruce-dark); font:inherit; font-size:var(--text-sm); font-weight:var(--weight-semibold); box-shadow:var(--shadow); cursor:pointer; }
/* The original request: who asked and when, its kind at the right, Edit as a pencil. */
.tp.rw #twDescription { margin:0; padding:var(--space-150) var(--space-175, 14px); border:1px solid var(--line); border-radius:var(--radius-lg); background:var(--surface); }
.tp.rw #twDescription > .tw-section-head { display:flex; align-items:center; gap:var(--space-75); margin:0 0 var(--space-75); }
.tp.rw #twDescription .rw-avatar, .tp.rw .rw-avatar { display:inline-grid; flex:0 0 auto; place-items:center; width:22px; height:22px; border:1px solid var(--line); border-radius:var(--radius-round); background:var(--surface-2); color:var(--ink-2); font-size:var(--text-2xs); font-weight:var(--weight-bold); }
.tp.rw #twDescription .rw-who { flex:1 1 auto; min-width:0; color:var(--ink); font-size:var(--text-sm); }
.tp.rw #twDescription .rw-when { color:var(--muted); }
.tp.rw #twDescription .rw-kind { order:2; margin:0; color:var(--muted); font-size:var(--text-xs); font-weight:var(--weight-semibold); letter-spacing:.04em; text-transform:uppercase; }
.tp.rw #twDescription .rw-pencil { order:3; display:inline-grid; place-items:center; width:26px; height:26px; padding:0; border:1px solid transparent; border-radius:var(--radius-md); background:none; color:var(--muted); opacity:0; }
.tp.rw #twDescription:hover .rw-pencil, .tp.rw #twDescription .rw-pencil:focus-visible { opacity:1; }
.tp.rw #twDescription .rw-pencil:hover { border-color:var(--control-border); color:var(--ink); }
.tp.rw .rw-pencil svg { width:14px; height:14px; fill:none; stroke:currentColor; stroke-width:1.5; stroke-linejoin:round; }
.tp.rw #twDescription .tp-description-by { display:none; }

/* ---------- The reply box, docked ---------- */
.tp.rw .comment-composer.rw-dock > .comment-avatar { display:none; }
.tp.rw .comment-composer.rw-dock { display:block; position:relative; flex:0 0 auto; margin:0; padding:0 var(--rw-pad) var(--space-150); background:var(--paper); }
.tp.rw .comment-composer.rw-dock .composer-card { position:relative; margin:0; border:1px solid var(--line-strong); border-radius:var(--radius-lg); background:var(--surface); box-shadow:none; }
.tp.rw .rw-reply-start { display:none; }
/* One line until used: Reply | Private note, "Reply to Ava Brooks…", AI help and R. */
.tp.rw .rw-dock.rw-closed .composer-card > :not(.tp-composer-head) { display:none !important; }
.tp.rw .rw-dock.rw-closed .tp-composer-head { border-bottom:0; }
.tp.rw .rw-dock.rw-closed .tp-composer-head .tp-inserts > :not(.ai-composer-wrap) { display:none !important; }
.tp.rw .rw-dock.rw-closed .rw-reply-start { order:1; display:flex; flex:1 1 auto; align-items:center; justify-content:space-between; gap:var(--space-100); min-height:36px; margin:0; padding:0 var(--space-100); border:0; border-radius:var(--radius-md); background:none; color:var(--muted); font:inherit; font-size:var(--text-sm); text-align:left; cursor:text; }
.tp.rw .rw-dock.rw-closed .rw-reply-start:hover { background:var(--hover-bg); }
.tp.rw .rw-dock.rw-closed .tp-inserts { order:2; }
.tp.rw .rw-reply-start kbd { padding:0 var(--space-50); border:1px solid var(--line-strong); border-radius:var(--radius-sm); color:var(--muted); font:inherit; font-size:var(--text-xs); }
.tp.rw .rw-reply-grip { position:absolute; top:-6px; left:50%; width:48px; height:10px; margin-left:-24px; border-radius:var(--radius-pill); cursor:row-resize; z-index:1; }
.tp.rw .rw-reply-grip::before { content:""; position:absolute; top:3px; left:12px; right:12px; height:4px; border-radius:var(--radius-pill); background:var(--line-strong); }
.tp.rw .rw-reply-grip:hover::before, .tp.rw .rw-reply-grip:focus-visible::before { background:var(--spruce); }
.tp.rw .rw-reply-grip:focus-visible { outline:none; }
.tp.rw .rw-dock.rw-closed .rw-reply-grip { display:none; }
.tp.rw .rw-dock #commentEditor { min-height:64px; overflow:auto; }

/* ---------- The side panel ---------- */
.tp.rw .detail-body > .detail-sidebar { position:relative; top:auto; display:block; align-self:stretch; min-width:0; max-height:none; margin:0; padding:0; border-left:1px solid var(--line-strong); background:var(--surface); }
.tp.rw .rw-grip { position:absolute; top:0; bottom:0; left:-4px; z-index:3; width:8px; cursor:col-resize; }
.tp.rw .rw-grip:hover, .tp.rw .rw-grip:focus-visible { background:linear-gradient(to right, transparent 3px, var(--spruce) 3px, var(--spruce) 5px, transparent 5px); outline:none; }
.tp.rw .rw-panel-close { display:none; }
.tp.rw .th-panel { margin:0; padding:0; border:0; background:transparent; }
.tp.rw .th-panel .th-panel-title.sr-only { position:absolute; }
.tp.rw .th-tabs { position:sticky; top:0; z-index:2; display:flex; align-items:stretch; gap:var(--space-25); height:40px; padding:0 var(--space-150); border-bottom:1px solid var(--line); background:var(--surface); }
.tp.rw .th-tab { position:relative; display:inline-flex; align-items:center; gap:var(--space-50); margin:0; padding:0 var(--space-100); border:0; background:none; color:var(--ink-2); font:inherit; font-size:var(--text-sm); font-weight:var(--weight-medium); cursor:pointer; }
.tp.rw .th-tab:hover { color:var(--ink); }
.tp.rw .th-tab[aria-selected="true"] { color:var(--spruce-dark); font-weight:var(--weight-semibold); box-shadow:inset 0 -2px 0 var(--spruce); }
.tp.rw .th-tab:focus-visible { outline:2px solid var(--spruce); outline-offset:-2px; }
.tp.rw .th-tab-count { padding:0 var(--space-75); border-radius:var(--radius-pill); background:var(--surface-2); color:var(--ink-2); font-size:var(--text-xs); font-weight:var(--weight-semibold); }
.tp.rw .th-tab-dot { width:7px; height:7px; border-radius:var(--radius-round); background:var(--spruce); }
.tp.rw .th-view { display:grid; align-content:start; gap:var(--space-150); padding:var(--space-150) var(--space-200) var(--space-200); }
.tp.rw .th-view[hidden] { display:none; }
.tp.rw .th-view .th-top:not(:has(> :not([hidden]))) { display:none; }
.tp.rw .ov-card:empty { display:none; }
/* Overview: cards. */
.tp.rw #thView-overview > .th-section:not([hidden]) { padding:var(--space-100) var(--space-150); border:1px solid var(--line); border-radius:var(--radius-lg); }
.tp.rw .th-head-static { display:flex; align-items:center; gap:var(--space-75); margin:0 0 var(--space-50); padding:0; color:var(--muted); font-size:var(--text-xs); font-weight:var(--weight-bold); letter-spacing:.06em; text-transform:uppercase; }
.tp.rw .th-head-static .th-line { margin-left:auto; color:var(--muted); font-weight:var(--weight-medium); letter-spacing:0; text-transform:none; }
/* Related: one line per section that has something, then Add. */
.tp.rw #thView-related { gap:0; }
.tp.rw #thView-related > .th-section:not([hidden]) + .th-section:not([hidden]) { border-top:1px solid var(--line); }
.tp.rw .th-view-empty { margin:var(--space-100) 0; color:var(--muted); font-size:var(--text-sm); }
.tp.rw .th-add-row { margin:var(--space-150) 0 0; padding-top:var(--space-100); border-top:1px solid var(--line); color:var(--muted); font-size:var(--text-sm); }
.tp.rw .th-add-label { margin-right:var(--space-25); }
/* Details: the fields, then People (CC and Watchers, each with its Add; no standing help sentence). */
.tp.rw #thView-details .detail-watchers-hint { display:none; }
.tp.rw #thView-details > .th-section:not([hidden]) + .th-section:not([hidden]) { padding-top:var(--space-150); border-top:1px solid var(--line); }

/* ---------- The fixed workspace (wide and tall enough) ---------- */
@media (min-width:701px) and (min-height:560px) {
  .ticket-detail.tw.tp.rw { display:flex; flex-direction:column; height:calc(100dvh - var(--rw-top, calc(var(--topbar-height) + var(--outage-banner-h, 0px) + var(--space-300))) - var(--space-200)); min-height:0; }
  .tp.rw > .rw-band, .tp.rw > .rw-banners, .tp.rw > #tpMissing { flex:0 0 auto; }
  .tp.rw > .detail-body { flex:1 1 auto; grid-template-rows:minmax(0, 1fr); min-height:0; }
  .tp.rw .detail-main { overflow:hidden; }
  .tp.rw .rw-stream { overflow-y:auto; overscroll-behavior:contain; }
  .tp.rw .detail-body > .detail-sidebar { overflow-y:auto; overscroll-behavior:contain; }
  /* Inside the panes nothing sits over what is scrolled to: only a little room (ticket-page.css keeps room for the top
     bar, which these panes are already under). The panel's tabs are pinned at its top. */
  .tp.rw .rw-stream *, .tp.rw .detail-sidebar * { scroll-margin-top:var(--space-150); }
  .tp.rw .detail-sidebar .th-view * { scroll-margin-top:var(--space-600); }
  body.tp-open .main-content:has(.tp.rw) { padding-bottom:0; }
  body.tp-open #viewContainer:has(> .ticket-page.open .tp.rw) { padding-bottom:var(--space-200); }
}
/* One page that scrolls (a short window, 200% zoom): the reply box stays at the bottom of the window. */
@media (max-height:559px), (max-width:700px) {
  .tp.rw .comment-composer.rw-dock { position:sticky; bottom:0; z-index:2; padding-top:var(--space-75); }
  .tp.rw .rw-grip, .tp.rw .rw-reply-grip { display:none; }
}

/* ---------- Below 1200 px: the panel is a drawer ---------- */
@media (min-width:701px) and (max-width:1199px) {
  .tp.rw > .detail-body { grid-template-columns:minmax(0, 1fr); }
  .tp.rw .rw-panel-button { display:inline-flex; align-items:center; min-height:32px; padding:0 var(--space-150); font-size:var(--text-sm); }
  .tp.rw .detail-body > .detail-sidebar { position:fixed; top:var(--rw-top, var(--topbar-height)); right:0; bottom:0; z-index:var(--z-drawer); width:min(var(--rw-panel-w, 360px), 92vw); overflow-y:auto; box-shadow:var(--shadow); visibility:hidden; transform:translateX(100%); }
  .tp.rw.rw-panel-open .detail-body > .detail-sidebar { visibility:visible; transform:none; }
  .tp.rw .rw-grip { display:none; }
  .tp.rw .rw-panel-close { position:absolute; top:var(--space-50); right:var(--space-75); z-index:3; display:inline-grid; place-items:center; width:32px; height:32px; padding:0; border:0; border-radius:var(--radius-md); background:none; color:var(--ink-2); font-size:var(--text-lg); cursor:pointer; }
  .tp.rw .rw-panel-close:hover { background:var(--hover-bg); }
  .tp.rw .th-tabs { padding-right:var(--space-500); }
  /* The values wrap to two lines. */
  .ticket-detail.tw.ts-compact.rw .tf-strip > .ts-row { flex:1 1 9rem; }
}
@media (prefers-reduced-motion:no-preference) {
  .tp.rw .detail-body > .detail-sidebar { transition:transform .18s ease, visibility .18s; }
}

/* ---------- The open reply box: its head, its menus, its foot ---------- */
.tp.rw .rw-dock .tp-composer-head { display:flex; flex-wrap:wrap; align-items:center; gap:var(--space-75); padding:var(--space-75) var(--space-100); border-bottom:1px solid var(--line); }
.tp.rw .rw-dock .tp-inserts { display:flex; flex-wrap:wrap; align-items:center; gap:var(--space-50); margin-left:auto; }
.tp.rw .rw-dock .rw-tool { display:inline-flex; align-items:center; gap:var(--space-50); min-height:28px; padding:0 var(--space-100); font-size:var(--text-sm); }
.tp.rw .rw-dock .rw-tool[aria-pressed="true"] { border-color:var(--spruce-pale); background:var(--spruce-pale); color:var(--spruce-dark); }
.tp.rw .rw-caret { display:inline-block; width:6px; height:6px; margin:0 0 var(--space-25) var(--space-25); border-right:1.5px solid currentColor; border-bottom:1.5px solid currentColor; transform:rotate(45deg); }
.tp.rw .rw-dock .rw-tool[aria-expanded="true"] .rw-caret { margin:var(--space-25) 0 0 var(--space-25); transform:rotate(225deg); }
.tp.rw .rw-attach { position:relative; }
.tp.rw .rw-menu { position:absolute; right:0; bottom:calc(100% + var(--space-25)); z-index:var(--z-menu); display:grid; gap:var(--space-25); min-width:12rem; padding:var(--space-50); border:1px solid var(--line-strong); border-radius:var(--radius-lg); background:var(--surface); box-shadow:var(--shadow); }
.tp.rw .rw-menu[hidden] { display:none; }
.tp.rw .rw-menu > .attach-button { display:flex; align-items:center; gap:var(--space-75); width:100%; min-height:32px; margin:0; padding:var(--space-50) var(--space-100); border:0; border-radius:var(--radius-md); background:none; color:var(--ink); font:inherit; font-size:var(--text-sm); text-align:left; }
.tp.rw .rw-menu > .attach-button:hover, .tp.rw .rw-menu > .attach-button:focus-visible { background:var(--hover-bg); outline:none; }
/* Aa: B, I, lists and link; the rest under More. */
.tp.rw .rw-dock .editor-toolbar.rw-format { padding:var(--space-50) var(--space-100); border-bottom:1px solid var(--line); }
.tp.rw .rw-dock .editor-toolbar.rw-format[hidden] { display:none; }
.tp.rw .rw-dock .editor-toolbar.rw-format .toolbar-divider { display:none; }
.tp.rw .rw-dock .editor-toolbar.rw-format:not(.rw-show-more) .rw-format-more { display:none; }
.tp.rw .rw-dock .editor-toolbar .rw-format-toggle { width:auto; margin-left:var(--space-50); padding:0 var(--space-75); border:0; background:none; color:var(--spruce-dark); font:inherit; font-size:var(--text-sm); font-weight:var(--weight-semibold); cursor:pointer; }
/* The To line: To Ava Brooks   + CC. */
.tp.rw .rw-dock .tp-to-cc { padding:var(--space-50) var(--space-150); border-bottom:1px solid var(--line); }
.tp.rw .rw-dock .tp-to-line { display:flex; flex-wrap:wrap; align-items:center; gap:var(--space-50) var(--space-150); color:var(--ink-2); font-size:var(--text-sm); }
.tp.rw .rw-dock .tp-to-name { color:var(--ink); font-weight:var(--weight-semibold); }
.tp.rw .rw-dock .tp-cc-line { display:inline-flex; flex-wrap:wrap; align-items:center; gap:var(--space-50); }
.tp.rw .rw-dock .tp-to-cc-note { margin:0; color:var(--ink-2); font-size:var(--text-sm); }
.tp.rw .rw-dock #commentEditor { margin:var(--space-100) var(--space-150) 0; }
/* The foot: who gets it, Time spent, Send. */
.tp.rw .rw-dock .composer-footer { display:flex; flex-wrap:wrap; align-items:center; gap:var(--space-75) var(--space-100); padding:var(--space-100) var(--space-150); }
.tp.rw .rw-dock .rw-foot-said { display:grid; flex:1 1 14rem; gap:var(--space-25); min-width:0; color:var(--muted); font-size:var(--text-sm); }
.tp.rw .rw-dock .rw-foot-said .tp-reach { margin:0; }
.tp.rw .rw-dock .rw-foot-said .composer-owner-note { margin:0; padding:0; border:0; background:none; color:var(--ink-2); font-size:var(--text-sm); }
.tp.rw .rw-dock .tw-post-group { margin-left:auto; }
.tp.rw .rw-time { position:relative; }
.tp.rw .rw-time-said:not(:empty) { font-size:var(--text-sm); }
.tp.rw .rw-time-box { position:absolute; bottom:calc(100% + var(--space-50)); left:0; z-index:var(--z-menu); display:grid; gap:var(--space-75); min-width:16rem; padding:var(--space-150); border:1px solid var(--line-strong); border-radius:var(--radius-lg); background:var(--surface); box-shadow:var(--shadow); }
.tp.rw .rw-time-box[hidden] { display:none; }
.tp.rw .rw-time-box > label { display:flex; align-items:center; gap:var(--space-75); margin:0; }
/* A private note: the box is tinted, and says only staff see it. */
.tp.rw .rw-dock.rw-note .composer-card { border-color:var(--saffron); background:var(--saffron-pale); }
.tp.rw .rw-dock.rw-note .tp-composer-head, .tp.rw .rw-dock.rw-note .tp-to-cc, .tp.rw .rw-dock.rw-note .editor-toolbar.rw-format { border-color:color-mix(in srgb, var(--saffron) 45%, var(--line)); }
/* Insert ▾: one search over templates, macros and articles. */
.rw-insert { position:fixed; z-index:var(--z-popover); display:grid; grid-template-rows:auto minmax(0, 1fr); width:min(22rem, calc(100vw - 24px)); max-height:min(26rem, 60vh); padding:var(--space-75); border:1px solid var(--line-strong); border-radius:var(--radius-lg); background:var(--surface); box-shadow:var(--shadow); }
.rw-insert[hidden] { display:none; }
.rw-insert-search { width:100%; box-sizing:border-box; margin:0 0 var(--space-50); }
.rw-insert-list { overflow:auto; }
.rw-insert-group { margin:var(--space-75) var(--space-75) var(--space-25); color:var(--muted); font-size:var(--text-xs); font-weight:var(--weight-bold); letter-spacing:.04em; text-transform:uppercase; }
.rw-insert-item { display:grid; gap:var(--space-25); width:100%; padding:var(--space-50) var(--space-75); border:0; border-radius:var(--radius-md); background:none; color:var(--ink); font:inherit; font-size:var(--text-sm); text-align:left; cursor:pointer; }
.rw-insert-item small { color:var(--muted); font-size:var(--text-xs); overflow-wrap:anywhere; }
.rw-insert-item:hover, .rw-insert-item:focus-visible { background:var(--hover-bg); outline:none; }
.rw-insert-item:focus-visible { box-shadow:inset 0 0 0 2px var(--spruce); }
.rw-insert-item[aria-disabled="true"] { color:var(--muted); cursor:default; }
.rw-insert-empty { margin:var(--space-100); color:var(--muted); font-size:var(--text-sm); }

/* ---------- A phone (700 px and narrower): one column, tabs Messages · Overview · Related · Details ---------- */
@media (max-width:700px) {
  .ticket-detail.tw.tp.rw { --rw-pad:var(--space-150); border-radius:var(--radius-md); }
  .tp.rw > .detail-body { grid-template-columns:minmax(0, 1fr); }
  /* Row 1 stays one row: the way back (its words wrap inside their own box when they must), the pager and Recent
     tickets. */
  .tp.rw .rw-band > .tw-nav { flex-wrap:nowrap; gap:var(--space-50); }
  .tp.rw .rw-band > .tw-nav > .page-breadcrumb { min-width:0; }
  .tp.rw .rw-band > .tw-nav > .tw-pager, .tp.rw .rw-band > .tw-nav > .rt { flex:none; }
  /* Row 2: the number and title, with Watch at the right of the same row. The title keeps at least 12rem, so a
     refused save's longer words move to a row of their own instead of squeezing it. */
  .tp.rw .rw-band > .detail-header { align-items:flex-start; gap:var(--space-50) var(--space-100); }
  .tp.rw .rw-band > .detail-header > .tp-title-column { flex:1 1 0; min-width:min(12rem, 100%); }
  .tp.rw .rw-band > .detail-header .detail-actions { position:relative; flex:0 0 auto; justify-content:flex-end; gap:0; width:auto; }
  .tp.rw .rw-band .tp-title-line #detailTitle { font-size:var(--text-lg); }
  /* "Saving…" and "Saved" show small under the eye, laid over the space there, so nothing on the page moves while they
     come and go; they take no room while gone. A refused save's words take a row of their own under the title, the eye
     beside them. */
  .tp.rw .rw-band .detail-save-status:not(.refused) { position:absolute; top:100%; right:0; z-index:1; order:1; padding:0; background:none; font-size:var(--text-2xs); pointer-events:none; }
  .tp.rw .rw-band .detail-save-status.refused { order:-1; flex:1 1 0; min-width:0; max-width:none; contain:none; }
  .tp.rw .rw-band > .detail-header:has(.detail-save-status.refused) .detail-actions { flex:1 1 100%; align-items:flex-start; }
  .tp.rw .rw-band .detail-save-status.rw-gone:not(.refused):not(.saving) { display:none !important; }
  /* The tabs: Messages and the panel's three views, 44 px targets. */
  .tp.rw.tpb-phone .detail-main > .comments-panel > .detail-tabs { display:flex; margin:0; padding:0 var(--rw-pad); border-bottom:1px solid var(--line); background:var(--surface); }
  .tp.rw.tpb-phone.tpb-help .detail-main { background:var(--surface); }
  .tp.rw .detail-body > .detail-sidebar { border-left:0; }
  /* The values as chips (ticket-sidebar-moves.js), inside the page's gutter. */
  .tp.rw .detail-main > .ts-phone-bar { margin:0; padding:var(--space-100) var(--rw-pad); border-bottom:1px solid var(--line); background:var(--surface); }
  /* Messages shows the conversation; a view tab shows the panel on that view (ticket-phone.js). */
  .tp.rw.tpb-phone:not(.tpb-help) .detail-body > .detail-sidebar { display:none; }
  /* The bar at the bottom and its sheet have every action (ticket-phone.css): the title row keeps Watch only. */
  .tp.rw.tpb-phone .rw-band > .detail-header .tb-wrap { display:none; }
  .tp.rw .th-view { padding:var(--space-150) var(--rw-pad); }
  /* The reply box docked at the bottom of Messages, above the bar (ticket-phone.css). */
  body.tpb-on .tp.rw .comment-composer.rw-dock { bottom:var(--tpb-h, 64px); }
  /* One line on a phone: only "Reply to Ava Brooks…" until it is used (Reply or Private note is chosen once open). */
  .tp.rw .rw-dock.rw-closed .tp-composer-head > .tp-composer-tabs, .tp.rw .rw-dock.rw-closed .tp-composer-head > .tp-inserts { display:none !important; }
  .tp.rw .rw-dock.rw-closed .rw-reply-start { min-height:44px; }
  body.tpb-on #ticketDetailModal .ticket-detail.tp.rw { padding-bottom:0; }
  body.tpb-on #viewContainer:has(> .ticket-page.open .tp.rw) { padding-bottom:calc(var(--tpb-h, 64px) + var(--space-150)); }
}

/* ---------- Icon buttons: Recent tickets, Keyboard shortcuts, Watch, the conversation's order ---------- */
.tp.rw .rw-band .rt-button.rt-icon, .tp.rw .rw-band .tw-shortcuts-button, .tp.rw .cv-sort-toggle { display:inline-grid; place-items:center; width:28px; height:28px; min-height:0; margin:0; padding:0; border:1px solid transparent; border-radius:var(--radius-md); background:none; color:var(--muted); cursor:pointer; }
.tp.rw .rw-band .rt-button.rt-icon:hover, .tp.rw .rw-band .tw-shortcuts-button:hover, .tp.rw .cv-sort-toggle:hover { border-color:var(--control-border); background:var(--hover-bg); color:var(--ink); }
.tp.rw .rw-band .rt-button.rt-icon svg, .tp.rw .rw-band .tw-shortcuts-button svg, .tp.rw .cv-sort-toggle svg { width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:1.5; stroke-linecap:round; stroke-linejoin:round; }
.tp.rw .cv-sort-toggle[aria-pressed="true"] { border-color:var(--spruce-pale); background:var(--spruce-pale); color:var(--spruce-dark); }
.tp.rw .rw-band .tb-watch { width:32px; height:32px; padding:0; justify-content:center; border-color:transparent; border-radius:var(--radius-md); background:none; color:var(--ink-2); }
.tp.rw .rw-band .tb-watch::before { content:none; }
.tp.rw .rw-band .tb-watch:hover { border-color:var(--control-border); background:var(--hover-bg); }
.tp.rw .rw-band .tb-watch[aria-pressed="true"] { border-color:transparent; background:var(--spruce-pale); color:var(--spruce-dark); }
.tb-eye { width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:1.5; stroke-linejoin:round; }
.tb-watch[aria-pressed="true"] .tb-eye path { fill:currentColor; fill-opacity:.18; }
.tp.rw .tb-watch-count { min-width:20px; height:20px; margin-left:calc(-1 * var(--space-75)); padding:0 var(--space-50); border:0; border-radius:var(--radius-pill); background:var(--surface-2); color:var(--ink-2); font:inherit; font-size:var(--text-xs); font-weight:var(--weight-semibold); cursor:pointer; }
.tp.rw .tb-watch-count[hidden] { display:none; }
.tp.rw .cv-tools { display:flex; align-items:center; gap:var(--space-100); }
@media (max-width:700px) {
  .tp.rw .rw-band .tb-watch { flex:0 0 auto; width:44px; height:44px; }
  .tp.rw .rw-band .rt-button.rt-icon, .tp.rw .rw-band .tw-shortcuts-button, .tp.rw .cv-sort-toggle { width:44px; height:44px; }
}
/* Between a phone and 900 px the conversation's chips would say the values row again: the row is in the header band
   here, no longer a sibling before the conversation (ticket-strip.css's rule for it), so it is said here. Where the
   values row is switched off, the chips stay. */
@media (min-width:701px) {
  .tp.rw:has(.rw-band > .tf-strip:not([hidden])) .detail-main > .ts-phone-bar { display:none !important; }
}
/* No keyboard on a phone or a tablet: no keyboard shortcuts button (as ticket-page.css has it; the icon rule above is
   more specific, so it says so again). */
@media (max-width:767px) {
  .tp.rw .rw-band .tw-shortcuts-button { display:none; }
}
