:root {
  --navy: #002238;
  --blue: #00558c;
  --blue-bright: #0077b6;
  --sky: #e6f0f5;
  --paper: #eef2f5;
  --white: #ffffff;
  --text: #414042;
  --muted: #636466;
  --line: #d6dde3;
  --line-soft: #e8edf1;
  --wire: #5f7080;
  --dot: #c3cfd8;
  --danger: #9b2c2c;
  --pin: #c8372d;

  --font-ui: "lato", "Helvetica Neue", Arial, sans-serif;
  --font-head: "urw-din", "Helvetica Neue", Arial, sans-serif;
  --font-cond: "urw-din-condensed", "urw-din", "Arial Narrow", sans-serif;

  --bar-h: 52px;
  --panel-w: 384px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--white);
  color: var(--text);
  font: 15px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

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

button { cursor: pointer; }

a { color: var(--blue); }

/* ---------- top bar ---------- */

.bar {
  height: var(--bar-h);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 0 14px 0 10px;
  border-bottom: 1px solid var(--line);
  background: var(--white);
  position: relative;
  z-index: 5;
}

.bar-left { display: flex; align-items: center; gap: 4px; min-width: 0; }
.bar-center { display: flex; justify-content: center; }
.bar-right { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }

.crumb {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  padding: 6px 2px 6px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
  flex: none;
}
.crumb::after { content: '/'; margin-left: 8px; color: var(--line); }
.crumb:hover { color: var(--navy); }
.crumb:empty { display: none; }
body.present .crumb { visibility: hidden; }

.crumb-static { color: var(--muted); font-size: 14px; padding: 6px 2px 6px 4px; white-space: nowrap; }

.title-btn {
  width: 28px; height: 28px;
  border: 0; border-radius: 3px;
  background: transparent;
  display: grid; place-items: center;
  color: var(--navy);
}
.title-btn:hover, .title-btn[aria-expanded="true"] { background: var(--sky); }
.title-caret {
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid currentColor;
}

.title {
  font: 700 19px/1.2 var(--font-head);
  color: var(--navy);
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  padding: 3px 6px;
  min-width: 80px;
  max-width: 420px;
  width: 22ch;
  outline: none;
}
.title:hover { border-bottom-color: var(--line); }
.title:focus { border-bottom-color: var(--blue); }

.save-state {
  font-size: 12.5px;
  color: var(--muted);
  margin-left: 10px;
  white-space: nowrap;
  min-width: 48px;
}

/* Others' edits are arriving as they are stored: a quiet dot beside the save state. */
.live-state {
  font-size: 12.5px;
  color: var(--muted);
  margin-left: 10px;
  white-space: nowrap;
}
.live-state::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue-bright);
  margin-right: 5px;
  vertical-align: 1px;
}

.search {
  width: 100%;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--white);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.search:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--sky); }
.search::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

.btn {
  height: 32px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--navy);
  white-space: nowrap;
}
.btn:hover { background: var(--sky); }
.btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.btn[aria-pressed="true"] { background: var(--navy); color: var(--white); }
.btn.primary { background: var(--navy); color: var(--white); }
.btn.primary:hover { background: var(--blue); }
.btn.active { border-color: var(--blue); }
.btn.help {
  width: 28px; height: 28px; padding: 0; margin-left: 6px;
  border-radius: 50%; border-color: var(--line);
  font: 600 15px/1 var(--font-head); color: var(--muted);
}
.btn.help:hover { color: var(--navy); }

/* ---------- work area ---------- */

.work {
  display: grid;
  grid-template-columns: 1fr var(--panel-w);
  height: calc(100% - var(--bar-h));
}

.canvas {
  position: relative;
  background: var(--paper);
  overflow: hidden;
  min-width: 0;
}

.canvas svg { display: block; width: 100%; height: 100%; }

.canvas.connecting { cursor: crosshair; }
.canvas.placing, .canvas.placing .grid { cursor: crosshair; }
.canvas.panning { cursor: grab; }
.canvas.panning:active { cursor: grabbing; }
.canvas.panning .node, .canvas.panning .link { pointer-events: none; }
.canvas.sliding .link .hit { cursor: grab; }

.hint {
  position: absolute;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: var(--white);
  padding: 7px 14px;
  border-radius: 3px;
  font-size: 14px;
  z-index: 2;
  pointer-events: none;
}

