/* =====================================================================
   Cohort Management Portal – User Flow – styles

   All colours are plain CSS colour NAMES (no #codes):

     navy           = brand colour: logo, headings, main button, active tab
     royalblue      = screens: label, step circle, arrows   (light background: lavender)
     chocolate      = notifications: label, step circle     (light background: papayawhip)
     darkslateblue  = role box and workflow accent
     silver         = tree lines
     lightsteelblue = screenshot frames
     ghostwhite     = page background
     gainsboro      = borders
     slategray      = small grey text
   ===================================================================== */


/* ---------- sizes used in many places (change them here) ---------- */
:root {
  --card-width: 380px;       /* every card has the same width (screenshots keep their own shape) */
  --arrow-y: 90px;           /* how far down from the top of a card the arrows run */
  --row-space: 24px;         /* space above and below each workflow row */
  --arm-y: calc(var(--row-space) + var(--arrow-y));   /* where the tree line meets a workflow row */
  --arm: 56px;               /* length of a tree branch line */
  --curve: 16px;             /* how round the tree corners are */
  --line: 2px;               /* thickness of the tree lines */
  --button-height: 36px;     /* every top-bar button has this height so they line up */
}


/* ---------- page ---------- */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: ghostwhite;
  color: black;
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
}

button {
  font-family: inherit;
  cursor: pointer;
}


/* ---------- buttons ---------- */
.plain-button,
.main-button {
  height: var(--button-height);
  padding: 0 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.plain-button {
  border: 1px solid gainsboro;
  background: white;
  color: black;
}
.plain-button:hover { border-color: navy; color: navy; }

.main-button {
  border: 1px solid navy;
  background: navy;
  color: white;
}
.main-button:hover { background: darkslateblue; border-color: darkslateblue; }
.main-button:disabled { background: slategray; border-color: slategray; cursor: wait; }


/* ---------- top bar ---------- */
.top-bar {
  background: white;
  border-bottom: 1px solid gainsboro;
  box-shadow: 0 2px 10px gainsboro;
  z-index: 2;
}

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
}

