/* Copyright (c) Health Dynamics Consulting Ltd. All rights reserved. Proprietary: see LICENSE. */
/*
 * Layer 4 of 5: layout. The shell (top bar, side navigation, main, footer), the page header, column layouts and the
 * four page templates (list, record, question, check answers). Reflows at 1100px, 900px (the side navigation becomes
 * a drawer), 640px and 520px, and works at 320px.
 */

/* ================================================================ Top bar */
/* Hybrid app design (8 Nov 2026, Carbon UI shell): one white 56px bar with the 3px palette stripe under it. The menu
   button, the logo mark and short name, the breadcrumb and page title, then search, help and jobs as icon buttons,
   the organisation switcher and the person's initials. */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--wfp-topbar-height);
  display: flex; align-items: center; gap: var(--hd-space-1);
  padding: 0 var(--hd-space-3) 3px;
  background: var(--hd-surface);
}
.site-header::after { content: ""; position: absolute; inset: auto 0 0 0; height: 3px; background: var(--hd-palette-stripe); }
.brand { display: inline-flex; align-items: center; gap: var(--hd-space-2); height: var(--wfp-control); padding: 0 10px 0 6px; border-radius: var(--hd-radius-pill); flex: none; text-decoration: none; color: var(--hd-text); font-family: var(--font-heading); font-weight: 800; font-size: .95rem; white-space: nowrap; }
.brand:hover { background: var(--wfp-hover); color: var(--hd-text); }
.brand:focus-visible { outline: none; box-shadow: var(--hd-focus-ring); }
.brand img { display: block; width: 28px; height: 28px; }
.topbar-title { display: flex; align-items: center; gap: var(--hd-space-2); min-width: 0; flex: 1 1 auto; padding-left: var(--hd-space-3); margin-left: var(--hd-space-1); border-left: 1px solid var(--hd-border); min-height: 24px; }
.topbar-title:empty { border-left: 0; }
.topbar-title nav { flex: none; max-width: 50%; overflow: hidden; }
.topbar-title .crumbs-trail { flex-wrap: nowrap; margin: 0; font-size: .88rem; font-weight: 600; white-space: nowrap; }
.topbar-title .crumbs-trail a { color: var(--hd-text-soft); text-decoration: none; }
.topbar-title .crumbs-trail a:hover { color: var(--hd-text); text-decoration: underline; }
.topbar-title .crumbs-trail li:last-child::after { content: "/"; margin-left: var(--hd-space-2); color: var(--hd-muted); }
.topbar-title h1 { margin: 0; font-size: var(--hd-text-h3); font-weight: 800; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar-title nav:last-child .crumbs-trail li:last-child::after { content: none; }
.header-actions { display: flex; align-items: center; gap: var(--hd-space-1); margin-left: auto; flex: none; }
.topbar-divider { width: 1px; height: 24px; background: var(--hd-border); margin: 0 var(--hd-space-1); flex: none; }
.rail-toggle { flex: none; }

/* The organisation switcher, compact, and the person's initials. */
.header-org > summary { min-height: var(--wfp-control); max-width: 220px; padding: 0 10px 0 12px; border: 1px solid var(--hd-border-input); font-size: .85rem; }
.header-org > summary .label { max-width: 160px; }
.header-account > summary { min-height: var(--wfp-control); width: var(--wfp-control); padding: 0; justify-content: center; border: 0; position: relative; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--hd-oxford); color: #fff; font-family: var(--font-heading); font-weight: 700; font-size: .78rem; letter-spacing: .02em; }
.header-account .menu-panel { right: 0; left: auto; }

/* Jobs: an icon button with the count of jobs running as a badge. */
.icon-badge { position: absolute; top: 1px; right: -1px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: var(--hd-radius-pill); background: var(--hd-deep-blue); color: #fff; font-size: .7rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--hd-surface); line-height: 1; }

/* Search in the top bar: an icon that expands (8 Nov 2026), with recently viewed items before you type. */
.top-search { position: relative; display: flex; align-items: center; }
.top-search-box { display: none; position: relative; align-items: center; width: min(380px, 40vw); }
.top-search.is-open .top-search-open { display: none; }
.top-search.is-open .top-search-box { display: flex; }
.top-search-box > .icon { position: absolute; left: var(--hd-space-3); color: var(--hd-muted); pointer-events: none; }
.top-search-input { width: 100%; min-height: var(--wfp-control); padding: 0 44px 0 40px; border: 1px solid var(--hd-border-input); border-radius: var(--hd-radius-pill); background: var(--hd-surface); font: inherit; font-size: .9rem; color: var(--hd-text); }
.top-search-input::placeholder { color: var(--hd-muted); }
.top-search-input:focus-visible { outline: none; border-color: var(--hd-accent); box-shadow: var(--hd-focus-ring); }
.top-search-key { position: absolute; right: var(--hd-space-3); min-width: 22px; padding: 0 6px; border: 1px solid var(--hd-border); border-radius: 6px; font-family: var(--font-mono); font-size: 12px; color: var(--hd-muted); text-align: center; background: var(--hd-bg); pointer-events: none; }
.top-search-input:focus ~ .top-search-key { display: none; }
.top-search-panel { position: absolute; left: 0; right: 0; top: calc(100% + var(--hd-space-2)); z-index: 70; max-height: min(70vh, 480px); overflow-y: auto; background: var(--hd-surface); border: 1px solid var(--hd-border); border-radius: var(--hd-radius); box-shadow: var(--hd-shadow-md); padding: var(--hd-space-2); }
.top-search-heading { margin: var(--hd-space-1) var(--hd-space-3) var(--hd-space-2); font-weight: 700; font-size: .75rem; color: var(--hd-muted); letter-spacing: .06em; text-transform: uppercase; }
.top-search-empty { margin: var(--hd-space-2) var(--hd-space-3); color: var(--hd-muted); font-size: .9rem; }
.top-search-panel a { display: flex; flex-direction: column; gap: 2px; padding: var(--hd-space-2) var(--hd-space-3); border-radius: var(--hd-radius-sm); color: var(--hd-text); text-decoration: none; }
.top-search-panel a:hover, .top-search-panel a[aria-selected="true"] { background: var(--hd-tint-pink); }
.top-search-label { font-weight: 600; font-size: .95rem; }
.top-search-detail { font-size: var(--hd-text-small); color: var(--hd-muted); }

/* ================================================================ Shell and side navigation */
.shell { display: flex; flex: 1; min-height: 0; }

.rail { width: var(--hd-sidebar-width); flex: none; background: var(--hd-surface); border-right: 1px solid var(--hd-border); padding: var(--hd-space-3); }
.rail ul { list-style: none; margin: 0; padding: 0; }
.rail li + li { margin-top: 2px; }
.rail a {
  display: flex; align-items: center; gap: var(--hd-space-3); min-height: 40px; padding: var(--hd-space-2) 14px;
  border-radius: var(--hd-radius-pill); color: var(--hd-text); text-decoration: none;
  font-family: var(--font-heading); font-weight: 700; font-size: .92rem; text-transform: var(--hd-ui-case);
}
.rail a .icon { color: var(--hd-muted); }
.rail a:hover { background: var(--hd-grey-bg); }
.rail a[aria-current="page"] { background: var(--hd-tint-pink); color: var(--hd-cerise-dark); }
.rail a[aria-current="page"] .icon { color: var(--hd-cerise-dark); }
/* Section labels: the one uppercase exception. */
.rail .rail-section { margin: var(--hd-space-4) 12px var(--hd-space-1); font-family: var(--font-body); font-weight: 700; font-size: .75rem; color: var(--hd-muted); letter-spacing: .06em; text-transform: uppercase; }
.rail .rail-group { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 0; margin: 0; background: none; border: 0; cursor: pointer; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; text-align: left; min-height: 28px; }
.rail .rail-group:hover { color: var(--hd-text); }
.rail .rail-group .rail-group-icon { width: 16px; height: 16px; transition: transform var(--wfp-motion); }
.rail .rail-group[aria-expanded="false"] .rail-group-icon { transform: rotate(-90deg); }
.rail ul.is-folded { display: none; }
.rail .rail-area { display: flex; align-items: center; gap: var(--hd-space-3); margin: 0 12px var(--hd-space-2); font-family: var(--font-heading); font-weight: 700; font-size: 1rem; color: var(--hd-text); }
.rail-back { padding-bottom: var(--hd-space-2) !important; border-bottom: 1px solid var(--hd-border) !important; }
.rail-foot { margin-top: var(--hd-space-4) !important; padding-top: var(--hd-space-3) !important; border-top: 1px solid var(--hd-border) !important; }
.rail-collapse { display: flex; align-items: center; gap: var(--hd-space-3); width: 100%; min-height: 40px; padding: var(--hd-space-2) 14px; background: none; border: 0; border-radius: var(--hd-radius-pill); cursor: pointer; color: var(--hd-muted); font: inherit; font-size: 13px; text-align: left; }
.rail-collapse:hover { background: var(--hd-grey-bg); color: var(--hd-text); }
.rail-collapse .icon-expand { display: none; }
/* On a phone the organisation switcher and account menu are in the drawer, so the top bar fits 320px. */
.rail-account { display: none; }
.rail-account-current { margin: 0 12px var(--hd-space-2); font-weight: 600; overflow-wrap: anywhere; }
.rail-account-list { margin-bottom: var(--hd-space-3) !important; }
.rail-account-button { display: flex; align-items: center; gap: var(--hd-space-3); width: 100%; min-height: 40px; padding: var(--hd-space-2) 14px; border: 0; border-radius: var(--hd-radius-pill); background: none; color: var(--hd-text); font-family: var(--font-heading); font-weight: 700; font-size: .92rem; text-align: left; cursor: pointer; }
.rail-account-button:hover { background: var(--hd-grey-bg); }

/* Collapsed: icons only; labels stay for screen readers and show as a tooltip. */
body.rail-collapsed .rail { width: var(--rail-collapsed); padding: var(--hd-space-3) var(--hd-space-2); }
body.rail-collapsed .rail .label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
body.rail-collapsed .rail .rail-section { margin: var(--hd-space-3) var(--hd-space-2); height: 0; border-top: 1px solid var(--hd-border); }
body.rail-collapsed .rail a, body.rail-collapsed .rail-collapse { justify-content: center; padding: var(--hd-space-2); position: relative; }
body.rail-collapsed .rail-collapse .icon-collapse { display: none; }
body.rail-collapsed .rail-collapse .icon-expand { display: inline-block; }
body.rail-collapsed .rail .rail-area { justify-content: center; margin: 0 0 var(--hd-space-2); }
body.rail-collapsed .rail ul.is-folded { display: block; }
body.rail-collapsed .rail .rail-group { pointer-events: none; min-height: 0; }
body.rail-collapsed .rail .rail-group-icon { display: none; }
body.rail-collapsed .rail [data-tip]:hover::after, body.rail-collapsed .rail [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; left: calc(100% + var(--hd-space-2)); top: 50%; transform: translateY(-50%); z-index: 50;
  padding: var(--hd-space-1) var(--hd-space-3); border-radius: var(--hd-radius-sm); background: var(--hd-oxford); color: #fff;
  font-family: var(--font-body); font-weight: 400; font-size: 13px; white-space: nowrap; box-shadow: var(--hd-shadow-md); pointer-events: none;
}
/* The side navigation stays in view as the page scrolls on wider screens. */
@media (min-width: 900px) {
  .rail { position: sticky; top: var(--wfp-topbar-height); z-index: 40; align-self: flex-start; max-height: calc(100vh - var(--wfp-topbar-height)); overflow-y: auto; }
  body:not(.rail-collapsed) .shell { background: linear-gradient(to right, var(--hd-surface) calc(var(--hd-sidebar-width) - 1px), var(--hd-border) calc(var(--hd-sidebar-width) - 1px), var(--hd-border) var(--hd-sidebar-width), transparent var(--hd-sidebar-width)); }
  body.rail-collapsed .rail { position: static; align-self: stretch; max-height: none; overflow: visible; }
}

/* ================================================================ Help side panel (Carbon side panel, 8 Nov 2026) */
/* 340px, white, beside the work: it pushes the content rather than covering it, and is not modal. On a phone it is a
   full-screen sheet under the top bar. */
.help-panel { flex: none; width: var(--wfp-help-width); background: var(--hd-surface); border-left: 1px solid var(--hd-border); position: sticky; top: var(--wfp-topbar-height); align-self: flex-start; height: calc(100vh - var(--wfp-topbar-height)); overflow-y: auto; z-index: 35; }
.help-panel-head { display: flex; justify-content: space-between; align-items: center; gap: var(--hd-space-2); min-height: var(--wfp-toolbar-height); padding: var(--hd-space-2) var(--hd-space-2) var(--hd-space-2) var(--hd-space-5); border-bottom: 1px solid var(--hd-border); }
.help-panel-title { margin: 0; font-size: 1rem; }
.help-panel-body { padding: var(--hd-space-4) var(--hd-space-5) var(--hd-space-8); display: flex; flex-direction: column; gap: var(--hd-space-4); font-size: .9rem; }
.help-panel-body > * { margin: 0; }
.help-panel-body .lead { font-size: 1rem; max-width: none; }
.help-panel-body h3 { font-size: .95rem; margin: 0 0 var(--hd-space-1); }
.help-panel-body p { margin: 0 0 var(--hd-space-2); }
.help-panel-page-help:empty { display: none; }
.help-panel-keys ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--hd-space-1); }
.help-panel-keys kbd { display: inline-flex; min-width: 22px; justify-content: center; padding: 0 5px; border: 1px solid var(--hd-border-input); border-radius: 4px; font-family: var(--font-mono); font-size: .75rem; margin-right: var(--hd-space-2); background: var(--hd-surface); }
.icon-btn.is-on { background: var(--hd-oxford); color: #fff; }

/* ================================================================ Main */
.main { --main-pad-top: 28px; --main-pad-x: 40px; flex: 1; min-width: 0; padding: var(--main-pad-top) var(--main-pad-x) 64px; }
.main-inner { max-width: var(--hd-public-max); }
.main-inner.wide { max-width: none; }

/* The page toolbar (Fluent command bar, 8 Nov 2026): one 52px white row under the top bar, edge to edge, staying in
   view. View settings, filters and the month at the start; the first two actions, then More, at the end. */
.page-toolbar {
  position: sticky; top: var(--wfp-topbar-height); z-index: 30;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--hd-space-2);
  min-height: var(--wfp-toolbar-height);
  margin: calc(-1 * var(--main-pad-top)) calc(-1 * var(--main-pad-x)) 0;
  padding: 6px var(--main-pad-x);
  background: var(--hd-surface); border-bottom: 1px solid var(--hd-border);
}
.page-toolbar + .page-scrub, .page-toolbar[hidden] + .page-scrub { margin-left: calc(-1 * var(--main-pad-x)); margin-right: calc(-1 * var(--main-pad-x)); }
.page-toolbar[hidden] + .page-scrub { margin-top: calc(-1 * var(--main-pad-top)); }
.page-toolbar:not([hidden]) ~ .main-inner, .page-scrub:not([hidden]) ~ .main-inner { padding-top: var(--hd-space-5); }
.page-toolbar-start, .page-toolbar-end { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--hd-space-2); min-width: 0; }
.page-toolbar-start { flex: 1 1 auto; }
.page-toolbar-end { margin-left: auto; }
.page-toolbar-start:empty, .page-toolbar-end:empty { display: none; }
.page-toolbar-meta { margin: 0; color: var(--hd-text-soft); font-size: .88rem; }
.page-toolbar .tags { display: flex; flex-wrap: wrap; gap: var(--hd-space-1); }

