/* =========================================================
   ГЕНЕАЛОГИЧЕСКОЕ ДРЕВО СЕМЬИ СУЧИЛИНЫХ
   ========================================================= */

:root {
  color-scheme: light;

  --page-bg: #e9e7e1;
  --paper: #f8f6f0;
  --paper-light: #fffefb;
  --paper-dark: #eeeae0;

  --text: #272723;
  --text-soft: #66645d;
  --text-muted: #8a877e;

  --border: #c8c3b6;
  --border-dark: #a9a394;

  --primary: #315ea8;
  --primary-hover: #284f8e;
  --primary-soft: #e7eef9;

  --danger: #a93a35;
  --danger-hover: #8f302c;

  --suchilin: #315ea8;
  --shcherb: #43845a;
  --metelkin: #b56b2a;
  --ovsyannikov: #7a5798;
  --unknown: #797873;

  --toolbar-height: 78px;
  --stage-width: 3600px;
  --stage-height: 3800px;

  --radius-small: 7px;
  --radius: 11px;
  --radius-large: 18px;

  --shadow-small:
    0 2px 5px rgba(31, 29, 24, 0.07),
    0 8px 20px rgba(31, 29, 24, 0.05);

  --shadow:
    0 8px 24px rgba(31, 29, 24, 0.12),
    0 2px 6px rgba(31, 29, 24, 0.06);

  --shadow-large:
    0 22px 65px rgba(22, 20, 17, 0.22),
    0 6px 20px rgba(22, 20, 17, 0.12);

  --font-ui:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;

  --font-tree:
    Georgia,
    "Times New Roman",
    Times,
    serif;
}

/* =========================================================
   БАЗОВЫЙ СБРОС
   ========================================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  width: 100%;
  height: 100%;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--page-bg);
  -webkit-text-size-adjust: 100%;
}

body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--page-bg);
}

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

button {
  color: inherit;
}

button:not(:disabled) {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select,
textarea {
  min-width: 0;
}

textarea {
  resize: vertical;
}

[hidden] {
  display: none !important;
}

::selection {
  color: #fff;
  background: var(--primary);
}

:focus-visible {
  outline: 3px solid rgba(49, 94, 168, 0.3);
  outline-offset: 2px;
}

/* =========================================================
   ДОСТУПНОСТЬ
   ========================================================= */

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.noscript-message {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 30px;
  font-size: 18px;
  text-align: center;
  background: var(--paper);
}

/* =========================================================
   ОБЩИЕ КНОПКИ
   ========================================================= */

.button,
.icon-button {
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--paper-light);
  box-shadow: 0 1px 2px rgba(20, 20, 18, 0.04);
  transition:
    border-color 120ms ease,
    background-color 120ms ease,
    color 120ms ease,
    box-shadow 120ms ease,
    transform 80ms ease;
}

.button {
  min-height: 38px;
  padding: 8px 14px;
  border-radius: var(--radius-small);
  font-weight: 650;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-small);
  font-size: 21px;
  line-height: 1;
}

.button:not(:disabled):hover,
.icon-button:not(:disabled):hover {
  border-color: var(--border-dark);
  background: #fff;
  box-shadow: 0 3px 8px rgba(20, 20, 18, 0.08);
}

.button:not(:disabled):active,
.icon-button:not(:disabled):active {
  transform: translateY(1px);
  box-shadow: none;
}

.button--primary {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
}

.button--primary:not(:disabled):hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.button--danger {
  border-color: var(--danger);
  color: #fff;
  background: var(--danger);
}

.button--danger:not(:disabled):hover {
  border-color: var(--danger-hover);
  background: var(--danger-hover);
}

.button--wide {
  width: 100%;
}

/* =========================================================
   ПОЛЯ ФОРМ
   ========================================================= */

.field {
  display: grid;
  gap: 7px;
}

.field__label {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}

.field__input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  color: var(--text);
  background: #fff;
  box-shadow: inset 0 1px 2px rgba(20, 20, 18, 0.04);
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease;
}

.field__input:hover {
  border-color: var(--border-dark);
}