.brand { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-text { min-width: 0; }

.brand-logo {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: navy;
  color: white;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.04em;
}

.brand h1 { margin: 0; font-size: 18px; font-weight: 700; color: navy; }
.brand h1,
.brand-subtitle { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-subtitle { font-size: 13px; color: slategray; }

/* right side of the top bar: everything on ONE line, all the same height */
.tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.legend {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-right: 6px;
  font-size: 13px;
  color: slategray;
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.screen-dot { background: royalblue; }
.notification-dot { background: chocolate; }

/* the − 100% + group looks like one control */
.zoom-group {
  display: inline-flex;
  align-items: center;
  height: var(--button-height);
  border: 1px solid gainsboro;
  border-radius: 10px;
  overflow: hidden;
  background: white;
}
.zoom-group button {
  width: 36px;
  height: 100%;
  border: none;
  background: white;
  font-size: 18px;
  color: black;
}
.zoom-group button:hover { background: ghostwhite; color: navy; }
#zoomText {
  min-width: 54px;
  height: 100%;
  display: grid;
  place-items: center;
  border-left: 1px solid gainsboro;
  border-right: 1px solid gainsboro;
  font-size: 13px;
  font-weight: 600;
  color: slategray;
}

/* ---------- drawing area ---------- */
/* "margin: auto" on the tree keeps it centred when it is small,
   and lets it scroll when it is bigger than the screen.
   The background has a light dot grid, like a design board. */
.drawing-area {
  flex: 1;
  display: flex;
  overflow: auto;
  cursor: grab;
  background-color: ghostwhite;
  background-image: radial-gradient(lightgray 1px, transparent 1px);
  background-size: 22px 22px;
}
.drawing-area.dragging { cursor: grabbing; user-select: none; }

.tree,
.overview {
  flex: none;
  margin: auto;
  padding: 64px;
  display: flex;
  align-items: flex-start; /* the app and role boxes line up with the FIRST workflow's line */
}

/* holds the app box / role box so that its middle sits on the first workflow's line */
.tree-holder {
  flex: none;
  height: calc(var(--arm-y) * 2);
  display: flex;
  align-items: center;
}

/* the lines between the app box, the role box and the workflows: on that same line */
.tree > .stub { margin-top: calc(var(--arm-y) - var(--line) / 2); }


/* ---------- tree boxes (nodes) ---------- */
.node {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-radius: 18px;
}
.node b { line-height: 1.25; }

.node-code {
  align-self: flex-start;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

/* level 1: the app */
.root-node {
  width: 270px;
  padding: 24px;
  background: linear-gradient(135deg, navy, royalblue);
  color: white;
  box-shadow: 0 10px 30px lightsteelblue;
}
.root-node .node-code { border: 1px solid cornflowerblue; }
.root-node b { font-size: 28px; font-weight: 800; }

.root-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.root-stats div {
  padding: 8px 4px;
  border-radius: 10px;
  border: 1px solid cornflowerblue;
  text-align: center;
}
.root-stats strong { display: block; font-size: 20px; }
.root-stats span { font-size: 11px; opacity: 0.85; }

/* level 2: the user role */
.role-node {
  width: 230px;
  padding: 20px;
  background: white;
  border: 1px solid gainsboro;
  box-shadow: 0 6px 18px gainsboro;
}
.role-node .node-code { background: lavender; color: darkslateblue; }
.role-node b { font-size: 18px; color: navy; }
.role-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin-bottom: 4px;
  border-radius: 50%;
  background: darkslateblue;
  color: white;
  font-weight: 700;
}

/* level 3: a workflow */
.workflow-node {
  width: 250px;
  padding: 18px 18px 18px 20px;
  background: white;
  border: 1px solid gainsboro;
  border-left: 6px solid darkslateblue;
  box-shadow: 0 6px 18px gainsboro;
}
.workflow-node .node-code { background: lavender; color: darkslateblue; }
.workflow-node b { font-size: 18px; color: navy; }
.node-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 12px;
  color: slategray;
}
.node-counts span { display: inline-flex; align-items: center; gap: 5px; }


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

/* straight line between two boxes on the same level */
.stub {
  flex: none;
  width: var(--arm);
  height: var(--line);
  background: silver;
}

/* the list of workflows */
.branches {
  display: flex;
  flex-direction: column;
}

/* one workflow row: [workflow box] — [cards] */
.branch {
  position: relative;
  display: flex;
  align-items: flex-start;   /* the box and all cards start at the top of the row */
  padding: var(--row-space) 0 var(--row-space) var(--arm);
}

/* holds the workflow box so that its middle sits exactly on the arrow line */
.workflow-holder {
  flex: none;
  height: calc(var(--arrow-y) * 2);
  display: flex;
  align-items: center;
}

/* blue line from the workflow box to its first card (on the arrow line) */
.start-line {
  flex: none;
  width: var(--arm);
  height: 3px;
  margin-top: calc(var(--arrow-y) - 1.5px);
  background: royalblue;
}

/* ::after = the vertical "spine" on the left that joins all workflows */
.branch::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-left: var(--line) solid silver;
}

/* ::before = the arm going right from the spine to the workflow box */
.branch::before {
  content: "";
  position: absolute;
  left: 0;
  top: calc(var(--arm-y) - var(--line) / 2);
  width: var(--arm);
  border-top: var(--line) solid silver;
}

/* first workflow: the line comes straight on from the role box, and the spine starts here going down */
.branch:first-child::after { top: calc(var(--arm-y) - var(--line) / 2); }

/* last workflow: the line curves  ╰  (spine ends here) */
.branch:last-child::before {
  top: calc(var(--arm-y) - var(--curve) + var(--line) / 2);
  height: var(--curve);
  border-top: none;
  border-bottom: var(--line) solid silver;
  border-left: var(--line) solid silver;
  border-bottom-left-radius: var(--curve);
}
.branch:last-child::after { bottom: auto; height: calc(var(--arm-y) - var(--curve) + var(--line)); }

