:root {
  --bg: #eef3fb;
  --sidebar: #ffffff;
  --panel: #ffffff;
  --panel-2: #f7f9fd;
  --text: #182033;
  --muted: #728096;
  --line: rgba(24, 32, 51, .1);
  --primary: #2f80ed;
  --primary-2: #62a7ff;
  --accent: #24b47e;
  --mine: #dff0ff;
  --other: #ffffff;
  --shadow: 0 18px 50px rgba(31, 54, 86, .12);
}

body[data-theme="light-red"] {
  --bg: #fbf1f2;
  --sidebar: #fffafa;
  --panel: #ffffff;
  --panel-2: #fff5f6;
  --text: #2a1518;
  --muted: #84666b;
  --line: rgba(116, 28, 38, .13);
  --primary: #c8324a;
  --primary-2: #ff7b8f;
  --accent: #d9912b;
  --mine: #ffe3e8;
  --other: #ffffff;
}

body[data-theme="dark-blue"] {
  --bg: #0d1726;
  --sidebar: #111d2f;
  --panel: #142238;
  --panel-2: #0f1b2d;
  --text: #eef6ff;
  --muted: #91a4bd;
  --line: rgba(238, 246, 255, .12);
  --primary: #4c9cff;
  --primary-2: #7ec3ff;
  --accent: #2dd4bf;
  --mine: #1e4972;
  --other: #1b2d46;
  --shadow: 0 22px 60px rgba(0, 0, 0, .32);
}

body[data-theme="dark-red"] {
  --bg: #241114;
  --sidebar: #2b171b;
  --panel: #321d22;
  --panel-2: #261418;
  --text: #fff3f4;
  --muted: #c9a2a8;
  --line: rgba(255, 243, 244, .13);
  --primary: #ff5d73;
  --primary-2: #ff9cab;
  --accent: #f0b75b;
  --mine: #65303b;
  --other: #42242a;
  --shadow: 0 22px 60px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }
[hidden], .is-hidden { display: none !important; }

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 18% 0%, rgba(47, 128, 237, .18), transparent 30rem),
    radial-gradient(circle at 100% 0%, rgba(255, 93, 115, .14), transparent 28rem),
    var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.tg-app {
  width: min(1480px, calc(100% - 24px));
  height: calc(100dvh - 24px);
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin: 12px auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.chat-list {
  position: fixed;
  z-index: 70;
  top: 12px;
  bottom: 12px;
  left: max(12px, calc((100vw - 1480px) / 2 + 12px));
  width: min(348px, calc(100vw - 28px));
  display: flex;
  min-height: 0;
  max-height: calc(100dvh - 24px);
  flex-direction: column;
  gap: 14px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px;
  background: var(--sidebar);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .24);
  transform: translateX(calc(-100% - 42px));
  transition: transform .22s ease;
}

body.nav-open .chat-list {
  transform: translateX(0);
}

.nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 65;
  background: rgba(0, 0, 0, .34);
  backdrop-filter: blur(3px);
}

.nav-toggle {
  position: fixed;
  z-index: 75;
  top: 24px;
  left: 24px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  color: var(--text);
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(0, 0, 0, .14);
  backdrop-filter: blur(8px);
}

.nav-toggle:hover,
.nav-toggle:focus-visible {
  border-color: var(--primary);
  color: var(--primary);
}

.brand-row,
.user-mini,
.chat-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-title-wrap {
  min-width: 0;
}

.chat-title-wrap > div {
  min-width: 0;
}

.brand-mark,
.dialog-avatar {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  font-weight: 900;
}

.dialog-avatar img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.avatar-clickable {
  cursor: zoom-in;
}

.avatar-clickable:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 42%, transparent);
  outline-offset: 2px;
}

.brand-row strong,
.user-mini strong {
  display: block;
  font-size: 1rem;
}

.brand-row span,
.user-mini small,
.dialog small,
.chat-head p,
.status {
  color: var(--muted);
}

.main-nav {
  display: grid;
  gap: 4px;
}

.main-nav button,
.head-actions button,
.primary,
.send-button,
.voice-button,
.circle-button,
.cancel-edit,
.download-button,
.attach-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  background: var(--panel);
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease;
}

.main-nav button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  border-color: transparent;
  background: transparent;
  line-height: 1;
}

.main-nav button span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid rgba(76, 156, 255, .55);
  border-radius: 8px;
  color: var(--primary);
  font-size: .85rem;
  line-height: 1;
}

.main-nav button.active,
.primary,
.send-button,
.download-button {
  border-color: transparent;
  background: var(--primary);
  color: #fff;
}