.field__input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow:
    0 0 0 3px rgba(49, 94, 168, 0.14),
    inset 0 1px 2px rgba(20, 20, 18, 0.04);
}

.field__input::placeholder {
  color: #aaa69c;
}

.field__textarea {
  min-height: 210px;
  line-height: 1.5;
}

.field__hint {
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-muted);
}

.form-error {
  padding: 9px 11px;
  margin: 0;
  border: 1px solid rgba(169, 58, 53, 0.25);
  border-radius: var(--radius-small);
  color: var(--danger);
  background: rgba(169, 58, 53, 0.07);
  font-size: 12px;
  line-height: 1.45;
}

/* =========================================================
   ЭКРАНЫ ЗАГРУЗКИ И ВХОДА
   ========================================================= */

.screen {
  position: fixed;
  inset: 0;
  z-index: 5000;
  padding: 24px;
  background:
    radial-gradient(
      circle at 50% 18%,
      rgba(255, 255, 255, 0.86),
      transparent 42%
    ),
    var(--page-bg);
}

.screen--center {
  display: grid;
  place-items: center;
}

.loading-card,
.login-card {
  width: min(100%, 410px);
  border: 1px solid var(--border);
  border-radius: var(--radius-large);
  background: rgba(255, 254, 251, 0.96);
  box-shadow: var(--shadow-large);
}

.loading-card {
  min-height: 150px;
  padding: 30px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  text-align: center;
}

.loading-card p {
  margin: 0;
  color: var(--text-soft);
  font-size: 14px;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(49, 94, 168, 0.18);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spinner-rotate 700ms linear infinite;
}

@keyframes spinner-rotate {
  to {
    transform: rotate(360deg);
  }
}

.login-card {
  padding: 32px;
}

.login-card__mark {
  width: 58px;
  height: 58px;
  margin: 0 auto 19px;
  display: grid;
  place-items: center;
  border: 2px solid var(--primary);
  border-radius: 50%;
  color: var(--primary);
  background: var(--primary-soft);
  font: 700 28px/1 var(--font-tree);
}

.login-card h1 {
  margin: 0;
  font: 700 25px/1.25 var(--font-tree);
  text-align: center;
}

.login-card__description {
  margin: 10px 0 24px;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

.login-card .field {
  margin-bottom: 17px;
}

/* =========================================================
   ОСНОВНОЕ ПРИЛОЖЕНИЕ
   ========================================================= */

.app {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: var(--toolbar-height) minmax(0, 1fr);
  overflow: hidden;
}

/* =========================================================
   ВЕРХНЯЯ ПАНЕЛЬ
   ========================================================= */

.toolbar {
  position: relative;
  z-index: 100;
  min-width: 0;
  height: var(--toolbar-height);
  padding: 10px 15px;
  display: grid;
  grid-template-columns:
    minmax(270px, 1fr)
    minmax(220px, 360px)
    auto;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(248, 246, 240, 0.97);
  box-shadow: 0 3px 14px rgba(30, 28, 24, 0.08);
  backdrop-filter: blur(12px);
}

.toolbar__title {
  min-width: 0;
}

.toolbar__title h1 {
  margin: 0;
  overflow: hidden;
  font: 700 20px/1.2 var(--font-tree);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar__meta {
  margin-top: 4px;
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--text-muted);
  font-size: 11px;
}

.save-status {
  color: var(--text-soft);
  transition: color 150ms ease;
}

.save-status[data-state="dirty"] {
  color: #9a6728;
}

.save-status[data-state="saving"] {
  color: var(--primary);
}

.save-status[data-state="saved"] {
  color: var(--shcherb);
}

.save-status[data-state="error"] {
  color: var(--danger);
}

.toolbar__search {
  min-width: 0;
}

.search-field {
  position: relative;
  display: block;
}

.search-field input {
  width: 100%;
  height: 40px;
  padding: 8px 40px 8px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  color: var(--text);
  background: #fff;
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease;
}

.search-field input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(49, 94, 168, 0.13);
}