/* only one workflow: no spine needed */
.branch:only-child::after { display: none; }
.branch:only-child::before {
  top: calc(var(--arm-y) - var(--line) / 2);
  height: 0;
  border-left: none;
  border-bottom: none;
  border-top: var(--line) solid silver;
}


/* ---------- cards (one screen or one notification) ----------
   Each card is:   [screenshot in a frame, step number on its corner]
                   [coloured label: "SCREEN 2" + title]
                   description text
*/
.card-row {
  display: flex;
  align-items: flex-start;   /* every card starts at the same top line */
}

.card {
  flex: none;
  width: var(--card-width);
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: zoom-in;
}
.card:focus { outline: none; }

/* The screenshot frame. The screenshot is shown COMPLETE, in its own shape:
   full frame width, and the height follows the picture (nothing is cut). */
.card-picture {
  position: relative;
  padding: 6px;
  background: white;
  border: 1px solid lightsteelblue;
  border-radius: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.card-picture img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
}
.card:hover .card-picture,
.card:focus .card-picture {
  border-color: royalblue;
  box-shadow: 0 0 0 2px royalblue, 0 8px 22px lightsteelblue;
}
.card.notification:hover .card-picture,
.card.notification:focus .card-picture {
  border-color: chocolate;
  box-shadow: 0 0 0 2px chocolate, 0 8px 22px bisque;
}

/* the round step number sitting on the top-left corner of the screenshot */
.step-circle {
  position: absolute;
  left: -14px;
  top: -14px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 3px solid ghostwhite;   /* same colour as the page, so it looks cut out */
  border-radius: 50%;
  color: white;
  font-size: 15px;
  font-weight: 700;
}

/* the coloured label under the screenshot */
.card-label {
  min-height: 64px;
  padding: 9px 12px;
  border-radius: 10px;
  color: white;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}
.card-label span {
  display: block;
  margin-bottom: 3px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* colours: blue for screens, orange-brown for notifications */
.screen .step-circle,
.screen .card-label { background: royalblue; }
.notification .step-circle,
.notification .card-label { background: chocolate; }

/* the description under the label */
.card-text {
  padding: 0 2px;
  font-size: 13px;
  line-height: 1.5;
  color: slategray;
}

.no-picture {
  display: grid;
  place-items: center;
  min-height: 180px;
  color: slategray;
  font-weight: 600;
}

/* small pill used in the popup ("SCREEN 2") */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.badge.screen { background: lavender; color: royalblue; }
.badge.notification { background: papayawhip; color: sienna; }

/* arrow between two cards: a thick blue line with a head.
   It runs at the same height (--arrow-y) on every card, through the screenshots. */
.arrow {
  flex: none;
  width: 56px;
  display: flex;
  align-items: center;
  margin-top: calc(var(--arrow-y) - 7px);   /* 7px = half the arrow head */
  padding: 0 6px;
}
.arrow-line {
  flex: 1;
  height: 3px;
  background: royalblue;
}
.arrow-head {
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 10px solid royalblue;
}


/* ---------- popup (big screenshot + details panel) ---------- */
.popup {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr 380px;
  background: color-mix(in srgb, black 85%, transparent);
}

.popup-image {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  overflow: auto;
}
.popup-image img {
  max-width: 100%;
  max-height: calc(100vh - 56px);
  border-radius: 10px;
  background: white;
  box-shadow: 0 10px 40px black;
}
.popup-image .no-picture { color: white; }

.popup-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 32px 28px 24px;
  background: white;
  overflow-y: auto;
}

.popup-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 1px solid gainsboro;
  border-radius: 50%;
  background: white;
  font-size: 14px;
  color: slategray;
}
.popup-close:hover { color: navy; border-color: navy; }

.popup-path {
  padding-right: 40px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: darkslateblue;
}
.popup-panel h2 { margin: 0; font-size: 22px; line-height: 1.3; color: navy; }
.popup-panel p { margin: 0; font-size: 15px; line-height: 1.6; color: slategray; }