.legend {
  position: absolute;
  left: 16px; bottom: 14px;
  display: flex; gap: 18px;
  font-size: 12.5px;
  color: var(--muted);
  pointer-events: none;
}
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.legend .wire { display: inline-block; width: 26px; height: 0; border-top: 1.5px solid var(--wire); }
.legend .wire.dashed { border-top-style: dashed; }
.legend .wire.dotted { border-top-style: dotted; border-top-width: 2px; }

.zoom-controls {
  position: absolute;
  right: 14px; bottom: 14px;
  display: flex; flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--white);
  overflow: hidden;
}
.zbtn {
  width: 30px; height: 30px;
  border: 0; background: transparent;
  color: var(--navy);
  font-size: 18px; line-height: 1;
}
.zbtn + .zbtn { border-top: 1px solid var(--line); }
.zbtn:hover { background: var(--sky); }

/* ---------- graph ---------- */

.grid { fill: url(#dotgrid); }

.link .hit { stroke: transparent; stroke-width: 14; fill: none; }
.link .wire { fill: none; transition: opacity .2s; }
.link.probable .wire { stroke-dasharray: 7 4; }
.link.possible .wire { stroke-dasharray: 2 4; stroke-linecap: round; }
.link.selected .wire { stroke: var(--blue); }
.link:hover .wire { stroke: var(--navy); }
.link .label {
  font: 400 11.5px var(--font-ui);
  fill: var(--wire);
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--paper);
  stroke-width: 4px;
  stroke-linejoin: round;
  pointer-events: none;
  user-select: none;
}
.link.selected .label { fill: var(--blue); }
.link.dim { opacity: .12; }

.arrow.selected { fill: var(--blue); }

.marquee { fill: var(--blue); fill-opacity: .07; stroke: var(--blue); stroke-width: 1; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; pointer-events: none; }
.corner { fill: var(--paper); stroke: var(--wire); stroke-width: 1.5; cursor: move; transition: opacity .2s; }
.corner:hover { stroke: var(--navy); stroke-width: 2; }
.corner.active { fill: var(--white); stroke: var(--blue); stroke-width: 2; }
.corner.active:hover { fill: var(--blue); }
.corner.selected { fill: var(--blue); stroke: var(--white); stroke-width: 2; }
.corner.dim { opacity: .12; }
body.present .corner:not(.active) { display: none; }
.swatches { display: flex; gap: 8px; align-items: center; height: 36px; }
.swatch { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; padding: 0; cursor: pointer; box-shadow: 0 0 0 1px var(--line); }
.swatch[aria-pressed="true"] { border-color: var(--white); box-shadow: 0 0 0 2px var(--navy); }
.select-with { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin: 12px 0 0; }
.bends { font-size: 13px; color: var(--muted); margin: 14px 0 0; }
.group-list { list-style: none; padding: 0; margin: 10px 0 0; max-height: 50vh; overflow: auto; }
.group-list li { padding: 3px 0; }
.group-actions { margin-top: 16px; }

.node { cursor: grab; transition: opacity .2s; }
.node:active { cursor: grabbing; }
.node .halo { fill: var(--blue); opacity: 0; stroke: none; }
.node.selected .halo { opacity: .16; }
.node .disc { fill: var(--white); stroke: var(--navy); stroke-width: 1.5; }
.node .ring { fill: none; }
.node.selected .ring, .node.selected .disc { stroke: var(--blue); }
.node:hover .ring, .node:hover .disc { stroke-width: 2.5; }
.node .glyph { fill: none; stroke: var(--navy); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.node .label {
  font: 700 13px var(--font-cond);
  fill: var(--navy);
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--paper);
  stroke-width: 3.5px;
  stroke-linejoin: round;
  user-select: none;
}
.node .label { cursor: text; }
.node.pinned .pin { fill: var(--navy); }
.node .pin { fill: transparent; }
.node.dim { opacity: .12; }
.node.target-ok { cursor: crosshair; }

body.present .node { cursor: pointer; }

.inline-name {
  position: absolute;
  transform: translateX(-50%);
  z-index: 3;
}
.inline-name input {
  font: 700 13px/1.2 var(--font-cond);
  color: var(--navy);
  text-align: center;
  background: var(--white);
  border: 1px solid var(--blue);
  border-radius: 2px;
  padding: 2px 6px;
  outline: none;
  box-shadow: 0 0 0 3px var(--sky);
}

/* ---------- panel ---------- */

.panel {
  border-left: 1px solid var(--line);
  background: var(--white);
  overflow-y: auto;
  overflow-x: hidden;
}
.panel-find { padding: 16px 24px 0; }
.panel-find[hidden] { display: none; }

.panel-inner { padding: 22px 24px 40px; }

.empty { color: var(--muted); }
.empty .counts { font-size: 13px; color: var(--muted); margin: -8px 0 10px; }
.empty .none { margin: 12px 0; }
.empty .example { margin: 14px 0 0; }

.entity-list { list-style: none; margin: 0 -10px; padding: 0; }
.entity-list .row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 7px 10px;
  border: 0; border-radius: 3px; background: transparent;
  text-align: left; cursor: pointer; color: var(--navy);
}
.entity-list .row:hover { background: var(--sky); }
.entity-list .row:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.entity-list .thumb {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--navy); background: var(--white);
  display: grid; place-items: center; overflow: hidden;
}
.entity-list .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.entity-list .thumb svg { stroke: var(--navy); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.entity-list .row-text { display: flex; flex-direction: column; min-width: 0; }
.entity-list .row-name { font-size: 15px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entity-list .row-type { font-size: 12.5px; color: var(--muted); }


.kind {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 2px;
}

.name-input {
  width: 100%;
  font: 700 26px/1.15 var(--font-head);
  color: var(--navy);
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  padding: 2px 0 6px;
  outline: none;
}
.name-input.invalid { border-bottom-color: var(--danger); color: var(--danger); }
.name-wrap { position: relative; }
.name-hits {
  position: absolute;
  left: 0; right: 0; top: 100%;
  z-index: 6;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: 0 6px 24px rgba(0, 34, 56, .12);
  padding: 4px;
}
.name-hits[hidden] { display: none; }
.name-hits .taken { font-size: 13.5px; color: var(--text); padding: 8px 8px 6px; line-height: 1.4; }
.name-hits .taken .link-btn { margin-left: 4px; }
.name-hits .hit {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 3px;
  padding: 6px 8px;
  font-size: 14px;
  color: var(--text);
}
.name-hits .hit:hover, .name-hits .hit:focus-visible { background: var(--sky); outline: none; }
.name-hits .thumb { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); overflow: hidden; display: grid; place-items: center; }
.name-hits .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.name-hits .thumb svg { stroke: var(--navy); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.name-hits .hit-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.name-hits .hit-type { font-size: 12.5px; color: var(--muted); }

.elsewhere { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.elsewhere .kind { margin-bottom: 8px; }

.name-input::placeholder { color: #a9b3bb; font-weight: 700; }
.name-input:hover { border-bottom-color: var(--line); }
.name-input:focus { border-bottom-color: var(--blue); }

.photo-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 16px;
  align-items: center;
  margin: 18px 0 10px;
}
.photo {
  width: 96px; height: 96px;
  border-radius: 50%;
  border: 1.5px solid var(--navy);
  background: var(--paper);
  display: grid; place-items: center;
  overflow: hidden;
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo svg { width: 44px; height: 44px; stroke: var(--navy); fill: none; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.photo-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }

/* ---------- project entity manager ---------- */

body.manager { overflow: hidden; }
.manager-main {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  height: calc(100% - var(--bar-h));
}
.manager-list { border-right: 1px solid var(--line); overflow-y: auto; }
.manager-list .counts { font-size: 13px; color: var(--muted); margin: -8px 0 10px; }
.manager-list .none { color: var(--muted); margin: 12px 0; }
.manager-list .entity-list .row.current { background: var(--sky); }
.manager-editor { overflow-y: auto; }
.manager-editor .panel-inner { max-width: 640px; }
.manager-editor .empty { padding-top: 24px; font-size: 16px; }
.name-note { font-size: 13.5px; color: var(--danger); margin: 6px 0 0; }
.chart-list { list-style: none; margin: 8px 0 0; padding: 0; }
.chart-list li { margin: 4px 0; }
a.link-btn { text-decoration: none; }
a.link-btn:hover { text-decoration: underline; }

.library {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 34, 56, .35);
  display: grid; place-items: center;
}
.library-box {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  overflow: auto;
  background: var(--white);
  border-radius: 4px;
  box-shadow: 0 12px 40px rgba(0, 34, 56, .25);
  padding: 18px 22px 22px;
}
.library-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.library-head h2 { margin: 0; font: 700 20px/1.2 var(--font-head); color: var(--navy); }
.library-head .x { border: 0; background: transparent; font-size: 22px; line-height: 1; color: var(--muted); padding: 2px 6px; }
.library-head .x:hover { color: var(--navy); }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 14px 12px; }
.library-item {
  border: 1px solid transparent; border-radius: 3px; background: transparent; padding: 4px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; font: inherit; color: var(--text);
}
.library-item img { width: 88px; height: 88px; object-fit: cover; border-radius: 50%; border: 1px solid var(--line); display: block; }
.library-item span { font-size: 12.5px; line-height: 1.3; text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.library-item:hover, .library-item:focus-visible { background: var(--sky); border-color: var(--line); outline: none; }

.link-btn {
  border: 0; background: transparent;
  color: var(--blue);
  padding: 3px 0;
  text-align: left;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }
.link-btn:disabled { color: var(--muted); cursor: default; text-decoration: none; }

.field { margin-top: 16px; }
.field label, .field .lab {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 5px;
}
.field input[type="text"], .field input[type="url"], .field input[type="email"], .field input[type="password"], .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 7px 9px;
  background: var(--white);
  outline: none;
  line-height: 1.4;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--sky);
}
.field textarea { resize: vertical; min-height: 72px; }
.field select {
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M0 0h10L5 6z' fill='%23002238'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.section {
  margin-top: 30px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 4px;
}
.section-head h3 {
  font: 700 16px/1.2 var(--font-head);
  color: var(--navy);
  margin: 0;
}
.section-head .count { color: var(--muted); font-size: 13px; margin-left: 8px; }

.kv { display: grid; grid-template-columns: 1fr 1.4fr 24px; gap: 8px; margin-top: 8px; align-items: center; }
.kv input { border: 1px solid var(--line); border-radius: 2px; padding: 6px 8px; outline: none; width: 100%; }
.kv input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--sky); }