.main-nav button.active span {
  border-color: rgba(255,255,255,.65);
  color: #fff;
}

.main-nav button:hover,
.head-actions button:hover,
.attach-button:hover,
.voice-button:hover,
.circle-button:hover,
.cancel-edit:hover,
.download-button:hover,
.send-button:hover,
.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, .1);
}

button:disabled,
.download-button:disabled {
  cursor: not-allowed;
  opacity: .55;
  transform: none;
  box-shadow: none;
}

.search-box {
  display: grid;
  gap: 7px;
}

.search-box span {
  color: var(--muted);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.search-box input,
.auth-card input,
.composer textarea,
.feed-composer textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-2);
  color: var(--text);
  outline: none;
}

.search-box input {
  min-height: 42px;
  padding: 0 14px;
}

.search-box input:focus,
.auth-card input:focus,
.composer textarea:focus,
.feed-composer textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(47, 128, 237, .12);
}

.dialogs {
  display: grid;
  gap: 7px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.people-list {
  display: grid;
  gap: 7px;
}

.dialog {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 18px;
  padding: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.dialog:hover,
.dialog.active {
  background: var(--panel-2);
}

.dialog.active {
  box-shadow: inset 3px 0 0 var(--primary);
}

.dialog-main {
  min-width: 0;
  flex: 1 1 auto;
}

.dialog-main strong,
.dialog-main small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-title-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.dialog-title-row strong {
  min-width: 0;
  flex: 1 1 auto;
}

.dialog-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
}

.dialog-preview {
  max-width: 100%;
}

.dialog-preview.is-typing,
.chat-head p.is-typing {
  color: var(--primary);
  font-weight: 800;
}

.dialog-unread {
  display: grid;
  min-width: 22px;
  height: 22px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 999px;
  padding: 0 6px;
  background: var(--primary);
  color: #fff;
  font-size: .75rem;
  font-weight: 900;
  line-height: 1;
}

.family {
  background: linear-gradient(135deg, var(--primary), var(--accent));
}

.user-mini {
  width: 100%;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 12px;
  background: var(--panel-2);
}

.auth-screen,
.dialogs-pane,
.chat-pane,
.profile-pane,
.photos-pane,
.feed-pane {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255,255,255,.08), transparent 16rem),
    var(--panel-2);
}

.auth-screen {
  display: grid;
  align-content: center;
  gap: 28px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: clamp(28px, 5vw, 68px);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--text);
  line-height: 1.05;
}

.auth-hero h1 {
  max-width: 760px;
  font-size: clamp(2.6rem, 6vw, 5.6rem);
}

.auth-hero p {
  max-width: 760px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.7;
}

.auth-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.auth-card,
.theme-panel {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 20px;
  background: var(--panel);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .08);
}

.auth-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
}

.auth-card input {
  min-height: 46px;
  padding: 0 14px;
}

.chat-pane,
.dialogs-pane,
.profile-pane,
.photos-pane,
.feed-pane,
.portal-pane {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.profile-pane,
.dialogs-pane,
.photos-pane,
.feed-pane,
.portal-pane {
  grid-template-rows: auto minmax(0, 1fr);
  padding-bottom: 24px;
}

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

.dialogs-home {
  width: min(760px, 100%);
  min-height: 0;
  margin: 0 auto;
  overflow: auto;
  padding: 18px;
  overscroll-behavior: contain;
}

.dialogs-home-search {
  position: sticky;
  z-index: 2;
  top: 0;
  display: block;
  padding-bottom: 12px;
  background: var(--panel-2);
}

.dialogs-home-search input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0 14px;
  outline: none;
  background: var(--panel);
  color: var(--text);
}

.dialogs-home-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 14%, transparent);
}