.popup-buttons {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid gainsboro;
}
#popupCounter { font-size: 13px; font-weight: 600; color: slategray; }
.popup-hint { font-size: 12px; color: silver; text-align: center; }


/* ---------- smaller screens ---------- */
@media (max-width: 1100px) {
  .legend, .brand-subtitle { display: none; }
}

/* ---------- phones (760px and below): top bar and popup ---------- */
@media (max-width: 760px) {
  .top-row { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .tools { flex-wrap: wrap; gap: 8px; }
  #actualSizeButton { display: none; }

  /* popup: screenshot on top, details below */
  .popup { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .popup-image { padding: 16px; }
  .popup-image img { max-height: 50vh; }
  .popup-panel { max-height: 50vh; padding: 24px 18px 18px; }
  .popup-panel h2 { font-size: 19px; }
  .popup-hint { display: none; }
}


/* ---------- phones: the tree ----------
   js/start-app.js puts the class "phone-layout" on <body> when the screen is
   760px or narrower. (A class is used instead of @media so that "Download PDF"
   can switch it off for a moment and always save the full desktop tree.)

   The tree turns from left-to-right into top-to-bottom:

     [CMP]
          |
     [Platform Admin]
          |
          ├── [WF 01]
          |      card
          |       ↓
          |      card
          └── [WF 02] ...
*/
.phone-layout .tree {
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  margin: 0;
  padding: 20px 16px 40px;
}
.phone-layout .drawing-area { cursor: auto; }

.phone-layout .root-node,
.phone-layout .role-node,
.phone-layout .workflow-node { width: 100%; }

/* the straight lines between levels now go down */
.phone-layout .stub {
  width: var(--line);
  height: 28px;
  margin-left: 28px;
}
.phone-layout .tree > .stub { margin-top: 0; }
.phone-layout .tree-holder { height: auto; }

/* workflows hang from a spine on the left */
.phone-layout .branches { margin-left: 28px; }

.phone-layout .branch {
  flex-direction: column;
  align-items: stretch;
  padding: 16px 0 16px 22px;
}
.phone-layout .workflow-holder { height: auto; }
.phone-layout .start-line { width: 3px; height: 26px; margin: 0 0 0 24px; }

/* the arm from the spine to the workflow box (always straight on phones) */
.phone-layout .branch::before {
  top: 56px;
  width: 22px;
  height: 0;
  border-top: var(--line) solid silver;
  border-left: none;
  border-bottom: none;
  border-radius: 0;
}
.phone-layout .branch:first-child::after { top: 0; }
.phone-layout .branch:last-child::after { top: 0; bottom: auto; height: 57px; }
.phone-layout .branch:only-child::after { display: block; }

/* cards stack one under the other */
.phone-layout .card-row { flex-direction: column; align-items: stretch; }
.phone-layout .card { width: 100%; }

/* arrows point down */
.phone-layout .arrow {
  align-self: center;
  width: auto;
  height: 46px;
  margin-top: 0;
  flex-direction: column;
  padding: 6px 0;
}
.phone-layout .arrow-line { width: 3px; height: auto; }
.phone-layout .arrow-head {
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 10px solid royalblue;
  border-bottom: none;
}


/* ---------- persona rows (CMP has five personas) ----------
   [app] ─┬─ [persona] ─┬─ [workflow] ...
   A persona row is a branch whose content is the role box and its own list of workflows. */
.persona-branch { padding: 0 0 0 var(--arm); }
.persona-branch > .stub { margin-top: calc(var(--arm-y) - var(--line) / 2); }
.role-detail { font-size: 12px; color: slategray; line-height: 1.35; }
.phone-layout .persona-branch { padding: 0 0 0 22px; }
.phone-layout .persona-branch > .stub { margin-top: 0; }
.phone-layout .persona-branch::before { top: 56px; }

/* every persona named at the top of the page */
.root-personas { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.root-personas-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.85; margin-right: 2px; }
.persona-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 999px; background: white; color: navy; font-size: 13px; font-weight: 700; }
.persona-chip i { font-style: normal; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: darkslateblue; color: white; font-size: 10px; }


/* =====================================================================
   SIDE PANEL, OVERVIEW, PDF MENU
   ===================================================================== */

/* ---------- the area under the top bar: side panel + drawing area ---------- */
.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
}
.workspace .drawing-area { min-width: 0; }

