/* ── Карточка человека (боковая панель) ─────────────────── */
.panel {
  flex: none;
  width: 0;
  overflow: hidden;
  border-left: 1px solid transparent;
  background: var(--card);
  transition: width .4s var(--ease), border-color .4s;
  z-index: 4;
}
.panel.is-open { width: var(--panel-w); border-color: var(--line); }

.panel__scroll { width: var(--panel-w); height: 100%; overflow-y: auto; padding: 20px 32px 48px; }

.panel__bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 -12px 8px; }
.panel__bar-title { font-size: 13px; color: var(--ink-3); }

.person-hero { display: flex; flex-direction: column; align-items: center; text-align: center; }
.person-hero .portrait { width: 168px; height: 206px; padding: 5px; border-width: 2px; }
.person-hero.is-late .portrait img { filter: grayscale(1); }
.person-hero__kin { margin-top: 18px; font: italic 600 20px/1 var(--font-display); color: var(--clay); }
.person-hero__name { margin-top: 20px; font: 500 44px/1 var(--font-display); letter-spacing: -.01em; }
.person-hero__kin + .person-hero__name { margin-top: 8px; }
.person-hero__maiden { margin-top: 8px; font: italic 500 19px/1.2 var(--font-display); color: var(--ink-2); }
.person-hero__dates { margin-top: 14px; font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.person-hero__place { margin-top: 4px; font-size: 14px; color: var(--ink-3); }
.person-hero__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 20px; }
.person-hero__links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 20px; margin-top: 14px; font-size: 13px; }

.section { margin-top: 36px; padding-top: 24px; border-top: 1px solid var(--line); }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section__title { font: 600 24px/1 var(--font-display); }
.section__count { font-size: 13px; color: var(--ink-3); }

.story p { font: 500 20px/1.55 var(--font-display); }
.story p + p { margin-top: .9em; }
.story p:first-child::first-letter {
  float: left;
  margin: 6px 10px 0 0;
  font: 600 64px/.74 var(--font-display);
  color: var(--clay);
}

.empty {
  padding: 22px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  text-align: center;
  font-size: 14px;
  color: var(--ink-2);
}
.empty .btn { margin-top: 14px; }

/* Воспоминания: короткие записи от разных родных */
.memories { display: grid; gap: 10px; }
.memories + .memory-form { margin-top: 16px; }
.memory { padding: 16px 18px 12px; border-radius: var(--r-md); background: var(--moss-wash); }
.memory__prompt { margin-bottom: 6px; font-size: 12px; color: var(--ink-3); }
.memory__text { font: 500 19px/1.45 var(--font-display); white-space: pre-line; overflow-wrap: anywhere; }
.memory__meta { display: flex; align-items: center; gap: 12px; margin-top: 10px; font-size: 12px; color: var(--ink-3); }
.memory__meta > span { margin-right: auto; }
.heart {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-size: 12px;
  color: var(--ink-3);
  transition: transform .15s var(--ease), color .15s, border-color .15s;
}
.heart:hover { transform: scale(1.08); color: var(--clay); }
.heart.is-on { border-color: var(--clay); color: var(--clay); }
.heart b { font-weight: 600; }