.main-dialog-list {
  display: grid;
  gap: 2px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.main-dialog-list .dialog {
  min-height: 70px;
  border-radius: 0;
  padding: 10px 14px;
}

.main-dialog-list .dialog + .dialog {
  border-top: 1px solid var(--line);
}

.main-dialog-list .dialog-avatar {
  width: 50px;
  height: 50px;
}

.chat-back {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  padding: 0;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-size: 1.8rem;
  line-height: 1;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 16px 20px 16px 72px;
  background: rgba(255, 255, 255, .03);
}

.chat-head h1 {
  font-size: 1.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-head p {
  margin: 4px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.notification-toggle {
  width: 40px;
  min-width: 40px;
  padding: 0;
  font-size: 1rem;
}

.notification-toggle.is-enabled {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
}

.notification-toggle.is-blocked {
  opacity: .65;
}

.messages {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 22px clamp(14px, 3vw, 34px);
  background:
    radial-gradient(circle at 10% 20%, rgba(47, 128, 237, .08), transparent 24rem),
    radial-gradient(circle at 90% 70%, rgba(36, 180, 126, .07), transparent 22rem),
    var(--panel-2);
}

.profile-pane {
  overflow: auto;
  overscroll-behavior: contain;
}

.message {
  position: relative;
  width: fit-content;
  max-width: min(68ch, 76%);
  margin: 0 0 10px;
  border: 1px solid var(--line);
  border-radius: 18px 18px 18px 5px;
  padding: 10px 12px 8px;
  background: var(--other);
  box-shadow: 0 8px 20px rgba(0, 0, 0, .06);
}

.message.has-actions {
  padding-right: 42px;
}

.message.mine {
  margin-left: auto;
  border-radius: 18px 18px 5px 18px;
  background: var(--mine);
}

.message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: .78rem;
}

.message-author-wrap {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.message-user-avatar {
  width: 24px;
  height: 24px;
  font-size: .68rem;
}

.message-author {
  color: var(--primary);
  font-weight: 800;
}

.profile-link,
.message-author {
  cursor: pointer;
}

.profile-link:hover,
.message-author:hover {
  text-decoration: underline;
}

.message-body {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.48;
}

.message-time {
  white-space: nowrap;
}

.message-actions {
  position: absolute;
  z-index: 12;
  top: 6px;
  right: 6px;
}

.message-actions-button {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 50%;
  background: color-mix(in srgb, var(--panel) 72%, transparent);
  color: var(--muted);
  cursor: pointer;
  font-size: 1.12rem;
  line-height: 1;
  opacity: .56;
}

.message:hover .message-actions-button,
.message-actions-button:focus,
.message-actions.is-open .message-actions-button {
  opacity: 1;
}

.message.is-highlighted {
  animation: message-highlight 1.4s ease;
}

@keyframes message-highlight {
  0%, 100% { box-shadow: 0 8px 20px rgba(0, 0, 0, .06); }
  35% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 32%, transparent), 0 16px 34px rgba(0, 0, 0, .18); }
}

.message-reply-quote {
  width: 100%;
  display: grid;
  gap: 2px;
  border: 0;
  border-left: 3px solid var(--primary);
  border-radius: 10px;
  margin: 6px 0 8px;
  padding: 7px 9px;
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.message-reply-quote strong,
.message-reply-quote span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-reply-quote strong {
  color: var(--primary);
  font-size: .82rem;
}

.message-reply-quote span {
  color: var(--muted);
  font-size: .8rem;
}

.message-actions-button:hover {
  border-color: var(--line);
  background: var(--panel);
  color: var(--text);
}

.message-actions-menu {
  position: absolute;
  top: 34px;
  right: 0;
  min-width: 164px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 18px 34px rgba(0, 0, 0, .16);
}

.message-actions-menu button {
  display: block;
  width: 100%;
  border: 0;
  padding: 11px 13px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 750;
  text-align: left;
}

.message-actions-menu button:hover {
  background: var(--panel-2);
}

.message-actions-menu .message-delete {
  color: #ef4444;
}

.birthday-announcement {
  position: sticky;
  z-index: 5;
  top: 0;
  display: grid;
  width: min(640px, 100%);
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin: 0 auto 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--line));
  border-radius: 20px;
  padding: 12px;
  background: color-mix(in srgb, var(--panel) 92%, var(--accent));
  box-shadow: 0 16px 34px rgba(0, 0, 0, .12);
}

.birthday-bot {
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--accent);
  color: #fff;
  font-size: .76rem;
  font-weight: 900;
}

.birthday-avatars {
  display: flex;
  align-items: center;
}

.birthday-avatar {
  width: 38px;
  height: 38px;
  margin-left: -8px;
  border: 2px solid var(--panel);
}

.birthday-avatar:first-child {
  margin-left: 0;
}

.birthday-announcement strong {
  display: block;
  color: var(--text);
}

.birthday-announcement p {
  margin: 3px 0 0;
  color: var(--muted);
  line-height: 1.35;
}

.message-photos {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.message-photos img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  object-fit: cover;
}

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.attachment-image,
.attachment-media,
.attachment-audio,
.attachment-document {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.attachment-preview-link {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  overflow: hidden;
  border-radius: inherit;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}

.attachment-with-actions {
  overflow: visible;
  padding-right: 42px;
}

.attachment-image.attachment-with-actions,
.attachment-media.attachment-with-actions,
.circle-message.attachment-with-actions {
  padding-right: 0;
}

.attachment-audio.attachment-with-actions {
  overflow: visible;
  padding-top: 42px;
}

.voice-message.attachment-with-actions {
  padding-right: 44px;
}

.attachment-actions {
  position: absolute;
  z-index: 16;
  top: 6px;
  right: 6px;
}

.attachment-actions-button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  color: var(--muted);
  cursor: pointer;
  font-size: 1.12rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 8px 16px rgba(0, 0, 0, .1);
}

