/*
 * OfficePress request record: the selected request in the queue's detail panel, the expanded record
 * (`/requests/:id/expanded`, also the no-script record) and paper output (stylesheet slot 11, after queues.css).
 * Only --op-* and the remapped --wf-* tokens appear here; paper gets light values because tokens.css keeps the dark
 * palette out of print, so no colour is written in this file. The look comes from design-drafts/r001-officepress-workspace
 * (DESIGN.md "Components -> Record / Actions and fields / Expanded record"); its sample data is not used.
 *
 * Shared record classes (reused by the guest review page, task 00009): put `record-surface` on the record's root and the
 * flat record rows apply to `.facts`/`.fact`, `.copy-block`, `.chip-list`, `.people-list`/`.person-row`,
 * `.comment-list`/`.comment`, `.file-list`/`.file-row`, `.timeline`, `.owner-actions`, the empty-state paragraphs
 * (`.wf-copy` directly inside a `.tab-panel` or `.record-section`) and the section pager (`.wf-row` nav). The same
 * class names are also drawn by the composer (`.file-row`, `.person-row`), so every rule below starts from
 * `.record-surface`; a page that does not carry it keeps the composer's look.
 *
 *   detail panel   `.queue-preview.record-surface`: header, full-width tabs, padded panels, decision bar pinned to the bottom
 *   record page    `.record-page`: reading column of 840px: header card, record card of flat sections, manage card
 *   phones         below 768px the decision bar stops sticking and its buttons share the row; controls reach 44px
 *   paper          light, no application chrome, sections flow across pages, every row kept together
 *
 * Status, selection and focus never rely on colour alone: status keeps its text and glyph (components.css), progress is
 * a strip of shapes with a text label, the guest-link marker is words, and focus is the shared 2px outline.
 * r005 rules this sheet must beat (r005/workspace.css loads later, wireframe.css earlier) are matched by specificity.
 */

/* ---------- Header: status, title, requester, progress ---------- */

.record-surface .preview-header {
  gap: var(--op-space-4);
  padding: var(--op-space-6) var(--op-space-6) var(--op-space-5);
  border-bottom: 1px solid var(--op-border);
}
.record-surface .preview-header > div:first-child { min-width: 0; flex: 1 1 auto; }
.record-surface .preview-header .wf-row { margin-bottom: var(--op-space-3); }