/* The thin month slider (8 Nov 2026) under the toolbar on time-based pages. */
.page-scrub { display: flex; align-items: center; gap: 10px; min-height: var(--wfp-scrub-height); padding: 0 var(--main-pad-x); background: var(--hd-surface); border-bottom: 1px solid var(--hd-border); font-size: .76rem; font-weight: 600; color: var(--hd-text-soft); position: sticky; top: calc(var(--wfp-topbar-height) + var(--wfp-toolbar-height)); z-index: 29; }

/* Page header: breadcrumbs (below top level), caption, h1, a one-line lead, then the primary action on the right. */
.page-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: var(--hd-space-4); margin-bottom: var(--hd-space-6); }
.page-header-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1 1 420px; }
.page-header h1 { margin: 0; }
.page-header-actions { display: flex; flex-wrap: wrap; gap: var(--hd-space-3); align-items: center; }
.page-header.record-header { align-items: flex-start; border-bottom: 1px solid var(--hd-border); padding-bottom: var(--hd-space-5); }
.page-header-meta { color: var(--hd-muted); font-size: var(--wfp-text-hint); margin: 0; }
.caption { display: block; margin: 0; font-size: var(--wfp-text-caption); font-weight: 500; color: var(--hd-muted); }
.lead { margin: 0; font-size: var(--wfp-text-lead); font-weight: 500; color: var(--hd-text-soft); max-width: var(--wfp-lead-max); }
/* Older page head and hero band, styled as the page header. */
.page-head { margin-bottom: var(--hd-space-6); }
.page-head h1 { margin-bottom: 6px; }
.page-head p { color: var(--hd-text-soft); max-width: 720px; }
.page-head.space-between { align-items: flex-start; }
.hero-band { padding: 0; margin-bottom: var(--hd-space-6); }
.hero-band p { color: var(--hd-text-soft); max-width: 720px; }
.eyebrow { display: block; margin-bottom: 6px; font-size: var(--wfp-text-caption); font-weight: 500; color: var(--hd-muted); }

