* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: #1e1f24;
  color: #e8e8ea;
}
.hidden { display: none !important; }
.panel {
  max-width: 420px;
  margin: 60px auto;
  padding: 24px;
  background: #2a2c33;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.row { display: flex; gap: 10px; align-items: center; }
input, textarea, select, button {
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #444;
  background: #1e1f24;
  color: #e8e8ea;
  font-size: 14px;
}
button { cursor: pointer; background: #3d6fe0; border: none; color: #fff; }
button:disabled { background: #555; cursor: default; }
button.danger { background: #c0392b; }
.error { color: #ff6b6b; }
.hint { color: #9aa; font-size: 12px; }
.role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check { font-size: 13px; color: #9aa; display: flex; gap: 6px; align-items: center; }
.check input { width: auto; }

#tree-list { list-style: none; padding: 0; margin: 0; }
#tree-list li {
  padding: 10px;
  margin-top: 8px;
  background: #1e1f24;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
}
#tree-list li:hover { background: #33353d; }
.share-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #9aa; }
.share-toggle input[type="checkbox"] { width: auto; }
.share-link {
  padding: 4px 8px;
  font-size: 12px;
  max-width: 220px;
  cursor: copy;
}

/* --- Редактор --- */
html, body { height: 100%; }
#editor-view { display: flex; flex-direction: column; height: 100vh; }
.toolbar { padding: 10px 16px; background: #2a2c33; }
.toolbar h2 { margin: 0; font-size: 18px; }
.status { margin-left: auto; font-size: 13px; color: #9aa; }
.status.online { color: #6fdc8c; }
.editor-layout { position: relative; flex: 1; min-height: 0; }
.canvas-wrap { position: absolute; inset: 0; overflow: hidden; }
#gl-canvas { display: block; width: 100%; height: 100%; cursor: grab; }
#gl-canvas.panning { cursor: grabbing; }
#labels { position: absolute; top: 0; left: 0; pointer-events: none; transform-origin: 0 0; }

/* Плавающая пилюля: перетаскивается, липнет к краям (позиция задаётся из JS) */
.pill {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  background: #b9bec8;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  z-index: 10;
  touch-action: none;
  user-select: none;
  cursor: grab;
  transition: left 0.15s ease, top 0.15s ease;
}
.pill.dragging { transition: none; cursor: grabbing; }
.pill.vertical { flex-direction: column; }
.pill button {
  border-radius: 999px;
  cursor: pointer;
  background: #fff;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pill button.active { box-shadow: inset 0 0 0 2px #3d6fe0; }

/* Модальное окно */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.modal-body { margin: 0; width: 420px; max-height: 90vh; overflow-y: auto; position: relative; }
/* Крестик закрытия — правый верхний угол окна */
.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  background: #1e1f24;
  color: #9aa;
  font-size: 13px;
  line-height: 1;
}
/* Лоадер (шаг 3 импорта) */
.loader {
  width: 42px;
  height: 42px;
  margin: 16px auto;
  border: 4px solid #444;
  border-top-color: #3d6fe0;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#import-status { text-align: center; color: #cfd3dd; }
#import-url { width: 100%; }
#pdf-ready {
  display: block;
  text-align: center;
  padding: 10px;
  border-radius: 6px;
  background: #2e7d46;
  color: #fff;
  text-decoration: none;
}
/* Лоадер загрузки древа поверх канваса */
.tree-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.75);
  z-index: 15;
  color: #1e1f24;
}

/* Карточка поверх canvas (сам прямоугольник рисует WebGL, белый полупрозрачный) */
.card-label {
  position: absolute;
  width: 180px;
  height: 270px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 10px 0;
  font-size: 16px;
  color: #1e1f24;
  pointer-events: none;
}
/* Капсула роли — над карточкой, цвет в цвет обводки (задаётся из JS) */
.card-role-capsule {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 16px;
  border-radius: 999px;
  background: #bfc7d9;
  color: #fff;
  font-size: 13px;
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
/* Фото-заглушка; обводка — в цвет обводки карточки (задаётся из JS) */
.card-photo {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  border: 2px solid #bfc7d9;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 8px 0 12px;
  overflow: hidden;
  position: relative;
}
.card-photo svg { width: 54px; height: 54px; fill: rgba(0, 0, 0, 0.35); }
.card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  position: absolute;
  inset: 0;
  transition: opacity 0.2s ease;
}
/* Лоадер поверх заглушки, пока грузится фото */
.photo-loading {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 3px solid rgba(0, 0, 0, 0.15);
  border-top-color: #4d99f2;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  z-index: 1;
}
.card-line { line-height: 1.3; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-surname { font-weight: 600; }
.card-dates { font-size: 13px; color: #4a4d55; margin-top: 3px; }
/* Редактирование — внутри карточки, правый верхний угол; рамка — в цвет обводки (задаётся из JS) */
.card-edit {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  background: #fff;
  color: #000;
  border: 2px solid #bfc7d9;
  border-radius: 9px;
  pointer-events: auto;
}
/* Создание родственника — по центру внизу карточки; рамка — в цвет обводки (задаётся из JS) */
.plus {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 26px;
  line-height: 1;
  border-radius: 50%;
  background: #fff;
  color: #000;
  border: 2px solid #bfc7d9;
  pointer-events: auto;
}
