html { background: var(--wf-gray-50); }

body { min-width: 320px; }

button,
input,
select,
textarea { color: inherit; }

p,
h1,
h2,
h3,
h4 { margin-top: 0; }

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.icon--sm { width: 15px; height: 15px; }
.icon--lg { width: 22px; height: 22px; }

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--wf-space-2);
  padding: 0 var(--wf-space-4);
  border: 1px solid var(--wf-gray-600);
  border-radius: var(--wf-radius-3);
  background: var(--wf-gray-600);
  color: var(--wf-white);
  font-weight: 700;
  font-size: var(--wf-text-sm);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover { background: var(--wf-gray-700); }

.button--secondary {
  border-color: var(--wf-border-strong);
  background: var(--wf-white);
  color: var(--wf-gray-700);
}

.button--secondary:hover,
.button--ghost:hover { background: var(--wf-gray-100); }

.button--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--wf-gray-700);
}

.button--danger {
  border-color: var(--wf-gray-600);
  background: var(--wf-white);
  color: var(--wf-gray-700);
}

.button--small { min-height: 32px; padding-inline: var(--wf-space-3); }

.button--icon {
  width: 38px;
  padding: 0;
}

.button:disabled,
.button[aria-disabled="true"] {
  border-color: var(--wf-gray-300);
  background: var(--wf-gray-100);
  color: var(--wf-gray-500);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--wf-space-1);
  min-height: 23px;
  padding: 0 var(--wf-space-2);
  border: 1px solid var(--wf-border-strong);
  border-radius: 999px;
  background: var(--wf-white);
  color: var(--wf-gray-700);
  font-size: var(--wf-text-xs);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.badge--solid { background: var(--wf-gray-600); border-color: var(--wf-gray-600); color: var(--wf-white); }
.badge--soft { background: var(--wf-gray-100); }
.badge--striped { background: repeating-linear-gradient(135deg, var(--wf-white), var(--wf-white) 5px, var(--wf-gray-100) 5px, var(--wf-gray-100) 10px); }
.badge--dot::before { width: 7px; height: 7px; border-radius: 50%; background: var(--wf-gray-500); content: ""; }

.field { display: grid; gap: var(--wf-space-2); }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--wf-space-4); }
.reference-list { display: grid; gap: var(--wf-space-2); }
.reference-row { display: grid; grid-template-columns: minmax(0, .7fr) minmax(0, 1.3fr) 38px; gap: var(--wf-space-2); align-items: center; }

.label {
  font-size: var(--wf-text-sm);
  font-weight: 700;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 40px;
  padding: var(--wf-space-2) var(--wf-space-3);
  border: 1px solid var(--wf-border-strong);
  border-radius: var(--wf-radius-3);
  background: var(--wf-white);
}

.textarea { min-height: 112px; resize: vertical; }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--wf-gray-100); color: var(--wf-gray-600); }
.help { margin: 0; color: var(--wf-text-muted); font-size: var(--wf-text-sm); }
.error { margin: 0; color: var(--wf-gray-700); font-size: var(--wf-text-sm); font-weight: 700; }
.field.is-invalid .input, .field.is-invalid .textarea { border: 2px solid var(--wf-gray-700); background: var(--wf-gray-50); }

.search {
  min-width: min(320px, 100%);
  position: relative;
}

.search .icon { position: absolute; top: 50%; left: 12px; transform: translateY(-50%); color: var(--wf-text-muted); }
.search .input { padding-left: 40px; }

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  z-index: 30;
  inset: 0 auto 0 0;
  width: var(--wf-sidebar-width);
  display: flex;
  flex-direction: column;
  padding: var(--wf-space-5) var(--wf-space-3);
  border-right: 1px solid var(--wf-border);
  background: var(--wf-white);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--wf-space-3);
  min-height: 42px;
  padding: 0 var(--wf-space-2);
  color: var(--wf-gray-700);
  font-size: var(--wf-text-lg);
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 2px solid var(--wf-gray-600);
  border-radius: var(--wf-radius-4);
  background: var(--wf-gray-50);
}

.nav-label {
  margin: var(--wf-space-6) var(--wf-space-3) var(--wf-space-2);
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-2xs);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.nav { display: grid; gap: var(--wf-space-1); }

.nav-link {
  min-height: 42px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--wf-space-3);
  padding: 0 var(--wf-space-3);
  border-radius: var(--wf-radius-3);
  color: var(--wf-gray-600);
  font-size: var(--wf-text-sm);
  font-weight: 700;
  text-decoration: none;
}

.nav-link:hover { background: var(--wf-gray-50); color: var(--wf-gray-700); }
.nav-link[aria-current="page"] { background: var(--wf-gray-100); color: var(--wf-gray-700); }
.nav-count { margin-left: auto; }
.nav-bottom { margin-top: auto; padding-top: var(--wf-space-4); border-top: 1px solid var(--wf-border); }
/* r006: the identity link's name truncates to one line instead of wrapping or overflowing. */
.nav-identity { min-width: 0; overflow: hidden; }
.nav-identity-name { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.avatar {
  width: 32px;
  height: 32px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--wf-border-strong);
  border-radius: 50%;
  background: var(--wf-gray-100);
  font-size: var(--wf-text-xs);
  font-weight: 700;
}
/* r006: a loaded picture fills the circle; empty or failed images fall back to initials text. */
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--link { display: inline-flex; text-decoration: none; }