.search-field__clear {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.search-field__clear:hover {
  background: var(--paper-dark);
  box-shadow: none;
}

.toolbar__controls {
  display: flex;
  gap: 7px;
  align-items: center;
}

/* =========================================================
   ОБЛАСТЬ ДЕРЕВА
   ========================================================= */

.viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  background:
    radial-gradient(
      circle at center,
      rgba(255, 255, 255, 0.48),
      transparent 62%
    ),
    var(--page-bg);
  touch-action: none;
  user-select: none;
}

.viewport.is-panning {
  cursor: grabbing;
}

.stage {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--stage-width);
  height: var(--stage-height);
  overflow: hidden;
  transform-origin: 0 0;
  border: 1px solid #bbb5a8;
  background:
    linear-gradient(
      to right,
      transparent calc(16.666% - 1px),
      rgba(82, 78, 69, 0.1) calc(16.666% - 1px),
      rgba(82, 78, 69, 0.1) 16.666%,
      transparent 16.666%
    ),
    linear-gradient(
      to right,
      transparent calc(33.333% - 1px),
      rgba(82, 78, 69, 0.1) calc(33.333% - 1px),
      rgba(82, 78, 69, 0.1) 33.333%,
      transparent 33.333%
    ),
    linear-gradient(
      to right,
      transparent calc(50% - 1px),
      rgba(82, 78, 69, 0.1) calc(50% - 1px),
      rgba(82, 78, 69, 0.1) 50%,
      transparent 50%
    ),
    linear-gradient(
      to right,
      transparent calc(66.666% - 1px),
      rgba(82, 78, 69, 0.1) calc(66.666% - 1px),
      rgba(82, 78, 69, 0.1) 66.666%,
      transparent 66.666%
    ),
    linear-gradient(
      to right,
      transparent calc(83.333% - 1px),
      rgba(82, 78, 69, 0.1) calc(83.333% - 1px),
      rgba(82, 78, 69, 0.1) 83.333%,
      transparent 83.333%
    ),
    repeating-linear-gradient(
      0deg,
      rgba(84, 79, 68, 0.018) 0,
      rgba(84, 79, 68, 0.018) 1px,
      transparent 1px,
      transparent 28px
    ),
    var(--paper);
  box-shadow: var(--shadow-large);
}

.stage__header {
  position: absolute;
  top: 34px;
  left: 0;
  z-index: 10;
  width: 100%;
  text-align: center;
  pointer-events: none;
}

.stage__header h2 {
  margin: 0;
  font: 700 32px/1.2 var(--font-tree);
}