.record-surface .preview-title,
.record-page .detail-title-row h1 {
  margin: 0 0 var(--op-space-2);
  color: var(--op-text);
  font: var(--op-text-heading);
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.record-surface .preview-header .wf-copy,
.record-surface .detail-meta { color: var(--op-text-2); font-size: var(--wf-text-xs); }
.record-surface .preview-header .wf-copy { margin: 0; }
.record-surface .preview-header .wf-copy > span:not(.meta-join),
.record-surface .preview-header .meta-join > span:not(.meta-dot) { color: var(--op-text); font-weight: 700; }
.record-surface .detail-meta { gap: var(--op-space-1) var(--op-space-2); }

/* The requester's avatar sits beside "Requested by", as drawn. */
.preview-byline { display: flex; align-items: center; gap: var(--op-space-2); min-width: 0; }
.preview-byline .avatar { flex: none; width: 24px; height: 24px; font-size: 10px; }
.preview-byline .wf-copy { min-width: 0; overflow-wrap: anywhere; }

.record-surface .preview-progress { max-width: none; margin-top: var(--op-space-5); }
.record-surface .progress-label { margin-top: var(--op-space-2); color: var(--op-text-2); font-size: var(--wf-text-xs); }

.record-surface .preview-actions { flex: none; }
.record-surface .preview-actions .button--icon { color: var(--op-text); }

/* ---------- Tabs and panels ---------- */

.record-surface .preview-body,
.preview-skeleton .preview-body { padding: 0; }
.record-surface .tabs { gap: var(--op-space-6); padding: 0 var(--op-space-6); }
.record-surface .tab { min-height: 48px; padding: 0 0 var(--op-space-2); }
.record-surface .tab-panel { padding: var(--op-space-6); }

.preview-skeleton .preview-header { padding: var(--op-space-6) var(--op-space-6) var(--op-space-5); }
.preview-skeleton .skeleton-tabs { padding-inline: var(--op-space-6); }
.preview-skeleton .skeleton-copy,
.preview-skeleton .skeleton-facts { margin-inline: var(--op-space-6); }

/* ---------- Details: proposal, facts, tags, references ---------- */

.record-surface .copy-block { margin-top: var(--op-space-6); }
.record-surface .copy-block:first-child { margin-top: 0; }
.record-surface .copy-block h2,
.record-surface .copy-block h3 {
  margin: 0 0 var(--op-space-2);
  color: var(--op-text);
  font: var(--op-text-body);
  font-weight: 700;
}
.record-surface .copy-block p {
  margin: 0;
  color: var(--op-text);
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

/* Facts: a caption above its value, two to a row; the label is text, never colour alone. */
.record-surface .facts {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--op-space-5) var(--op-space-6);
  margin: var(--op-space-5) 0 0;
  padding: var(--op-space-5) 0 0;
  border-top: 1px solid var(--op-border);
}
.record-surface .fact { display: block; min-width: 0; padding: 0; border: 0; }
.record-surface .fact dt { margin: 0 0 6px; color: var(--op-text-2); font-size: var(--wf-text-2xs); }
.record-surface .fact dd {
  margin: 0;
  color: var(--op-text);
  font-size: var(--wf-text-sm);
  font-weight: 700;
  overflow-wrap: anywhere;
}
.record-surface .fact dd a { color: var(--op-link); }
.record-surface .copy-block .facts { margin-top: 0; padding-top: 0; border-top: 0; }
/* The panel above the facts is a sentence; the line between them is enough. */
.record-surface .copy-block + .facts { margin-top: var(--op-space-6); }

.record-surface .chip-list { gap: var(--op-space-2); }
.record-surface .chip {
  min-height: 24px;
  padding: 0 var(--op-space-3);
  border-color: var(--op-border);
  background: var(--op-sunken);
  color: var(--op-text);
  font-size: var(--wf-text-xs);
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* ---------- People, comments, files: flat rows between dividers ---------- */

.record-surface .people-list,
.record-surface .comment-list,
.record-surface .file-list { gap: 0; }

.record-surface .person-row,
.record-surface .comment,
.record-surface .file-row {
  align-items: flex-start;
  flex-wrap: nowrap;
  gap: var(--op-space-3);
  padding: var(--op-space-4) 0;
  border: 0;
  border-top: 1px solid var(--op-border);
  border-radius: 0;
  background: transparent;
}
.record-surface .person-row:first-child,
.record-surface .comment:first-child,
.record-surface .file-row:first-child { border-top: 0; padding-top: 0; }
.record-surface .person-row:last-child,
.record-surface .comment:last-child,
.record-surface .file-row:last-child { padding-bottom: 0; }

.record-surface .person-row > :nth-child(2),
.record-surface .file-row > :nth-child(2),
.record-surface .comment-body { flex: 1 1 0; min-width: 0; overflow-wrap: anywhere; }
.record-surface .person-row strong,
.record-surface .file-row strong,
.record-surface .comment strong { display: block; color: var(--op-text); font-size: var(--wf-text-sm); }
.record-surface .person-row small,
.record-surface .file-row small,
.record-surface .comment small { display: block; color: var(--op-text-2); font-size: var(--wf-text-xs); }
.record-surface .person-row > .badge,
.record-surface .file-row > .badge,
.record-surface .file-row > .button { flex: none; margin-left: auto; white-space: nowrap; }
.record-surface .person-row .avatar,
.record-surface .comment .avatar { flex: none; }
.record-surface .person-reason { margin: var(--op-space-1) 0 0; color: var(--op-text); font-size: var(--wf-text-xs); }

.record-surface .comment-body > small { margin-top: 2px; }
.record-surface .comment-body > p {
  margin: var(--op-space-2) 0 0;
  color: var(--op-text);
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: pre-line;
}
.record-surface .comment-role { color: var(--op-text-2); font-size: var(--wf-text-xs); font-weight: 400; }
/* A comment made through a guest link says so in words and in an outlined tag, so it reads on paper too. */
.record-surface .comment-role--guest {
  display: inline-block;
  margin-left: var(--op-space-1);
  padding: 0 var(--op-space-2);
  border: 1px solid var(--op-control-border);
  border-radius: var(--op-radius-full);
  color: var(--op-text);
  font-size: var(--wf-text-2xs);
  font-weight: 700;
  line-height: 18px;
}

/* Files: the icon is a plain glyph, the name carries the row. */
.record-surface .file-row > [data-icon]:first-child { margin-top: 2px; color: var(--op-text-2); }
.record-surface .file-row .badge { color: var(--op-text); }

/* ---------- Activity ---------- */

.record-surface .timeline { gap: 0; }
.record-surface .timeline-item { grid-template-columns: 28px minmax(0, 1fr); gap: var(--op-space-3); padding-bottom: var(--op-space-5); }
.record-surface .timeline-item:last-child { padding-bottom: 0; }
.record-surface .timeline-item:not(:last-child)::before { top: 30px; left: 13px; background: var(--op-border-strong); }
.record-surface .timeline-mark {
  width: 28px;
  height: 28px;
  padding: 6px;
  border-color: var(--op-control-border);
  background: var(--op-surface);
  color: var(--op-text-2);
}
.record-surface .timeline-item p { color: var(--op-text); font-size: var(--wf-text-sm); overflow-wrap: anywhere; }
.record-surface .timeline-item p.wf-copy { margin-top: 2px; color: var(--op-text-2); font-size: var(--wf-text-xs); }
.record-surface .timeline-item time { display: block; margin-top: 2px; color: var(--op-text-2); font-size: var(--wf-text-xs); }

/* ---------- Empty sections and the section pager ---------- */

.record-surface .tab-panel > .wf-copy,
.record-surface .record-section > .wf-copy {
  margin: 0;
  padding: var(--op-space-5);
  border: 1px dashed var(--op-border-strong);
  border-radius: var(--op-radius-8);
  color: var(--op-text-2);
  font-size: var(--wf-text-sm);
  text-align: center;
}
.record-surface .tab-panel > nav.wf-row,
.record-surface .record-section > nav.wf-row { gap: var(--op-space-2); margin-top: var(--op-space-4); }
.empty-action { margin: var(--op-space-4) 0 0; }

/* ---------- Comment composer ---------- */

.record-surface .form-grid { gap: var(--op-space-3); margin-top: var(--op-space-5); }
.record-surface .form-grid .textarea { min-height: 96px; }
.record-surface .form-grid > div:has(> .button) { display: flex; justify-content: flex-end; }
.record-surface .tab-panel > .form-grid:first-child,
.record-surface .tab-panel > .wf-copy + .form-grid { margin-top: var(--op-space-6); }

/* ---------- Actions: decision, owner, recovery, guest links ---------- */

.record-surface .owner-actions {
  gap: var(--op-space-3) var(--op-space-4);
  margin: 0;
  padding: var(--op-space-4) var(--op-space-6);
  border: 0;
  border-top: 1px solid var(--op-border);
  border-radius: 0;
  background: var(--op-surface);
}
.record-surface .owner-actions > div:first-child { min-width: min(100%, 240px); flex: 1 1 240px; }
.record-surface .owner-actions h3 { margin: 0 0 var(--op-space-1); color: var(--op-text); font: var(--op-text-body); font-weight: 700; }
.record-surface .owner-actions .wf-copy,
.record-surface .owner-actions .help { margin: 0; color: var(--op-text-2); font-size: var(--wf-text-xs); }
.record-surface .owner-actions .wf-row { flex-wrap: wrap; justify-content: flex-end; gap: var(--op-space-2); }

/* Side by side, the panel is a column so a short record still has its decision bar at the foot; when stacked the
   panel keeps the queue sheet's block display (it is hidden until a request opens) and the bar follows the content. */
@media (min-width: 768px) {
  @container queues (min-width: 661px) {
    .page--queues .queue-layout .queue-preview.record-surface { display: flex; flex-direction: column; }
    .queue-preview.record-surface > * { flex: none; }
    .queue-preview.record-surface > .owner-actions--decision { margin-top: auto; }
  }
}

/* The decision bar stays at the bottom of the panel while the record scrolls. */
.queue-preview.record-surface .owner-actions--decision {
  position: sticky;
  bottom: 0;
  z-index: 2;
  border-top-color: var(--op-border-strong);
  box-shadow: 0 -1px 0 var(--op-border);
}
.queue-preview.record-surface .owner-actions--cancel { background: var(--op-sunken); }

/* Recovery after an uncertain command: a banner with its own heading and a heavy bar, not only a hue. */
.record-surface .owner-actions[role="status"] {
  border-left: 4px solid var(--op-accent-strong);
  background: var(--op-toolbar);
}
.record-surface .owner-actions.comment-status {
  margin: 0;
  padding: var(--op-space-3) var(--op-space-4);
  border: 1px solid var(--op-border);
  border-left: 4px solid var(--op-accent-strong);
  border-radius: var(--op-radius-8);
}

/* Guest reviewer access (owner): one stacked column, the one-time link on a line with its copy control. */
.record-surface .owner-actions.guest-access { gap: var(--op-space-3); }
.record-surface .guest-access .help { max-width: 60ch; }
.record-surface .guest-access-link .input { font: var(--op-font-mono); font-size: var(--wf-text-xs); }
.record-surface .guest-access .error { margin: 0; }

/* ---------- Dialogs: decision confirmation, share, revoke ---------- */

.record-surface .dialog .field { gap: var(--op-space-2); }
.record-surface .dialog .textarea { min-height: 112px; }
.record-surface .dialog-body p { margin: 0; color: var(--op-text); overflow-wrap: anywhere; }
.record-surface .dialog-body .help { margin-top: var(--op-space-2); color: var(--op-text-2); }

/* ---------- Expanded record: a reading column of header card, record card, manage card ---------- */

.record-page { max-width: 840px; }
.record-page > .back-link { min-height: 44px; margin: 0 0 var(--op-space-2); color: var(--op-text-2); }

.record-page > .record-header,
.record-page > .record-body,
.record-page > .record-manage {
  border: 1px solid var(--op-border);
  border-radius: var(--op-radius-12);
  background: var(--op-surface);
}
.record-page > .record-header { margin-bottom: var(--op-space-4); padding: var(--op-space-8) var(--op-space-8) var(--op-space-6); }
.record-page .detail-title-row { gap: var(--op-space-5); }
.record-page .detail-title-row > div:first-child { min-width: 0; flex: 1 1 auto; }
.record-page .detail-title-row h1 { margin-bottom: var(--op-space-2); }
.record-page .record-header .wf-row { margin-bottom: var(--op-space-3); }
.record-page .record-header .preview-progress { margin-top: var(--op-space-5); }
.record-page .record-provenance { color: var(--op-text-2); font-size: var(--wf-text-xs); overflow-wrap: anywhere; }

.record-page .record-next { margin-top: var(--op-space-4); color: var(--op-text-2); font-size: var(--wf-text-xs); }
.record-page .record-next strong { color: var(--op-text); }
.record-page .record-next a { color: var(--op-link); font-weight: 700; }

.record-page > .record-body { display: block; margin-bottom: var(--op-space-4); padding: 0 var(--op-space-8); }
.record-page .record-section {
  padding: var(--op-space-6) 0;
  border: 0;
  border-top: 1px solid var(--op-border);
  border-radius: 0;
  background: transparent;
}
.record-page .record-section:first-child { border-top: 0; }
.record-page .record-section h2 {
  margin: 0 0 var(--op-space-3);
  color: var(--op-text);
  font: var(--op-text-title);
}
.record-page .record-section > p { margin: 0 0 var(--op-space-1); color: var(--op-text); line-height: 1.6; overflow-wrap: anywhere; white-space: pre-line; }
.record-page .record-section > p.wf-copy { white-space: normal; }
.record-page .record-section .facts { margin-top: var(--op-space-5); }

/* The legacy record carries its owner and decision panels inside the card, as inset bands. */
.record-page > .record-body > .owner-actions {
  margin: var(--op-space-6) 0 0;
  padding: var(--op-space-4) var(--op-space-5);
  border: 1px solid var(--op-border);
  border-radius: var(--op-radius-8);
  background: var(--op-sunken);
}
.record-page > .record-body > .owner-actions + .record-section { margin-top: var(--op-space-4); }

/* Owner actions beneath the record: one headed card. */
.record-page > .record-manage { margin-top: 0; }
.record-page .record-manage > h2 {
  margin: 0;
  padding: var(--op-space-5) var(--op-space-8) var(--op-space-1);
  color: var(--op-text);
  font: var(--op-text-title);
}
.record-page .record-manage .owner-actions { padding: var(--op-space-4) var(--op-space-8); }
.record-page .record-manage .owner-actions--cancel { margin-top: 0; }
.record-page .record-manage .owner-actions:first-of-type,
.record-page .record-manage > h2 + .owner-actions { border-top: 0; }

/* Comment composer and recovery status on a page without a decision panel beside them. */
.record-page .record-section .form-grid { margin-top: var(--op-space-5); }
.record-page > .record-actions > .owner-actions[role="status"] { margin-bottom: var(--op-space-4); border: 1px solid var(--op-border); border-left: 4px solid var(--op-accent-strong); border-radius: var(--op-radius-8); }

/* Loading and failure of the print assembly: the same banners the panel uses, readable in both modes. */
.record-page > .record-loading { padding: var(--op-space-3) var(--op-space-4); border: 1px solid var(--op-border); border-radius: var(--op-radius-8); background: var(--op-toolbar); color: var(--op-text); }
.record-page > .record-loading .help { color: var(--op-text-2); }
.record-page > .record-status {
  padding: var(--op-space-4) var(--op-space-5);
  border: 1px solid var(--op-danger);
  border-left-width: 4px;
  border-radius: var(--op-radius-8);
  background: var(--op-danger-tint);
}
.record-page > .record-status h2 { color: var(--op-text); font: var(--op-text-body); font-weight: 700; }
.record-page > .record-status .wf-copy { color: var(--op-text); }

/* ---------- Tablet: tighter spacing ---------- */

@media (max-width: 1150px) {
  .record-surface .preview-header { padding: var(--op-space-5); }
  .record-surface .tabs { gap: var(--op-space-5); padding: 0 var(--op-space-5); }
  .record-surface .tab-panel { padding: var(--op-space-5); }
  .record-surface .owner-actions { padding: var(--op-space-4) var(--op-space-5); }
  .preview-skeleton .preview-header { padding: var(--op-space-5); }
  .preview-skeleton .skeleton-tabs { padding-inline: var(--op-space-5); }
  .preview-skeleton .skeleton-copy,
  .preview-skeleton .skeleton-facts { margin-inline: var(--op-space-5); }
}

/* ---------- Phones: one column, the decision bar in the flow, 44px controls ---------- */

@media (max-width: 767px) {
  .record-surface .preview-header { flex-wrap: wrap; padding: var(--op-space-5); }
  .record-surface .preview-actions { margin-left: auto; }
  .record-surface .tabs { gap: var(--op-space-5); padding: 0 var(--op-space-5); scroll-padding-inline: var(--op-space-5); }
  .record-surface .facts { gap: var(--op-space-5) var(--op-space-4); }
  .queue-preview.record-surface .owner-actions--decision { position: static; box-shadow: none; }
  .record-surface .owner-actions--decision .wf-row { width: 100%; flex-wrap: nowrap; justify-content: stretch; }
  .record-surface .owner-actions--decision .wf-row .button { flex: 1 1 0; }
  .record-surface .owner-actions > .button { width: 100%; }
  .record-surface .owner-actions .button,
  .record-surface .form-grid .button,
  .record-surface .file-row > .button { min-height: 44px; }
  .record-surface .form-grid > div:has(> .button) { display: block; }
  .record-surface .form-grid > div:has(> .button) > .button { width: 100%; }
  .record-surface .preview-actions .button--icon { width: 44px; min-height: 44px; }

  .record-page > .record-header { padding: var(--op-space-5); }
  .record-page > .record-body { padding: 0 var(--op-space-5); }
  .record-page .record-manage > h2 { padding: var(--op-space-4) var(--op-space-5) var(--op-space-1); }
  .record-page .record-manage .owner-actions { padding: var(--op-space-4) var(--op-space-5); }
  .record-page .detail-title-row { flex-direction: column; }
  .record-page .detail-title-row .page-actions { width: 100%; }
  .record-page .detail-title-row .page-actions .button { min-height: 44px; }
  .record-page .record-section .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 440px) {
  .record-surface .facts,
  .record-page .record-section .facts { grid-template-columns: minmax(0, 1fr); }
  .record-surface .person-row > .badge { max-width: 40%; white-space: normal; text-align: center; }
}

/* ---------- Forced colours ---------- */

@media (forced-colors: active) {
  .queue-preview.record-surface .owner-actions--decision { border-top-color: CanvasText; }
  .record-surface .owner-actions[role="status"],
  .record-surface .owner-actions.comment-status,
  .record-page > .record-status { border-left-color: Highlight; }
  .record-surface .comment-role--guest { border-color: CanvasText; }
}

/* ---------- Paper ----------
 * Readable light pages whatever the screen mode: tokens.css keeps the dark palette out of print, the application chrome
 * is hidden here and by shell.css and r005, and every section and history row is kept; rows stay whole across pages.
 * Status shapes and the progress strip print as drawn.
 */

@media print {
  html, body, .mode-scope, .app-shell, .main, .page { background: var(--op-surface); color: var(--op-text); }
  .app-shell { display: block; min-height: 0; }
  .main { margin: 0; }
  .app-header, .sidebar, .drawer-overlay, .mode-control, .toast, dialog,
  .preview-actions, .preview-return, .record-actions, .back-link { display: none !important; }

  .record-page { max-width: none; padding: 0; font-size: 10.5pt; }
  .record-page > .record-header,
  .record-page > .record-body,
  .record-page > .record-manage { border: 0; border-radius: 0; background: transparent; box-shadow: none; }
  .record-page > .record-header { margin-bottom: var(--op-space-4); padding: 0 0 var(--op-space-4); border-bottom: 1px solid var(--op-border-strong); }
  .record-page > .record-body { margin-bottom: 0; padding: 0; }
  .record-page .record-section { padding: var(--op-space-4) 0; break-inside: auto; }
  .record-page .record-section h2 { break-after: avoid; padding-bottom: var(--op-space-1); border-bottom: 1px solid var(--op-border-strong); }
  .record-page .detail-title-row h1 { font-size: 18pt; }
  .record-page .record-provenance { color: var(--op-text); font-size: 9pt; }

  .record-surface .person-row,
  .record-surface .comment,
  .record-surface .file-row,
  .record-surface .timeline-item,
  .record-surface .fact,
  .record-surface .chip { break-inside: avoid; }
  .record-surface .person-row small,
  .record-surface .file-row small,
  .record-surface .comment small,
  .record-surface .timeline-item time,
  .record-surface .timeline-item p.wf-copy,
  .record-surface .progress-label,
  .record-surface .fact dt { color: var(--op-text); font-size: 9pt; }
  .record-surface .person-row strong,
  .record-surface .file-row strong,
  .record-surface .comment strong,
  .record-surface .comment-body > p,
  .record-surface .timeline-item p,
  .record-surface .fact dd { font-size: 10.5pt; }
  .record-surface .comment-role { color: var(--op-text); font-size: 9pt; }
  .record-surface .comment-role--guest { border-color: var(--op-text); }

  .record-surface .badge,
  .record-surface .avatar,
  .record-surface .signoff,
  .record-surface .tick-strip,
  .record-surface .progress-track,
  .record-surface .timeline-mark,
  .record-surface .chip { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .record-page a { color: var(--op-text); text-decoration: underline; }
}
