/*
 * Org Chart chrome. Values come from tokens.css; measurements from Org_Chart_UI_Spec.md.
 * The printed page itself is SVG drawn by js/render.mjs and never styled here.
 */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/inter-latin-700-normal.woff2") format("woff2"); }

:root {
  --bar-h: 52px;
  --panel-w: 344px;
  --tool-h: 40px;
  --strip-h: 84px;
  --canvas: #0c0d10;
  --page-shadow: 0 4px 24px rgb(0 0 0 / 0.5);
}
:root[data-theme="light"] {
  --canvas: #dcd8cf;
  --page-shadow: 0 2px 12px rgb(0 0 0 / 0.18);
}

/* The app fills the window; screens scroll inside themselves. */
html, body { height: 100dvh; overflow: hidden; }
body { font-size: var(--fs-ui); line-height: var(--lh-snug); }
main { padding: 0; }
.grow { flex: 1; }
[hidden] { display: none !important; }

/* ---- Top bar ---- */
.bar {
  height: calc(var(--bar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(var(--space-s), env(safe-area-inset-right)) 0 max(var(--space-s), env(safe-area-inset-left));
  flex: none; display: flex; align-items: center; gap: var(--space-xs);
  background: var(--surface); border-bottom: var(--border) solid var(--line);
}
.brand-mark { display: flex; align-items: center; gap: 10px; margin-right: var(--space-2xs); color: inherit; text-decoration: none; }
.brand-mark span { display: flex; flex-direction: column; line-height: 1.1; }
.brand-mark b { font-size: 15px; }
.brand-mark small { font-size: 12px; color: var(--ink-2); }
.bar-file, .bar-actions { display: flex; align-items: center; gap: var(--space-2xs); min-width: 0; }
.pill {
  min-height: 30px; padding: 0 12px; border-radius: var(--r-pill);
  border: var(--border) solid var(--line); background: transparent; color: var(--ink);
  font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46ch;
}
.pill.quiet { color: var(--ink-2); }
.pill.warn { border-color: var(--warn); color: var(--ink); }
.dd::after { content: "▾"; font-weight: 400; opacity: 0.7; }
.btn { border-radius: var(--r-s); }
.btn[disabled], button[disabled] { opacity: 0.45; cursor: not-allowed; }

/* ---- Shared screen pieces ---- */
.screen { flex: 1; min-height: 0; }
.center { display: grid; place-items: center; overflow: auto; background: var(--surface-2); padding: var(--space-m); }
.center-text { text-align: center; max-width: none; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: var(--w-strong); text-decoration: underline; text-underline-offset: 0.2em; }
.error-card { border: 1.5px solid var(--bad); border-radius: var(--r-m); padding: 12px 14px; background: var(--surface); max-width: 560px; }
.error-card b { display: block; margin-bottom: 4px; }
.check { display: inline-flex; align-items: center; gap: 8px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* Opening a file */
.start { width: min(560px, 100%); display: flex; flex-direction: column; gap: var(--space-s); }
.drop {
  border: 2px dashed var(--line); border-radius: var(--r-l); background: var(--surface);
  padding: var(--space-l) var(--space-m); display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
}
.drop.over { border-color: var(--accent); }
.drop h1 { font-size: var(--fs-h3); }
.drop p { max-width: none; }
.file-btn { cursor: pointer; }
.recent .label { padding: 0 2px 4px; }
.recent .row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 2px; border-bottom: var(--border) solid var(--line); }
.recent button.link { text-align: left; }
.copy { text-align: center; font-size: 12px; color: var(--ink-3); max-width: none; }

/* Match Columns and checks */
.sheet { overflow: auto; padding: var(--space-m) var(--space-l); display: flex; flex-direction: column; gap: var(--space-s); }
.sheet-head h1 { font-size: var(--fs-h3); }
.sheet-foot { display: flex; align-items: center; gap: var(--space-2xs); padding-top: var(--space-2xs); }
table.map { border-collapse: collapse; width: 100%; max-width: 1200px; }
table.map th { text-align: left; font-size: 11.5px; font-weight: var(--w-strong); color: var(--ink-3); text-transform: var(--label-case); letter-spacing: var(--label-track); padding: 6px 8px; border-bottom: var(--border) solid var(--ink-3); }
table.map td { padding: 5px 8px; border-bottom: var(--border) solid var(--line); vertical-align: middle; }
table.map td:first-child { width: 220px; }
table.map td:nth-child(2) { width: 320px; }
table.map td:last-child { width: 130px; }
table.map select { width: 100%; }
.req { color: var(--ink-3); font-size: 11.5px; margin-left: 4px; }
.tag { display: inline-block; border: var(--border) solid var(--ink-2); border-radius: 4px; padding: 0 6px; font-size: 11.5px; white-space: nowrap; }
.tag.likely { border-style: dashed; border-color: var(--warn); }
.tag.none { border-color: var(--line); color: var(--ink-3); }
.issues { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-s); max-width: 1200px; }
.issues .group { display: flex; flex-direction: column; gap: 8px; }
.issue { border: var(--border) solid var(--line); border-radius: var(--r-m); padding: 9px 11px; background: var(--surface); display: flex; flex-direction: column; gap: 3px; }
.issue.error { border: 1.5px solid var(--bad); }
.issue.warning { border-color: var(--warn); }
.issue .rows { font-size: 11.5px; color: var(--ink-3); }

/* ---- Editor ---- */
.editor { display: grid; grid-template-columns: var(--panel-w) minmax(0, 1fr); }
.panel { background: var(--surface); border-right: var(--border) solid var(--line); overflow-y: auto; overscroll-behavior: contain; }
.psec { padding: 14px 16px; border-bottom: var(--border) solid var(--line); display: flex; flex-direction: column; gap: 9px; }
.psec:last-of-type { border-bottom: 0; }
.psec > .label { font-size: 11.5px; }
.fld { display: grid; grid-template-columns: 100px minmax(0, 1fr); align-items: center; gap: 8px; }
.fld > span { color: var(--ink-2); }
.fld select, .fld input[type="text"], .fld input[type="search"] {
  width: 100%; min-height: 34px; padding: 0 8px; border-radius: var(--r-s);
  border: var(--border) solid var(--line); background: var(--surface-2);
}
.hint { font-size: 12px; color: var(--ink-3); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: var(--border) solid var(--line); border-radius: var(--r-s); overflow: hidden; }
.seg button { min-height: 32px; border: 0; border-right: var(--border) solid var(--line); background: transparent; color: var(--ink-2); font-size: 12.5px; padding: 0 6px; }
.seg button:last-child { border-right: 0; }
/* The selected segment is a quiet fill; blue stays on the main action (one brand color, used sparingly). */
.seg button[aria-pressed="true"] { background: var(--selected); color: var(--ink); font-weight: var(--w-strong); }
.seg.mini { grid-auto-columns: auto; background: var(--surface); }
.seg.mini button { min-height: 28px; padding: 0 10px; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; }
.multi { position: relative; }
.multi summary { list-style: none; min-height: 34px; padding: 0 8px; border-radius: var(--r-s); border: var(--border) solid var(--line); background: var(--surface-2); display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.multi summary::-webkit-details-marker { display: none; }
.multi summary::after { content: "▾"; color: var(--ink-3); }
.multi .opts { position: absolute; z-index: var(--z-overlay); left: 0; right: 0; top: calc(100% + 4px); max-height: 280px; overflow: auto; background: var(--surface); border: var(--border) solid var(--line); border-radius: var(--r-s); padding: 6px; box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: 2px; }
.multi .opts label { display: flex; gap: 8px; align-items: center; padding: 4px 6px; border-radius: 4px; }
.multi .opts .n { margin-left: auto; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.swatches { display: inline-flex; gap: 3px; margin-right: 6px; vertical-align: middle; }
.swatches i { width: 11px; height: 11px; border-radius: 2px; display: inline-block; }
.panel .copy { padding: 12px 16px 16px; }

.canvas { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--canvas); }
.tool {
  height: var(--tool-h); flex: none; display: flex; align-items: center; gap: 12px; padding: 0 14px;
  background: var(--surface); border-bottom: var(--border) solid var(--line); color: var(--ink-2); font-size: 12.5px; white-space: nowrap;
}
.tool b { color: var(--ink); }
.tool .low { color: var(--bad); font-weight: var(--w-strong); }
.stage { flex: 1; min-height: 0; overflow: auto; position: relative; padding: 24px; outline: none; }
.stage:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.paper { margin: 0 auto; background: #fff; box-shadow: var(--page-shadow); cursor: default; }
.paper svg { display: block; width: 100%; height: auto; }
.sel-ring { position: absolute; border: 2px solid var(--accent); border-radius: var(--r-s); pointer-events: none; box-shadow: 0 0 0 3px rgb(127 178 255 / 0.25); }
.strip { height: var(--strip-h); flex: none; display: flex; gap: 10px; align-items: center; padding: 0 14px; overflow-x: auto; background: var(--surface); border-top: var(--border) solid var(--line); }
.thumb { flex: none; width: 92px; padding: 0; border: 2px solid transparent; border-radius: 4px; background: #fff; }
.thumb[aria-current="page"] { border-color: var(--accent); }
.thumb svg { display: block; width: 100%; height: auto; }
.outline { flex: 1; min-height: 0; overflow: auto; padding: 20px 28px; background: var(--surface); }
.outline ul { list-style: none; padding-left: 20px; border-left: var(--border) solid var(--line); margin: 4px 0 4px 6px; }
.outline > ul { border-left: 0; padding-left: 0; margin-left: 0; }
.outline li { padding: 3px 0; }
.outline .t { color: var(--ink-2); }
.outline .c { color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---- Menus, dialog, toast ---- */
.menu {
  position: fixed; z-index: var(--z-overlay); min-width: 232px; max-width: 320px;
  background: var(--surface); border: var(--border) solid var(--line); border-radius: var(--r-m);
  box-shadow: 0 8px 28px rgb(0 0 0 / 0.35); padding: 4px 0; font-size: 13px;
}
.menu .mh { padding: 8px 12px 4px; font-size: 11px; font-weight: var(--w-strong); color: var(--ink-3); text-transform: var(--label-case); letter-spacing: var(--label-track); }
.menu .who { padding: 8px 12px; border-bottom: var(--border) solid var(--line); margin-bottom: 4px; }
.menu .who b { display: block; }
.menu .who span { color: var(--ink-2); font-size: 12px; }
.menu button.mi { width: 100%; min-height: 32px; display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 0 12px; border: 0; background: transparent; color: var(--ink); text-align: left; }
.menu button.mi span { color: var(--ink-3); font-size: 12px; }
.menu .sep { border-top: var(--border) solid var(--line); margin: 4px 0; }
.menu .edit { padding: 6px 12px 8px; display: flex; gap: 6px; }
.menu .edit input { flex: 1; min-height: 32px; padding: 0 8px; border-radius: var(--r-s); border: var(--border) solid var(--line); background: var(--surface-2); }
.dlg { margin: auto; border: var(--border) solid var(--line); border-radius: var(--r-l); background: var(--surface); color: var(--ink); padding: var(--space-s); width: min(420px, 92vw); }
.dlg::backdrop { background: rgb(0 0 0 / 0.5); }
.dlg h2 { font-size: var(--fs-lead); margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field input { min-height: 36px; padding: 0 10px; border-radius: var(--r-s); border: var(--border) solid var(--line); background: var(--surface-2); }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dlg-fields { display: flex; flex-direction: column; gap: 12px; }
.dlg .error-card { margin-top: 12px; }
/* Dragging an open role onto its manager */
.drop-ring { border-style: dashed; box-shadow: 0 0 0 4px rgb(127 178 255 / 0.3); }
.stage.dragging, .stage.dragging * { cursor: grabbing !important; user-select: none; }
.drag-chip { position: fixed; z-index: var(--z-overlay); pointer-events: none; transform: translate(12px, 12px); background: var(--surface); color: var(--ink); border: 1.5px dashed var(--accent); border-radius: var(--r-s); padding: 6px 10px; font-size: 12.5px; box-shadow: 0 6px 18px rgb(0 0 0 / 0.35); max-width: 260px; }
.drag-chip b { display: block; font-size: 11px; color: var(--accent); text-transform: var(--label-case); letter-spacing: var(--label-track); }
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: var(--z-overlay); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: var(--r-pill); font-size: 13px; max-width: none; }

@media (hover: hover) and (pointer: fine) {
  .pill:hover { border-color: var(--ink-3); }
  .seg button:not([aria-pressed="true"]):hover { background: var(--surface-2); color: var(--ink); }
  .menu button.mi:not([disabled]):hover { background: var(--surface-2); }
  .thumb:hover { border-color: var(--line); }
  .recent .row:hover { background: var(--surface); }
}

/* No phone layout in v1 (spec): below 40rem the editor says so instead of squeezing. */
@media (max-width: 39.99rem) {
  .editor { grid-template-columns: 1fr; }
  .panel { display: none; }
}
.hidden-list { display: flex; flex-direction: column; gap: 4px; }
.hidden-row { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; }

/* ---- Print: only the pages, one per sheet, at the chart's paper size (set by export.mjs) ---- */
#print-root { display: none; }
@media print {
  html, body { height: auto; overflow: visible; background: #fff; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; }
  #print-root svg { display: block; width: 100%; height: auto; break-after: page; }
  #print-root svg:last-child { break-after: auto; }
}

/* ---- Staff photos (Cards section) ---- */
.photo-row { display: flex; flex-direction: column; gap: 6px; }
.photo-row .hint { margin: 0; max-width: none; }
.photo-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.btn.sm { padding-inline: 10px; font-size: 12.5px; }
@media (pointer: fine) { .btn.sm { min-height: 30px; } }