.main { min-height: 100vh; margin-left: var(--wf-sidebar-width); }

.mobile-bar {
  display: none;
  min-height: var(--wf-mobile-bar-height);
  align-items: center;
  justify-content: space-between;
  padding: var(--wf-space-2) var(--wf-space-4);
  border-bottom: 1px solid var(--wf-border);
  background: var(--wf-white);
}

.drawer-overlay { display: none; }

.page {
  width: min(100%, var(--wf-page-max));
  margin-inline: auto;
  padding: var(--wf-content-gutter);
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--wf-space-5);
  margin-bottom: var(--wf-space-6);
}

.page-title { margin: 0 0 var(--wf-space-1); color: var(--wf-gray-700); font-size: 28px; line-height: var(--wf-line-tight); }
.page-subtitle { margin: 0; color: var(--wf-text-muted); }
.page-actions { display: flex; align-items: center; gap: var(--wf-space-2); }

.surface {
  border: 1px solid var(--wf-border);
  border-radius: var(--wf-radius-4);
  background: var(--wf-white);
}

.surface-header { padding: var(--wf-space-4) var(--wf-space-5); border-bottom: 1px solid var(--wf-border); }
.surface-body { padding: var(--wf-space-5); }
.surface-footer { padding: var(--wf-space-4) var(--wf-space-5); border-top: 1px solid var(--wf-border); }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--wf-space-3); margin-bottom: var(--wf-space-5); }
.stat { padding: var(--wf-space-4); }
.stat strong { display: block; margin-top: var(--wf-space-2); font-size: 24px; line-height: 1; }
.stat span { color: var(--wf-text-muted); font-size: var(--wf-text-sm); }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--wf-space-3);
  flex-wrap: wrap;
  margin-bottom: var(--wf-space-4);
}

.toolbar-group { display: flex; align-items: center; gap: var(--wf-space-2); flex-wrap: wrap; }
.toolbar--full { display: block; }
.toolbar--full .toolbar-group { width: 100%; flex-wrap: nowrap; }
.toolbar--full .search { flex: 1; min-width: 0; }
.toolbar--full .result-count { white-space: nowrap; }
.toolbar .select { width: auto; min-width: 148px; }

.segmented {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--wf-border);
  border-radius: var(--wf-radius-3);
  background: var(--wf-gray-100);
}

.segment {
  min-height: 32px;
  padding: 0 var(--wf-space-3);
  border: 0;
  border-radius: var(--wf-radius-2);
  background: transparent;
  color: var(--wf-text-muted);
  font-size: var(--wf-text-sm);
  font-weight: 700;
}

.segment.is-active,
.segment[aria-selected="true"] { background: var(--wf-white); color: var(--wf-gray-700); box-shadow: var(--wf-shadow-1); }

.queue-layout {
  min-height: calc(100vh - 190px);
  display: grid;
  grid-template-columns: minmax(330px, 390px) minmax(0, 1fr);
  overflow: hidden;
}

.queue-list { border-right: 1px solid var(--wf-border); background: var(--wf-gray-25); }
.queue-list-header { padding: var(--wf-space-4); border-bottom: 1px solid var(--wf-border); background: var(--wf-white); }
.result-count { color: var(--wf-text-muted); font-size: var(--wf-text-sm); }

.request-list { list-style: none; margin: 0; padding: 0; }
.request-list li + li { border-top: 1px solid var(--wf-border); }

.request-row {
  width: 100%;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: var(--wf-space-3);
  align-items: start;
  padding: var(--wf-space-4);
  border: 0;
  border-left: 3px solid transparent;
  background: var(--wf-white);
  color: inherit;
  text-align: left;
}

.request-row:hover { background: var(--wf-gray-50); }
.request-row.is-selected { border-left-color: var(--wf-gray-600); background: var(--wf-gray-100); }
.request-icon { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--wf-border); border-radius: var(--wf-radius-4); background: var(--wf-white); }
.request-title { display: block; margin: 0 0 2px; color: var(--wf-gray-700); font-size: var(--wf-text-md); font-weight: 700; }
.request-meta, .request-submeta { display: block; color: var(--wf-text-muted); font-size: var(--wf-text-sm); }
.request-submeta { margin-top: var(--wf-space-1); }
.request-side { display: grid; justify-items: end; gap: var(--wf-space-2); color: var(--wf-text-muted); font-size: var(--wf-text-xs); }