/* ================================================================ Column layouts */
.grid { display: grid; gap: var(--hd-space-5); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack > * + * { margin-top: var(--hd-space-4); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--hd-space-3); }
/* Reading pages: two-thirds and one-third. */
.l-split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--hd-space-6); align-items: start; }
.l-split > * { min-width: 0; }
.l-two-thirds { max-width: 760px; }
/* List page (compact filters, 7 Nov 2026, option A): the toolbar (Filters button, count and chips), then the
   280px filter panel as the left column when open, pushing the results; closed, the results take the full width.
   Without JavaScript the panel shows open. */
.l-list { display: flex; flex-direction: column; gap: var(--hd-space-4); }
.l-list-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--hd-space-3) var(--hd-space-4); }
.l-list-toolbar .filter-summary { margin: 0; flex: 1 1 auto; }
.l-list-body { display: grid; grid-template-columns: var(--hd-filter-column) minmax(0, 1fr); gap: var(--hd-space-6); align-items: start; }
.l-list-body > * { min-width: 0; }
@media (scripting: enabled) and (min-width: 900px) {
  .l-list[data-filters-open="false"] > .l-list-body { grid-template-columns: minmax(0, 1fr); }
  .l-list[data-filters-open="false"] > .l-list-body > .filter-panel { display: none; }
}
.l-list-results { display: flex; flex-direction: column; gap: var(--hd-space-4); }
/* Record (Case) page: the record header across, then a side menu and the content. */
.l-record { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: var(--hd-space-8); align-items: start; }
.l-record > * { min-width: 0; }
/* The side menu stays in view on long pages (15 Nov 2026), under the top bar and the Case's header line. */
@media (min-width: 900px) {
  .l-record > .case-contents { position: sticky; top: calc(var(--wfp-topbar-height) + var(--wfp-toolbar-height) + var(--hd-space-4)); max-height: calc(100vh - var(--wfp-topbar-height) - var(--wfp-toolbar-height) - var(--hd-space-6)); overflow-y: auto; }
}
/* Question page: one decision per page, a narrow column. Check answers uses the same column with a summary list. */
.l-question { max-width: 720px; }
.l-question h1, .l-question .fieldset-legend-page { margin-bottom: var(--hd-space-6); }