.x {
  width: 24px; height: 24px;
  border: 0; background: transparent;
  color: var(--muted);
  border-radius: 3px;
  font-size: 16px; line-height: 1;
}
.x:hover { background: var(--sky); color: var(--danger); }

.source {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line-soft);
}
.source:first-of-type { border-top: 0; padding-top: 2px; }
.source .row { display: grid; grid-template-columns: 1fr 24px; gap: 8px; align-items: center; }
.source input, .source textarea {
  width: 100%;
  border: 1px solid var(--line); border-radius: 2px;
  padding: 6px 8px; outline: none;
}
.source input:focus, .source textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--sky); }
.source .meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.source textarea { margin-top: 8px; min-height: 44px; resize: vertical; }
.source .num { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }

.conn-list { list-style: none; margin: 8px 0 0; padding: 0; }
.conn-list li { padding: 0; }
.conn-list button {
  width: 100%;
  text-align: left;
  border: 0; background: transparent;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: baseline;
  color: var(--text);
}
.conn-list button:hover { color: var(--navy); background: var(--sky); margin: 0 -8px; padding-left: 8px; padding-right: 8px; width: calc(100% + 16px); }
.conn-list .dir { color: var(--muted); font-size: 13px; }
.conn-list .who { font-weight: 700; color: var(--navy); }
.conn-list .what { color: var(--muted); }

