.family-chat-page {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
  padding: 0 !important;
  max-width: none !important;
  margin: 0 !important;
  overflow: hidden;
  background: #b8d4f0;
}

.family-chat-top {
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(91, 159, 230, 0.12);
}

.family-chat-gate {
  padding: 20px 16px;
  max-width: 420px;
  margin: 0 auto;
}

.family-chat-gate__hint {
  color: var(--text-muted, #64748b);
  margin: 0 0 16px;
  line-height: 1.45;
}

.family-chat-names {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.family-chat-name-btn {
  padding: 10px 16px;
  border: 2px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.family-chat-name-btn.is-active {
  border-color: var(--color-primary, #5b9fe6);
  background: #eff6ff;
  color: var(--color-primary, #5b9fe6);
}

.family-chat-gate__label {
  display: block;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted, #64748b);
}

.family-chat-gate__label input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  font-size: 16px;
}

.family-chat-gate__error {
  color: #dc2626;
  font-size: 14px;
  margin: 0 0 12px;
}

.family-chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px;
  background: transparent;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.family-chat-head__back,
.family-chat-head__action {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #f1f5f9;
  color: #26364a;
  font-size: 22px;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.family-chat-head__action {
  width: 38px;
  height: 38px;
  font-size: 18px;
}

.family-chat-head__avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #60a5fa 0%, #2563eb 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.25);
  flex-shrink: 0;
}

.family-chat-head__main {
  flex: 1;
  min-width: 0;
}

.family-chat-head__title {
  margin: 0;
  color: var(--color-text, #2b2134);
  font-size: 19px;
  font-weight: 900;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.family-chat-head__status {
  margin: 4px 0 0;
  font-size: 12px;
  color: #22a06b;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.family-chat-rooms {
  display: flex;
  gap: 8px;
  padding: 9px 12px 10px;
  overflow-x: auto;
  background: transparent;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  scrollbar-width: none;
}

.family-chat-rooms::-webkit-scrollbar {
  display: none;
}

.family-chat-room {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.94);
  color: #475569;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
  cursor: pointer;
}

.family-chat-room.is-active {
  background: #5b9fe6;
  color: #fff;
  box-shadow: 0 8px 18px rgba(91, 159, 230, 0.28);
}

.family-chat-room--empty:not(.is-active) {
  opacity: 0.55;
  border-style: dashed;
}

.family-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  background-color: #b8d4f0;
  background-image: url('/assets/chat/shiba-pattern.svg');
  background-size: 320px 320px;
  background-repeat: repeat;
}

.family-chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.45;
  word-break: break-word;
}

.family-chat-msg--mine {
  align-self: flex-end;
  background: linear-gradient(145deg, #6eb3f7 0%, #4a9ae8 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(74, 154, 232, 0.28);
}

.family-chat-msg--theirs {
  align-self: flex-start;
  background: #fff;
  border: none;
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

.family-chat-msg__author {
  display: block;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--color-primary, #5b9fe6);
}

.family-chat-msg__img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(280px, 78vw);
  min-width: 140px;
  max-height: 360px;
  object-fit: contain;
  border-radius: 12px;
  margin-bottom: 2px;
  cursor: pointer;
  pointer-events: auto;
  -webkit-user-drag: none;
  touch-action: manipulation;
}

.family-chat-page .family-chat-msg__img,
.family-chat-lightbox__img {
  pointer-events: auto;
  -webkit-touch-callout: none;
  user-select: none;
}

.family-chat-msg__photo {
  -webkit-touch-callout: none;
  user-select: none;
}

.family-chat-msg--image {
  padding: 6px;
  max-width: min(300px, 88vw);
}

.family-chat-msg--video {
  padding: 6px;
  max-width: min(320px, 92vw);
}

.family-chat-msg__video-btn {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 14px;
  overflow: hidden;
  background: #0f172a;
  cursor: pointer;
  touch-action: manipulation;
}

.family-chat-msg__vid-preview {
  display: block;
  width: 100%;
  max-height: min(220px, 42vh);
  object-fit: cover;
  opacity: 0.35;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.family-chat-msg__video-btn.is-ready .family-chat-msg__vid-preview {
  opacity: 1;
}

.family-chat-msg__video-play {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.family-chat-msg__video-play::after {
  content: '';
  position: absolute;
  left: 54%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-style: solid;
  border-width: 10px 0 10px 16px;
  border-color: transparent transparent transparent #1e293b;
}

.family-chat-msg__video-badge {
  position: absolute;
  left: 10px;
  bottom: 28px;
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.family-chat-msg__video-hint {
  display: block;
  width: 100%;
  padding: 8px 10px;
  background: rgba(15, 23, 42, 0.88);
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.family-chat-msg__video-btn.is-error .family-chat-msg__video-hint {
  background: #7f1d1d;
  color: #fff;
}

.family-chat-uploadbar {
  margin: 8px 12px 0;
  padding: 10px 12px 12px;
  border-radius: 18px;
  background: linear-gradient(135deg, #1e3a5f 0%, #1e293b 100%);
  color: #fff;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.22);
}

.family-chat-uploadbar[hidden] {
  display: none !important;
}

.family-chat-uploadbar__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.family-chat-uploadbar__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #38bdf8;
  animation: fc-pulse 1s infinite;
  flex-shrink: 0;
}

.family-chat-uploadbar__text {
  flex: 1;
  font-size: 14px;
  font-weight: 800;
}

.family-chat-uploadbar__pct {
  font-size: 13px;
  font-weight: 800;
  opacity: 0.9;
  font-variant-numeric: tabular-nums;
}

.family-chat-uploadbar__track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
}

.family-chat-uploadbar__fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #38bdf8, #5b9fe6);
  transition: width 0.15s ease;
}

.family-chat-lightbox--video .family-chat-lightbox__stage--video {
  flex-direction: column;
  gap: 12px;
}

.family-chat-lightbox__video {
  width: 100%;
  max-width: min(960px, 100%);
  max-height: min(78vh, 720px);
  border-radius: 12px;
  background: #000;
}

.family-chat-lightbox__video-wait {
  margin: 0;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}

.family-chat-lightbox--video.is-video-ready .family-chat-lightbox__video-wait {
  display: none;
}

.family-chat-msg__photo {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
}

.family-chat-msg__photo--error .family-chat-msg__img-fallback {
  display: block;
  width: 100%;
  min-height: 120px;
  padding: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.5);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.08);
  color: inherit;
  font-size: 14px;
  cursor: pointer;
  pointer-events: auto;
}

.family-chat-msg--theirs .family-chat-msg__photo--error .family-chat-msg__img-fallback {
  border-color: #cbd5e1;
  background: #f8fafc;
  color: #334155;
}

.family-chat-msg__audio {
  display: none;
}

/* —— Голосовые (стиль MAX) —— */
.family-chat-msg--voice {
  padding: 8px 10px 6px;
  min-width: 200px;
}

.family-chat-msg--voice.family-chat-msg--theirs {
  background: #fff;
}

.family-chat-msg--voice.family-chat-msg--mine {
  background: linear-gradient(145deg, #6eb3f7 0%, #4a9ae8 100%);
}

.family-chat-voice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.family-chat-voice audio {
  display: none;
}

.family-chat-voice__play {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: #4a9ae8;
  box-shadow: 0 4px 12px rgba(74, 154, 232, 0.35);
  -webkit-tap-highlight-color: transparent;
}

.family-chat-msg--mine .family-chat-voice__play {
  background: rgba(255, 255, 255, 0.95);
}

.family-chat-voice__icon {
  display: block;
  width: 0;
  height: 0;
  border-style: solid;
}

.family-chat-voice__icon--play {
  margin-left: 3px;
  border-width: 8px 0 8px 14px;
  border-color: transparent transparent transparent #fff;
}

.family-chat-msg--mine .family-chat-voice__icon--play {
  border-left-color: #4a9ae8;
}

.family-chat-voice__play.is-playing .family-chat-voice__icon--play {
  width: 14px;
  height: 16px;
  margin-left: 0;
  border: none;
  background: linear-gradient(to right, #fff 0 35%, transparent 35% 65%, #fff 65% 100%);
  mask: none;
}

.family-chat-msg--mine .family-chat-voice__play.is-playing .family-chat-voice__icon--play {
  background: linear-gradient(to right, #4a9ae8 0 35%, transparent 35% 65%, #4a9ae8 65% 100%);
}

.family-chat-voice__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.family-chat-voice__wave {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 28px;
  min-width: 0;
}

.family-chat-voice__wave span {
  flex: 1;
  min-width: 2px;
  max-width: 4px;
  border-radius: 2px;
  background: rgba(74, 154, 232, 0.45);
  transition: opacity 0.12s;
}

.family-chat-msg--mine .family-chat-voice__wave span {
  background: rgba(255, 255, 255, 0.55);
}

.family-chat-voice__dur {
  font-size: 12px;
  font-weight: 700;
  color: #4a9ae8;
  line-height: 1;
}

.family-chat-msg--mine .family-chat-voice__dur {
  color: rgba(255, 255, 255, 0.92);
}

.family-chat-msg--voice .family-chat-msg__time {
  margin-top: 2px;
  font-size: 11px;
}

/* —— Стикеры —— */
.family-chat-msg--sticker {
  background: transparent !important;
  box-shadow: none !important;
  padding: 4px;
}

.family-chat-msg__sticker {
  width: 140px;
  height: 140px;
  display: block;
  object-fit: contain;
  border-radius: 8px;
  pointer-events: none;
  user-select: none;
}

.family-chat-msg--sticker .family-chat-msg__author {
  margin-bottom: 2px;
}

.family-chat-msg__voice-dur {
  display: none;
}

.family-chat-msg__time {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  opacity: 0.7;
  text-align: right;
}

.family-chat-msg--system {
  align-self: center;
  background: transparent;
  color: var(--text-muted, #64748b);
  font-size: 12px;
  text-align: center;
  max-width: 100%;
}

.family-chat-msg__body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.family-chat-msg--deleted {
  opacity: 0.65;
}

.family-chat-msg--deleted .family-chat-msg__body {
  font-style: italic;
}

.family-chat-msg__reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.family-chat-reaction {
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 14px;
  line-height: 1.3;
  cursor: pointer;
}

.family-chat-reaction.is-mine {
  border-color: #93c5fd;
  background: #eff6ff;
}

.family-chat-actions {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

.family-chat-actions__reacts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  background: #fff;
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 8px;
}

.family-chat-actions__emoji {
  font-size: 28px;
  line-height: 1;
  border: none;
  background: transparent;
  padding: 4px 6px;
  border-radius: 8px;
  cursor: pointer;
}

.family-chat-actions__emoji:active {
  background: #f1f5f9;
}

.family-chat-actions__delete,
.family-chat-actions__cancel,
.family-chat-actions__open,
.family-chat-actions__print {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 16px;
  margin-bottom: 8px;
  cursor: pointer;
}

.family-chat-actions__title {
  text-align: center;
  color: #fff;
  font-weight: 700;
  margin: 0 0 10px;
}

.family-chat-actions__open,
.family-chat-actions__print {
  background: #fff;
  color: #334155;
}

.family-chat-actions__delete {
  background: #fee2e2;
  color: #b91c1c;
}

.family-chat-actions__cancel {
  background: #fff;
  color: #334155;
}

.family-chat-bottom {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  position: relative;
  z-index: 12;
}

.family-chat-recordbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 12px 0;
  padding: 10px 12px;
  border-radius: 18px;
  background: #1e293b;
  color: #fff;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.22);
}

.family-chat-recordbar[hidden] {
  display: none !important;
}

.family-chat-recordbar__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  animation: fc-pulse 1s infinite;
  flex-shrink: 0;
}

.family-chat-recordbar__text {
  flex: 1;
  font-size: 14px;
  font-weight: 800;
}

.family-chat-recordbar__send,
.family-chat-recordbar__cancel {
  border: 0;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.family-chat-recordbar__send {
  background: #5b9fe6;
  color: #fff;
}

.family-chat-recordbar__cancel {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

@keyframes fc-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.family-chat-compose {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px;
  background: transparent;
}

.family-chat-compose__field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  background: #f1f5f9;
  border-radius: 24px;
  padding: 4px 6px 4px 14px;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.family-chat-compose__field input[type="text"] {
  flex: 1;
  padding: 10px 0;
  border: 0;
  background: transparent;
  font-size: 16px;
  min-width: 0;
  outline: none;
}

.family-chat-compose__inline {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.family-chat-compose__mini {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  display: grid;
  place-items: center;
  -webkit-tap-highlight-color: transparent;
}

.family-chat-tool {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #e8f2fc;
  font-size: 22px;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(91, 159, 230, 0.15);
  -webkit-tap-highlight-color: transparent;
}

.family-chat-tool--emoji {
  background: #fff8e7;
  font-size: 24px;
}

.family-chat-tool--sticker {
  background: #fff4e6;
  font-size: 24px;
}

.family-chat-tool--mic {
  background: #f1f5f9;
  font-size: 22px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.family-chat-tool--record:active,
.family-chat-tool--recording {
  background: #fecaca;
  animation: fc-pulse 1s infinite;
}

.family-chat-compose input[type="text"] {
  /* legacy — см. .family-chat-compose__field input */
}

.family-chat-compose__inline {
  display: none;
}

.family-chat-send {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  background: linear-gradient(165deg, #93c9ff 0%, #5b9fe6 42%, #3b82d6 100%);
  box-shadow:
    0 4px 0 #2563b8,
    0 8px 20px rgba(59, 130, 214, 0.45),
    inset 0 2px 0 rgba(255, 255, 255, 0.45),
    inset 0 -2px 0 rgba(0, 0, 0, 0.08);
  transition: transform 0.1s, box-shadow 0.1s;
}

.family-chat-send:active {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 #2563b8,
    0 4px 12px rgba(59, 130, 214, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

.family-chat-send__icon {
  display: block;
  width: 14px;
  height: 14px;
  margin: 0 auto;
  border-top: 3px solid #fff;
  border-right: 3px solid #fff;
  transform: rotate(45deg) translate(-1px, 1px);
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.15));
}

/* —— Панель эмодзи / стикеров —— */
.family-chat-picker {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.12);
  max-height: min(52vh, 380px);
  display: flex;
  flex-direction: column;
}

.family-chat-picker[hidden] {
  display: none !important;
}

.family-chat-picker__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 6px;
  gap: 8px;
}

.family-chat-picker__modes {
  display: flex;
  gap: 6px;
}

.family-chat-picker__mode {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 800;
  background: #f1f5f9;
  color: #64748b;
  cursor: pointer;
}

.family-chat-picker__mode.is-active {
  background: #dbeafe;
  color: #2563eb;
}

.family-chat-picker__close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: #f1f5f9;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

.family-chat-picker__cats {
  display: flex;
  gap: 4px;
  padding: 0 10px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.family-chat-picker__cats.hidden {
  display: none;
}

.family-chat-picker__tab {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: #f8fafc;
  font-size: 22px;
  cursor: pointer;
  flex-shrink: 0;
}

.family-chat-picker__tab.is-active {
  background: #dbeafe;
}

.family-chat-picker__body {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
  min-height: 0;
}

.family-chat-picker__body.hidden {
  display: none;
}

.family-chat-picker__panel {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}

.family-chat-picker__panel.hidden {
  display: none;
}

.family-chat-picker__emoji {
  border: 0;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  padding: 6px 2px;
  border-radius: 10px;
  cursor: pointer;
}

.family-chat-picker__emoji:active {
  background: #e8f2fc;
  transform: scale(1.12);
}

.family-chat-picker__body--stickers {
  padding: 4px 10px 12px;
}

.family-chat-stickers__grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 4px 10px 16px;
  overflow-y: auto;
}

.family-chat-stickers__item {
  border: 0;
  background: transparent;
  border-radius: 12px;
  padding: 4px;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s;
}

.family-chat-stickers__item:active {
  transform: scale(0.92);
  background: #e8f2fc;
}

.family-chat-stickers__item img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
}

.family-chat-msg__voice-fallback {
  display: block;
  font-size: 14px;
  line-height: 1.4;
}

.admin-btn--primary {
  width: 100%;
  margin-top: 8px;
}

.category-btn--chat {
  background: linear-gradient(145deg, #5eead4 0%, #14b8a6 100%) !important;
  box-shadow: 0 8px 20px rgba(20, 184, 166, 0.35);
}

/* Старый SW мог отдавать ChatPage с overlay — убиваем навсегда */
.family-chat-recording {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Standalone: my-voice.uz/family — только чат для бабушек */
.family-chat-page--standalone {
  min-height: 100dvh;
  background: linear-gradient(180deg, #e8f4ff 0%, #f5f8fc 40%);
}

.family-chat-gate--standalone {
  max-width: 420px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  text-align: center;
}

.family-chat-gate__title {
  font-size: 1.75rem;
  margin: 0 0 0.5rem;
}

.family-chat-names--big {
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.family-chat-name-btn--big {
  min-height: 3.5rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.family-chat-pin-display {
  font-size: 2rem;
  letter-spacing: 0.35em;
  margin: 1rem 0;
  font-variant-numeric: tabular-nums;
}

.family-chat-pinpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  max-width: 280px;
  margin: 0 auto;
}

.family-chat-pinpad__key {
  min-height: 3.25rem;
  border: none;
  border-radius: 12px;
  background: #fff;
  font-size: 1.35rem;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.family-chat-pinpad__key--wide {
  grid-column: span 1;
}

.family-chat-pinpad__key:active {
  transform: scale(0.97);
  background: #e3f0ff;
}

.family-chat-gate__back {
  margin-top: 1.5rem;
  border: none;
  background: transparent;
  font-size: 1rem;
  color: #2563eb;
}

/* Просмотр фото + печать */
.family-chat-lightbox {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  touch-action: none;
  overscroll-behavior: none;
}

.family-chat-lightbox__toolbar {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  flex-shrink: 0;
  justify-content: flex-end;
  position: relative;
  z-index: 2;
  touch-action: manipulation;
}

.family-chat-lightbox__btn {
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
}

.family-chat-lightbox__btn--save,
.family-chat-lightbox__btn--print {
  font-size: 28px;
  line-height: 1;
  padding: 8px 14px;
  touch-action: manipulation;
}

.family-chat-lightbox__btn--print.family-chat-lightbox__btn--wait {
  opacity: 0.45;
}

.family-chat-lightbox__btn--delete {
  font-size: 28px;
  line-height: 1;
  padding: 8px 14px;
  touch-action: manipulation;
  background: rgba(220, 38, 38, 0.35);
}

.family-chat-lightbox__btn--close {
  flex: 0 0 44px;
  font-size: 18px;
  padding: 8px 0;
}

.family-chat-lightbox__stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 8px 12px 16px;
  overflow: hidden;
  touch-action: none;
}

.family-chat-lightbox__zoom {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.family-chat-lightbox__img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  pointer-events: auto;
  transform-origin: center center;
  will-change: transform;
  -webkit-touch-callout: none;
  user-select: none;
}

.family-chat-lightbox__error {
  color: #fff;
  text-align: center;
  padding: 24px;
}

.family-chat-lightbox__hint {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  margin: 0;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.88);
  color: #fff;
  font-size: 14px;
  z-index: 5001;
  pointer-events: none;
}

.family-chat-print-root {
  display: none;
}

@media print {
  body.is-printing-family-photo > *:not(.family-chat-print-root) {
    display: none !important;
  }

  body.is-printing-family-photo .family-chat-print-root {
    display: block !important;
    position: fixed;
    inset: 0;
    margin: 0;
    padding: 0;
  }

  body.is-printing-family-photo .family-chat-print-root img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    object-fit: contain;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