.attachment-actions.is-open .attachment-actions-button,
.attachment-actions-button:hover,
.attachment-actions-button:focus {
  border-color: var(--line);
  background: var(--panel);
  color: var(--text);
}

.attachment-actions-menu {
  position: absolute;
  top: 36px;
  right: 0;
  min-width: 170px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 18px 34px rgba(0, 0, 0, .16);
}

.attachment-actions-menu a,
.attachment-actions-menu button {
  display: block;
  width: 100%;
  border: 0;
  padding: 11px 13px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  text-align: left;
  white-space: nowrap;
}

.attachment-actions-menu a:hover,
.attachment-actions-menu button:hover {
  background: var(--panel-2);
}

.attachment-actions-menu .attachment-delete {
  color: #ef4444;
}

.attachment-image img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.attachment-media {
  grid-column: 1 / -1;
}

.attachment-media video,
.attachment-audio audio {
  display: block;
  width: 100%;
}

.attachment-media video {
  border-radius: inherit;
}

.attachment-audio {
  grid-column: 1 / -1;
  padding: 10px;
}

.attachment-audio.attachment-with-actions {
  padding-top: 42px;
}

.voice-message {
  grid-column: 1 / -1;
  display: grid;
  width: min(340px, 100%);
  grid-template-columns: auto minmax(110px, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--line));
  border-radius: 999px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--primary) 7%, var(--panel));
}

.voice-message.attachment-with-actions {
  padding-right: 44px;
}

.voice-play {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 900;
  line-height: 1;
}

.voice-wave {
  --progress: 0%;
  display: grid;
  grid-template-columns: repeat(18, 1fr);
  gap: 3px;
  align-items: center;
  height: 32px;
  overflow: hidden;
}

.voice-wave span {
  display: block;
  height: var(--h);
  min-height: 5px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--primary) 0 var(--progress),
    color-mix(in srgb, var(--primary) 32%, var(--line)) var(--progress) 100%
  );
}

.voice-duration {
  color: var(--muted);
  font-size: .82rem;
  font-variant-numeric: tabular-nums;
}

.circle-message {
  grid-column: 1 / -1;
  display: inline-grid;
  gap: 7px;
  justify-items: center;
  margin-top: 8px;
}

.circle-video-shell {
  position: relative;
  width: 168px;
  height: 168px;
  overflow: hidden;
  border: 4px solid color-mix(in srgb, var(--primary) 42%, var(--panel));
  border-radius: 50%;
  background: #000;
  box-shadow: 0 12px 26px rgba(0, 0, 0, .18);
}

.circle-video-shell video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}

.circle-play {
  position: absolute;
  inset: 50% auto auto 50%;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .56);
  color: #fff;
  cursor: pointer;
  font-weight: 900;
  transform: translate(-50%, -50%);
}

.circle-message.is-playing .circle-play {
  opacity: .18;
}

.circle-video-shell:hover .circle-play,
.circle-play:focus-visible {
  opacity: 1;
}

.circle-duration {
  color: var(--muted);
  font-size: .82rem;
  font-variant-numeric: tabular-nums;
}

.attachment-document {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  color: var(--text);
  text-decoration: none;
}

.attachment-document.attachment-with-actions {
  overflow: visible;
  padding-right: 46px;
}

.attachment-document strong,
.attachment-document small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-document small {
  color: var(--muted);
}

.attachment-document b {
  color: var(--primary);
  font-size: .82rem;
}

.document-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  color: var(--primary);
  font-size: .72rem;
  font-weight: 900;
}

.composer {
  --composer-button: clamp(34px, 8.5vw, 40px);
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  gap: 5px;
  border-top: 1px solid var(--line);
  padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--panel) 96%, transparent);
}

.composer.is-editing {
  border-top-color: color-mix(in srgb, var(--primary) 42%, var(--line));
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--primary) 20%, transparent);
}

.reply-preview {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-left: 3px solid var(--primary);
  border-radius: 12px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--primary) 10%, var(--panel));
}

.reply-preview span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.reply-preview strong,
.reply-preview small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-preview strong {
  color: var(--primary);
}

.reply-preview small {
  color: var(--muted);
}

.reply-preview button {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 900;
}

.composer-bar {
  display: grid;
  min-width: 0;
  grid-template-columns: var(--composer-button) minmax(0, 1fr) auto;
  gap: 7px;
  align-items: end;
}