.queue-preview { min-width: 0; background: var(--wf-white); }
.preview-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--wf-space-4); padding: var(--wf-space-6); border-bottom: 1px solid var(--wf-border); }
.preview-header .wf-row { margin-bottom: var(--wf-space-5); }
.preview-progress { margin-top: var(--wf-space-4); max-width: 420px; }
.settings-stack { display: grid; gap: var(--wf-space-4); max-width: 820px; }
.record-page { max-width: 820px; }
.record-header .preview-progress { margin-top: var(--wf-space-4); }
.record-body { display: grid; gap: var(--wf-space-4); }
.record-section { padding: var(--wf-space-5) var(--wf-space-6); }
.record-section h2 { margin: 0 0 var(--wf-space-3); font-size: 18px; }
.record-section .facts { grid-template-columns: minmax(0, 1fr); }
.record-actions { flex: 0 0 auto; }
.owner-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--wf-space-4); flex-wrap: wrap; margin: 0 var(--wf-space-6) var(--wf-space-6); padding: var(--wf-space-4) var(--wf-space-5); }
.owner-actions h3 { margin: 0 0 var(--wf-space-1); }
/* Doubled class: every theme restyles `.avatar` later in the cascade and must not shrink this. */
.avatar.avatar--lg { width: 48px; height: 48px; font-size: var(--wf-text-sm); }
.user-headline { display: flex; align-items: center; gap: var(--wf-space-3); }
.user-headline h1 { margin: 0; }
.aside-action { margin: var(--wf-space-4) 0 0; }
.aside-action .button { width: 100%; }
.preview-title { margin: 0 0 var(--wf-space-1); font-size: 24px; line-height: var(--wf-line-tight); }
.preview-body { padding: var(--wf-space-5) var(--wf-space-6) var(--wf-space-8); }
.preview-actions { display: flex; gap: var(--wf-space-2); }

.tabs { display: flex; gap: var(--wf-space-5); overflow-x: auto; border-bottom: 1px solid var(--wf-border); }
.tab {
  min-height: 44px;
  padding: 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--wf-text-muted);
  font-size: var(--wf-text-sm);
  font-weight: 700;
  white-space: nowrap;
}
.tab[aria-selected="true"] { border-bottom-color: var(--wf-gray-600); color: var(--wf-gray-700); }
.tab-panel { padding-top: var(--wf-space-5); }

.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--wf-space-8); }
.preview-body .facts { grid-template-columns: minmax(0, 1fr); }
.fact { display: grid; grid-template-columns: minmax(110px, .7fr) minmax(0, 1fr); gap: var(--wf-space-3); padding: var(--wf-space-3) 0; border-bottom: 1px solid var(--wf-border); }
.fact dt { color: var(--wf-text-muted); }
.fact dd { margin: 0; color: var(--wf-gray-700); font-weight: 700; }

.copy-block { margin-top: var(--wf-space-6); }
.copy-block h2,
.copy-block h3 { margin-bottom: var(--wf-space-2); font-size: var(--wf-text-lg); }
.copy-block p { margin: 0; color: var(--wf-text-muted); }

.collection { overflow: hidden; }
.collection-head,
.collection-row {
  display: grid;
  grid-template-columns: minmax(240px, 1.8fr) minmax(110px, .7fr) minmax(130px, .9fr) minmax(130px, .9fr) auto;
  gap: var(--wf-space-4);
  align-items: center;
  padding: var(--wf-space-3) var(--wf-space-4);
}
.collection--templates .collection-head,
.collection--templates .collection-row { grid-template-columns: minmax(240px, 2.4fr) minmax(160px, .8fr); }
.user-collection .collection-head,
.user-collection .collection-row { grid-template-columns: minmax(240px, 1.8fr) minmax(140px, .8fr) minmax(160px, .8fr); }
.collection-head { background: var(--wf-gray-50); border-bottom: 1px solid var(--wf-border); color: var(--wf-text-muted); font-size: var(--wf-text-xs); font-weight: 700; text-transform: uppercase; }
.collection-row + .collection-row { border-top: 1px solid var(--wf-border); }
.collection-row:hover { background: var(--wf-gray-25); }
.collection-title { color: var(--wf-gray-700); font-weight: 700; }
.collection-title .request-meta { font-weight: 400; }
.user-link { color: inherit; text-decoration: none; }
.user-link:hover strong { text-decoration: underline; }
.collection-title a { text-decoration: none; }
.collection-title a:hover { text-decoration: underline; }
.user-identity { min-width: 0; display: flex; align-items: center; gap: var(--wf-space-3); }
.user-identity > :last-child { min-width: 0; }
.user-identity strong,
.user-identity small { display: block; }
.user-identity small { overflow: hidden; color: var(--wf-text-muted); text-overflow: ellipsis; white-space: nowrap; }
.cell-label { display: none; color: var(--wf-text-subtle); font-size: var(--wf-text-xs); font-weight: 700; text-transform: uppercase; }
.row-actions { display: flex; justify-content: flex-end; gap: var(--wf-space-1); }
.empty-state { display: none; padding: var(--wf-space-10); text-align: center; }
.empty-state.is-visible { display: block; }
.empty-state .icon { width: 28px; height: 28px; margin: 0 auto var(--wf-space-3); }
/* The "Select a request" placeholder sits in the middle of the side-by-side preview panel. */
@media (min-width: 1181px) {
  .queue-preview:has(> .empty-state.is-visible) { display: flex; flex-direction: column; }
  .queue-preview > .empty-state.is-visible { margin-block: auto; }
}