.endpoints {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}
.endpoint {
  font: 700 17px/1.2 var(--font-head);
  color: var(--navy);
  border: 0; background: transparent; padding: 0;
  text-align: left;
}
.endpoint:hover { color: var(--blue); }
.endpoint.to { text-align: right; }
.swap {
  border: 1px solid var(--line); border-radius: 3px; background: var(--white);
  width: 30px; height: 30px; color: var(--navy);
}
.swap:hover { background: var(--sky); }

.danger-zone { margin-top: 34px; padding-top: 16px; border-top: 1px solid var(--line-soft); }

/* read-only (present) views */
.read .kind { margin-bottom: 4px; }
.read h2 {
  font: 700 30px/1.1 var(--font-cond);
  color: var(--navy);
  margin: 0 0 6px;
}
.read .aka { color: var(--muted); margin: 0 0 14px; }
.read .photo { width: 140px; height: 140px; margin: 14px 0 18px; }
.read .photo svg { width: 60px; height: 60px; }
.read p.desc { margin: 0 0 8px; line-height: 1.6; }
.read dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 10px 0 0; }
.read dt { color: var(--muted); }
.read dd { margin: 0; }
.read ol.sources { padding-left: 20px; margin: 8px 0 0; }
.read ol.sources li { margin-bottom: 10px; }
.read .src-meta { color: var(--muted); font-size: 13.5px; }
.read .src-note { margin-top: 2px; }
.read .endpoints { margin-top: 6px; }
.read .endpoint { cursor: pointer; }

/* ---------- menus ---------- */