.composer textarea {
  height: 40px;
  min-height: var(--composer-button);
  min-width: 0;
  max-height: 96px;
  overflow-y: auto;
  border-radius: 22px;
  padding: 10px 14px;
  resize: none;
  line-height: 1.35;
  scrollbar-width: thin;
}

.composer-actions {
  display: flex;
  flex: 0 0 auto;
  min-width: 0;
  gap: 5px;
  align-items: center;
  justify-content: flex-end;
}

.drop-zone {
  position: absolute;
  z-index: 18;
  inset: 10px;
  display: grid;
  place-items: center;
  gap: 4px;
  border: 1px dashed color-mix(in srgb, var(--primary) 36%, var(--line));
  border-radius: 18px;
  padding: 14px;
  background: color-mix(in srgb, var(--primary) 6%, var(--panel-2));
  color: var(--muted);
  pointer-events: none;
  opacity: 0;
  text-align: center;
  transition: border-color .16s ease, background .16s ease, opacity .16s ease, transform .16s ease;
}

.drop-zone strong {
  color: var(--text);
  font-size: .92rem;
}

.drop-zone span {
  font-size: .8rem;
}

.drop-zone.compact {
  grid-template-columns: auto auto;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
}

.drop-zone.is-dragging {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 14%, var(--panel-2));
  opacity: 1;
  transform: translateY(-1px);
}

.drop-zone.is-disabled {
  cursor: not-allowed;
  opacity: .45;
}

.attach-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.attach-button input {
  display: none;
}

.attach-button.is-disabled {
  cursor: not-allowed;
  opacity: .45;
}

.cancel-edit {
  border-color: color-mix(in srgb, var(--primary) 30%, var(--line));
  background: color-mix(in srgb, var(--primary) 9%, var(--panel));
  color: var(--primary);
}

.icon-composer-button,
.icon-record-button {
  width: var(--composer-button);
  height: var(--composer-button);
  min-width: var(--composer-button);
  min-height: var(--composer-button);
  padding: 0;
  border-radius: 50%;
  font-size: 1.12rem;
}

.icon-composer-button span,
.icon-record-button span {
  display: grid;
  place-items: center;
  line-height: 1;
}

.send-button.icon-composer-button {
  background: var(--primary);
  color: #fff;
}

.composer:not(.has-sendable):not(.is-editing) .send-button {
  display: none;
}

.composer.has-sendable:not(.is-editing) #voice-button,
.composer.has-sendable:not(.is-editing) #circle-button {
  display: none;
}

.composer.is-recording .send-button {
  display: none;
}

.composer.is-editing .attach-button,
.composer.is-editing #voice-button,
.composer.is-editing #circle-button {
  display: none;
}

.composer.is-editing .composer-bar {
  grid-template-columns: minmax(0, 1fr) auto;
}

.voice-button.recording {
  border-color: transparent;
  background: #ef4444;
  color: #fff;
  box-shadow: 0 0 0 5px rgba(239, 68, 68, .14);
}

.circle-button.recording {
  border-color: transparent;
  background: #ef4444;
  color: #fff;
  box-shadow: 0 0 0 5px rgba(239, 68, 68, .14);
}

.pending-attachments {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.pending-chip {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: .78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pending-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pending-remove {
  display: grid;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--muted) 16%, transparent);
  color: var(--muted);
  cursor: pointer;
  font-size: .95rem;
  line-height: 1;
}

.pending-remove:hover {
  background: #ef4444;
  color: #fff;
}

.pending-chip.voice-pending {
  border-color: color-mix(in srgb, var(--primary) 28%, var(--line));
  background: color-mix(in srgb, var(--primary) 9%, var(--panel-2));
  color: var(--text);
}

.pending-chip.circle-pending {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, var(--panel-2));
  color: var(--text);
}

.composer .status {
  grid-column: 1 / -1;
  min-height: 0;
  margin: 0;
  font-size: .78rem;
  line-height: 1.2;
}

.profile-pane .chat-head {
  align-items: flex-start;
}

.theme-panel {
  width: min(880px, calc(100% - 36px));
  align-self: start;
  margin: 24px auto;
}

.profile-settings {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  background: var(--panel-2);
}

.profile-settings label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.profile-settings input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  background: var(--panel);
  color: var(--text);
}

.profile-avatar-picker {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.profile-avatar-preview {
  width: 82px;
  height: 82px;
  font-size: 1.5rem;
}

.feed-scroll {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 18px;
}

.feed-composer,
.feed-card {
  position: relative;
  width: min(820px, 100%);
  margin: 0 auto 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 14px;
  background: var(--panel);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .06);
}