.catalog-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--wf-space-5); }
.catalog-layout--full { grid-template-columns: minmax(0, 1fr); }
.category-list { display: grid; gap: var(--wf-space-1); align-content: start; position: sticky; top: var(--wf-space-5); }
.category-button { min-height: 40px; padding: 0 var(--wf-space-3); border: 0; border-radius: var(--wf-radius-3); background: transparent; color: var(--wf-text-muted); text-align: left; font-weight: 700; }
.category-button:hover { background: var(--wf-gray-50); }
.category-button.is-active { background: var(--wf-gray-100); color: var(--wf-gray-700); }
.catalog-main { min-width: 0; }
.blank-card { display: flex; align-items: center; justify-content: space-between; gap: var(--wf-space-4); padding: var(--wf-space-5); margin-bottom: var(--wf-space-5); border: 1px dashed var(--wf-gray-400); border-radius: var(--wf-radius-4); background: var(--wf-white); }
.template-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--wf-space-3); }
.template-card { display: flex; align-items: flex-start; gap: var(--wf-space-4); min-height: 106px; padding: var(--wf-space-4); border: 1px solid var(--wf-border); border-radius: var(--wf-radius-4); background: var(--wf-white); color: inherit; text-decoration: none; }
.template-card:hover { border-color: var(--wf-gray-400); background: var(--wf-gray-25); }
.template-icon { width: 44px; height: 44px; display: grid; flex: 0 0 auto; place-items: center; border-radius: var(--wf-radius-4); background: var(--wf-gray-100); }
.template-card h3 { margin: 0 0 var(--wf-space-1); font-size: var(--wf-text-lg); }
.template-card p { margin: 0; color: var(--wf-text-muted); font-size: var(--wf-text-sm); }

.editor-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr) 300px; gap: var(--wf-space-5); align-items: start; }
.step-nav { display: grid; gap: var(--wf-space-2); position: sticky; top: var(--wf-space-5); }
.step-button { min-height: 48px; display: flex; align-items: center; gap: var(--wf-space-3); padding: 0 var(--wf-space-3); border: 0; border-radius: var(--wf-radius-3); background: transparent; color: var(--wf-text-muted); text-align: left; font-weight: 700; }
.step-button:hover { background: var(--wf-gray-50); }
.step-button.is-active { background: var(--wf-gray-100); color: var(--wf-gray-700); }
.step-number { width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid var(--wf-border-strong); border-radius: 50%; background: var(--wf-white); font-size: var(--wf-text-xs); }
.step-button.is-complete .step-number { background: var(--wf-gray-600); color: var(--wf-white); }
.form-card { min-width: 0; }
.form-section { padding: var(--wf-space-6); }
.form-section h2 { margin-bottom: var(--wf-space-1); font-size: 22px; }
.form-section > p { color: var(--wf-text-muted); }
.form-grid { display: grid; gap: var(--wf-space-5); }
.form-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--wf-space-3); padding: var(--wf-space-4) var(--wf-space-6); border-top: 1px solid var(--wf-border); }
.form-action-group { display: flex; align-items: center; gap: var(--wf-space-2); }
.summary-aside { position: sticky; top: var(--wf-space-5); }
.summary-list { display: grid; gap: var(--wf-space-3); margin: 0; }
.summary-list div { display: flex; justify-content: space-between; gap: var(--wf-space-4); padding-bottom: var(--wf-space-3); border-bottom: 1px solid var(--wf-border); }
.summary-list dt { color: var(--wf-text-muted); }
.summary-list dd { margin: 0; font-weight: 700; text-align: right; }
.notice { display: flex; align-items: flex-start; gap: var(--wf-space-3); padding: var(--wf-space-3) var(--wf-space-4); margin-bottom: var(--wf-space-5); border: 1px solid var(--wf-border-strong); border-radius: var(--wf-radius-3); background: var(--wf-gray-50); }
.notice p { margin: 0; }
.notice > [data-icon] { display: inline-flex; flex: 0 0 auto; }

.chip-list { display: flex; flex-wrap: wrap; gap: var(--wf-space-2); }
.chip { display: inline-flex; align-items: center; gap: var(--wf-space-1); padding: var(--wf-space-1) var(--wf-space-2); border: 1px solid var(--wf-border); border-radius: 999px; background: var(--wf-gray-50); font-size: var(--wf-text-sm); }