.menu {
  position: absolute;
  min-width: 220px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: 0 6px 24px rgba(0, 34, 56, .12);
  padding: 6px;
  z-index: 50;
}
.menu button.item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  width: 100%;
  border: 0; background: transparent;
  padding: 7px 10px;
  border-radius: 2px;
  text-align: left;
  color: var(--text);
}
.menu button.item:hover, .menu button.item:focus-visible { background: var(--sky); color: var(--navy); outline: none; }
.menu button.item.danger { color: var(--danger); }
.menu button.item:disabled { color: var(--muted); cursor: default; background: transparent; }
.menu.help-menu { width: 400px; padding: 12px 16px 14px; color: var(--muted); font-size: 14px; }
.menu.help-menu .head { padding: 0; margin: 0 0 8px; font: 600 15px/1.3 var(--font-ui); color: var(--text); }
.menu.help-menu ul { padding-left: 18px; margin: 0; }
.menu.help-menu li { margin-bottom: 7px; }
.menu .sep { height: 1px; background: var(--line-soft); margin: 6px 4px; }
.menu .head { font-size: 12.5px; color: var(--muted); padding: 6px 10px 2px; }
.menu label.item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: 2px; cursor: pointer;
}
.menu label.item:hover { background: var(--sky); }
.menu label.item input { margin: 0; accent-color: var(--blue); }
.menu .sub { font-size: 12.5px; color: var(--muted); }
.menu .open-row { display: grid; grid-template-columns: 1fr 24px; align-items: center; gap: 4px; }
.menu .open-row .item { padding-right: 4px; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%; bottom: 26px;
  transform: translateX(-50%);
  background: var(--navy);
  color: var(--white);
  padding: 10px 16px;
  border-radius: 3px;
  font-size: 14px;
  z-index: 100;
  max-width: min(560px, 90vw);
}

/* ---------- present mode ---------- */

body.present .bar-right .btn:not(#presentBtn):not(#exportBtn):not(#helpBtn),
body.present .title-btn,
body.present .save-state,
body.present .live-state,
body.present .rearrange { visibility: hidden; }
body.present .title { pointer-events: none; }
body.present .legend { color: var(--text); }

/* ---------- small screens ---------- */

@media (max-width: 860px) {
  .bar { grid-template-columns: 1fr auto; gap: 8px; padding: 0 8px; }
  .title { width: 12ch; font-size: 17px; }
  .save-state, .live-state { display: none; }
  .btn { padding: 0 8px; font-size: 14px; }
  #rearrangeBtn, #fitBtn { display: none; }
  .work { grid-template-columns: 1fr; grid-template-rows: 1fr minmax(240px, 46%); }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .legend { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- editor: link back home ---------- */

.home-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--navy);
  text-decoration: none;
  font: 700 16px/1 var(--font-head);
  padding: 6px 12px 6px 6px;
  margin-right: 6px;
  border-right: 1px solid var(--line);
  white-space: nowrap;
}
.home-link:hover { color: var(--blue); }
body.present .home-link { visibility: hidden; }

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

body.home { overflow: auto; background: var(--white); }

.bar.home-bar { grid-template-columns: 1fr auto; }

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 700 19px/1.2 var(--font-head);
  color: var(--navy);
  padding: 3px 6px;
}

.mark { width: 20px; height: 20px; flex: none; }
.mark path { stroke: var(--navy); stroke-width: 1.8; fill: none; }
.mark circle { fill: var(--pin); }

.home-main {
  max-width: 1360px;
  margin: 0 auto;
  padding: 26px 32px 80px;
}

.home-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.home-head[hidden] { display: none; }
.home-count { margin: 0; color: var(--muted); font-size: 14px; min-height: 1.5em; }
.home-head .search { width: min(360px, 100%); }

/* account control in the bar */
.account { display: flex; align-items: center; gap: 12px; margin-right: 10px; }
.account:empty { display: none; }
.account-email {
  font-size: 13.5px; color: var(--muted);
  max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- login page: the signed-out front door while the cloud is on ---------- */

.login-view {
  min-height: calc(100vh - var(--bar-h));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px 80px;
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: -11px -11px;
}
.login-view[hidden] { display: none; }

.login-card {
  width: min(400px, 100%);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 34, 56, .1), 0 2px 8px rgba(0, 34, 56, .06);
  padding: 36px 32px 32px;
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-bottom: 6px;
}
.login-mark { width: 26px; height: 26px; }
.login-word { font: 700 23px/1 var(--font-head); color: var(--navy); }
.login-tagline { text-align: center; color: var(--muted); font-size: 14.5px; margin: 0 0 28px; }