/* ================================================================ Footer */
.site-footer { background: var(--hd-oxford); color: #fff; font-size: .88rem; position: relative; padding: var(--hd-space-6) var(--gutter); }
.site-footer::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--hd-palette-stripe); }
.site-footer a { color: #fff; }
.site-footer a:hover { color: var(--hd-tint-pink); }
.site-footer :focus-visible { outline-color: #fff; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--hd-space-4); }
.footer-links { display: flex; flex-wrap: wrap; gap: var(--hd-space-4); list-style: none; margin: 0; padding: 0; }
.footer-brand { font-family: var(--font-heading); font-weight: 700; }

/* ================================================================ Plain layout: sign in, install, notices */
body.plain { background: var(--hd-hero-gradient); background-attachment: fixed; }
.plain-header { padding: var(--hd-space-5) var(--gutter); }
.plain-header img { height: 44px; width: auto; display: block; }
.plain-main { flex: 1; padding: var(--hd-space-5) var(--gutter) var(--hd-space-10); }
.plain-card { max-width: 480px; margin: 0 auto; background: var(--hd-surface); border-radius: var(--hd-radius); box-shadow: var(--hd-shadow-md); padding: var(--hd-space-10) var(--hd-space-8); }
.plain-card.wide { max-width: 860px; }
.plain-card h1 { font-size: 1.6rem; }
.plain-card .outlined-pill { margin-bottom: var(--hd-space-5); }

/* ================================================================ Utilities (inline styles are blocked by the content security policy) */
.mt-0 { margin-top: 0; }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mb-0 { margin-bottom: 0; }
.mb-5 { margin-bottom: var(--space-5); }
.maxw-200 { max-width: 200px; }
.maxw-320 { max-width: 320px; }
.maxw-360 { max-width: 360px; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.qr-row { align-items: flex-start; gap: var(--space-6); }
.cerise-panel { background: var(--hd-cerise); padding: var(--space-4); border-radius: var(--hd-radius); }
.swatch-sm { width: 16px; height: 16px; display: inline-block; }

/* ================================================================ Reflow */
@media (max-width: 1100px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .l-split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 899px) {
  .main { --main-pad-top: var(--hd-space-6); --main-pad-x: var(--gutter); }
  .help-panel { position: fixed; top: var(--wfp-topbar-height); right: 0; bottom: 0; left: 0; width: auto; height: auto; z-index: 45; border-left: 0; box-shadow: var(--hd-shadow-md); }
  .topbar-title nav { max-width: 40%; }
  .rail { position: fixed; top: var(--wfp-topbar-height); bottom: 0; left: 0; z-index: 40; transform: translateX(-100%); transition: transform var(--wfp-motion); box-shadow: var(--hd-shadow-md); overflow-y: auto; }
  body.rail-open .rail { transform: none; }
  body.rail-collapsed .rail { width: var(--hd-sidebar-width); padding: var(--hd-space-3); }
  body.rail-collapsed .rail .label { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; white-space: normal; }
  body.rail-collapsed .rail .rail-section { margin: var(--hd-space-4) 12px var(--hd-space-1); height: auto; border-top: 0; }
  body.rail-collapsed .rail a { justify-content: flex-start; padding: var(--hd-space-2) 14px; }
  body.rail-collapsed .rail [data-tip]::after { display: none; }
  .rail-foot { display: none; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .main { padding-bottom: var(--hd-space-10); }
  .l-list-body, .l-record { grid-template-columns: minmax(0, 1fr); gap: var(--hd-space-5); }
  /* On a phone the panel opens only as the full-screen sheet (or shows open without JavaScript). */
  @media (scripting: enabled) { .l-list:not(.filters-sheet-open) > .l-list-body > .filter-panel { display: none; } }
}
@media (max-width: 639px) {
  h1 { font-size: 1.6rem; }
  .site-header { gap: 2px; padding: 0 6px 3px; }
  .brand { padding: 0 6px; }
  .brand-name, .topbar-title nav, .topbar-divider { display: none; }
  .topbar-title { border-left: 0; padding-left: 2px; margin-left: 0; }
  .header-actions { gap: 0; }
  .menu-panel, .case-actions .menu-panel, .toolbar-more .menu-panel, .header-account .menu-panel, .pick-menu .menu-panel { position: fixed; left: var(--hd-space-4); right: var(--hd-space-4); top: calc(var(--wfp-topbar-height) + var(--hd-space-2)); min-width: 0; width: auto; max-width: none; }
  .top-search.is-open .top-search-box { position: fixed; left: var(--hd-space-2); right: var(--hd-space-2); top: 8px; width: auto; z-index: 60; }
  .top-search-key { display: none; }
  .top-search-panel { position: fixed; left: var(--hd-space-4); right: var(--hd-space-4); top: calc(var(--wfp-topbar-height) + var(--hd-space-2)); }
  .rail-account { display: block; border-bottom: 1px solid var(--hd-border); margin-bottom: var(--hd-space-3); }
  .header-actions .header-org, .header-actions .header-account { display: none; }
  .main { padding-top: var(--hd-space-5); }
  .card { padding: var(--hd-space-5) var(--hd-space-4); }
  .plain-card { padding: var(--hd-space-6) var(--hd-space-4); }
  /* No sideways page scroll: long button labels wrap. */
  .btn { white-space: normal; max-width: 100%; text-align: center; }
}
@media (max-width: 520px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 359px) {
  .grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
}

@media print {
  .site-header, .rail, .site-footer, .toasts, .top-search, .help-panel, .page-toolbar, .page-scrub, .scroll-controls { display: none !important; }
  body { background: #fff; }
  .scroll-frame > .scroll-area::before, .scroll-frame > .scroll-area::after { display: none; }
}

/* ---- the post card and Profiles (D219 piece D, group 6), from the prototype */
/* A planned change in the post's history: its tag sits after the change's words. */
.history .history-planned { margin-left: var(--space-2); }
/* The post as at an earlier month: the card's facts layout, one column in the narrow right-hand stack. */
dl.post-fields { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-1) var(--space-3); margin: var(--space-2) 0 0; font-size: 14px; }
dl.post-fields dt { font-weight: 700; }
dl.post-fields dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
/* The post card's warnings and change state panel sit above the two columns. */
#posts-app[data-view="show"] > .warning-callout, #posts-app[data-view="show"] > div > .warning-callout { margin-bottom: var(--space-4); }
#posts-app[data-view="show"] .inline-panel[aria-labelledby="h-change-state"] { margin: 0 0 var(--space-4); }
/* Profiles: the choose-a-profile empty state fills the detail column; the competency count toolbar sits above its tables. */
.profile-detail > .empty-state { margin: 0; }
.profiles-body > .table-toolbar { margin-bottom: var(--space-3); }