.file-list,
.people-list,
.comment-list,
.timeline,
.preference-list { display: grid; gap: var(--wf-space-3); }
.people-list { grid-template-columns: minmax(0, 1fr); }
.file-row,
.person-row,
.comment,
.preference-card { display: flex; align-items: flex-start; gap: var(--wf-space-3); padding: var(--wf-space-4); border: 1px solid var(--wf-border); border-radius: var(--wf-radius-4); background: var(--wf-white); }
.file-row > :nth-child(2), .person-row > :nth-child(2), .preference-card > :nth-child(2) { min-width: 0; flex: 1; }
.file-row strong, .person-row strong, .comment strong, .preference-card strong { display: block; }
.file-row small, .person-row small, .comment small, .preference-card small { color: var(--wf-text-muted); }
.participant-list { display: grid; gap: var(--wf-space-3); }
.participant-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) 38px; gap: var(--wf-space-2) var(--wf-space-3); align-items: start; padding: var(--wf-space-4); border: 1px solid var(--wf-border); border-radius: var(--wf-radius-4); background: var(--wf-white); }
.participant-row > .avatar { grid-column: 1; grid-row: 1; }
.participant-identity { grid-column: 2; grid-row: 1; }
.participant-row > .button { grid-column: 3; grid-row: 1; }
.participant-role { grid-column: 2; grid-row: 2; max-width: 220px; }
.participant-list + p { margin-top: var(--wf-space-5); }
.participant-identity { min-width: 0; }
.participant-identity strong,
.participant-identity small { display: block; }
.participant-identity small { color: var(--wf-text-muted); }
.participant-role { min-width: 0; }
.profile-choice-list { display: grid; gap: var(--wf-space-2); max-height: 280px; overflow-y: auto; margin: var(--wf-space-4) 0; }
.profile-choice { width: 100%; display: grid; grid-template-columns: 36px minmax(0, 1fr) 18px; gap: var(--wf-space-3); align-items: center; padding: var(--wf-space-3); border: 1px solid var(--wf-border); border-radius: var(--wf-radius-3); background: var(--wf-white); color: inherit; text-align: left; }
.profile-choice:hover { background: var(--wf-gray-50); }
.profile-choice[aria-pressed="true"] { border-color: var(--wf-gray-500); background: var(--wf-gray-100); }
.profile-choice strong,
.profile-choice small { display: block; }
.profile-choice small { color: var(--wf-text-muted); }
.profile-choice[hidden] { display: none; }
.compact-empty { padding: var(--wf-space-5); border: 1px dashed var(--wf-border-strong); border-radius: var(--wf-radius-3); }
.participant-picker .dialog-body { padding-bottom: var(--wf-space-3); }
.upload-zone { display: grid; place-items: center; min-height: 112px; padding: var(--wf-space-4); border: 1px dashed var(--wf-gray-400); border-radius: var(--wf-radius-4); background: var(--wf-gray-25); text-align: center; }
.upload-zone input[type="file"] { justify-self: center; width: auto; max-width: 100%; }

.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--wf-space-5); align-items: start; }
.detail-layout > *,
.detail-aside,
.detail-layout .surface { min-width: 0; }
.detail-header { margin-bottom: var(--wf-space-5); }
.back-link { display: inline-flex; align-items: center; gap: var(--wf-space-2); margin-bottom: var(--wf-space-3); color: var(--wf-text-muted); font-size: var(--wf-text-sm); font-weight: 700; text-decoration: none; }
.back-link:hover { text-decoration: underline; }
.detail-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--wf-space-4); }
.detail-title-row h1 { margin: 0 0 var(--wf-space-2); font-size: 28px; }
.detail-meta { display: flex; gap: var(--wf-space-2); flex-wrap: wrap; color: var(--wf-text-muted); font-size: var(--wf-text-sm); }
.detail-aside { display: grid; gap: var(--wf-space-4); position: sticky; top: var(--wf-space-5); }
.aside-card { padding: var(--wf-space-5); }
.aside-card h2 { margin-bottom: var(--wf-space-3); font-size: var(--wf-text-lg); }
.progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: var(--wf-gray-200); }
.progress-value { height: 100%; width: 50%; background: var(--wf-gray-600); transition: width var(--wf-motion-medium); }
.progress-label { margin: var(--wf-space-2) 0 0; color: var(--wf-text-muted); font-size: var(--wf-text-sm); }
.decision-stack { display: grid; grid-template-columns: 1fr 1fr; gap: var(--wf-space-2); margin-top: var(--wf-space-4); }
.decision-stack .button { width: 100%; }
.mobile-action-dock { display: none; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline-item { position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: var(--wf-space-3); padding-bottom: var(--wf-space-4); }
.timeline-item:not(:last-child)::before { position: absolute; top: 28px; bottom: 0; left: 14px; width: 1px; background: var(--wf-border-strong); content: ""; }
.timeline-mark { z-index: 1; width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--wf-border-strong); border-radius: 50%; background: var(--wf-white); }
.timeline-item p { margin: 0; }
.timeline-item time { color: var(--wf-text-muted); font-size: var(--wf-text-xs); }
.comment { align-items: flex-start; }
.comment-body { flex: 1; }
.comment-body p { margin: var(--wf-space-1) 0 0; }