.feed-composer {
  display: grid;
  gap: 10px;
}

.feed-composer textarea {
  min-height: 94px;
  padding: 12px 14px;
  resize: vertical;
}

.feed-settings {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.feed-type-option,
.feed-pin-toggle {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.feed-type-option input,
.feed-pin-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.feed-type-option:has(input:checked),
.feed-pin-toggle:has(input:checked) {
  border-color: transparent;
  background: color-mix(in srgb, var(--primary) 14%, var(--panel));
  color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 9%, transparent);
}

.feed-composer .drop-zone,
.feed-composer .pending-attachments {
  width: 100%;
}

.feed-edit-attachments {
  display: grid;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
  background: color-mix(in srgb, var(--panel-2) 74%, transparent);
}

.feed-edit-attachments[hidden] {
  display: none;
}

.feed-edit-attachments-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
}

.feed-edit-attachment-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 8px;
}

.feed-edit-attachment {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 7px;
  background: var(--panel);
  cursor: grab;
}

.feed-edit-attachment.is-drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 12%, transparent);
}

.feed-edit-attachment-preview {
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  overflow: hidden;
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 900;
}

.feed-edit-attachment-preview img,
.feed-edit-attachment-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.feed-edit-attachment-meta {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.feed-edit-attachment-name {
  overflow: hidden;
  color: var(--text);
  font-size: .84rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-edit-attachment-size {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
}

.feed-edit-attachment-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.feed-edit-attachment-tools button {
  display: grid;
  min-width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 8px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 900;
}

.feed-edit-attachment-tools button:hover {
  border-color: transparent;
  background: color-mix(in srgb, var(--primary) 14%, var(--panel-2));
  color: var(--primary);
}

.feed-edit-attachment-tools .danger:hover,
.feed-card-menu button.danger:hover {
  background: color-mix(in srgb, #ef4444 13%, transparent);
  color: #ef4444;
}

.feed-edit-empty {
  color: var(--muted);
  font-size: .84rem;
  font-weight: 800;
}

.feed-actions,
.feed-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.feed-actions {
  justify-content: space-between;
}

.feed-submit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.feed-composer.is-editing {
  border-color: color-mix(in srgb, var(--primary) 34%, var(--line));
  box-shadow: 0 16px 34px color-mix(in srgb, var(--primary) 11%, transparent);
}

.feed-list {
  display: grid;
  gap: 12px;
}

.load-more-button {
  min-height: 44px;
  width: min(260px, 100%);
  justify-self: center;
  margin: 14px auto 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 18px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 900;
}

.load-more-button:hover {
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 36%, var(--line));
}

.load-more-button:disabled {
  cursor: wait;
  opacity: .72;
}

.feed-card.empty {
  color: var(--muted);
}

.feed-card.is-pinned {
  border-color: color-mix(in srgb, var(--primary) 28%, var(--line));
  box-shadow: 0 16px 34px rgba(0, 0, 0, .1);
}

.feed-birthday-card {
  display: flex;
  align-items: center;
  gap: 14px;
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, transparent), transparent 58%),
    var(--panel);
}

.feed-birthday-avatar {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  border: 2px solid color-mix(in srgb, var(--accent) 54%, #fff);
  box-shadow: 0 10px 22px color-mix(in srgb, var(--accent) 18%, transparent);
  cursor: pointer;
}

.feed-birthday-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.feed-birthday-copy b {
  color: var(--accent);
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.feed-birthday-copy strong {
  color: var(--text);
  font-size: 1.08rem;
  overflow-wrap: anywhere;
}

.feed-birthday-copy span {
  color: var(--muted);
  line-height: 1.35;
}

.feed-card-head {
  margin-bottom: 10px;
}

.feed-card-head strong,
.feed-card-head small {
  display: block;
}

.feed-card-head small {
  color: var(--muted);
}

.feed-author-avatar {
  width: 42px;
  height: 42px;
}

.feed-badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.feed-card-actions {
  position: relative;
  margin-left: 0;
}

.feed-card-menu-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  padding: 0;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 900;
}

.feed-card-menu {
  position: absolute;
  z-index: 8;
  top: calc(100% + 8px);
  right: 0;
  min-width: 170px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 18px 38px rgba(0, 0, 0, .18);
}

.feed-card-menu button {
  width: 100%;
  min-height: 40px;
  border: 0;
  padding: 0 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-weight: 800;
}

.feed-card-menu button:hover {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--primary);
}