.stage__header p {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

/* =========================================================
   ЗАГОЛОВКИ ПОКОЛЕНИЙ
   ========================================================= */

.generation-headers {
  position: absolute;
  inset: 115px 0 auto;
  z-index: 8;
  height: 70px;
  pointer-events: none;
}

.generation-header {
  position: absolute;
  top: 0;
  width: 380px;
  padding: 10px 12px;
  border-top: 2px solid var(--border-dark);
  border-bottom: 1px solid var(--border);
  color: var(--text-soft);
  background: rgba(248, 246, 240, 0.82);
  font: 700 15px/1.2 var(--font-ui);
  text-align: center;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

/* =========================================================
   ПОДПИСИ ВЕТВЕЙ
   ========================================================= */

.branch-labels {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
}

.branch-label {
  position: absolute;
  left: 24px;
  width: 320px;
  padding: 11px 13px 11px 18px;
  border-left: 5px solid var(--branch-color, var(--unknown));
  border-radius: 0 var(--radius-small) var(--radius-small) 0;
  color: var(--branch-color, var(--unknown));
  background: rgba(255, 254, 251, 0.82);
  font: 700 18px/1.25 var(--font-tree);
  box-shadow: 0 2px 7px rgba(30, 28, 24, 0.05);
}

/* =========================================================
   СЛОЙ СОЕДИНИТЕЛЬНЫХ ЛИНИЙ
   ========================================================= */

.connections {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.connections path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  transition:
    opacity 150ms ease,
    stroke-width 150ms ease;
}

.family-line {
  stroke-width: 2.2;
  opacity: 0.85;
}

.spouse-line {
  stroke: #756f64;
  stroke-width: 2;
  opacity: 0.92;
}

.sibling-line {
  stroke: #8b8579;
  stroke-width: 1.6;
  stroke-dasharray: 4 4;
  opacity: 0.72;
}

.connections path.is-dimmed {
  opacity: 0.07;
}

.connections path.is-highlighted {
  stroke-width: 4;
  opacity: 1;
}

/* =========================================================
   СЛОЙ КАРТОЧЕК
   ========================================================= */

.nodes-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.person-card {
  --branch-color: var(--unknown);

  position: absolute;
  width: 310px;
  min-height: 82px;
  padding: 15px 66px 14px 16px;
  border: 2px solid var(--branch-color);
  border-radius: var(--radius);
  color: var(--text);
  background: rgba(255, 254, 251, 0.97);
  box-shadow: var(--shadow-small);
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  transition:
    box-shadow 130ms ease,
    opacity 130ms ease,
    filter 130ms ease,
    transform 130ms ease;
}

.person-card:hover {
  box-shadow: var(--shadow);
}

.person-card:active,
.person-card.is-dragging {
  cursor: grabbing;
}

.person-card.is-dragging {
  z-index: 100;
  box-shadow:
    0 18px 42px rgba(25, 23, 20, 0.22),
    0 5px 14px rgba(25, 23, 20, 0.12);
  transform: scale(1.015);
}

.person-card.is-unknown {
  border-style: dashed;
  background: rgba(250, 248, 242, 0.98);
}

.person-card.is-highlighted {
  z-index: 20;
  box-shadow:
    0 0 0 7px color-mix(
      in srgb,
      var(--branch-color) 15%,
      transparent
    ),
    var(--shadow);
  transform: scale(1.025);
}

.person-card.is-dimmed {
  opacity: 0.14;
  filter: grayscale(0.75);
}

.person-card__content {
  min-width: 0;
  pointer-events: none;
}

.person-card__name {
  overflow-wrap: anywhere;
  font: 700 16px/1.22 var(--font-tree);
}

.person-card__date {
  margin-top: 6px;
  color: #4d4a44;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.3;
}

.person-card__date:empty,
.person-card__meta:empty {
  display: none;
}

.person-card__meta {
  margin-top: 5px;
  overflow-wrap: anywhere;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.35;
}

.person-card__actions {
  position: absolute;
  top: 12px;
  right: 11px;
  display: flex;
  gap: 5px;
}

.person-card__info,
.person-card__edit {
  width: 27px;
  height: 27px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.92);
  font: 700 13px/1 var(--font-ui);
  box-shadow: 0 1px 3px rgba(25, 23, 20, 0.06);
  transition:
    color 120ms ease,
    border-color 120ms ease,
    background-color 120ms ease;
}

.person-card__info:hover,
.person-card__edit:hover {
  border-color: var(--branch-color);
  color: var(--branch-color);
  background: #fff;
}

.person-card__status {
  position: absolute;
  top: -10px;
  right: 12px;
  min-width: 25px;
  height: 19px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border: 1px solid var(--branch-color);
  border-radius: 99px;
  color: var(--branch-color);
  background: var(--paper-light);
  font-size: 9px;
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0.02em;
}

.person-card__status:empty {
  display: none;
}

/* Цветовые классы ветвей */

.person-card[data-branch="suchilin"] {
  --branch-color: var(--suchilin);
}

.person-card[data-branch="shcherb"] {
  --branch-color: var(--shcherb);
}

.person-card[data-branch="metelkin"] {
  --branch-color: var(--metelkin);
}

.person-card[data-branch="ovsyannikov"] {
  --branch-color: var(--ovsyannikov);
}

/* =========================================================
   ЛЕГЕНДА И ПОДСКАЗКА
   ========================================================= */

.legend {
  position: absolute;
  left: 38px;
  bottom: 30px;
  z-index: 8;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 11px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-soft);
  background: rgba(255, 254, 251, 0.9);
  box-shadow: var(--shadow-small);
  font-size: 11px;
  pointer-events: none;
}

