/*
 * page.css - the middle area (js/page.js): Home and the written workflow page.
 * Sharp edges, 1px borders, dense padding, 15px text. Every class starts with "pg-".
 */

.pg {
  position: relative;               /* markup draws in an overlay inside this, so it scrolls with the text */
  max-width: 760px;
  margin: 0 auto;
  padding: 0 0 16px;                /* #middle-inner gives the side gutter and room for "Mark up" */
  font-family: var(--cw-font, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif);
  font-size: var(--cw-fs-page, 15px);
  line-height: 1.45;
  color: var(--cw-text, #1b1f24);
  box-sizing: border-box;
}

.pg *,
.pg *::before,
.pg *::after {
  box-sizing: border-box;
}

.pg button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-align: inherit;
}

.pg button:disabled {
  cursor: default;
}

.pg button:focus-visible,
.pg [tabindex]:focus-visible {
  outline: 2px solid var(--cw-accent, #1d4ed8);
  outline-offset: 1px;
}

.pg p {
  margin: 0;
}

.pg-muted {
  color: var(--cw-muted, #5b6570);
}

.pg-time {
  color: var(--cw-muted, #5b6570);
  font-size: var(--cw-fs-sm, 12px);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- top line: Back + where you are */

.pg-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--cw-muted, #5b6570);
}

.pg .pg-back {
  flex: none;
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--cw-border, #d4d8de);
  background: var(--cw-surface, #fff);
  color: var(--cw-text, #1b1f24);
}

.pg .pg-back:hover {
  border-color: var(--cw-accent, #1d4ed8);
  color: var(--cw-accent, #1d4ed8);
}

.pg-crumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.pg-crumb {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.pg .pg-crumb:hover {
  color: var(--cw-accent, #1d4ed8);
  text-decoration: underline;
}

.pg-crumb-here {
  color: var(--cw-text, #1b1f24);
}

.pg-crumb-sep {
  flex: none;
  color: var(--cw-border-strong, #9aa3ad);
}

/* ---------------------------------------------------------------- headings */

.pg-h1 {
  font-size: 22px;
  line-height: 1.25;
  font-weight: 650;
  margin: 4px 0 8px;
}

.pg-h2 {
  font-size: 15px;
  line-height: 1.3;
  font-weight: 650;
  margin: 0;
}

.pg-title {
  font-size: 22px;
  line-height: 1.25;
  font-weight: 650;
  margin: 4px 0 6px;
  overflow-wrap: anywhere;
}

.pg-code {
  color: var(--cw-muted, #5b6570);
  font-weight: 500;
  margin-right: 8px;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- pencils (click-to-edit) */

.pg .pg-pencil {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 26px;
  height: 26px;
  margin-left: 4px;
  vertical-align: middle;
  color: var(--cw-muted, #5b6570);
  border: 1px solid transparent;
  opacity: 0;
}

.pg-title:hover .pg-pencil,
.pg-fact:hover .pg-pencil,
.pg-fact.is-active .pg-pencil,
.pg .pg-pencil:focus-visible {
  opacity: 1;
}

.pg .pg-pencil:hover {
  color: var(--cw-accent, #1d4ed8);
  border-color: var(--cw-border, #d4d8de);
  background: var(--cw-surface, #fff);
}

/* Touch screens: the pencil shows once its line is tapped (the title's stays faintly visible). */
@media (hover: none) {
  .pg-title .pg-pencil {
    opacity: 0.6;
  }
  .pg-fact:not(.is-active) .pg-pencil {
    display: none;
  }
}

/* ---------------------------------------------------------------- chips and relation marks */

.pg-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
}

.pg-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 8px;
  font-size: var(--cw-fs-sm, 12px);
  line-height: 1;
  white-space: nowrap;
  border: 1px solid var(--cw-border, #d4d8de);
  background: var(--cw-surface-2, #f8f9fa);
  color: var(--cw-muted, #5b6570);
}

.pg .pg-chip-btn::after {
  content: "";
  width: 0;
  height: 0;
  border-top: 4px solid currentColor;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}

.pg .pg-chip-btn[aria-expanded="true"]::after {
  transform: rotate(180deg);
}

.pg .pg-chip-btn:hover {
  border-color: currentColor;
}

.pg-chip-rel {
  color: var(--cw-accent, #1d4ed8);
  border-color: #b9c9f2;
  background: var(--cw-accent-weak, #e8eefc);
}

.pg .pg-chip-outline {
  height: auto;
  min-height: 24px;
  padding: 4px 8px;
  white-space: normal;
  line-height: 1.3;
  font-weight: 600;
  color: #7a4a00;
  border-color: #e8c48a;
  background: #fff4dc;
}

.pg-chip-ok {
  color: var(--cw-ok, #2e7d32);
  border-color: #b9d9bb;
  background: #f2f8f2;
}

.pg .pg-chip-edited {
  color: var(--cw-warn, #b26a00);
  border-color: #e8c48a;
  background: #fff7e8;
}

.pg .pg-chip-new {
  color: var(--cw-purple, #5e35b1);
  border-color: #cbbdf0;
  background: #f5f1fc;
}

.pg-mark {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
  border: 2px solid transparent;
}

.pg-mark-owner {
  background: var(--cw-accent, #1d4ed8);
  border-color: var(--cw-accent, #1d4ed8);
}

.pg-mark-involved {
  border-color: var(--cw-accent, #1d4ed8);
}

.pg-q {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 12px;
  font-weight: 600;
  vertical-align: middle;
  border: 1px solid var(--cw-border-strong, #9aa3ad);
  color: var(--cw-muted, #5b6570);
  cursor: help;
}

/* ---------------------------------------------------------------- "Edited here" reveal */

.pg-reveal {
  margin: 0 0 8px;
  padding: 8px;
  font-size: 13px;
  border: 1px solid var(--cw-border, #d4d8de);
  background: var(--cw-surface-2, #f8f9fa);
}

.pg-reveal-line + .pg-reveal-line {
  margin-top: 2px;
}

.pg-reveal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.pg-reveal-actions:empty {
  display: none;
}

.pg-reveal .pg-history {
  margin-top: 8px;
}

/* ---------------------------------------------------------------- intro and summary */

.pg-intro {
  padding: 0 0 10px;
  margin: 0 0 8px;
  border-bottom: 1px solid var(--cw-border, #d4d8de);
}

.pg-intro.is-selected,
.pg-nest-head.is-selected {
  outline: 2px solid var(--cw-accent, #1d4ed8);
  outline-offset: 3px;
}

.pg-intro.is-hover {
  outline: 1px solid #8fa9e8;
  outline-offset: 3px;
}

.pg-facts {
  margin: 0;
}

.pg-fact {
  display: grid;
  grid-template-columns: 9.5em minmax(0, 1fr);
  gap: 8px;
  padding: 2px 0;
}

.pg-fact dt {
  display: flex;
  align-items: flex-start;
  gap: 2px;
  color: var(--cw-muted, #5b6570);
  font-size: 13px;
  padding-top: 2px;
}

.pg-fact dt .pg-pencil {
  width: 22px;
  height: 22px;
  margin: -2px 0 0 2px;
}

.pg-fact dd {
  display: flex;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
  margin: 0;
}

.pg-fact.is-editing dd {
  display: block;
}

.pg-val {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.pg-clamp {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pg-clamp-1 {
  -webkit-line-clamp: 1;
}

.pg-clamp-2 {
  -webkit-line-clamp: 2;
}

.pg-clamp-3 {
  -webkit-line-clamp: 3;
}

.pg-clamp.is-cut {
  cursor: pointer;
}

.pg .pg-val-empty {
  flex: 0 1 auto;
  color: var(--cw-muted, #5b6570);
  font-style: italic;
  text-align: left;
}

.pg .pg-val-empty:hover {
  color: var(--cw-accent, #1d4ed8);
  text-decoration: underline;
}

.pg-facts-more {
  margin-top: 2px;
}

.pg-facts-more .pg-fact:last-child .pg-val {
  font-size: 13px;
}

/* Toggles: a caret and a short label; the thing is always there, collapsed. */
.pg .pg-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 2px 0;
  font-size: 13px;
  color: var(--cw-accent, #1d4ed8);
}

.pg .pg-toggle:hover {
  text-decoration: underline;
}

.pg-caret {
  display: inline-block;
  flex: none;
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.12s;
}

[aria-expanded="true"] > .pg-caret {
  transform: rotate(90deg);
}

.pg-wflags {
  margin: 4px 0 0;
}

.pg .pg-wflags-toggle {
  color: var(--cw-text, #1b1f24);
  text-align: left;
}

.pg-summary > .pg-toggle {
  margin-top: 2px;
}

/* ---------------------------------------------------------------- steps */

.pg-steps-block {
  margin-top: 4px;
}

.pg-steps-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 8px 0 6px;
}

.pg-hint {
  font-size: var(--cw-fs-sm, 12px);
  color: var(--cw-muted, #5b6570);
}

.pg-steps {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pg-item {
  margin: 0;
  padding: 0;
}

.pg-step {
  position: relative;
  margin-top: -1px;
  border: 1px solid var(--cw-border, #d4d8de);
  background: var(--cw-surface, #fff);
}

.pg-steps > .pg-item:first-child > .pg-step,
.pg-steps > .pg-gap:first-child + .pg-item > .pg-step {
  margin-top: 0;
}

.pg-step.is-open {
  margin: 6px 0 7px;
  border-color: var(--cw-border-strong, #9aa3ad);
}

.pg-step.is-hover {
  z-index: 1;
  outline: 2px solid #8fa9e8;
  outline-offset: -1px;
}

.pg-step.is-selected {
  z-index: 2;
  outline: 2px solid var(--cw-accent, #1d4ed8);
  outline-offset: -1px;
}

.pg-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  min-height: 40px;
  padding: 8px;
  cursor: pointer;
}

.pg-row:hover,
.pg-step.is-hover > .pg-row {
  background: #f1f5fe;
}

.pg-step.is-selected > .pg-row {
  background: var(--cw-accent-weak, #e8eefc);
}

.pg-row:focus-visible {
  outline: 2px solid var(--cw-accent, #1d4ed8);
  outline-offset: -2px;
}

.pg-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--cw-border-strong, #9aa3ad);
  background: var(--cw-surface-2, #f8f9fa);
  color: var(--cw-text, #1b1f24);
}

/* Every number square looks the same (no colour code to learn); the row's words say what it is. */
.pg-num-start,
.pg-num-end,
.pg-num-wait,
.pg-num-decision,
.pg-num-task,
.pg-num-call {
  background: none;
  border-color: transparent;
}

.pg-k-decision .pg-num-decision {
  background: none;
  border-color: transparent;
}

.pg-num-start::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 8px solid var(--cw-muted, #5b6570);
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}

.pg-num-end::before {
  content: "";
  width: 10px;
  height: 10px;
  background: var(--cw-muted, #5b6570);
}

.pg-num-wait::before,
.pg-num-decision::before {
  content: "";
  width: 9px;
  height: 9px;
  border: 2px solid var(--cw-muted, #5b6570);
}

.pg-num-decision::before {
  transform: rotate(45deg);
}

.pg-main {
  min-width: 0;
  padding-top: 2px;
  overflow-wrap: break-word;        /* whole words move to the next line; words are never split */
}

.pg-label {
  font-weight: 600;
}

.pg-lead {
  color: var(--cw-muted, #5b6570);
}

/* "changed" / "not in diagram": this step of an edited page differs from the diagram. */
.pg-diff {
  display: inline-block;
  margin-left: var(--cw-pad-2, 6px);
  padding: 0 4px;
  border: 1px solid #e8c48a;
  background: #fff7e8;
  color: var(--cw-warn, #b26a00);
  font-size: var(--cw-fs-sm, 12px);
  font-weight: 400;
  line-height: 16px;
  vertical-align: 1px;
  white-space: nowrap;
}

.pg-k-start .pg-label,
.pg-k-end .pg-label,
.pg-k-wait .pg-label {
  font-weight: 500;
}

.pg-k-start > .pg-row,
.pg-k-end > .pg-row,
.pg-k-wait > .pg-row {
  min-height: 34px;
  padding-top: 5px;
  padding-bottom: 5px;
}

.pg-side {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 4px 6px;
  min-width: 0;
  max-width: 320px;
  padding-top: 2px;
}

.pg-who {
  min-width: 0;
  max-width: 190px;
  padding: 1px 6px;
  font-size: var(--cw-fs-sm, 12px);
  line-height: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--cw-muted, #5b6570);
  border: 1px solid var(--cw-border, #d4d8de);
  background: var(--cw-surface-2, #f8f9fa);
}

/* The same person as the step before: still written, just quieter. */
.pg-who.pg-who-same {
  border-color: transparent;
  background: transparent;
  color: #7a838d;
}

/* Markers in words: "? 1 question", "! Never skip", "2 notes", "Changed", "1 suggestion". */
.pg-marks {
  display: inline-flex;
  flex: none;
  flex-wrap: wrap;
  gap: 3px;
}

.pg-marks:empty {
  display: none;
}

.pg-mk {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-height: 20px;
  padding: 0 5px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  border: 1px solid;
  cursor: pointer;
}

.pg-mk-glyph {
  font-weight: 800;
}

.pg-mk-more {
  color: var(--cw-muted, #5b6570);
  background: var(--cw-surface, #fff);
  border-color: var(--cw-border, #d4d8de);
}

.pg .is-flash {
  animation: pg-flash 1.4s ease-out;
}

@keyframes pg-flash {
  0%, 40% { outline: 3px solid var(--cw-accent, #1d4ed8); outline-offset: 2px; }
  100% { outline: 3px solid transparent; outline-offset: 2px; }
}

.pg-mk-q {
  background: var(--cw-q, #fff2b3);
  border-color: #dcc048;
  color: #6b5600;
}

.pg-mk-me {
  border-width: 2px;
  border-color: #8a6d00;
}

.pg-mk-a {
  background: var(--cw-a, #dbeafe);
  border-color: #93b4ec;
  color: var(--cw-accent, #1d4ed8);
}

.pg-mk-p {
  background: var(--cw-p, #dcfce7);
  border-color: #8fd0a4;
  color: #1e6b36;
}

.pg-mk-c {
  background: var(--cw-c, #fde2e2);
  border-color: #e9a1a1;
  color: var(--cw-danger, #c62828);
}

.pg-mk-n {
  background: #eceff2;
  border-color: #c3c9d0;
  color: #3c4650;
}

.pg-mk-inside {
  background: #f5f1fc;
  border-color: #cbbdf0;
  color: var(--cw-purple, #5e35b1);
}

/* "+ Add a step here": a slim line between steps, shown on hover or keyboard focus. */
.pg-gap {
  position: relative;
  height: 0;
  z-index: 3;
  list-style: none;
}

.pg-gap::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -4px;
  height: 8px;
}

/* Centred on the line between two rows; the rows' 8px padding keeps it off their words. */
.pg .pg-gap-btn {
  position: absolute;
  left: 40px;
  top: -8px;
  height: 16px;
  padding: 0 8px;
  font-size: 11px;
  line-height: 14px;
  white-space: nowrap;
  color: var(--cw-accent, #1d4ed8);
  background: var(--cw-surface, #fff);
  border: 1px dashed var(--cw-accent, #1d4ed8);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s;
}

.pg-gap:hover .pg-gap-btn,
.pg .pg-gap-btn:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

@media (hover: none) {
  .pg-gap {
    display: none;
  }
}

/* ---------------------------------------------------------------- an opened step */

.pg-body {
  padding: 2px 12px 10px 42px;
  border-top: 1px solid var(--cw-border, #d4d8de);
}

.pg-sec {
  margin: 8px 0;
}

.pg-sec-h {
  margin: 0 0 4px;
  font-size: var(--cw-fs-sm, 12px);
  font-weight: 700;
  color: var(--cw-muted, #5b6570);
}

.pg-how {
  margin: 0;
  padding-left: 1.4em;
}

.pg-how li {
  margin: 2px 0;
  padding-left: 2px;
}

.pg-sfacts {
  margin: 8px 0;
}

.pg-sfact {
  display: grid;
  grid-template-columns: 8.5em minmax(0, 1fr);
  gap: 8px;
  padding: 2px 0;
}

.pg-sfact dt {
  color: var(--cw-muted, #5b6570);
  font-size: 13px;
  padding-top: 2px;
}

.pg-sfact dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.pg-sfact-note dd {
  font-size: 14px;
  color: #39424c;
}

.pg-callouts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0;
}

.pg-callout {
  padding: 6px 8px;
  border-left: 3px solid;
}

.pg-callout-q {
  background: var(--cw-q, #fff2b3);
  border-left-color: #d4a900;
}

.pg-callout-a {
  background: var(--cw-a, #dbeafe);
  border-left-color: var(--cw-accent, #1d4ed8);
}

.pg-callout-p {
  background: var(--cw-p, #dcfce7);
  border-left-color: var(--cw-ok, #2e7d32);
}

.pg-callout-c {
  background: var(--cw-c, #fde2e2);
  border-left-color: var(--cw-danger, #c62828);
}

.pg-callout-title {
  font-size: 13px;
  font-weight: 700;
  cursor: help;
}

.pg-callout-text {
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.pg-callout .pg-btn {
  margin-top: 6px;
}

.pg-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pg .pg-opt {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 6px;
  width: 100%;
  min-height: 34px;
  padding: 5px 8px;
  text-align: left;
  border: 1px solid var(--cw-border, #d4d8de);
  background: var(--cw-surface-2, #f8f9fa);
}

.pg .pg-opt:hover:not(:disabled) {
  border-color: var(--cw-accent, #1d4ed8);
}

.pg-opt-label {
  font-weight: 700;
}

.pg-opt-arrow {
  color: var(--cw-muted, #5b6570);
}

.pg-opt-go {
  font-weight: 600;
  color: var(--cw-accent, #1d4ed8);
}

.pg .pg-opt:disabled .pg-opt-go {
  color: var(--cw-muted, #5b6570);
}

.pg-opt-sub {
  font-size: 13px;
  color: var(--cw-muted, #5b6570);
}

.pg-call {
  margin: 8px 0;
  padding: 8px;
  border: 1px solid #cbbdf0;
  background: #f8f5fd;
}

.pg-call-name {
  font-weight: 600;
}

.pg-call-acts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.pg-notes-sec {
  margin-top: 10px;
}

.pg-thread:empty {
  display: none;
}

.pg .pg-add-note {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 2px 0;
  font-size: 13px;
  color: var(--cw-accent, #1d4ed8);
}

.pg .pg-add-note:hover {
  text-decoration: underline;
}

.pg-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 8px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--cw-border, #d4d8de);
}

.pg-source {
  flex: 1 1 220px;
  min-width: 0;
  font-size: var(--cw-fs-sm, 12px);
  color: var(--cw-muted, #5b6570);
  overflow-wrap: anywhere;
}

.pg-acts {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-left: auto;
}

.pg .pg-quiet {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 2px 6px;
  font-size: 13px;
  color: var(--cw-muted, #5b6570);
  border: 1px solid transparent;
}

.pg .pg-quiet:hover:not(:disabled) {
  color: var(--cw-accent, #1d4ed8);
  border-color: var(--cw-border, #d4d8de);
  background: var(--cw-surface, #fff);
}

.pg .pg-quiet:disabled {
  opacity: 0.4;
}

.pg .pg-pin.is-on {
  color: var(--cw-accent, #1d4ed8);
}

.pg .pg-danger {
  color: var(--cw-danger, #c62828);
}

/* ---------------------------------------------------------------- linked workflow written out in place */

.pg-nest {
  margin: 0 0 8px 20px;
  padding: 6px 0 2px 10px;
  border-left: 3px solid var(--cw-purple, #5e35b1);
}

.pg-nest-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px 2px 8px;
  border: 1px solid #cbbdf0;
  background: #f5f1fc;
}

.pg-nest-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 30px;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
}

.pg-nest-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pg-nest-head.is-hover {
  outline: 1px solid #8fa9e8;
}

.pg-nest > .pg-wflags-toggle {
  margin-top: 2px;
}

.pg-nest > .pg-steps {
  margin-top: 6px;
}

/* ---------------------------------------------------------------- buttons and links */

.pg .pg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 30px;
  padding: 3px 10px;
  font-size: 13px;
  white-space: nowrap;
  color: var(--cw-text, #1b1f24);
  background: var(--cw-surface, #fff);
  border: 1px solid var(--cw-border-strong, #9aa3ad);
}

.pg .pg-btn:hover:not(:disabled) {
  color: var(--cw-accent, #1d4ed8);
  border-color: var(--cw-accent, #1d4ed8);
}

.pg .pg-btn:disabled {
  opacity: 0.5;
}

.pg .pg-btn-primary {
  color: #fff;
  background: var(--cw-accent, #1d4ed8);
  border-color: var(--cw-accent, #1d4ed8);
}

.pg .pg-btn-primary:hover:not(:disabled) {
  color: #fff;
  background: #1a43bd;
}

.pg .pg-btn.is-on {
  color: var(--cw-accent, #1d4ed8);
  background: var(--cw-accent-weak, #e8eefc);
  border-color: var(--cw-accent, #1d4ed8);
}

.pg .pg-btn-danger {
  color: #fff;
  background: var(--cw-danger, #c62828);
  border-color: var(--cw-danger, #c62828);
}

.pg .pg-btn-danger:hover:not(:disabled) {
  color: #fff;
  background: #a61f1f;
  border-color: #a61f1f;
}

.pg .pg-btn-danger-quiet {
  color: var(--cw-danger, #c62828);
  border-color: #e9a1a1;
}

.pg .pg-link {
  display: inline;
  color: var(--cw-accent, #1d4ed8);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.pg-src-ref {
  border-bottom: 1px dotted var(--cw-muted, #5b6570);
  cursor: help;
}

.pg-confirm {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

/* ---------------------------------------------------------------- forms */

.pg-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pg-form-step {
  padding: 8px 0 2px;
}

.pg-item > .pg-form-step {
  margin: 6px 0 7px;
  padding: 10px 12px;
  border: 1px solid var(--cw-accent, #1d4ed8);
  background: var(--cw-surface, #fff);
}

.pg-form-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--cw-accent, #1d4ed8);
}

.pg-form-rename {
  padding: 4px 0 8px;
}

.pg-form-field {
  flex: 1 1 auto;
  padding: 2px 0 6px;
}

.pg-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.pg-field-label {
  font-size: var(--cw-fs-sm, 12px);
  font-weight: 600;
  color: var(--cw-muted, #5b6570);
}

.pg-input {
  width: 100%;
  min-height: 36px;
  padding: 6px 8px;
  font: inherit;
  font-size: 15px;
  color: var(--cw-text, #1b1f24);
  background: #fff;
  border: 1px solid var(--cw-border-strong, #9aa3ad);
  border-radius: 0;
}

.pg-input:focus {
  outline: 2px solid var(--cw-accent, #1d4ed8);
  outline-offset: -1px;
  border-color: var(--cw-accent, #1d4ed8);
}

.pg-textarea {
  resize: vertical;
  line-height: 1.4;
}

.pg-input-title {
  font-size: 20px;
  font-weight: 600;
}

.pg-form-btns {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.pg-form-right {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-left: auto;
}

/* ---------------------------------------------------------------- collapsed blocks (notes, history) */

.pg-block {
  margin-top: 12px;
  border-top: 1px solid var(--cw-border, #d4d8de);
}

.pg-block:last-child {
  border-bottom: 1px solid var(--cw-border, #d4d8de);
}

.pg .pg-block-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 8px 0;
  font-size: 15px;
  font-weight: 650;
  text-align: left;
}

.pg .pg-block-head:hover .pg-block-label {
  color: var(--cw-accent, #1d4ed8);
}

.pg-block + .pg-block {
  margin-top: 0;
}

.pg-block-count {
  font-weight: 400;
  color: var(--cw-muted, #5b6570);
}

.pg-block-body {
  padding: 0 0 10px 14px;
}

/* ---------------------------------------------------------------- home */

.pg-welcome p {
  margin: 2px 0;
}

.pg-welcome .pg-toggle {
  margin-top: 6px;
}

.pg-tips {
  margin: 4px 0 0;
  padding-left: 1.4em;
}

.pg-tips li {
  margin: 3px 0;
}

.pg-sec-block {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--cw-border, #d4d8de);
}

.pg-sec-block > .pg-h2 {
  margin-bottom: 6px;
}

.pg-identity .pg-muted {
  margin-bottom: 8px;
}

.pg-names {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0;
}

.pg .pg-name {
  min-height: 32px;
  padding: 3px 10px;
  border: 1px solid var(--cw-border-strong, #9aa3ad);
  background: var(--cw-surface, #fff);
}

.pg .pg-name:hover {
  color: var(--cw-accent, #1d4ed8);
  border-color: var(--cw-accent, #1d4ed8);
}

.pg-inline {
  display: flex;
  gap: 6px;
  max-width: 440px;
}

.pg-inline .pg-input {
  flex: 1 1 auto;
  min-width: 0;
}

.pg-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 0 6px;
  font-size: var(--cw-fs-sm, 12px);
  color: var(--cw-muted, #5b6570);
}

.pg-legend .pg-mark + span {
  margin-right: 10px;
}

.pg-wf-list {
  margin: 0 0 6px;
  padding: 0;
  list-style: none;
  border: 1px solid var(--cw-border, #d4d8de);
}

.pg-wf-list li + li {
  border-top: 1px solid var(--cw-border, #d4d8de);
}

.pg .pg-wf-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  padding: 6px 8px;
  text-align: left;
  background: var(--cw-surface, #fff);
}

.pg .pg-wf-row:hover {
  background: var(--cw-surface-2, #f8f9fa);
}

.pg-wf-code {
  flex: none;
  width: 3em;
  font-size: 13px;
  color: var(--cw-muted, #5b6570);
  font-variant-numeric: tabular-nums;
}

.pg-wf-title {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pg-first {
  padding: 16px;
  text-align: center;
  border: 1px dashed var(--cw-border-strong, #9aa3ad);
  background: var(--cw-surface-2, #f8f9fa);
}

.pg-first p {
  margin: 0 0 8px;
  color: var(--cw-muted, #5b6570);
}

.pg-empty-text {
  margin: 12px 0;
  color: var(--cw-muted, #5b6570);
}

/* ---------------------------------------------------------------- the page column's own width */

/* A narrow page (a phone, or a small window with the list and the diagram open): who and the
   markers go under the step's words instead of squeezing them. (#middle is the container.) */
@container page (max-width: 560px) {
  .pg-row {
    grid-template-columns: 26px minmax(0, 1fr);
    row-gap: 4px;
  }

  .pg-side {
    grid-column: 2;
    justify-content: flex-start;
    max-width: none;
    padding-top: 0;
  }

  .pg-side:not(:has(*)) {
    display: none;
  }

  .pg-who {
    max-width: 100%;
  }

  .pg-body {
    padding-left: 10px;
    padding-right: 10px;
  }

  .pg-fact,
  .pg-sfact {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .pg-nest {
    margin-left: 6px;
    padding-left: 6px;
  }

  .pg-title {
    font-size: 20px;
  }
}

/* ---------------------------------------------------------------- answers, callouts, the whole-workflow block */

.pg-answer {
  margin-top: 4px;
  padding: 4px 6px;
  border-left: 3px solid var(--cw-k-answer, #f9a825);
  background: var(--cw-surface, #fff);
  color: var(--cw-text, #1b1f24);
  font-size: 14px;
  overflow-wrap: break-word;
}

.pg .pg-callout-more {
  font-size: 13px;
}

.pg-about .pg-block-body {
  padding-left: 0;
}

.pg-about .pg-block-label {
  white-space: nowrap;
}

.pg-about .pg-block-count {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ---------------------------------------------------------------- home: one next step */

.pg .pg-btn-big {
  min-height: 40px;
  padding: 6px 16px;
  font-size: 15px;
  font-weight: 600;
}

.pg-identity {
  border-top: 0;
  padding-top: 4px;
  margin-top: 10px;
}

.pg-next-line {
  margin: 0 0 8px;
}

.pg-next-line .pg-q {
  margin-left: 6px;
}

.pg .pg-next-btn {
  display: flex;
  justify-content: flex-start;
  max-width: 100%;
  min-height: 40px;
  padding: 6px 12px;
  font-size: 15px;
  white-space: normal;
  text-align: left;
}

.pg-next-title {
  font-weight: 600;
}

.pg-next-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 8px;
}

.pg-help {
  margin-top: 8px;
}

/* ---------------------------------------------------------------- phones, tablets and touch */

@media (pointer: coarse) {
  .pg .pg-btn,
  .pg .pg-quiet,
  .pg .pg-toggle,
  .pg .pg-add-note,
  .pg .pg-name,
  .pg .pg-back,
  .pg .pg-crumb,
  .pg .pg-opt,
  .pg .pg-block-head,
  .pg .pg-chip-btn,
  .pg .pg-link {
    min-height: var(--cw-tap, 40px);
  }

  .pg .pg-link {
    display: inline-flex;
    align-items: center;
  }

  .pg .pg-pencil,
  .pg-fact dt .pg-pencil {
    width: var(--cw-tap, 40px);
    height: var(--cw-tap, 40px);
  }

  .pg-fact {
    padding: 4px 0;
  }

  .pg-mk {
    min-height: 26px;
  }

  .pg-chip {
    height: auto;
    min-height: 32px;
  }

  .pg-q {
    position: relative;
    width: 24px;
    height: 24px;
  }

  .pg-q::before {
    content: '';
    position: absolute;
    inset: -8px;
  }

  .pg-row {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
}

.pg-callout.is-answered {
  background: var(--cw-surface-2, #f8f9fa);
  border-left-color: var(--cw-border-strong, #9aa3ad);
  color: var(--cw-muted, #5b6570);
}