.review-summary { display: grid; gap: var(--wf-space-5); }
.summary-section { padding-bottom: var(--wf-space-5); border-bottom: 1px solid var(--wf-border); }
.summary-section:last-child { padding-bottom: 0; border-bottom: 0; }
.summary-section h3 { margin-bottom: var(--wf-space-3); font-size: var(--wf-text-lg); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--wf-space-4); }
.preference-card > .switch { flex: 0 0 auto; margin-left: auto; }
.switch { position: relative; width: 44px; height: 24px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { position: absolute; inset: 0; border: 1px solid var(--wf-gray-400); border-radius: 999px; background: var(--wf-gray-100); transition: background var(--wf-motion-fast); }
.switch-track::after { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--wf-gray-500); content: ""; transition: transform var(--wf-motion-fast); }
.switch input:checked + .switch-track { background: var(--wf-gray-600); }
.switch input:checked + .switch-track::after { background: var(--wf-white); transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--wf-focus); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: .45; }


.dialog {
  width: min(calc(100% - 32px), 520px);
  padding: 0;
  border: 1px solid var(--wf-border-strong);
  border-radius: var(--wf-radius-4);
  background: var(--wf-white);
  color: var(--wf-text);
  box-shadow: var(--wf-shadow-2);
}
.dialog::backdrop { background: rgb(66 66 66 / 38%); }
.dialog-header, .dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: var(--wf-space-3); padding: var(--wf-space-4) var(--wf-space-5); }
.dialog-header { border-bottom: 1px solid var(--wf-border); }
.dialog-header h2 { margin: 0; font-size: var(--wf-text-xl); }
.dialog-body { padding: var(--wf-space-5); }
.dialog-footer { justify-content: flex-end; border-top: 1px solid var(--wf-border); }

.toast {
  position: fixed;
  z-index: 80;
  right: var(--wf-space-5);
  bottom: var(--wf-space-5);
  max-width: min(360px, calc(100% - 32px));
  display: flex;
  align-items: center;
  gap: var(--wf-space-3);
  padding: var(--wf-space-3) var(--wf-space-4);
  border: 1px solid var(--wf-gray-400);
  border-radius: var(--wf-radius-4);
  background: var(--wf-gray-700);
  color: var(--wf-white);
  box-shadow: var(--wf-shadow-2);
  transform: translateY(24px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--wf-motion-fast), transform var(--wf-motion-fast);
}
.toast.is-visible { transform: translateY(0); opacity: 1; }

.workflow-page { min-height: 100vh; padding: var(--wf-space-8) var(--wf-space-4); }
.workflow-wrap { width: min(100%, 980px); margin-inline: auto; }
.workflow-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--wf-space-5); margin-bottom: var(--wf-space-8); }
.workflow-header h1 { margin-bottom: var(--wf-space-2); font-size: 32px; }
.workflow-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--wf-space-4); }
.workflow-card { min-height: 170px; display: flex; flex-direction: column; gap: var(--wf-space-3); padding: var(--wf-space-5); border: 1px solid var(--wf-border); border-radius: var(--wf-radius-4); background: var(--wf-white); text-decoration: none; }
.workflow-card:hover { border-color: var(--wf-gray-400); background: var(--wf-gray-25); }
.workflow-card .button { align-self: flex-start; margin-top: auto; }

.verify-page { min-height: 100vh; display: grid; place-items: center; padding: var(--wf-space-4); background: var(--wf-gray-50); }
.verify-card { width: min(100%, 460px); padding: var(--wf-space-8); text-align: center; }
.verify-mark { width: 56px; height: 56px; display: grid; place-items: center; margin: 0 auto var(--wf-space-5); border: 2px solid var(--wf-gray-600); border-radius: var(--wf-radius-4); }
.verify-card h1 { margin-bottom: var(--wf-space-2); font-size: 24px; }
.verify-card p { color: var(--wf-text-muted); }
.verify-card .button { width: 100%; margin-top: var(--wf-space-3); }