.memory-form { display: grid; gap: 10px; }
.memory-form textarea { min-height: 92px; }
.memory-form__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gallery__item { position: relative; aspect-ratio: 1; overflow: hidden; border-radius: var(--r-sm); background: var(--paper-2); }
.gallery__item img { width: 100%; height: 100%; object-fit: cover; }
.gallery__tag {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(30, 38, 34, .72);
  color: #fff;
  font-size: 10px;
  letter-spacing: .04em;
}
.gallery__remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: rgba(30, 38, 34, .72);
  color: #fff;
  line-height: 1;
}
.gallery__add {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 4px;
  aspect-ratio: 1;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.gallery__add:hover { border-color: var(--moss); background: var(--moss-wash); }
.gallery__add.is-busy { opacity: .6; pointer-events: none; }
.gallery__add span { padding: 0 6px; text-align: center; }
.gallery__add b { font: 500 28px/1 var(--font-display); color: var(--moss); }
.gallery__add input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.kin { display: grid; gap: 14px; }
.kin__row { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: start; }
.kin__label { padding-top: 9px; font-size: 13px; color: var(--ink-3); }
.kin__list { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.kin__chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px 0 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  font-size: 14px;
  white-space: nowrap;
}
.kin__chip:hover { border-color: var(--moss); background: var(--moss-wash); }
.kin__chip .portrait { width: 24px; height: 29px; padding: 1px; border-width: 1px; }
.kin__add { height: 38px; padding: 0 14px; border: 1px dashed var(--line-strong); border-radius: 999px; background: none; font-size: 13px; color: var(--moss); }
.kin__add:hover { border-color: var(--moss); background: var(--moss-wash); }

.panel__foot { margin-top: 32px; font-size: 12px; color: var(--ink-3); text-align: center; }

/* Форма */
.form__title { font: 500 36px/1.05 var(--font-display); }
.form__sub { margin-top: 6px; font-size: 14px; color: var(--ink-2); }
.form { display: grid; gap: 18px; margin-top: 24px; }
.form__pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 6px; align-content: start; }
.field__label { font-size: 13px; font-weight: 500; }
.field__hint { font-size: 12px; color: var(--ink-3); }
.field.is-invalid .input { border-color: var(--danger); }
.field.is-invalid .field__hint { color: var(--danger); }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: var(--r-sm); background: var(--paper-2); }
.segmented button { height: 36px; border: 0; border-radius: 6px; background: none; font-size: 14px; color: var(--ink-2); }
.segmented button.is-active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(40, 30, 10, .14); }

.form__actions {
  position: sticky;
  bottom: -48px;
  display: flex;
  gap: 8px;
  margin: 8px -32px -48px;
  padding: 16px 32px 20px;
  border-top: 1px solid var(--line);
  background: var(--card);
}
.form__actions .btn--primary { flex: 1; }

/* ── Истории ────────────────────────────────────────────── */
.view--stories { overflow-y: auto; }
.stories { width: min(760px, 100%); margin: 0 auto; padding: 56px 24px 96px; }
.stories__title { margin-top: 12px; font: 500 clamp(44px, 6vw, 72px)/1 var(--font-display); letter-spacing: -.01em; }
.stories__lead { max-width: 560px; margin-top: 16px; font-size: 17px; color: var(--ink-2); }

.story-card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 28px;
  width: 100%;
  margin-top: 40px;
  padding: 40px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  text-align: left;
}
.story-card .portrait { width: 96px; height: 118px; }
.story-card__name { font: 600 30px/1.05 var(--font-display); }
.story-card__meta { margin-top: 6px; font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.story-card__text { margin-top: 14px; font: 500 20px/1.55 var(--font-display); color: var(--ink-2); }
.story-card__more { display: inline-block; margin-top: 14px; font-size: 14px; font-weight: 500; color: var(--moss); }
.story-card:hover .story-card__more { text-decoration: underline; text-underline-offset: 4px; }

.waiting { margin-top: 64px; padding: 28px; border-radius: var(--r-lg); background: var(--moss-wash); }
.waiting__title { font: 600 26px/1.1 var(--font-display); }
.waiting__lead { margin-top: 6px; font-size: 14px; color: var(--ink-2); }
.waiting .kin__list { margin-top: 18px; }
.waiting .kin__chip { background: var(--card); }

@media (max-width: 760px) {
  .panel { position: absolute; inset: 0; z-index: 7; width: 100%; transform: translateY(100%); transition: transform .4s var(--ease); border: 0; }
  .panel.is-open { width: 100%; transform: none; }
  .panel__scroll { width: 100%; padding: 12px 20px 40px; }
  .form__actions { bottom: -40px; margin: 8px -20px -40px; padding-inline: 20px; }
  .story-card { grid-template-columns: 64px 1fr; gap: 18px; }
  .story-card .portrait { width: 64px; height: 78px; }
}