.login-form .field { margin-top: 14px; }
.login-form .field:first-child { margin-top: 0; }

.login-message { margin: 14px 0 0; font-size: 13.5px; color: var(--muted); }
.login-message.error { color: var(--danger); }

.login-actions { display: flex; gap: 8px; margin-top: 20px; }
.login-actions .btn { flex: 1; }
.login-actions .btn:not(.primary) { border: 1px solid var(--line); }

.login-or {
  display: flex; align-items: center; gap: 10px;
  margin: 24px 0 16px;
  color: var(--muted); font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
}
.login-or::before, .login-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.login-providers { display: flex; gap: 10px; }
.login-provider {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px;
  border: 1px solid var(--line);
}
.login-provider:hover { background: var(--sky); }
.login-provider svg { flex: none; }

@media (max-width: 420px) {
  .login-view { padding: 24px 12px 60px; }
  .login-card { padding: 28px 20px 24px; border-radius: 8px; }
  .login-actions { flex-direction: column; }
  .login-providers { flex-direction: column; }
}

/* groups of projects: this computer, then each cloud org */
.group-head { display: flex; align-items: baseline; gap: 18px; margin: 6px 0 18px; }
.group-label {
  font: 700 12.5px/1.2 var(--font-ui);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.group-note { margin: -6px 0 40px; color: var(--muted); font-size: 14px; }
.group-note .link-btn { padding: 0; }

.project { margin-bottom: 44px; }
.project-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.project-name { font: 700 22px/1.2 var(--font-head); color: var(--navy); margin: 0; }
.project-meta { font-size: 13.5px; color: var(--muted); flex: 1; }
.project-actions { display: flex; gap: 18px; align-self: center; }
.project-head .name-edit { font-size: 22px; width: auto; min-width: 280px; margin: 0; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 30px 24px;
}

.tile { position: relative; }

.tile-link {
  display: block;
  color: inherit;
  text-decoration: none;
  outline: none;
}

.tile .thumb {
  aspect-ratio: 4 / 3;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
  transition: border-color .15s;
}
.tile .thumb svg { display: block; width: 100%; height: 100%; }
.tile-link:hover .thumb, .tile-link:focus-visible .thumb { border-color: var(--navy); }

.tile .name {
  font: 700 17px/1.25 var(--font-head);
  color: var(--navy);
  margin: 12px 0 3px;
  padding-right: 34px;
}
.tile .meta { font-size: 13px; color: var(--muted); line-height: 1.45; }

.tile .name-edit {
  display: block;
  width: 100%;
  margin: 8px 0 3px;
  font: 700 17px/1.25 var(--font-head);
  color: var(--navy);
  border: 1px solid var(--blue);
  border-radius: 2px;
  padding: 3px 6px;
  outline: none;
  box-shadow: 0 0 0 3px var(--sky);
}

.tile .more {
  position: absolute;
  right: 0;
  bottom: 22px;
  width: 28px; height: 28px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--navy);
  display: grid; place-items: center;
  opacity: 0;
  transition: opacity .15s;
}
.tile .more svg { fill: currentColor; }
.tile:hover .more, .tile:focus-within .more, .tile .more[aria-expanded="true"] { opacity: 1; }
.tile .more:hover, .tile .more[aria-expanded="true"] { background: var(--sky); border-color: var(--line); }

.home-empty {
  width: min(560px, 86%);
  margin: 12vh auto 0;
  text-align: center;
  color: var(--text);
}
.home-empty h1 {
  font: 700 32px/1.1 var(--font-head);
  color: var(--navy);
  margin: 0 0 14px;
}
.home-empty p { margin: 0 0 12px; font-size: 18px; line-height: 1.6; }
.home-empty-actions {
  display: flex; align-items: center; justify-content: center; gap: 18px;
  margin-top: 24px;
}
.home-empty .link-btn { font-size: 16px; }

@media (max-width: 860px) {
  .bar.home-bar { grid-template-columns: 1fr auto; }
  .home-main { padding: 18px 16px 60px; }
  .home-head { flex-direction: column; align-items: stretch; }
  .home-head .search { width: 100%; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 22px 16px; }
  .tile .more { opacity: 1; }
  .home-link { padding-right: 6px; margin-right: 2px; }
  .manager-main { grid-template-columns: 1fr; grid-template-rows: 40% 1fr; }
  .manager-list { border-right: 0; border-bottom: 1px solid var(--line); }
}