.section-nav { display: grid; gap: var(--wf-space-1); }
.section-button { min-height: 42px; padding: 0 var(--wf-space-3); border: 0; border-radius: var(--wf-radius-3); background: transparent; color: var(--wf-text-muted); text-align: left; font-weight: 700; }
.section-button.is-active { background: var(--wf-gray-100); color: var(--wf-gray-700); }
.readiness { display: grid; gap: var(--wf-space-2); list-style: none; margin: 0; padding: 0; }
.readiness li { display: flex; align-items: center; gap: var(--wf-space-2); font-size: var(--wf-text-sm); }
.readiness .icon { color: var(--wf-gray-600); }
.readiness-action { padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

@media (max-width: 1180px) {
  .queue-layout { display: block; min-height: auto; }
  .queue-list { border-right: 0; }
  .queue-preview { display: none; }
  .queue-layout.is-preview-open .queue-preview { display: block; border-top: 1px solid var(--wf-border); }
  .owner-actions { margin: 0 var(--wf-space-4) var(--wf-space-4); }
  .editor-layout { grid-template-columns: 190px minmax(0, 1fr); }
  .summary-aside { grid-column: 2; position: static; }
}

@media (max-width: 900px) {
  :root { --wf-content-gutter: 20px; }
  .sidebar { width: var(--wf-drawer-width); transform: translateX(-100%); transition: transform var(--wf-motion-medium) var(--wf-motion-ease); box-shadow: var(--wf-shadow-2); }
  .sidebar.is-open { transform: translateX(0); }
  .drawer-overlay { position: fixed; z-index: 25; inset: 0; display: block; background: rgb(66 66 66 / 30%); opacity: 0; pointer-events: none; transition: opacity var(--wf-motion-fast); }
  .drawer-overlay.is-open { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; }
  .mobile-bar { display: flex; position: sticky; z-index: 20; top: 0; }
  .mobile-bar .brand { min-height: auto; padding: 0; }
  .mobile-bar .brand-mark { width: 30px; height: 30px; }
  /* The avatar stays 30px; the link around it is the thumb-sized target. */
  .mobile-bar .avatar--link { align-items: center; justify-content: center; min-width: 44px; min-height: 44px; margin-right: -7px; }
  .catalog-layout { grid-template-columns: 1fr; }
  .category-list { display: flex; position: static; gap: var(--wf-space-2); overflow-x: auto; padding-bottom: var(--wf-space-1); }
  .category-button { flex: 0 0 auto; padding-inline: var(--wf-space-4); border: 1px solid var(--wf-border); border-radius: 999px; background: var(--wf-white); white-space: nowrap; }
  .editor-layout { grid-template-columns: 1fr; }
  .step-nav, .section-nav { display: flex; position: static; overflow-x: auto; }
  .step-button, .section-button { flex: 0 0 auto; }
  .summary-aside { grid-column: 1; }
  .detail-layout { grid-template-columns: minmax(0, 1fr); }
  .detail-aside { grid-row: 1; position: static; }
  .editor-layout .summary-aside.detail-aside { grid-row: auto; }
        .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  :root { --wf-content-gutter: 16px; }
  .page-header { align-items: stretch; flex-direction: column; margin-bottom: var(--wf-space-5); }
  .page-title { font-size: 24px; }
  .page-actions { width: 100%; }
  .page-actions .button { flex: 1; }
  .toolbar { align-items: stretch; }
  .toolbar > *, .toolbar-group, .search { width: 100%; }
  .toolbar .select { min-width: 0; flex: 1; }
  .segmented { width: 100%; overflow-x: auto; }
  .segment { flex: 1 0 auto; }
  .queue-layout { margin-inline: calc(var(--wf-content-gutter) * -1); border-left: 0; border-right: 0; border-radius: 0; }
  .request-row { grid-template-columns: 40px minmax(0, 1fr); }
  .request-side { grid-column: 2; display: flex; align-items: center; justify-content: space-between; }
  .reference-row { grid-template-columns: minmax(0, 1fr) 38px; }
  .reference-row .input:first-child { grid-column: 1 / -1; }
  .reference-row .input:nth-child(2) { grid-column: 1; }
  .reference-row .button { grid-column: 2; grid-row: 2; }
  .participant-role { grid-column: 2 / 4; max-width: none; }
  .people-list .person-row { flex-wrap: wrap; }
  .people-list .person-row .row-actions { width: calc(100% - 52px); flex: 0 0 calc(100% - 52px); justify-content: flex-start; margin-left: 52px; }
  .collection-head { display: none; }
  .collection-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--wf-space-3); padding: var(--wf-space-4); }
  .collection--templates .collection-row,
  .user-collection .collection-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar--full .toolbar-group { flex-wrap: wrap; }
  .collection-row > :first-child { grid-column: 1 / -1; }
  .collection-row .row-actions { grid-column: 1 / -1; justify-content: flex-start; padding-top: var(--wf-space-2); border-top: 1px solid var(--wf-border); }
  .user-identity small { white-space: normal; }
  .cell-label { display: block; }
  .template-grid { grid-template-columns: 1fr; }
  .blank-card { align-items: flex-start; flex-direction: column; }
  .field-row, .facts { grid-template-columns: 1fr; }
  .fact { grid-template-columns: minmax(100px, .65fr) minmax(0, 1fr); }
  .form-section { padding: var(--wf-space-5) var(--wf-space-4); }
  .form-actions { padding: var(--wf-space-4); }
  .detail-title-row { align-items: flex-start; flex-direction: column; }
  .detail-title-row h1 { font-size: 24px; }
  .aside-card .decision-stack { display: none; }
  body.has-action-dock { padding-bottom: 76px; }
  .mobile-action-dock { position: fixed; z-index: 18; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: 1fr 1fr; gap: var(--wf-space-2); padding: var(--wf-space-3) var(--wf-space-4); border-top: 1px solid var(--wf-border); background: var(--wf-white); box-shadow: 0 -4px 16px rgb(66 66 66 / 10%); }
  .mobile-action-dock .button { width: 100%; }
  .dialog { width: 100%; max-width: none; margin: auto 0 0; border-radius: var(--wf-radius-4) var(--wf-radius-4) 0 0; }
  .toast { right: var(--wf-space-4); bottom: calc(var(--wf-space-4) + env(safe-area-inset-bottom, 0px)); left: var(--wf-space-4); }
  .workflow-header { flex-direction: column; }
  .workflow-header h1 { font-size: 28px; }
  .workflow-grid { grid-template-columns: 1fr; }
}