.feed-badges b {
  border-radius: 999px;
  padding: 5px 8px;
  background: color-mix(in srgb, var(--primary) 10%, var(--panel-2));
  color: var(--primary);
  font-size: .72rem;
  font-weight: 900;
}

.feed-announcement .feed-badges b:first-child {
  background: color-mix(in srgb, #ef4444 12%, var(--panel-2));
  color: #ef4444;
}

.feed-memory .feed-badges b:first-child {
  background: color-mix(in srgb, var(--accent) 14%, var(--panel-2));
  color: var(--accent);
}

.feed-body {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}

.photos-scroll {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 18px;
}

.photo-album-panel {
  position: relative;
  width: min(1040px, 100%);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  background: var(--panel);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .06);
}

.photo-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.photo-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.photo-toolbar-copy strong,
.photo-toolbar-copy span {
  display: block;
}

.photo-toolbar-copy span {
  margin-top: 3px;
  color: var(--muted);
  font-size: .9rem;
}

.photo-album-panel .drop-zone {
  margin-bottom: 10px;
}

.album-pending {
  margin-bottom: 8px;
}

.photo-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  gap: 3px;
  overflow: hidden;
  border-radius: 14px;
  background: color-mix(in srgb, var(--line) 72%, transparent);
}

.photo-gallery-grid .empty {
  grid-column: 1 / -1;
  color: var(--muted);
}

.photo-tile {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #050505;
  color: #fff;
  text-decoration: none;
  aspect-ratio: 1;
}

.photo-tile.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 24%, transparent);
}

.photo-tile-preview {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  background: #050505;
  color: #fff;
  cursor: zoom-in;
  text-decoration: none;
}

.photo-select {
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 3;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .6);
  border-radius: 999px;
  padding: 0;
  background: rgba(0, 0, 0, .36);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.photo-tile.is-selected .photo-select {
  border-color: transparent;
  background: var(--primary);
  color: #fff;
}

.photo-tile img,
.photo-tile video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .22s ease;
}

.photo-tile:hover img,
.photo-tile:hover video {
  transform: scale(1.04);
}

.media-badge {
  position: absolute;
  top: 7px;
  left: 7px;
  z-index: 1;
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(0, 0, 0, .58);
  color: #fff;
  font-size: .72rem;
  line-height: 1;
}

.portal-pane {
  min-height: calc(100vh - 24px);
  background: var(--panel-2);
}

