* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: -apple-system, "Segoe UI", "DejaVu Sans", Arial, sans-serif;
  background: #faf7f2;
  color: #2b2a28;
  height: 100%;
}
body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.topbar {
  background: #fff;
  border-bottom: 1px solid #ece7dd;
  padding: 14px 26px 0;
  flex-shrink: 0;
}
.topbar .row1 { display: flex; align-items: baseline; justify-content: space-between; }
.eyebrow { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: #a39d90; margin-bottom: 4px; }
h1 { font-size: 19px; font-weight: 700; color: #2b2a28; }
.format-toggle { display: flex; gap: 2px; background: #f1ede4; border-radius: 9px; padding: 3px; margin-bottom: 10px; }
.format-toggle button {
  border: none; background: transparent; padding: 6px 14px; font-size: 12px; font-weight: 600;
  color: #8a8478; border-radius: 7px; cursor: pointer;
}
.format-toggle button.active { background: #fff; color: #2b2a28; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.tabs { display: flex; gap: 4px; margin-top: 8px; }
.tab { padding: 9px 18px; font-size: 13px; font-weight: 600; color: #b0aa9c; border-bottom: 2.5px solid transparent; cursor: pointer; background: none; border-left:none; border-right:none; border-top:none; }
.tab.active { color: #3d6fb4; border-bottom-color: #3d6fb4; }

.legend {
  background: #fff; padding: 9px 26px; display: flex; gap: 20px;
  border-bottom: 1px solid #ece7dd; font-size: 11.5px; color: #8a8478; flex-shrink: 0;
}
.legend span { display: flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.layout { display: flex; flex: 1; min-height: 0; position: relative; }
.stage-wrap { flex: 1; overflow: auto; position: relative; background: #faf7f2; }
#stage { position: relative; }

svg.lines { position: absolute; top: 0; left: 0; pointer-events: none; }

.zone { position: absolute; border-radius: 18px; }
.col-head { position: absolute; top: 8px; font-size: 12px; font-weight: 700; text-align: center; pointer-events: none; }
.col-head .sub { font-weight: 400; font-size: 10px; color: #8a8478; display: block; margin-top: 1px; }

.node {
  position: absolute; background: #fff; border: 1px solid #eee9de;
  border-radius: 12px; padding: 10px 13px; width: 190px;
  box-shadow: 0 2px 6px rgba(60,50,30,.06); cursor: pointer;
}
.node:hover { border-color: #d8d2c4; }
.badge {
  position: absolute; top: -9px; left: -9px; width: 20px; height: 20px; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.node .t { font-size: 12px; font-weight: 700; color: #2b2a28; margin-bottom: 3px; }
.node .d {
  font-size: 10.5px; line-height: 1.35; color: #8a8478;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.node.leaf-prog { color: #fff; }
.node.leaf-prog .t, .node.leaf-prog .d { color: #fff; }
.node.selected { box-shadow: 0 0 0 3px rgba(61,111,180,.18); border-color: #3d6fb4; }

.node .edit-form input, .node .edit-form textarea {
  width: 100%; border: 1px solid #d8d2c4; border-radius: 6px; padding: 5px 7px;
  font-family: inherit; font-size: 11px; margin-bottom: 5px; resize: none;
}
.node .edit-form textarea { height: 46px; }
.node .edit-actions { display: flex; gap: 6px; justify-content: flex-end; }
.node .edit-actions button { font-size: 10px; border: none; border-radius: 5px; padding: 4px 9px; font-weight: 600; cursor: pointer; }
.btn-save { background: #3d6fb4; color: #fff; }
.btn-cancel { background: #eee9de; color: #6b6558; }
.edit-hint { font-size: 9px; color: #c2bdb1; margin-top: 4px; }

.pill {
  position: absolute; display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px dashed #d8d2c4; border-radius: 10px; padding: 8px 12px;
  font-size: 11px; color: #8a8478; font-weight: 600; width: 190px; cursor: pointer;
}
.pill:hover { border-color: #b0aa9c; }
.toggle {
  width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 1.5px solid #d8d2c4;
  font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; cursor: pointer; color: #8a8478;
}
.toggle:hover { border-color: #3d6fb4; color: #3d6fb4; }
.node-toggle { position: absolute; top: -9px; right: -9px; }

.notes-tab {
  position: absolute; top: 50%; right: 0; transform: translateY(-50%);
  background: #fff; border: 1px solid #ece7dd; border-right: none; border-radius: 10px 0 0 10px;
  padding: 14px 8px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; color: #8a8478; writing-mode: vertical-rl;
  box-shadow: -2px 0 6px rgba(60,50,30,.05); cursor: pointer; z-index: 3; font-family: inherit;
}
.notes-tab:hover { color: #3d6fb4; border-color: #d8d2c4; }
.notes-tab[hidden] { display: none; }

.notes-col {
  width: 320px; background: #fff; border-left: 1px solid #ece7dd;
  display: flex; flex-direction: column; flex-shrink: 0;
}
.notes-col[hidden] { display: none; }
.notes-col .nc-head { padding: 14px 16px 10px; border-bottom: 1px solid #f1ede4; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.nc-close {
  font-size: 11px; color: #a39d90; font-weight: 600; border: 1px solid #e4dfd2; border-radius: 6px;
  padding: 4px 9px; background: #fff; cursor: pointer; flex-shrink: 0; font-family: inherit;
}
.nc-close:hover { color: #c94f6d; border-color: #c94f6d; }
.nc-eyebrow { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: #a39d90; }
.nc-title { font-size: 15px; font-weight: 700; color: #2b2a28; margin-top: 2px; min-height: 20px; }
.nc-list { flex: 1; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.nc-empty { font-size: 12px; color: #c2bdb1; text-align: center; margin-top: 30px; }
.note { background: #f7f4ee; border-radius: 10px; padding: 10px 12px; position: relative; }
.note .meta { font-size: 10px; color: #a39d90; margin-bottom: 4px; display: flex; justify-content: space-between; }
.note .txt { font-size: 11.5px; color: #3a382f; line-height: 1.4; white-space: pre-wrap; }
.note .del { position: absolute; top: 8px; right: 9px; font-size: 10px; color: #c2bdb1; cursor: pointer; border: none; background: none; }
.note .del:hover { color: #c94f6d; }
.nc-input { padding: 12px 16px 16px; border-top: 1px solid #f1ede4; }
.nc-input textarea {
  width: 100%; height: 52px; border-radius: 9px; border: 1px solid #e4dfd2; padding: 8px 10px;
  font-size: 11.5px; font-family: inherit; color: #3a382f; resize: none;
}
.nc-input button {
  margin-top: 7px; background: #3d6fb4; color: #fff; border: none; border-radius: 8px;
  padding: 7px 14px; font-size: 11.5px; font-weight: 700; float: right; cursor: pointer;
}
.nc-input button:disabled { opacity: .5; cursor: default; }
.nc-placeholder { padding: 30px 18px; font-size: 12px; color: #c2bdb1; text-align: center; }