@media (max-width: 440px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat { padding: var(--wf-space-3); }
  .stat strong { font-size: 20px; }
  .form-actions { align-items: stretch; flex-direction: column-reverse; }
  .form-actions > div { display: grid; grid-template-columns: 1fr 1fr; gap: var(--wf-space-2); }
  .form-actions .button { width: 100%; }
  .decision-stack { grid-template-columns: 1fr; }
  .verify-card { padding: var(--wf-space-6) var(--wf-space-5); }
}

/*
 * Account summary list (r006, round 5 approved layout). One surface holds three
 * disclosure rows (Profile, Email, Password): a title, the value that is true now,
 * one action that opens the row's own form in place, and status that lives in the row
 * whether the form is open or closed. `.account-list` is the container queried for the
 * three-column layout named in specs.md ("three columns when the list is at least
 * 640px wide, measured on the container").
 */
.account-stack { display: grid; gap: var(--wf-space-5); max-width: 880px; }
.account-list { container-type: inline-size; padding: 0; }
.account-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--wf-space-1) var(--wf-space-4);
  padding: var(--wf-space-5) var(--wf-space-5);
}
.account-row + .account-row { border-top: 1px solid var(--wf-border); }
.account-row-title { grid-column: 1; grid-row: 1; margin: 0; padding-top: var(--wf-space-1); font-size: var(--wf-text-sm); }
.account-row-value { grid-column: 2; grid-row: 1; min-width: 0; }
.account-row-action { grid-column: 3; grid-row: 1; flex: 0 0 auto; }
.account-row-note, .pending-change, .account-row-panel { grid-column: 2 / -1; }
.account-row-main { margin: 0; font-size: var(--wf-text-md); font-weight: 700; overflow-wrap: anywhere; }
.account-row-facts { margin: 0; overflow-wrap: anywhere; }
.account-identity { display: flex; align-items: flex-start; gap: var(--wf-space-3); min-width: 0; }
.account-identity > div { min-width: 0; }
.account-stack > .notice { margin-bottom: 0; }
@container (max-width: 639px) {
  .account-row { grid-template-columns: minmax(0, 1fr) auto; }
  .account-row-title { grid-row: 1; align-self: center; padding-top: 0; }
  .account-row-action { grid-column: 2; grid-row: 1; }
  .account-row-value { grid-column: 1 / -1; grid-row: 2; }
  .account-row-note, .pending-change, .account-row-panel { grid-column: 1 / -1; }
  /* Thumb-sized targets, and 16px controls so iOS does not zoom the page on focus. */
  .account-row .button { min-height: 44px; }
  .account-row .input { min-height: 44px; font-size: 16px; }
  .pending-change .form-action-group { flex-wrap: wrap; }
}

.account-row-panel { margin-top: var(--wf-space-4); padding-top: var(--wf-space-4); border-top: 1px dashed var(--wf-border-strong); display: grid; gap: var(--wf-space-4); }
.account-row-panel .field { max-width: 440px; }
.account-actions { display: flex; align-items: center; gap: var(--wf-space-3); }

/* Both labels share one cell, so the button keeps its width when the working label shows. */
.button.button-swap { display: inline-grid; align-items: center; justify-items: center; }
.button-swap > span { grid-area: 1 / 1; }
.button-swap > span[data-shown="false"] { visibility: hidden; }
.button-swap[data-busy] { cursor: progress; }
.account-row .help { max-width: 68ch; }

.pending-change { display: grid; gap: var(--wf-space-2); margin-top: var(--wf-space-3); }
.pending-address { display: block; }
/* A plain note for something that is over (a cancelled change, a question about unsaved text);
   the tinted block is kept for a change that is still waiting. */
.account-quiet-note { display: grid; gap: var(--wf-space-2); margin-top: var(--wf-space-3); padding: var(--wf-space-3) var(--wf-space-4); border: 1px solid var(--wf-border); border-radius: var(--wf-radius-3); }
.account-quiet-note p { margin: 0; }
.account-quiet-note .form-action-group { flex-wrap: wrap; }
.account-row-note.error { margin: var(--wf-space-2) 0 0; }
.pending-change strong { display: block; overflow-wrap: anywhere; }
.pending-change .form-action-group { margin-top: var(--wf-space-1); }

.saved-note { display: flex; align-items: flex-start; gap: var(--wf-space-2); margin: var(--wf-space-2) 0 0; font-weight: 700; }
.saved-note > [data-icon] { display: inline-flex; flex: 0 0 auto; }
.saved-note .icon { width: 16px; height: 16px; margin-top: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0ms !important; }
}


@media print {
  .sidebar, .mobile-bar, .drawer-overlay, .record-actions, .back-link, .toast, dialog { display: none !important; }
  body, .app-shell, .main, .page { background: #fff; display: block; padding: 0; margin: 0; }
  .record-page { max-width: none; }
  .surface, .record-section { border: 0; box-shadow: none; padding: 0 0 16px; break-inside: avoid; }
  .record-body { gap: 0; }
  .record-section h2 { border-bottom: 1px solid #ccc; padding-bottom: 4px; }
  a { color: #000; text-decoration: underline; }
}