.legend span {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.legend b {
  color: var(--text);
}

.viewport-tip {
  position: absolute;
  right: 13px;
  bottom: 12px;
  z-index: 50;
  max-width: calc(100% - 26px);
  padding: 7px 10px;
  border-radius: var(--radius-small);
  color: #fff;
  background: rgba(38, 37, 34, 0.78);
  font-size: 10px;
  line-height: 1.35;
  pointer-events: none;
  backdrop-filter: blur(5px);
}

/* =========================================================
   БОКОВАЯ ПАНЕЛЬ ИНФОРМАЦИИ
   ========================================================= */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  border: 0;
  background: rgba(23, 22, 20, 0.32);
  backdrop-filter: blur(2px);
}

.details-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 950;
  width: min(440px, 94vw);
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-left: 1px solid var(--border);
  background: var(--paper-light);
  box-shadow: -14px 0 48px rgba(24, 22, 19, 0.18);
  transform: translateX(102%);
  visibility: hidden;
  transition:
    transform 190ms ease,
    visibility 190ms ease;
}

.details-drawer.is-open {
  transform: translateX(0);
  visibility: visible;
}

.details-drawer__header {
  padding: 23px 22px 18px;
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--paper);
}

.details-drawer__eyebrow,
.editor__eyebrow {
  margin-bottom: 5px;
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.details-drawer__header h2,
.editor__header h2 {
  margin: 0;
  font: 700 24px/1.2 var(--font-tree);
}

.details-drawer__subtitle {
  margin: 7px 0 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.details-drawer__body {
  min-height: 0;
  padding: 20px 22px 32px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.details-drawer__body h3 {
  margin: 25px 0 10px;
  font: 700 17px/1.3 var(--font-tree);
}

.details-drawer__body h3:first-child {
  margin-top: 0;
}

.details-drawer__body p {
  margin: 0 0 11px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.55;
}

.details-drawer__body ul {
  margin: 0;
  padding-left: 20px;
}

.details-drawer__body li {
  margin-bottom: 9px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.5;
}

.details-empty {
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  background: var(--paper);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.details-drawer__footer {
  padding: 15px 22px;
  border-top: 1px solid var(--border);
  background: var(--paper);
}

/* =========================================================
   МОДАЛЬНЫЕ ОКНА
   ========================================================= */

.modal {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(25, 23, 20, 0.52);
  backdrop-filter: blur(3px);
}

.editor,
.confirm-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 660px);
  max-height: calc(100vh - 48px);
  border: 1px solid var(--border);
  border-radius: var(--radius-large);
  background: var(--paper-light);
  box-shadow: var(--shadow-large);
}

.editor {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.editor__header {
  padding: 20px 22px 17px;
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--paper);
  border-radius: var(--radius-large) var(--radius-large) 0 0;
}

.editor__body {
  min-height: 0;
  padding: 20px 22px 28px;
  display: grid;
  gap: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.editor__footer {
  padding: 14px 22px;
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  background: var(--paper);
  border-radius: 0 0 var(--radius-large) var(--radius-large);
}

.photo-placeholder {
  padding: 15px;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  border: 1px dashed var(--border-dark);
  border-radius: var(--radius);
  background: var(--paper);
}

.photo-placeholder h3 {
  margin: 0 0 5px;
  font: 700 16px/1.3 var(--font-tree);
}

.photo-placeholder p {
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.4;
}

/* =========================================================
   ПОДТВЕРЖДЕНИЕ
   ========================================================= */

.confirm-dialog {
  max-width: 430px;
  padding: 24px;
}

.confirm-dialog h2 {
  margin: 0;
  font: 700 23px/1.25 var(--font-tree);
}

.confirm-dialog p {
  margin: 12px 0 22px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.5;
}

.confirm-dialog__actions {
  display: flex;
  gap: 9px;
  justify-content: flex-end;
}

/* =========================================================
   УВЕДОМЛЕНИЯ
   ========================================================= */

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 3000;
  width: min(390px, calc(100vw - 36px));
  display: grid;
  gap: 9px;
  pointer-events: none;
}

.toast {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: rgba(255, 254, 251, 0.97);
  box-shadow: var(--shadow);
  font-size: 12px;
  line-height: 1.45;
  pointer-events: auto;
  animation: toast-show 180ms ease-out;
}

.toast[data-type="success"] {
  border-left: 4px solid var(--shcherb);
}

.toast[data-type="error"] {
  border-left: 4px solid var(--danger);
}

.toast[data-type="info"] {
  border-left: 4px solid var(--primary);
}

.toast.is-hiding {
  animation: toast-hide 160ms ease-in forwards;
}

@keyframes toast-show {
  from {
    opacity: 0;
    transform: translateY(9px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-hide {
  to {
    opacity: 0;
    transform: translateY(7px);
  }
}

/* =========================================================
   ПРОКРУТКА
   ========================================================= */

.details-drawer__body,
.editor__body {
  scrollbar-width: thin;
  scrollbar-color: var(--border-dark) transparent;
}

.details-drawer__body::-webkit-scrollbar,
.editor__body::-webkit-scrollbar {
  width: 9px;
}

.details-drawer__body::-webkit-scrollbar-track,
.editor__body::-webkit-scrollbar-track {
  background: transparent;
}

.details-drawer__body::-webkit-scrollbar-thumb,
.editor__body::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 99px;
  background: var(--border-dark);
  background-clip: padding-box;
}

/* =========================================================
   АДАПТИВНОСТЬ
   ========================================================= */

@media (max-width: 1320px) {
  :root {
    --toolbar-height: 126px;
  }

  .toolbar {
    grid-template-columns: minmax(260px, 1fr) minmax(220px, 340px);
    grid-template-rows: auto auto;
  }

  .toolbar__controls {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}

@media (max-width: 850px) {
  :root {
    --toolbar-height: 176px;
  }

  .toolbar {
    padding: 10px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    gap: 8px;
  }

  .toolbar__title h1 {
    font-size: 17px;
  }

  .toolbar__search {
    width: 100%;
  }

  .toolbar__controls {
    grid-column: auto;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .toolbar__controls::-webkit-scrollbar {
    display: none;
  }

  .details-drawer {
    width: 100%;
  }

  .modal {
    padding: 10px;
  }

  .editor,
  .confirm-dialog {
    max-height: calc(100vh - 20px);
  }

  .editor__header,
  .editor__body,
  .editor__footer {
    padding-left: 15px;
    padding-right: 15px;
  }

  .photo-placeholder {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .login-card {
    padding: 24px 19px;
  }

  .toolbar__controls .button {
    min-height: 35px;
    padding-inline: 11px;
    font-size: 11px;
  }

  .toolbar__controls .icon-button {
    width: 35px;
    height: 35px;
  }

  .details-drawer__header,
  .details-drawer__body,
  .details-drawer__footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .editor__footer,
  .confirm-dialog__actions {
    flex-direction: column-reverse;
  }

  .editor__footer .button,
  .confirm-dialog__actions .button {
    width: 100%;
  }

  .viewport-tip {
    display: none;
  }
}

/* =========================================================
   ПЕЧАТЬ
   ========================================================= */

@media print {
  html,
  body {
    width: auto;
    height: auto;
    overflow: visible;
    background: #fff;
  }

  .toolbar,
  .viewport-tip,
  .details-drawer,
  .drawer-backdrop,
  .modal,
  .toast-region {
    display: none !important;
  }

  .app {
    display: block;
    height: auto;
  }

  .viewport {
    overflow: visible;
    background: #fff;
  }

  .stage {
    position: relative;
    width: var(--stage-width);
    height: var(--stage-height);
    transform: none !important;
    box-shadow: none;
  }

  .person-card {
    box-shadow: none;
  }
}

/* =========================================================
   УМЕНЬШЕНИЕ АНИМАЦИЙ
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