.menu-button { display: none; }   /* phones only (see the bottom of this file) */


/* ---------- side panel ---------- */
.sidebar {
  flex: none;
  width: 300px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: white;
  border-right: 1px solid gainsboro;
  z-index: 1;
}

.sidebar-top { padding: 14px 14px 10px; border-bottom: 1px solid whitesmoke; }

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid gainsboro;
  border-radius: 10px;
  background: ghostwhite;
  cursor: text;
}
.search-box:focus-within { border-color: royalblue; background: white; box-shadow: 0 0 0 3px lavender; }
.search-box input {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  outline: none;
  font: inherit;
  font-size: 14px;
}
/* magnifying glass made of a ring and a handle */
.search-icon {
  position: relative;
  flex: none;
  width: 12px;
  height: 12px;
  border: 2px solid slategray;
  border-radius: 50%;
}
.search-icon::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 2px;
  height: 6px;
  background: slategray;
  transform: rotate(-45deg);
}

.sidebar-summary { margin-top: 10px; font-size: 12px; line-height: 1.4; color: slategray; }

.side-nav,
.search-results {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 10px 16px;
}

/* "Overview" */
.side-overview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: black;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.side-overview:hover { background: ghostwhite; color: navy; }
.side-overview.active { background: lavender; color: navy; }

/* four small squares: the overview icon */
.side-overview-icon {
  flex: none;
  width: 14px;
  height: 14px;
  background:
    linear-gradient(currentColor, currentColor) 0 0 / 6px 6px no-repeat,
    linear-gradient(currentColor, currentColor) 100% 0 / 6px 6px no-repeat,
    linear-gradient(currentColor, currentColor) 0 100% / 6px 6px no-repeat,
    linear-gradient(currentColor, currentColor) 100% 100% / 6px 6px no-repeat;
}

/* one persona group */
.side-persona { margin-top: 4px; }
.side-persona-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: none;
  border-radius: 10px;
  background: none;
  color: black;
  font-size: 14px;
  font-weight: 700;
  text-align: left;
}
.side-persona-head:hover { background: ghostwhite; }
.side-icon {
  flex: none;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: darkslateblue;
  color: white;
  font-size: 11px;
  font-weight: 700;
}
.side-persona-name { flex: 1; min-width: 0; }
.side-persona-count {
  padding: 1px 8px;
  border-radius: 10px;
  background: whitesmoke;
  font-size: 12px;
  font-weight: 600;
  color: slategray;
}
.side-chevron {
  width: 7px;
  height: 7px;
  margin: 0 4px 3px;
  border-right: 2px solid slategray;
  border-bottom: 2px solid slategray;
  transform: rotate(45deg);
  transition: transform 0.15s;
}
.side-persona:not(.open) .side-chevron { transform: rotate(-45deg); margin-bottom: 0; }

/* the workflows of an open persona */
.side-workflows {
  display: none;
  margin: 2px 0 6px 23px;
  padding-left: 10px;
  border-left: 2px solid whitesmoke;
}
.side-persona.open .side-workflows { display: block; }

.side-workflow {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  color: black;
  font-size: 13px;
  text-decoration: none;
}
.side-workflow:hover { background: ghostwhite; color: navy; }
.side-workflow.active { background: lavender; color: navy; font-weight: 600; }
.side-code {
  padding: 2px 6px;
  border-radius: 5px;
  background: whitesmoke;
  font-size: 10.5px;
  font-weight: 700;
  color: darkslateblue;
  white-space: nowrap;
}
.side-workflow.active .side-code { background: white; }
.side-title { line-height: 1.3; }
.side-counts { font-size: 11.5px; white-space: nowrap; }
.side-counts b { color: royalblue; }
.side-counts i { margin: 0 3px; font-style: normal; color: silver; }
.side-counts em { font-style: normal; font-weight: 700; color: chocolate; }