.portal-pane iframe {
  width: calc(100% - 28px);
  height: calc(100vh - 128px);
  margin: 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.theme-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  background: var(--panel-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.theme-card.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(47, 128, 237, .12);
}

.theme-card small {
  color: var(--muted);
}

.theme-preview {
  display: block;
  height: 54px;
  border-radius: 16px;
}

.blue-light { background: linear-gradient(135deg, #eef3fb 0 40%, #2f80ed 40% 70%, #dff0ff 70%); }
.red-light { background: linear-gradient(135deg, #fbf1f2 0 40%, #c8324a 40% 70%, #ffe3e8 70%); }
.blue-dark { background: linear-gradient(135deg, #0d1726 0 40%, #4c9cff 40% 70%, #1e4972 70%); }
.red-dark { background: linear-gradient(135deg, #241114 0 40%, #ff5d73 40% 70%, #65303b 70%); }

.save-theme {
  justify-self: start;
}

.avatar-viewer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, .62);
}

.avatar-viewer-panel {
  position: relative;
  display: grid;
  gap: 14px;
  width: min(440px, 100%);
  justify-items: center;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 22px;
  padding: 22px;
  background: var(--panel);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .36);
}

.avatar-viewer-panel img {
  width: min(320px, 78vw);
  aspect-ratio: 1;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-viewer-panel strong {
  color: var(--text);
}

.avatar-viewer-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
}

.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 82;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .94);
  color: #fff;
}

.photo-viewer-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  margin: 0;
  padding: clamp(54px, 8vh, 74px) clamp(12px, 7vw, 90px);
}

.photo-viewer-stage img,
.photo-viewer-stage video {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: none;
  max-height: none;
  border-radius: 8px;
  object-fit: contain;
  object-position: center;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .38);
}

.photo-viewer-close,
.photo-viewer-action,
.photo-viewer-nav {
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  background: rgba(24, 24, 27, .72);
  color: #fff;
  text-decoration: none;
  backdrop-filter: blur(12px);
  cursor: pointer;
}

.photo-viewer-close {
  position: absolute;
  z-index: 3;
  top: calc(14px + env(safe-area-inset-top));
  right: 14px;
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 1.55rem;
}

.photo-viewer-topbar {
  position: absolute;
  z-index: 3;
  top: calc(14px + env(safe-area-inset-top));
  left: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.photo-viewer-topbar span {
  border-radius: 999px;
  padding: 9px 12px;
  background: rgba(24, 24, 27, .72);
  color: rgba(255, 255, 255, .82);
  font-weight: 800;
  backdrop-filter: blur(12px);
}

.photo-viewer-action {
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 1.1rem;
  font-weight: 900;
}

.photo-viewer-action.is-selected {
  border-color: transparent;
  background: var(--primary);
}

.photo-viewer-nav {
  position: absolute;
  z-index: 3;
  top: 50%;
  width: 46px;
  height: 64px;
  padding: 0;
  border-radius: 18px;
  transform: translateY(-50%);
  font-size: 2.2rem;
}

.photo-viewer-prev {
  left: 18px;
}

.photo-viewer-next {
  right: 18px;
}

.user-profile-viewer {
  position: fixed;
  inset: 0;
  z-index: 78;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, .58);
}

.user-profile-card {
  position: relative;
  display: grid;
  gap: 16px;
  width: min(520px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  background: var(--panel);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .34);
}

.profile-card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-right: 36px;
}

.profile-card-avatar {
  width: 76px;
  height: 76px;
  font-size: 1.4rem;
}

.profile-card-head h2 {
  font-size: 1.45rem;
}

.profile-card-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.profile-card-info {
  display: grid;
  gap: 8px;
}

.profile-card-info p {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: var(--panel-2);
}

.profile-card-info span {
  color: var(--muted);
}

.profile-card-info strong {
  overflow-wrap: anywhere;
}

.user-profile-card h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.profile-card-avatars {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
  gap: 8px;
}

.profile-card-avatar-tile {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0;
  background: var(--panel-2);
  cursor: zoom-in;
  aspect-ratio: 1;
}

.profile-card-avatar-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-card-empty {
  color: var(--muted);
}

@media (max-width: 880px) {
  .tg-app {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    grid-template-columns: 1fr;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .chat-list {
    top: 8px;
    bottom: 8px;
    left: 8px;
    width: min(340px, calc(100vw - 16px));
    max-height: calc(100dvh - 16px);
    border: 1px solid var(--line);
    border-radius: 22px;
  }

  .nav-toggle {
    top: 12px;
    left: 12px;
  }

  .chat-head {
    gap: 10px;
    padding: 14px 10px 14px 74px;
  }

  .chat-head h1 {
    font-size: 1.08rem;
  }

  .chat-head p {
    font-size: .86rem;
  }

  .head-actions {
    gap: 5px;
  }

  .head-actions button {
    min-height: 36px;
    padding: 0 10px;
    font-size: .84rem;
  }

  .head-actions .notification-toggle {
    width: 36px;
    min-width: 36px;
    padding: 0;
  }

  .dialogs {
    max-height: 230px;
  }

  .chat-pane,
  .dialogs-pane,
  .profile-pane,
  .photos-pane,
  .feed-pane,
  .portal-pane {
    height: 100%;
    min-height: 0;
  }

  .portal-pane iframe {
    height: 70vh;
  }

  .auth-cards,
  .theme-grid {
    grid-template-columns: 1fr;
  }

  .composer {
    --composer-button: clamp(32px, 10vw, 38px);
    padding: 6px 7px calc(6px + env(safe-area-inset-bottom));
  }

  .composer-bar {
    gap: 5px;
  }

  .composer-actions {
    gap: 4px;
  }

  .composer textarea {
    padding: 9px 12px;
  }

  .pending-attachments,
  .drop-zone.compact,
  .composer .status {
    grid-column: 1 / -1;
  }

  .feed-actions,
  .photo-toolbar,
  .photo-toolbar-actions,
  .profile-avatar-picker {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .feed-actions,
  .photo-toolbar,
  .photo-toolbar-actions {
    display: grid;
  }

  .photo-gallery-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .photo-viewer-stage {
    padding: calc(64px + env(safe-area-inset-top)) 0 calc(54px + env(safe-area-inset-bottom));
  }

  .photo-viewer-stage img,
  .photo-viewer-stage video {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
  }

  .dialogs-home {
    padding: 12px;
  }

  .main-dialog-list .dialog {
    min-height: 68px;
  }

  .photo-viewer-nav {
    width: 40px;
    height: 54px;
    border-radius: 16px;
    font-size: 1.9rem;
  }

  .photo-viewer-prev {
    left: 8px;
  }

  .photo-viewer-next {
    right: 8px;
  }

  .feed-card-head {
    flex-wrap: wrap;
  }

  .feed-badges {
    width: 100%;
    margin-left: 54px;
  }

  .message {
    max-width: 92%;
  }
}
