/* ===========================================================================
   Process Hub — app styles.
   Light theme, works down to phone width. Tokens first, then layout.
   =========================================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --text: #1D1D1F;
  --text-soft: #6E6E73;
  --border: rgba(0, 0, 0, 0.09);
  --border-strong: rgba(0, 0, 0, 0.18);
  --accent: #0A66C2;
  --accent-soft: #EAF2FB;
  --danger: #C0392B;
  --warn: #B45309;
  --warn-soft: #FEF6E7;
  --good: #2E7D53;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --sidebar-w: 330px;
  --header-h: 52px;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78em;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ---- header -------------------------------------------------------------- */

.app-header {
  flex: 0 0 var(--header-h);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}

.app-brand {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.2px;
  color: var(--text);
  text-decoration: none;
}

.drawer-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  width: 34px;
  height: 32px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text);
}

.pill-status {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-soft);
  white-space: nowrap;
}
.pill-status.live { background: #EAF6EE; color: var(--good); }
.pill-status.draft { background: var(--warn-soft); color: var(--warn); }
.pill-status.error { background: #FBEAE8; color: var(--danger); }

/* ---- conflict bar -------------------------------------------------------- */

.conflict-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  background: var(--warn-soft);
  border-bottom: 1px solid #F0D9A8;
  font-size: 0.86rem;
  color: #6B4A0B;
}
/* An author display rule beats the hidden attribute, so restate it. */
.conflict-bar[hidden] { display: none; }

.btn {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
a.btn { display: inline-block; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #084A8E; color: #fff; }

/* ---- layout -------------------------------------------------------------- */

.app-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.sidebar {
  flex: 0 0 var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-height: 0;
}

.sidebar-search {
  position: relative;
  padding: 0.7rem 0.8rem 0.5rem;
}
.sidebar-search input {
  width: 100%;
  font: inherit;
  font-size: 0.88rem;
  padding: 0.45rem 2rem 0.45rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
.sidebar-search input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}
.search-hint {
  position: absolute;
  right: 1.35rem;
  top: 1.05rem;
  pointer-events: none;
  opacity: 0.55;
}
.sidebar-search input:focus + .search-hint { display: none; }

.sidebar-count {
  padding: 0 0.9rem 0.6rem;
  font-size: 0.72rem;
  color: var(--text-soft);
  border-bottom: 1px solid var(--border);
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.4rem 2rem;
  -webkit-overflow-scrolling: touch;
}

.detail {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}

/* ---- tree ---------------------------------------------------------------- */

.tree-head {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.4rem;
  border-radius: 6px;
  cursor: default;
}
.tree-node.depth-0 > .tree-head { margin-top: 0.35rem; }
.tree-node.depth-0 > .tree-head .tree-label {
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.tree-node.depth-1 > .tree-head .tree-label { font-weight: 600; font-size: 0.87rem; }

.caret {
  flex: 0 0 18px;
  background: none;
  border: none;
  font-size: 0.7rem;
  color: var(--text-soft);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.caret.empty { visibility: hidden; }

.tree-label { flex: 1; min-width: 0; }

.tree-count {
  font-size: 0.68rem;
  color: var(--text-soft);
  background: var(--bg);
  border-radius: 999px;
  padding: 0 6px;
}

.tree-children { padding-left: 0.85rem; }

.tree-process {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 0.83rem;
  padding: 0.3rem 0.45rem;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text);
  cursor: pointer;
}
.tree-process:hover { background: var(--bg); }
.tree-process.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tree-process-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  flex: 0 0 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border-strong);
}
.status-dot.status-draft { background: #D9A441; }
.status-dot.status-mapped { background: #6FA8DC; }
.status-dot.status-reviewed,
.status-dot.status-published { background: var(--good); }
.status-dot.status-needs_rework { background: var(--danger); }

.flag {
  font-size: 0.66rem;
  font-weight: 600;
  padding: 0 5px;
  border-radius: 999px;
  white-space: nowrap;
}
.flag.handoff { background: var(--accent-soft); color: var(--accent); }
.flag.issue { background: #FBEAE8; color: var(--danger); }

.tree-extra {
  margin-top: 1.2rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.tree-link {
  text-align: left;
  font: inherit;
  font-size: 0.83rem;
  padding: 0.35rem 0.55rem;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--accent);
  cursor: pointer;
}
.tree-link:hover { background: var(--bg); }

/* ---- search results ------------------------------------------------------ */

.result {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  font: inherit;
  padding: 0.4rem 0.5rem;
  border: none;
  border-radius: 7px;
  background: none;
  cursor: pointer;
}
.result:hover { background: var(--bg); }
.result-body { min-width: 0; flex: 1; }
.result-title {
  display: block;
  font-size: 0.84rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--text-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kind {
  flex: 0 0 auto;
  align-self: flex-start;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 2px;
  background: var(--bg);
  color: var(--text-soft);
}
.kind-process { background: var(--accent-soft); color: var(--accent); }
.kind-article { background: #EFEAF8; color: #5B3FA8; }
.kind-faq { background: #EAF6EE; color: var(--good); }
.kind-variable { background: var(--warn-soft); color: var(--warn); }

/* ---- detail pane --------------------------------------------------------- */

.pane { max-width: 860px; padding: 1.6rem 1.6rem 5rem; }

.pane-head { margin-bottom: 1.6rem; }
.pane-head h1 { font-size: 1.6rem; line-height: 1.25; letter-spacing: -0.4px; }

.crumbs {
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-soft);
  margin-bottom: 0.35rem;
}

.lede { color: var(--text-soft); margin-top: 0.5rem; }
.note { font-size: 0.86rem; color: var(--warn); margin-top: 0.4rem; }

.badges { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.7rem; }
.badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-soft);
}
.badge.status-draft { background: #FBF0DC; color: #8A6314; }
.badge.status-published, .badge.status-approved { background: #EAF6EE; color: var(--good); }
.badge.warn { background: var(--accent-soft); color: var(--accent); }
.badge.issue { background: #FBEAE8; color: var(--danger); }
.badge.lock { background: #EFEAF8; color: #5B3FA8; }

.usage {
  margin-top: 0.8rem;
  font-size: 0.82rem;
  color: var(--warn);
  background: var(--warn-soft);
  border-radius: 7px;
  padding: 0.45rem 0.7rem;
}
.usage.none { color: var(--text-soft); background: var(--bg); }

.block { margin-bottom: 1.8rem; }
.block h2 {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  margin-bottom: 0.7rem;
}

/* ---- step flow ----------------------------------------------------------- */

.flow { margin-bottom: 1.8rem; }

.step {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: 9px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.55rem;
  box-shadow: var(--shadow);
}
.step-entry { border-left-color: var(--good); }
.step-action { border-left-color: var(--accent); }
.step-decision { border-left-color: var(--warn); }
.step-resolution { border-left-color: #5B3FA8; }

.step-head { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.step-head h3 { font-size: 0.98rem; font-weight: 650; flex: 1; min-width: 12ch; }
.step-n {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-soft);
  background: var(--bg);
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
  padding: 1px 6px;
}
.step-type {
  font-size: 0.63rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-soft);
}

.step-meta { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.5rem 0; }
.pill {
  font-size: 0.7rem;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-soft);
}
.pill.dept { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.script {
  border-left: 3px solid var(--good);
  background: #F4FAF6;
  border-radius: 0 7px 7px 0;
  padding: 0.5rem 0.75rem;
  margin: 0.55rem 0;
  font-style: italic;
  font-size: 0.9rem;
}

.sop { font-size: 0.9rem; margin: 0.45rem 0; }

.checks { list-style: none; margin: 0.5rem 0; }
.checks li {
  position: relative;
  padding-left: 1.5rem;
  font-size: 0.87rem;
  margin-bottom: 0.25rem;
}
.checks li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.3em;
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--border-strong);
  border-radius: 3px;
}

.attached { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.6rem; }
.chip-link {
  font: inherit;
  font-size: 0.76rem;
  padding: 2px 9px;
  border: 1px solid #C6D9F0;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
}
.chip-link:hover { background: #DCEAF9; }

.trigger {
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
  font-size: 0.82rem;
  color: var(--text-soft);
}
.trigger strong { color: var(--text); }

.handoff-marker {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--warn);
  background: var(--warn-soft);
  border-radius: 999px;
  padding: 2px 10px;
  margin: 0.4rem 0 0.55rem 0.8rem;
}

/* ---- variables in text --------------------------------------------------- */

.var-chip {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 4px;
  padding: 0 4px;
  font-weight: 600;
  cursor: help;
}
.var-chip.internal { background: #EFEAF8; color: #5B3FA8; }
.var-chip.pending { border-bottom: 1.5px dotted currentColor; }
.var-chip.missing { background: #FBEAE8; color: var(--danger); }

/* ---- issues -------------------------------------------------------------- */

.issue-row {
  display: flex;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 0.4rem;
  font-size: 0.87rem;
}
.sev {
  flex: 0 0 auto;
  align-self: flex-start;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-soft);
}
.sev-high .sev { background: #FBEAE8; color: var(--danger); }
.sev-medium .sev { background: var(--warn-soft); color: var(--warn); }
.issue-meta { font-size: 0.73rem; color: var(--text-soft); }

/* ---- lists and tiles ----------------------------------------------------- */

.list-row {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 0.35rem;
  cursor: pointer;
}
.list-row:hover { border-color: var(--accent); }
.list-title { display: block; font-size: 0.9rem; font-weight: 600; }
.list-sub { display: block; font-size: 0.78rem; color: var(--text-soft); }
.list-tail { display: block; font-size: 0.72rem; color: var(--text-soft); margin-top: 0.15rem; }
.list-row.issue-list .sev { display: inline-block; margin-bottom: 0.25rem; }

h2.group {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  margin: 1.4rem 0 0.5rem;
}
h2.group span { color: var(--border-strong); }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.6rem;
  margin-bottom: 2rem;
}
.tile {
  display: block;
  text-align: left;
  font: inherit;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: default;
}
button.tile { cursor: pointer; }
button.tile:hover { border-color: var(--accent); }
.tile-n { display: block; font-size: 1.7rem; font-weight: 700; letter-spacing: -1px; }
.tile-label { display: block; font-size: 0.82rem; font-weight: 600; }
.tile-sub { display: block; font-size: 0.72rem; color: var(--text-soft); }

.meta dl { display: grid; grid-template-columns: minmax(110px, 170px) 1fr; gap: 0.3rem 1rem; }
.meta dt { font-size: 0.78rem; color: var(--text-soft); }
.meta dd { font-size: 0.88rem; }

.refs { list-style: none; font-size: 0.85rem; }
.refs li { padding-left: 1.1rem; position: relative; margin-bottom: 0.2rem; }
.refs li::before { content: '›'; position: absolute; left: 0; color: var(--text-soft); }

.empty { color: var(--text-soft); font-size: 0.87rem; padding: 0.5rem 0.2rem; }

/* ---- prose (article and FAQ bodies) -------------------------------------- */

.prose { font-size: 0.93rem; line-height: 1.7; }
.prose p { margin-bottom: 0.7rem; }
.prose ul, .prose ol { margin: 0.5rem 0 0.8rem 1.3rem; }
.prose li { margin-bottom: 0.3rem; }
.prose a { color: var(--accent); }
.prose b, .prose strong { font-weight: 650; }
.prose u { text-decoration: none; font-weight: 650; display: inline-block; margin-top: 0.4rem; }
.prose table { border-collapse: collapse; width: 100%; margin: 0.7rem 0; font-size: 0.86rem; }
.prose th, .prose td { border: 1px solid var(--border-strong); padding: 6px 9px; text-align: left; }
.prose th { background: var(--bg); }

/* ---- narrow screens ------------------------------------------------------ */

@media (max-width: 800px) {
  .drawer-toggle { display: block; }

  .sidebar {
    position: fixed;
    top: var(--header-h);
    bottom: 0;
    left: 0;
    width: min(85vw, var(--sidebar-w));
    transform: translateX(-102%);
    transition: transform 0.2s ease;
    z-index: 30;
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.14);
  }
  body.drawer-open .sidebar { transform: translateX(0); }

  .pane { padding: 1.1rem 1rem 4rem; }
  .pane-head h1 { font-size: 1.35rem; }
  .meta dl { grid-template-columns: 1fr; gap: 0 0; }
  .meta dd { margin-bottom: 0.5rem; }
  .search-hint { display: none; }
}

/* ===========================================================================
   Editing
   =========================================================================== */

.editable {
  border-radius: 5px;
  padding: 1px 4px;
  margin: -1px -4px;
  cursor: text;
  transition: background 0.12s, box-shadow 0.12s;
}
.editable:hover { background: var(--accent-soft); }
.editable:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.editable.is-empty { color: var(--text-soft); }
.editable .ph { opacity: 0.55; font-style: italic; }

.editable-h1 .editable { display: block; }

.edit-shell {
  display: block;
  margin: -2px 0;
}
.edit-input {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.5;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
}
.edit-input:focus { outline: none; box-shadow: 0 0 0 3px rgba(10, 102, 194, 0.14); }
select.edit-input { padding: 0.3rem 0.4rem; }

.edit-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.3rem;
}
.edit-hint { flex: 1; font-size: 0.72rem; color: var(--text-soft); }

.btn.small { font-size: 0.74rem; padding: 0.18rem 0.55rem; }
.btn.tiny {
  font-size: 0.68rem;
  padding: 0 0.4rem;
  line-height: 1.6;
  border-radius: 5px;
  margin-left: 0.3rem;
}
.btn.danger { color: var(--danger); border-color: rgba(192, 57, 43, 0.35); }
.btn.danger:hover { background: #FBEAE8; color: var(--danger); border-color: var(--danger); }

.field-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  margin: 0.7rem 0 0.2rem;
}

.step-tools { display: flex; gap: 0.15rem; opacity: 0; transition: opacity 0.12s; }
.step:hover .step-tools, .step:focus-within .step-tools { opacity: 1; }

.add-step-row { margin-top: 0.6rem; }

.row-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.9rem; }

.step-meta .pill .editable { display: inline-block; min-width: 3ch; }
.step-meta .pill:has(.is-empty) { opacity: 0.55; }

.checks li { display: flex; align-items: baseline; gap: 0.3rem; }
.checks li .editable { flex: 1; }

.issue-row .issue-body { flex: 1; }

.owner-group { margin-bottom: 1.6rem; }
.group-actions { float: right; font-weight: 400; text-transform: none; letter-spacing: 0; }

/* ---- export menu --------------------------------------------------------- */

.export-wrap { position: relative; }

.export-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: 290px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
  padding: 0.3rem;
  z-index: 40;
}
.export-menu button {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  padding: 0.45rem 0.6rem;
  border: none;
  border-radius: 7px;
  background: none;
  color: var(--text);
  cursor: pointer;
}
.export-menu button:hover { background: var(--bg); }
.export-menu strong { display: block; font-size: 0.85rem; font-weight: 600; }
.export-menu span { display: block; font-size: 0.73rem; color: var(--text-soft); }
.export-menu button.danger strong { color: var(--danger); }

/* ---- variable picker ----------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 1rem 1rem;
  z-index: 60;
}
.modal[hidden] { display: none; }

.modal-box {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border-radius: 12px;
  padding: 1.1rem 1.2rem 1rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.24);
  max-height: 78vh;
  display: flex;
  flex-direction: column;
}
.modal-box h3 { font-size: 1rem; }
.modal-sub { font-size: 0.8rem; color: var(--text-soft); margin-bottom: 0.6rem; }
.modal-box input[type="search"] {
  width: 100%;
  font: inherit;
  font-size: 0.88rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 0.4rem; margin-top: 0.7rem; }

.pick-list { flex: 1; overflow-y: auto; min-height: 0; }
.pick-row {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  padding: 0.4rem 0.55rem;
  border: none;
  border-radius: 7px;
  background: none;
  cursor: pointer;
}
.pick-row:hover { background: var(--bg); }
.pick-value { display: block; font-size: 0.86rem; font-weight: 600; }
.pick-q { display: block; font-size: 0.74rem; color: var(--text-soft); }

@media (max-width: 800px) {
  .export-menu { width: min(88vw, 290px); }
  .step-tools { opacity: 1; }
}

/* Phone: the header stays on one row, so it sheds a word at a time — first
   Live call, then Export. Both keep a title for a long press. */
@media (max-width: 560px) {
  .app-header { gap: 0.4rem; padding: 0 0.6rem; }
  .app-header a.btn .btn-text { display: none; }
}

@media (max-width: 400px) {
  #exportBtn .btn-text { display: none; }
}

/* Smallest phones: the drawer button and the page itself say where you are,
   so the wordmark goes too. */
@media (max-width: 360px) {
  .app-brand { display: none; }
}

/* ===========================================================================
   Process map
   =========================================================================== */

.view-toggle { display: inline-flex; gap: 2px; margin-bottom: 1.1rem;
  background: var(--bg); border-radius: 8px; padding: 2px; }
.view-toggle .vt {
  font: inherit; font-size: 0.78rem; font-weight: 600;
  padding: 0.25rem 0.9rem; border: none; border-radius: 6px;
  background: none; color: var(--text-soft); cursor: pointer;
}
.view-toggle .vt.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.canvas-host { margin-bottom: 1.8rem; }

.canvas-toolbar {
  display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap;
  padding: 0.4rem 0.5rem; background: var(--surface);
  border: 1px solid var(--border); border-bottom: none;
  border-radius: 10px 10px 0 0;
}
.canvas-toolbar .spacer { flex: 1; }
.zoom-level { font-size: 0.72rem; color: var(--text-soft); min-width: 42px; text-align: center; }

.detail-toggle { display: inline-flex; gap: 2px; background: var(--bg);
  border-radius: 7px; padding: 2px; }
.detail-toggle .cdt {
  font: inherit; font-size: 0.72rem; font-weight: 600;
  padding: 0.15rem 0.6rem; border: none; border-radius: 5px;
  background: none; color: var(--text-soft); cursor: pointer;
}
.detail-toggle .cdt.on { background: var(--surface); color: var(--accent); }

.canvas-viewport {
  position: relative;
  height: min(70vh, 620px);
  overflow: hidden;
  background: var(--bg);
  background-image: radial-gradient(circle, rgba(0, 0, 0, 0.07) 1px, transparent 1px);
  background-size: 20px 20px;
  border: 1px solid var(--border);
  border-radius: 0 0 10px 10px;
  cursor: grab;
  touch-action: none;
}
.canvas-viewport.panning { cursor: grabbing; }

.canvas-stage { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.canvas-wires { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; }
.canvas-wires .wire-label { font-size: 10px; fill: #4A5260; paint-order: stroke;
  stroke: #F5F7FA; stroke-width: 3px; }
.canvas-cards { position: absolute; top: 0; left: 0; }

.node {
  position: absolute;
  background: var(--surface);
  border: 1px solid #DDE2E9;
  border-left: 3.5px solid var(--border-strong);
  border-radius: 9px;
  padding: 0.55rem 0.7rem;
  box-shadow: var(--shadow);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.node.dragging { cursor: grabbing; box-shadow: 0 8px 22px rgba(0, 0, 0, 0.16); z-index: 5; }
.node-entry { border-left-color: var(--good); }
.node-action { border-left-color: var(--accent); }
.node-decision { border-left-color: var(--warn); }
.node-resolution { border-left-color: #5B3FA8; }

.node-head { display: flex; align-items: flex-start; gap: 0.4rem; }
.node-n {
  flex: 0 0 auto; font-size: 0.66rem; font-weight: 700; color: var(--text-soft);
  background: var(--bg); border-radius: 999px; padding: 1px 6px; margin-top: 1px;
}
.node-title { flex: 1; font-size: 0.82rem; font-weight: 650; line-height: 1.3; }
.node-open {
  flex: 0 0 auto; background: none; border: none; cursor: pointer;
  color: var(--text-soft); font-size: 0.75rem; padding: 0 2px; opacity: 0;
}
.node:hover .node-open { opacity: 1; }
.node-open:hover { color: var(--accent); }

.node-role { font-size: 0.7rem; color: var(--text-soft); margin-top: 0.15rem; }
.node-meta { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.35rem; }
.node-dept {
  font-size: 0.65rem; font-weight: 600; padding: 1px 7px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}
.node-meta span:not(.node-dept) {
  font-size: 0.65rem; padding: 1px 7px; border-radius: 999px;
  background: var(--bg); color: var(--text-soft);
}
.node-sop { font-size: 0.7rem; color: #4A5260; margin-top: 0.35rem; line-height: 1.4; }
.node-trigger { font-size: 0.66rem; color: var(--text-soft); margin-top: 0.3rem; }

@media (max-width: 800px) {
  .canvas-viewport { height: 62vh; }
  .node-open { opacity: 1; }
}

.pane.wide { max-width: none; }
.pane.wide .pane-head, .pane.wide .block, .pane.wide .issues { max-width: 860px; }

/* ===========================================================================
   Rich text editor, carried over from the FAQ Editor
   =========================================================================== */

.rt {
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  overflow: hidden;
  background: var(--surface);
}

.rt-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 0.35rem 0.4rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.rt-toolbar button {
  font: inherit;
  font-size: 0.76rem;
  line-height: 1.5;
  padding: 0.1rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  color: var(--text);
  cursor: pointer;
}
.rt-toolbar button:hover { background: var(--surface); border-color: var(--border); }
.rt-toolbar .sep { width: 1px; align-self: stretch; background: var(--border); margin: 2px 3px; }
.rt-toolbar .spacer { flex: 1; }
.rt-toolbar .var-btn { color: var(--accent); font-weight: 600; }
.rt-toolbar .src-toggle.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

.rt-area {
  min-height: 190px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 0.8rem 0.9rem;
  font-size: 0.92rem;
  line-height: 1.65;
  outline: none;
}
.rt-area:focus { box-shadow: inset 0 0 0 2px var(--accent-soft); }
.rt-area p { margin: 0 0 0.6rem; }
.rt-area ul, .rt-area ol { margin: 0.4rem 0 0.6rem 1.4rem; }
.rt-area li { margin-bottom: 0.25rem; }
.rt-area a { color: var(--accent); }
.rt-area .note { background: #f0f0f8; border-left: 3px solid #2d2d7a; padding: 6px 10px; margin: 8px 0; }
.rt-area .warn { background: #fff8e6; border-left: 3px solid #e0a800; padding: 6px 10px; margin: 8px 0; }
.rt-area .term { background: #eef4ee; border-left: 3px solid #3a7a3a; padding: 6px 10px; margin: 8px 0; }
.rt-area table { border-collapse: collapse; margin: 8px 0; font-size: 0.85rem; width: 100%; }
.rt-area th, .rt-area td { border: 1px solid #c7c7d6; padding: 5px 8px; text-align: left; }
.rt-area th { background: #f0f0f8; }
.rt-area .faq-var { cursor: default; user-select: all; }

.rt-source {
  display: none;
  width: 100%;
  min-height: 240px;
  padding: 0.8rem 0.9rem;
  border: none;
  outline: none;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text);
}
.rt.show-source .rt-area { display: none; }
.rt.show-source .rt-source { display: block; }

/* ---- live preview -------------------------------------------------------- */

.preview-wrap {
  margin-top: 0.7rem;
  border: 1px dashed var(--border-strong);
  border-radius: 9px;
  background: #fff;
  overflow: hidden;
}
.preview-label {
  padding: 0.35rem 0.8rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  background: var(--bg);
  border-bottom: 1px dashed var(--border);
}
.preview-body { padding: 0.4rem 0.9rem 1rem; }

/* A mirror of the published page, so the answer is judged as it will appear. */
.faq-preview {
  max-width: 860px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  color: #111;
  background: #fff;
}
.preview-q { padding: 0.5rem 0 0.4rem; }
.preview-q:empty { display: none; }
.faq-preview .faq-q-text { font-size: 15px; font-weight: 700; color: #111; line-height: 1.45; }

.faq-preview .faq-a-inner {
  padding: 8px 0 4px;
  font-size: 14px;
  color: #333;
  line-height: 1.7;
  border-top: 1px solid #e8e8e8;
}
.faq-preview .faq-a-inner p { margin-bottom: 10px; }
.faq-preview .faq-a-inner p:last-child { margin-bottom: 0; }
.faq-preview .faq-a-inner ol,
.faq-preview .faq-a-inner ul { margin: 8px 0 10px 22px; }
.faq-preview .faq-a-inner li { margin-bottom: 5px; }
.faq-preview .faq-a-inner a { color: #2d2d7a; }
.faq-preview .faq-a-inner a:hover { text-decoration: underline; }

.faq-preview .note {
  background: #f0f0f8; border-left: 3px solid #2d2d7a;
  padding: 8px 12px; font-size: 13.5px; margin: 10px 0; color: #333;
}
.faq-preview .warn {
  background: #fff8e6; border-left: 3px solid #e0a800;
  padding: 8px 12px; font-size: 13.5px; margin: 10px 0; color: #555;
}
.faq-preview .term {
  background: #eef4ee; border-left: 3px solid #3a7a3a;
  padding: 8px 12px; font-size: 13.5px; margin: 10px 0; color: #234;
}
.faq-preview .term strong { color: #111; }

.faq-preview .setback-table,
.faq-preview .facility-table {
  width: 100%; border-collapse: collapse; margin: 10px 0 14px; font-size: 13.5px;
}
.faq-preview .setback-table th, .faq-preview .setback-table td,
.faq-preview .facility-table th, .faq-preview .facility-table td {
  border: 1px solid #c7c7d6; padding: 8px 12px;
  vertical-align: top; text-align: left; line-height: 1.5;
}
.faq-preview .setback-table thead th,
.faq-preview .facility-table thead th {
  background: #f0f0f8; color: #2d2d7a; font-weight: 700;
  font-size: 12.5px; letter-spacing: 0.3px; text-transform: uppercase;
}
.faq-preview .setback-table tbody td:first-child,
.faq-preview .facility-table tbody td:first-child {
  background: #fafafc; font-weight: 700; color: #111;
}

/* Variables read as ordinary text in the preview, because that is how a
   member of the public will see them. */
.faq-preview .faq-var {
  background: transparent; border: none; padding: 0;
  color: inherit; font-weight: inherit; border-bottom: none;
}

/* ---- link modal ---------------------------------------------------------- */

.fm-field { margin-bottom: 0.7rem; }
.fm-field label { display: block; font-size: 0.78rem; font-weight: 600; margin-bottom: 0.2rem; }
.fm-field input[type="text"], .fm-field select {
  width: 100%;
  font: inherit;
  font-size: 0.88rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
}
.lm-choice { display: flex; gap: 1rem; margin-bottom: 0.4rem; font-size: 0.82rem; }
.lm-choice label { display: flex; align-items: center; gap: 0.3rem; font-weight: 400; }

@media (max-width: 800px) {
  .rt-toolbar button { font-size: 0.72rem; padding: 0.1rem 0.4rem; }
  .rt-area { min-height: 150px; }
}

/* ===========================================================================
   Content rules
   =========================================================================== */

.rule-block {
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.6rem;
}
.rule-block.sev-high { border-left-color: var(--danger); }
.rule-block.sev-medium { border-left-color: var(--warn); }
.rule-block.sev-low { border-left-color: var(--border-strong); }

.rule-head { display: flex; align-items: center; gap: 0.5rem; }
.rule-name { flex: 1; font-size: 0.92rem; font-weight: 650; min-width: 0; }
.rule-count {
  font-size: 0.7rem; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  background: #FBEAE8; color: var(--danger); white-space: nowrap;
}
.rule-count.clear { background: #EAF6EE; color: var(--good); }
.rule-message { font-size: 0.82rem; color: var(--text-soft); margin: 0.4rem 0 0.5rem; }
.rule-error { font-size: 0.82rem; color: var(--danger); margin-top: 0.4rem; }

.list-row.finding { padding: 0.4rem 0.65rem; }
.list-row.finding .list-title { font-size: 0.85rem; font-weight: 600; }

.rule-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.7rem;
  box-shadow: var(--shadow);
}
.rule-card.off { opacity: 0.55; }
.rule-card-head { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.6rem; }

.rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.5rem 0.9rem;
  margin-bottom: 0.5rem;
}
.rule-field label {
  display: block;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-soft);
  margin-bottom: 0.1rem;
}

.scope-row { display: flex; flex-wrap: wrap; gap: 0.2rem; }
.scope-chip {
  font: inherit;
  font-size: 0.7rem;
  padding: 1px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: none;
  color: var(--text-soft);
  cursor: pointer;
}
.scope-chip.on { background: var(--accent-soft); border-color: #C6D9F0; color: var(--accent); font-weight: 600; }

.row-actions .spacer { flex: 1; }

/* ===========================================================================
   Routes, attachments and issues on the step list
   =========================================================================== */

.flow-note {
  font-size: 0.82rem; color: var(--text-soft); background: var(--surface);
  border: 1px dashed var(--border-strong); border-radius: 8px;
  padding: 0.5rem 0.75rem; margin-bottom: 0.8rem;
}

.routes {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.5rem;
  margin-top: 0.6rem; padding-top: 0.5rem; border-top: 1px dashed rgba(0, 0, 0, 0.12);
  font-size: 0.8rem;
}
.routes-label {
  font-size: 0.66rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-soft);
}
.route-end { color: var(--text-soft); font-style: italic; }
.route {
  display: inline-flex; align-items: center; gap: 0.3rem; max-width: 100%;
  background: var(--bg); border-radius: 999px; padding: 0.1rem 0.25rem 0.1rem 0.6rem;
}
.route-cond { font-weight: 600; color: var(--warn); min-width: 2ch; }
.route-cond .editable .ph { color: var(--text-soft); font-weight: 400; }
.route-to {
  font: inherit; font-size: 0.78rem; background: none; border: none; cursor: pointer;
  color: var(--text); padding: 0; text-align: left; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22ch;
}
.route-to:hover { color: var(--accent); }
.route-add {
  font: inherit; font-size: 0.76rem; color: var(--text-soft);
  border: 1px dashed var(--border-strong); border-radius: 999px;
  background: none; padding: 0.12rem 0.5rem; max-width: 100%;
}

.step.flash-step { box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }

.attached { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; margin-bottom: 0.4rem; }
.chip { display: inline-flex; align-items: center; max-width: 100%; }
.chip .chip-link { border-radius: 999px 0 0 999px; padding-right: 0.4rem; max-width: 30ch;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-link.faq { background: #EAF6EE; color: var(--good); }
.btn.chip-x {
  font-size: 0.72rem; padding: 0.12rem 0.45rem; border-radius: 0 999px 999px 0;
  border: none; background: var(--bg); color: var(--text-soft);
}
.btn.chip-x:hover { color: var(--danger); }

.block h2 .count { font-weight: 400; color: var(--text-soft); text-transform: none; letter-spacing: 0; }
.issue-row .issue-body .editable { font-size: 0.87rem; }
.issue-row .sev .editable { display: inline; }
details.resolved { margin-top: 0.5rem; }
details.resolved summary {
  cursor: pointer; font-size: 0.8rem; color: var(--text-soft); padding: 0.3rem 0;
}
.resolved-row { opacity: 0.75; }
.resolved-row .sev { background: #EAF6EE; color: var(--good); }

.hint { font-size: 0.76rem; color: var(--text-soft); align-self: center; }
.hint-block { font-size: 0.82rem; color: var(--text-soft); margin: 0.2rem 0 0.9rem; }

/* ---- tree: new process --------------------------------------------------- */

.tree-add {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 6px;
  border: none; background: none; color: var(--text-soft);
  font-size: 0.95rem; line-height: 1; cursor: pointer; opacity: 0;
}
.tree-head:hover .tree-add, .tree-add:focus-visible { opacity: 1; }
.tree-add:hover { background: var(--accent-soft); color: var(--accent); }
@media (hover: none) { .tree-add { opacity: 0.6; } }

/* ---- modals: forms, attach, merge ---------------------------------------- */

.fm-field textarea {
  width: 100%; font: inherit; font-size: 0.88rem; padding: 0.45rem 0.6rem;
  border: 1px solid var(--border-strong); border-radius: 8px; resize: vertical;
}
.fm-row { display: flex; gap: 0.6rem; }
.fm-row .fm-field { flex: 1; min-width: 0; }
@media (max-width: 480px) { .fm-row { flex-direction: column; gap: 0; } }

.am-tabs { display: flex; gap: 2px; background: var(--bg); border-radius: 8px;
  padding: 2px; margin-bottom: 0.5rem; }
.am-tab {
  flex: 1; font: inherit; font-size: 0.8rem; font-weight: 600; border: none;
  border-radius: 6px; background: none; color: var(--text-soft);
  padding: 0.3rem 0.5rem; cursor: pointer;
}
.am-tab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.modal-box.wide { max-width: 720px; }
.merge-body { flex: 1; overflow-y: auto; min-height: 0; }
.merge-body h4 {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-soft); margin: 0.8rem 0 0.35rem;
}
.merge-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 0.1rem 0.6rem; align-items: center;
  padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 0.3rem; font-size: 0.84rem;
}
.merge-row.conflict { border-color: #F2C89B; background: var(--warn-soft); }
.merge-kind {
  font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-soft);
}
.merge-label { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.merge-note { grid-column: 2; font-size: 0.74rem; color: var(--text-soft); }
.merge-choice, .merge-who { grid-row: 1 / span 2; grid-column: 3; display: flex; gap: 0.6rem;
  font-size: 0.8rem; white-space: nowrap; }
.merge-choice label { display: flex; align-items: center; gap: 0.25rem; cursor: pointer; }
.merge-who { font-size: 0.7rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.merge-who.mine { background: var(--accent-soft); color: var(--accent); }
.merge-who.live { background: #EAF6EE; color: var(--good); }
@media (max-width: 560px) {
  .merge-row { grid-template-columns: 1fr; }
  .merge-note, .merge-choice, .merge-who { grid-column: 1; grid-row: auto; }
}

/* ---- the map: routes ----------------------------------------------------- */

.canvas-selbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem;
  padding: 0.35rem 0.6rem; min-height: 2.2rem;
  background: var(--surface); border: 1px solid var(--border); border-bottom: none;
  font-size: 0.8rem;
}
.selbar-hint { color: var(--text-soft); font-size: 0.76rem; }
.selbar-what { font-weight: 700; color: var(--accent); }
.selbar-field { flex: 1; min-width: 12rem; }

.canvas-wires .wire-hit { pointer-events: stroke; cursor: pointer; }
.canvas-wires .wire-label { pointer-events: all; cursor: pointer; }
.canvas-wires .wire-label.selected { fill: #0A66C2; font-weight: 700; }

.node-port {
  position: absolute; right: -7px; top: 50%; width: 14px; height: 14px; margin-top: -7px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--accent);
  cursor: crosshair; opacity: 0.35; transition: opacity 0.12s, transform 0.12s;
}
.node:hover .node-port, .node.linking .node-port { opacity: 1; transform: scale(1.15); }
@media (hover: none) { .node-port { opacity: 0.9; width: 18px; height: 18px; margin-top: -9px; right: -9px; } }
.node.link-target { outline: 2px solid var(--accent); outline-offset: 2px; }
.canvas-viewport.linking, .canvas-viewport.linking .node { cursor: crosshair; }

/* ---- issues register: rule blocks ---------------------------------------- */

button.rule-head {
  width: 100%; font: inherit; text-align: left; background: none; border: none;
  padding: 0; cursor: pointer; color: inherit;
}
button.rule-head[disabled] { cursor: default; }
.rule-head .caret { flex: 0 0 14px; }
.rule-skipped { font-size: 0.74rem; color: var(--text-soft); margin-top: 0.3rem; }
.rule-block .rule-message { margin-top: 0.5rem; }

/* ---- coverage ------------------------------------------------------------ */

.cov-legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; font-size: 0.78rem;
  color: var(--text-soft); margin: 0.9rem 0 0.5rem; }
.cov-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px;
  margin-right: 0.3rem; vertical-align: -1px; }

.cov-table { background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; margin-bottom: 1.4rem; }
.cov-row {
  display: grid; grid-template-columns: minmax(8rem, 1.4fr) 4.5rem minmax(6rem, 2fr) 4.5rem 6rem 4.5rem;
  gap: 0.6rem; align-items: center; padding: 0.4rem 0.75rem;
  border-top: 1px solid var(--border); font-size: 0.84rem;
}
.cov-table.vars .cov-row { grid-template-columns: minmax(8rem, 2fr) repeat(4, 4.5rem); }
.cov-headrow {
  border-top: none; background: var(--accent-soft); color: var(--accent);
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
}
.cov-row .num { text-align: right; font-variant-numeric: tabular-nums; }
.cov-row .num em { font-style: normal; font-size: 0.7rem; color: var(--danger); display: block; }
.cov-row.depth-0 { font-weight: 650; background: #FAFBFC; }
.cov-row.depth-1 .cov-name { padding-left: 1rem; }
.cov-row.depth-2 .cov-name { padding-left: 2rem; }
.cov-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cov-bar { display: flex; gap: 2px; height: 12px; }
.cov-bar span { display: block; height: 100%; border-radius: 2px; min-width: 3px; }
.cov-bar.empty { background: var(--bg); border-radius: 2px; }

@media (max-width: 700px) {
  /* The bar is the point on a phone; the columns it summarises drop away. */
  .cov-row { grid-template-columns: minmax(0, 1fr) 4.6rem minmax(5rem, 1.2fr); gap: 0.4rem; }
  .cov-headrow { font-size: 0.62rem; }
  .cov-row > :nth-child(n+4) { display: none; }
  .cov-table.vars .cov-row { grid-template-columns: minmax(0, 1fr) repeat(4, 3.2rem); }
  .cov-table.vars .cov-row > :nth-child(n+4) { display: block; }
}

/* ---- departments --------------------------------------------------------- */

.dept-list { display: flex; flex-direction: column; gap: 0.3rem; }
.dept-row {
  display: grid; grid-template-columns: minmax(8rem, 1.3fr) minmax(6rem, 1fr) minmax(8rem, 1.2fr) auto;
  gap: 0.5rem; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.4rem 0.6rem; font-size: 0.86rem;
}
.dept-row.depth-0 { font-weight: 650; }
.dept-row.depth-1 { margin-left: 1.2rem; }
.dept-row.depth-2 { margin-left: 2.4rem; }
.dept-used { font-size: 0.74rem; color: var(--text-soft); font-weight: 400; }
.dept-parent { font-size: 0.78rem; font-weight: 400; color: var(--text-soft); min-width: 0; }
.dept-tools { display: flex; flex-wrap: wrap; gap: 0.2rem; justify-content: flex-end; }
@media (max-width: 700px) {
  .dept-row { grid-template-columns: 1fr; gap: 0.2rem; }
  .dept-tools { justify-content: flex-start; }
  .dept-row.depth-1 { margin-left: 0.6rem; }
  .dept-row.depth-2 { margin-left: 1.2rem; }
}

/* ===========================================================================
   Publishing to GitHub
   =========================================================================== */

.gh-saved {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem;
  background: #EAF6EE; border-radius: 8px; padding: 0.45rem 0.6rem;
  font-size: 0.82rem; margin-bottom: 0.7rem;
}
.gh-saved[hidden] { display: none; }
.gh-saved span { flex: 1; min-width: 10rem; color: var(--good); font-weight: 600; }
.fm-field input[type="password"] {
  width: 100%; font: inherit; font-size: 0.88rem; padding: 0.45rem 0.6rem;
  border: 1px solid var(--border-strong); border-radius: 8px;
}
.gh-result { font-size: 0.82rem; min-height: 1.2em; margin: 0.2rem 0 0.4rem; line-height: 1.45; }
.gh-result:empty { display: none; }
.gh-result.busy { color: var(--text-soft); }
.gh-result.good { color: var(--good); }
.gh-result.bad { color: var(--danger); }
.gh-result a { color: inherit; font-weight: 600; }
.gh-result .btn { margin-left: 0.3rem; }
.gh-help { font-size: 0.8rem; color: var(--text-soft); margin-top: 0.3rem; }
.gh-help summary { cursor: pointer; }
.gh-help ol { margin: 0.4rem 0 0 1.2rem; }
.gh-help li { margin-bottom: 0.2rem; }
.gh-help a { color: var(--accent); }

.pub-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 0.6rem; align-items: center;
  padding: 0.35rem 0.6rem; border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 0.25rem; font-size: 0.84rem;
}
.pub-label { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pub-note { font-size: 0.72rem; color: var(--text-soft); }
#publishModal .merge-body { max-height: 38vh; margin-bottom: 0.6rem; }
.modal-actions .spacer { flex: 1; }
.btn.quiet-link { border: none; background: none; color: var(--accent); padding-left: 0; }
.fm-field input#pubMessage { width: 100%; font: inherit; font-size: 0.88rem; padding: 0.45rem 0.6rem;
  border: 1px solid var(--border-strong); border-radius: 8px; }

/* ---- sign-in screen ------------------------------------------------------ */

body.gated > :not(.gate) { visibility: hidden; }
.gate {
  position: fixed; inset: 0; z-index: 100; overflow-y: auto;
  background: var(--bg); display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 16px 2rem;
}
.gate-box {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 1.5rem 1.4rem 1.2rem; box-shadow: 0 10px 34px rgba(0, 0, 0, 0.08);
}
.gate-brand { font-weight: 800; letter-spacing: -0.3px; color: var(--accent); margin-bottom: 0.6rem; }
.gate-box h1 { font-size: 1.5rem; letter-spacing: -0.4px; margin-bottom: 0.3rem; }
.gate-lede { font-size: 0.88rem; color: var(--text-soft); margin-bottom: 0.9rem; }
.gate-why { font-size: 0.84rem; color: var(--danger); background: #FBEAE8; border-radius: 8px;
  padding: 0.45rem 0.6rem; margin-bottom: 0.8rem; }
.gate-box label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 0.25rem; }
.gate-box input {
  width: 100%; font: inherit; font-size: 0.92rem; padding: 0.55rem 0.7rem;
  border: 1px solid var(--border-strong); border-radius: 8px;
}
.gate-box input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.gate-result { font-size: 0.82rem; min-height: 1.2em; margin: 0.45rem 0; line-height: 1.45; }
.gate-result:empty { display: none; }
.gate-result.busy { color: var(--text-soft); }
.gate-result.good { color: var(--good); }
.gate-result.bad { color: var(--danger); }
.btn.gate-go { width: 100%; justify-content: center; padding: 0.55rem; font-size: 0.92rem; margin: 0.4rem 0 0.8rem; }
.gate .gh-help p { margin-top: 0.4rem; }

/* ===========================================================================
   Sidebar sections, and the FAQ tree
   =========================================================================== */

.section-switch {
  display: flex; gap: 2px; margin: 0.7rem 0.8rem 0; padding: 2px;
  background: var(--bg); border-radius: 9px;
}
.section-switch button {
  flex: 1; font: inherit; font-size: 0.82rem; font-weight: 650; border: none;
  border-radius: 7px; background: none; color: var(--text-soft); padding: 0.35rem 0.5rem;
  cursor: pointer;
}
.section-switch button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.faq-tab { margin-top: 0.35rem; }
.faq-tab-head {
  display: flex; align-items: center; gap: 0.3rem; padding: 0.3rem 0.4rem; border-radius: 6px;
}
.faq-tab-head.active { background: var(--accent-soft); }
.faq-tab-name {
  flex: 1; min-width: 0; font: inherit; font-size: 0.8rem; font-weight: 700; text-align: left;
  letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-soft);
  background: none; border: none; padding: 0; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.faq-tab-name:hover { color: var(--accent); }
.faq-tab-name.quiet { cursor: default; font-style: italic; }
.faq-tab-name.quiet:hover { color: var(--text-soft); }
.faq-new {
  font-size: 0.58rem; font-weight: 700; letter-spacing: 0.04em; font-style: normal;
  background: var(--accent); color: #fff; border-radius: 3px; padding: 1px 4px;
}

.faq-rows { padding-left: 0.9rem; min-height: 0.4rem; }
.faq-row {
  display: flex; align-items: center; gap: 0.35rem; padding: 0.28rem 0.4rem;
  border-radius: 6px; cursor: pointer; font-size: 0.84rem; line-height: 1.3;
  border-top: 2px solid transparent; border-bottom: 2px solid transparent;
}
.faq-row:hover { background: var(--bg); }
.faq-row.active { background: var(--accent-soft); }
.faq-row .grip { color: #B7BEC8; font-size: 0.7rem; cursor: grab; letter-spacing: -2px; flex: 0 0 auto; }
.faq-row.dragging { opacity: 0.4; }
.faq-q-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.faq-row.active .faq-q-text { white-space: normal; font-weight: 600; }
.faq-row .status-dot { flex: 0 0 auto; }

.faq-heading {
  margin-top: 0.35rem; font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--accent); cursor: grab;
}
.faq-heading-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.faq-heading.pending { color: var(--text-soft); font-style: italic; }
.faq-heading .faq-mini, .faq-heading .faq-nudge { opacity: 0; }
.faq-heading:hover .faq-mini, .faq-heading:hover .faq-nudge,
.faq-heading:focus-within .faq-mini, .faq-heading:focus-within .faq-nudge { opacity: 1; }
@media (hover: none) { .faq-heading .faq-mini, .faq-heading .faq-nudge { opacity: 0.7; } }

.faq-nudge { display: inline-flex; gap: 2px; flex: 0 0 auto; }
.faq-mini {
  flex: 0 0 auto; font: inherit; font-size: 0.72rem; line-height: 1; min-width: 22px; height: 22px;
  border: 1px solid var(--border); border-radius: 5px; background: var(--surface);
  color: var(--text-soft); cursor: pointer; text-transform: none; letter-spacing: 0; font-weight: 600;
}
.faq-mini:hover:not([disabled]) { border-color: var(--accent); color: var(--accent); }
.faq-mini[disabled] { opacity: 0.35; cursor: default; }
.faq-mini.danger:hover { border-color: var(--danger); color: var(--danger); }

.faq-add { display: flex; gap: 0.3rem; padding: 0.3rem 0.4rem 0.2rem; }
.faq-tree-foot { padding: 0.6rem 0.4rem 0; }

/* Where a dragged row will land */
.faq-row.drop-before { border-top-color: var(--accent); }
.faq-row.drop-after { border-bottom-color: var(--accent); }
.drop-into { outline: 2px dashed var(--accent); outline-offset: -2px; border-radius: 6px; }

/* ---- the FAQ dashboard and tab page -------------------------------------- */

.cov-table.faq-tabs .cov-row {
  grid-template-columns: minmax(8rem, 2fr) 5rem 5rem 6.5rem 4.5rem minmax(6rem, 1fr);
}
button.cov-row.cov-link {
  width: 100%; font: inherit; text-align: left; background: none; border: none;
  border-top: 1px solid var(--border); cursor: pointer; color: inherit;
}
button.cov-row.cov-link:hover { background: var(--bg); }
.cov-row .num.warn { color: var(--warn); font-weight: 700; }
.cov-row .when { font-size: 0.78rem; color: var(--text-soft); }
@media (max-width: 700px) {
  .cov-table.faq-tabs .cov-row { grid-template-columns: minmax(0, 1fr) 4.6rem 5.5rem; }
  .cov-table.faq-tabs .cov-row > :nth-child(3),
  .cov-table.faq-tabs .cov-row > :nth-child(5),
  .cov-table.faq-tabs .cov-row > :nth-child(6) { display: none; }
  .cov-table.faq-tabs .cov-row > :nth-child(4) { display: block; }
}

.inline-select {
  font: inherit; font-size: 0.88rem; padding: 0.3rem 0.5rem; max-width: 100%;
  border: 1px solid var(--border-strong); border-radius: 7px; background: var(--surface);
}
.faq-position { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; }
.faq-position .hint { margin-left: 0.3rem; }
.crumbs a { color: inherit; }
.crumbs a:hover { color: var(--accent); }

.tab-stepper-source { margin-bottom: 0.6rem; font-size: 0.88rem; }
.stepper-rows { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.5rem; }
.stepper-row {
  display: grid; grid-template-columns: 7rem 1fr auto; gap: 0.5rem; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 7px; padding: 0.35rem 0.55rem; font-size: 0.86rem;
}
.stepper-row .sr-label { font-weight: 700; font-size: 0.76rem; color: var(--accent); }
.stepper-preview { display: flex; flex-wrap: wrap; gap: 6px; }
.sp-step {
  flex: 1 1 0; min-width: 120px; background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); padding: 0.4rem 0.6rem; font-size: 0.8rem; border-radius: 5px;
}
.sp-step b { display: block; font-size: 0.66rem; color: var(--accent); letter-spacing: 0.04em; }
.tab-q-heading {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--accent); margin: 0.9rem 0 0.35rem;
}
@media (max-width: 560px) {
  .stepper-row { grid-template-columns: 1fr auto; }
  .stepper-row .sr-label { grid-column: 1 / -1; }
}

/* The sidebar keeps its width whatever it holds: long FAQ questions would
   otherwise widen it, because a flex item will not shrink below its content. */
.sidebar { min-width: 0; width: var(--sidebar-w); }
.sidebar-body, #tree, .faq-tab, .faq-rows { min-width: 0; }

/* ===========================================================================
   Eight sections: the switch, the lists, and the dashboard tables
   =========================================================================== */

.section-switch { display: grid; grid-template-columns: repeat(4, 1fr); }
.section-switch button { font-size: 0.74rem; padding: 0.3rem 0.2rem; white-space: nowrap; }

.side-group { margin-top: 0.35rem; }
.side-group-head { display: flex; align-items: center; gap: 0.3rem; padding: 0.3rem 0.4rem; }
.side-group-name {
  flex: 1; min-width: 0; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.02em;
  text-transform: uppercase; color: var(--text-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.side-rows { padding-left: 0.9rem; min-width: 0; }
.side-rows.flat { padding-left: 0; margin-top: 0.3rem; }
.side-row {
  display: flex; align-items: center; gap: 0.4rem; width: 100%; min-width: 0;
  font: inherit; font-size: 0.84rem; text-align: left; line-height: 1.3;
  padding: 0.32rem 0.45rem; border: none; border-radius: 6px; background: none;
  color: inherit; cursor: pointer;
}
.side-row:hover { background: var(--bg); }
.side-row.active { background: var(--accent-soft); }
.side-row.off { opacity: 0.5; }
.side-row-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-row-title { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.side-row-sub {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  white-space: normal; overflow: hidden; font-size: 0.76rem; color: var(--text-soft);
}
.side-row-text:has(.side-row-sub) { white-space: normal; }
.side-tail {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.7rem; color: var(--text-soft);
}
.side-row.depth-0 { font-weight: 650; }
.side-row.depth-1 { padding-left: 1.2rem; }
.side-row.depth-2 { padding-left: 2rem; }
.side-row.depth-3 { padding-left: 2.8rem; }
.side-row .status-dot { flex: 0 0 auto; }

.status-dot.var-current { background: var(--good); }
.status-dot.var-pending { background: #E0A100; }
.status-dot.var-stale { background: var(--danger); }

.side-sev {
  flex: 0 0 auto; width: 18px; height: 18px; border-radius: 4px; font-size: 0.64rem;
  font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--text-soft);
}
.side-sev.sev-high { background: #FBEAE8; color: var(--danger); }
.side-sev.sev-medium { background: var(--warn-soft); color: var(--warn); }

.mini-bar { display: inline-flex; gap: 1px; width: 44px; height: 7px; }
.mini-bar i { display: block; height: 100%; border-radius: 1px; }
.mini-bar.empty { background: var(--bg); border-radius: 2px; }

/* Dashboard tables for the new sections */
.cov-table.dash-table .cov-row { grid-template-columns: minmax(8rem, 2fr) repeat(3, 6rem); }
.cov-table.vars-dash .cov-row { grid-template-columns: minmax(8rem, 2fr) repeat(4, 4.8rem) auto; }
.cov-table.rules-dash .cov-row { grid-template-columns: minmax(8rem, 2fr) minmax(8rem, 1.4fr) 5rem 4.5rem; }
.cov-row.off { opacity: 0.5; }
.dash-actions { display: inline-flex; gap: 0.25rem; justify-content: flex-end; }
@media (max-width: 700px) {
  .cov-table.dash-table .cov-row { grid-template-columns: minmax(0, 1fr) repeat(3, 3.6rem); }
  .cov-table.dash-table .cov-row > * { display: block; }
  .cov-table.vars-dash .cov-row { grid-template-columns: minmax(0, 1fr) repeat(3, 3.4rem); }
  .cov-table.vars-dash .cov-row > :nth-child(n+5) { display: none; }
  .cov-table.rules-dash .cov-row { grid-template-columns: minmax(0, 1fr) 4rem; }
  .cov-table.rules-dash .cov-row > :nth-child(2),
  .cov-table.rules-dash .cov-row > :nth-child(3) { display: none; }
  .cov-table.rules-dash .cov-row > :nth-child(4) { display: block; }
}

.badge.sev-badge.sev-high { background: #FBEAE8; color: var(--danger); }
.badge.sev-badge.sev-medium { background: var(--warn-soft); color: var(--warn); }
.issue-note { font-size: 0.95rem; }

/* Adding steps on the map, and verifying from the variables dashboard */
.node-add {
  flex: 0 0 auto; background: none; border: none; cursor: pointer; color: var(--text-soft);
  font-size: 0.95rem; line-height: 1; padding: 0 2px; opacity: 0;
}
.node:hover .node-add { opacity: 1; }
.node-add:hover { color: var(--accent); }
@media (hover: none) { .node-add { opacity: 1; } }
.node.just-added { box-shadow: 0 0 0 3px var(--accent-soft), 0 6px 18px rgba(10, 102, 194, 0.18); }
.btn.primary-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

.verify-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.35rem; }
.verify-row .list-row { flex: 1; min-width: 0; margin-bottom: 0; }
.verify-row .btn { flex: 0 0 auto; }

/* FAQ figures on Coverage and Departments */
.cov-table.faq-cov .cov-row { grid-template-columns: minmax(8rem, 2fr) repeat(5, 5.6rem); }
.faq-tiles { margin-bottom: 1rem; }
.faq-none { margin-top: 0.4rem; }
@media (max-width: 700px) {
  .cov-table.faq-cov .cov-row { grid-template-columns: minmax(0, 1fr) repeat(3, 3.8rem); }
  .cov-table.faq-cov .cov-row > * { display: block; }
  .cov-table.faq-cov .cov-row > :nth-child(n+5) { display: none; }
}

/* Public sources for variables */
.source-link { display: flex; align-items: flex-start; gap: 0.5rem; flex-wrap: wrap; }
.source-link .editable { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
.source-link .btn { flex: 0 0 auto; }
.source-reuse { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  margin-top: 0.8rem; font-size: 0.82rem; color: var(--text-soft); }
.source-reuse select { max-width: 100%; }
.source-card { border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem; background: var(--surface); }
.source-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.source-title { font-weight: 600; font-size: 0.9rem; overflow-wrap: anywhere; min-width: 0; }
.source-head .hint { margin-left: auto; }
.source-vars { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.45rem; }
.source-var { font-size: 0.78rem; padding: 0.1rem 0.45rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); text-decoration: none;
  overflow-wrap: anywhere; max-width: 100%; }
.source-var:hover { text-decoration: underline; }
.source-cite { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap;
  padding: 0.4rem 0; border-bottom: 1px solid var(--border); font-size: 0.86rem; }
.source-cite:last-child { border-bottom: none; }
.source-excerpt { flex-basis: 100%; font-size: 0.8rem; color: var(--text-soft); white-space: pre-line; }
.source-missing { font-size: 0.8rem; color: var(--warn); font-weight: 600; }