/* bottom of the panel: matrix link + hide button */
.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid gainsboro;
}
.matrix-link {
  flex: 1;
  padding: 9px 12px;
  border-radius: 8px;
  background: lavender;
  color: navy;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
}
.matrix-link:hover { background: navy; color: white; }

.collapse-button,
.rail-expand {
  flex: none;
  width: 36px;
  height: 36px;
  border: 1px solid gainsboro;
  border-radius: 10px;
  background: white;
  font-size: 16px;
  color: slategray;
}
.collapse-button:hover,
.rail-expand:hover { border-color: navy; color: navy; }

/* collapsed: a thin rail with the expand button and one badge per persona */
.side-rail { display: none; }

@media (min-width: 761px) {
  .sidebar.collapsed { width: 60px; }
  .sidebar.collapsed .sidebar-top,
  .sidebar.collapsed .side-nav,
  .sidebar.collapsed .search-results,
  .sidebar.collapsed .sidebar-foot { display: none; }
  .sidebar.collapsed .side-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
  }
}
.rail-button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: darkslateblue;
  color: white;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}
.rail-button[data-overview] { border-radius: 10px; background: white; border: 1px solid gainsboro; color: slategray; }
.rail-button:hover { background: navy; color: white; }
.rail-button.active { box-shadow: 0 0 0 3px white, 0 0 0 5px royalblue; }
.rail-button[data-overview].active { background: lavender; color: navy; box-shadow: none; }


/* ---------- search results ---------- */
.search-count { margin: 4px 6px 8px; font-size: 12px; font-weight: 600; color: slategray; }
.search-empty { margin: 16px 8px; font-size: 13px; color: slategray; }
.search-result {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 10px;
  border-radius: 10px;
  color: black;
  text-decoration: none;
}
.search-result:hover { background: ghostwhite; }
.search-result b { font-size: 13.5px; line-height: 1.3; color: navy; }
.search-result small { font-size: 11.5px; line-height: 1.35; color: slategray; }
.search-kind {
  align-self: flex-start;
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.search-kind.screen { background: lavender; color: royalblue; }
.search-kind.notification { background: papayawhip; color: sienna; }
mark { padding: 0 1px; border-radius: 2px; background: lemonchiffon; color: inherit; }


/* ---------- overview: personas side by side, their workflows hanging below ---------- */
.overview {
  flex-direction: column;
  align-items: center;
  padding: 48px 40px 64px;
}
.ov-root { width: 380px; }
.ov-hint { margin-top: 6px; font-size: 12px; opacity: 0.85; }

.ov-root-line { width: var(--line); height: 32px; background: silver; }

.ov-columns { display: flex; align-items: flex-start; }

.ov-column {
  position: relative;
  width: 300px;
  display: flex;
  flex-direction: column;
  padding: 32px 12px 0;
}
/* the line across the top that joins every persona to the app */
.ov-column::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  border-top: var(--line) solid silver;
}
.ov-column:first-child::before { left: 50%; }
.ov-column:last-child::before { right: 50%; }
.ov-column:only-child::before { display: none; }
/* ...and the short line down to each persona */
.ov-column::after {
  content: "";
  position: absolute;
  top: 0;
  left: calc(50% - var(--line) / 2);
  height: 32px;
  border-left: var(--line) solid silver;
}

.ov-role { width: 100%; }
.ov-role-counts { margin-top: 4px; font-weight: 600; }

/* the workflows: a spine down from the persona box, an arm to each workflow */
.ov-list { margin: 0; padding: 0 0 0 26px; list-style: none; }
.ov-item { position: relative; padding: 12px 0 0 22px; }
.ov-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 34px;
  width: 22px;
  border-top: var(--line) solid silver;
}
.ov-item::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-left: var(--line) solid silver;
}
.ov-item:last-child::after { bottom: auto; height: calc(34px + var(--line)); }

.ov-workflow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 8px;
  padding: 11px 14px 12px;
  background: white;
  border: 1px solid gainsboro;
  border-left: 5px solid darkslateblue;
  border-radius: 12px;
  box-shadow: 0 4px 12px gainsboro;
  color: black;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.ov-workflow:hover {
  border-color: royalblue;
  box-shadow: 0 0 0 2px royalblue, 0 8px 20px lightsteelblue;
  transform: translateY(-1px);
}
.ov-workflow .node-code { background: lavender; color: darkslateblue; }
.ov-workflow b { flex-basis: 100%; order: 3; font-size: 15px; line-height: 1.3; color: navy; }
.ov-workflow .node-counts { font-weight: 600; }


/* ---------- Download PDF menu ---------- */
.pdf-holder { position: relative; }
.pdf-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: 340px;
  padding: 6px;
  background: white;
  border: 1px solid gainsboro;
  border-radius: 12px;
  box-shadow: 0 12px 32px lightsteelblue;
}
.pdf-menu button,
.pdf-menu a {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: none;
  text-align: left;
}
.pdf-menu button:hover,
.pdf-menu a:hover { background: ghostwhite; }
.pdf-menu a { color: inherit; text-decoration: none; }
.pdf-menu b { display: block; font-size: 14px; color: navy; }
.pdf-menu span { display: block; margin-top: 3px; font-size: 12px; line-height: 1.4; color: slategray; }


/* ---------- popup: where the screenshot came from, and the link button ---------- */
.popup-meta {
  padding: 10px 12px;
  border-radius: 10px;
  background: ghostwhite;
  font-size: 12.5px;
  line-height: 1.5;
  color: black;
}
.popup-meta:empty { display: none; }
.meta-label {
  display: block;
  margin-bottom: 2px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: darkslateblue;
}
.meta-source { color: slategray; }

.link-button {
  align-self: flex-start;
  padding: 0;
  border: none;
  background: none;
  color: royalblue;
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-button:hover { color: navy; }


/* ---------- phones: the side panel becomes a drawer, the overview stacks ---------- */
@media (max-width: 760px) {
  .menu-button {
    display: grid;
    place-items: center;
    flex: none;
    width: 38px;
    height: 38px;
    border: 1px solid gainsboro;
    border-radius: 10px;
    background: white;
    font-size: 18px;
  }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    width: min(86vw, 330px);
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  .sidebar.drawer-open { transform: none; box-shadow: 0 0 40px slategray; }
  .collapse-button { display: none; }
  .scrim { position: fixed; inset: 0; z-index: 25; background: color-mix(in srgb, black 40%, transparent); }
  .pdf-menu { position: fixed; top: auto; left: 12px; right: 12px; width: auto; margin-top: 8px; }
}

.phone-layout .overview { width: 100%; margin: 0; padding: 20px 16px 40px; align-items: stretch; }
.phone-layout .ov-root { width: 100%; }
.phone-layout .ov-root-line { margin-left: 28px; }
.phone-layout .ov-columns { flex-direction: column; }
.phone-layout .ov-column { width: 100%; padding: 28px 0 0; }
.phone-layout .ov-column::before { display: none; }
.phone-layout .ov-column::after { left: 28px; height: 28px; }


/* =====================================================================
   PRINT: the full tree on one page (tools/build_pdf.py uses this)
   Only the tree is printed, at 100%, with every screenshot; text, boxes
   and lines stay as vectors, so the PDF is sharp at any zoom.
   ===================================================================== */
@media print {
  html, body { height: auto; overflow: visible; background: ghostwhite; }
  body { display: block; }
  .top-bar, .sidebar, .scrim, .overview, .popup { display: none !important; }
  .workspace, .drawing-area { display: block; overflow: visible; background: ghostwhite; }
  .tree, .tree[hidden] { display: flex !important; zoom: 1 !important; margin: 0; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
