:root {
  color-scheme: light;
  --bg: #eef1f5;
  --sidebar: #f8f9fb;
  --panel: #ffffff;
  --panel-2: #f4f6f8;
  --panel-3: #e9edf2;
  --text: #17202b;
  --muted: #465566;
  --subtle: #5f6d7c;
  --line: #dfe4ea;
  --line-strong: #cbd3dc;
  --primary: #1769aa;
  --primary-hover: #0f588f;
  --primary-button: #1769aa;
  --primary-button-hover: #0f588f;
  --primary-soft: #e4f0f9;
  --accent: #23856d;
  --danger: #b53a46;
  --mine: #dceefa;
  --other: #ffffff;
  --focus: #0b72c4;
  --avatar-text: #ffffff;
  --shadow: 0 8px 24px rgba(29, 42, 55, .1);
  --rail-width: 88px;
  --dialogs-width: 344px;
  --mobile-nav-height: 66px;
}

body[data-theme="light-red"] {
  --bg: #f1f2f4;
  --sidebar: #fafbfc;
  --panel: #ffffff;
  --panel-2: #f6f5f6;
  --panel-3: #ebe8ea;
  --text: #251c20;
  --muted: #5f4b52;
  --subtle: #6d5960;
  --line: #e5dfe2;
  --line-strong: #cec3c8;
  --primary: #a9364d;
  --primary-hover: #8d293e;
  --primary-button: #a9364d;
  --primary-button-hover: #8d293e;
  --primary-soft: #f7e6e9;
  --accent: #8b6b2d;
  --mine: #f5e4e8;
}

body[data-theme="dark-blue"] {
  color-scheme: dark;
  --bg: #101419;
  --sidebar: #151a20;
  --panel: #1b2128;
  --panel-2: #20272f;
  --panel-3: #29323c;
  --text: #eef3f7;
  --muted: #aeb8c2;
  --subtle: #8793a0;
  --line: #303944;
  --line-strong: #42505e;
  --primary: #70baf0;
  --primary-hover: #8ac7f2;
  --primary-button: #1769aa;
  --primary-button-hover: #2380c3;
  --primary-soft: #223c50;
  --accent: #56b99e;
  --danger: #ed7380;
  --mine: #24465d;
  --other: #242c35;
  --focus: #75b7e8;
  --avatar-text: #102432;
  --shadow: 0 8px 28px rgba(0, 0, 0, .28);
}

body[data-theme="dark-red"] {
  color-scheme: dark;
  --bg: #151618;
  --sidebar: #191b1f;
  --panel: #1f2226;
  --panel-2: #25292e;
  --panel-3: #30353b;
  --text: #f4f5f6;
  --muted: #bec5cc;
  --subtle: #9da7b1;
  --line: #343a41;
  --line-strong: #48515a;
  --primary: #ef91a5;
  --primary-hover: #f3a3b4;
  --primary-button: #a9364d;
  --primary-button-hover: #be425a;
  --primary-soft: #4a2832;
  --accent: #e0b35f;
  --danger: #f08c96;
  --mine: #482932;
  --other: #282b30;
  --focus: #ef91a5;
  --avatar-text: #21151a;
  --shadow: 0 8px 28px rgba(0, 0, 0, .3);
}

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

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  min-width: 320px;
  color: var(--text);
  font-family: "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  text-rendering: optimizeLegibility;
}

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

button,
summary,
label[for],
.attach-button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent);
  outline-offset: 2px;
}

button:disabled,
a[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: .55;
}

img,
video {
  max-width: 100%;
}

.icon {
  width: 20px;
  height: 20px;
  display: block;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#nav-toggle,
.nav-backdrop {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

.family-shell.tg-app {
  width: 100%;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--rail-width) var(--dialogs-width) minmax(0, 1fr);
  margin: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: var(--panel);
  box-shadow: none;
}

.app-rail.chat-list {
  position: relative;
  z-index: 20;
  inset: auto;
  grid-column: 1;
  grid-row: 1;
  width: var(--rail-width);
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: visible;
  padding: 12px 7px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: var(--sidebar);
  box-shadow: none;
  transform: none;
  transition: none;
}

.brand-row {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.brand-mark,
.dialog-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--avatar-text);
  background: var(--primary);
  font-weight: 750;
  user-select: none;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background: var(--primary-button);
  color: #ffffff;
  font-size: 17px;
}

.brand-copy {
  display: none;
}

.main-nav {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 3px;
}

.main-nav button {
  position: relative;
  width: 100%;
  min-height: 56px;
  display: grid;
  grid-template-rows: 24px auto;
  place-items: center;
  gap: 2px;
  border: 0;
  border-radius: 7px;
  padding: 7px 4px 5px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
}

.main-nav button > .icon {
  width: 22px;
  height: 22px;
}

.main-nav button:hover {
  background: var(--panel-3);
  color: var(--text);
}

.main-nav button.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.main-nav button.active::before {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: -7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
  content: "";
}

.main-nav button > span,
.main-nav button.active > span {
  max-width: 100%;
  width: auto;
  height: auto;
  display: block;
  overflow: visible;
  border: 0;
  border-radius: 0;
  color: inherit;
  font-size: inherit;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main-nav .archive-nav {
  margin-top: auto;
}

.user-mini {
  width: 48px;
  height: 48px;
  min-height: 48px;
  display: grid;
  place-items: center;
  align-self: center;
  overflow: visible;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: transparent;
  color: var(--text);
}

.user-mini .dialog-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.user-mini:hover .dialog-avatar {
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.user-mini-copy {
  display: none;
}

.conversation-panel {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.conversation-panel-head {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 14px 10px 18px;
}

.conversation-panel-head h1,
.mobile-page-head h1,
.chat-head h1,
.page-head h1 {
  margin: 0;
  color: var(--text);
  font-size: 21px;
  font-weight: 720;
  line-height: 1.2;
}

.connection-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.connection-label i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.icon-button {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 50%;
  padding: 0;
  background: transparent;
  color: var(--muted);
}

.icon-button:hover {
  background: var(--panel-2);
  color: var(--text);
}

.conversation-search,
.dialogs-home-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 12px 8px;
  color: var(--muted);
}

.conversation-search .icon,
.dialogs-home-search .icon {
  position: absolute;
  left: 12px;
  z-index: 1;
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.conversation-search input,
.dialogs-home-search input {
  width: 100%;
  height: 40px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 12px 0 38px;
  background: var(--panel-2);
  color: var(--text);
  outline: none;
}

.conversation-search input:focus,
.dialogs-home-search input:focus {
  border-color: var(--primary);
  background: var(--panel);
}

.people-list,
.main-dialog-list {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: auto;
  padding: 0 6px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.dialog {
  position: relative;
  width: 100%;
  min-height: 70px;
  display: flex;
  align-items: center;
  gap: 11px;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  padding: 9px 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

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

.dialog.active {
  background: var(--primary-soft);
}

.dialog.active .dialog-time {
  color: var(--muted);
}

.dialog .dialog-avatar,
.chat-title-wrap .dialog-avatar {
  width: 46px;
  height: 46px;
  overflow: hidden;
  border-radius: 50%;
  font-size: 15px;
}

.dialog-avatar {
  position: relative;
  width: 46px;
  height: 46px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line-strong) 76%, transparent);
  border-radius: 50%;
  aspect-ratio: 1;
  isolation: isolate;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--panel) 24%, transparent);
}

.dialog-avatar img {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  min-width: 100%;
  min-height: 100%;
  max-width: none;
  max-height: none;
  display: block;
  border-radius: 0;
  object-fit: cover;
  object-position: 50% 30%;
  transform: none;
}

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

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

.dialog-title-row strong {
  min-width: 0;
  overflow: hidden;
  flex: 1;
  color: var(--text);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-time {
  flex: 0 0 auto;
  color: var(--subtle);
  font-size: 11px;
}

.dialog-preview {
  min-width: 0;
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-preview.is-typing,
.chat-head .is-typing {
  color: var(--accent);
}

.dialog-unread {
  position: absolute;
  right: 10px;
  bottom: 9px;
  min-width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  padding: 0 5px;
  background: var(--primary);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
}

.workspace-pane,
.auth-screen {
  grid-column: 3;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  height: 100dvh;
  overflow: hidden;
  background: var(--panel);
}

.auth-screen {
  position: relative;
  z-index: 100;
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 24px;
  background: var(--bg);
}

.auth-layout {
  width: min(860px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-intro {
  min-height: 500px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 40px;
  padding: 36px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}

.auth-intro > div:nth-child(2) {
  margin-top: auto;
  margin-bottom: auto;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 19px;
}

.auth-intro h1 {
  max-width: 13ch;
  margin: 8px 0 14px;
  font-size: 36px;
  font-weight: 740;
  line-height: 1.13;
}

.auth-intro p {
  max-width: 42ch;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.4;
  text-transform: uppercase;
}

.auth-points {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  color: var(--muted);
  font-size: 13px;
}

.auth-points span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.auth-points .icon {
  width: 17px;
  height: 17px;
  color: var(--primary);
}

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 34px;
  background: var(--panel);
}

.auth-card {
  display: grid;
  gap: 16px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.auth-card-head {
  margin-bottom: 3px;
}

.auth-card h2 {
  margin: 0;
  font-size: 24px;
}

.auth-card-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-card label,
.profile-fields label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.auth-card input,
.profile-fields input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--text);
  outline: none;
}

.auth-card input:focus,
.profile-fields input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.primary,
.secondary-button,
.danger-button,
.download-button,
.load-more-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 650;
  text-decoration: none;
}

.primary,
.download-button {
  background: var(--primary-button);
  color: #ffffff;
}

.primary:hover,
.download-button:hover {
  background: var(--primary-button-hover);
}

.secondary-button,
.load-more-button {
  border-color: var(--line-strong);
  background: var(--panel);
  color: var(--text);
}

.secondary-button:hover,
.load-more-button:hover {
  background: var(--panel-2);
}

.danger-button {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
  background: transparent;
  color: var(--danger);
}

.auth-submit {
  width: 100%;
  min-height: 44px;
  margin-top: 2px;
}

.register-panel {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.registration-closed {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.family-access-admin {
  width: min(820px, 100%);
  margin-top: 16px;
}

.family-access-heading,
.family-invitation-form,
.family-invite-result,
.family-access-row,
.family-access-actions {
  display: flex;
  align-items: center;
}

.family-access-heading,
.family-access-row {
  justify-content: space-between;
}

.family-access-heading p,
.family-access-meta {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.family-invitation-form {
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 12px;
}

.family-invitation-form label {
  display: grid;
  gap: 6px;
  width: min(220px, 100%);
}

.family-invitation-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--panel-2);
  color: var(--text);
}

.family-invite-result {
  align-items: stretch;
  gap: 8px;
  margin-bottom: 12px;
}

.family-invite-result code {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--panel-2);
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.family-access-group {
  margin-top: 20px;
}

.family-access-group h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.family-access-list {
  border-top: 1px solid var(--line);
}

.family-access-row {
  min-height: 58px;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.family-access-row strong,
.family-access-row span {
  overflow-wrap: anywhere;
}

.family-access-actions {
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.family-access-actions button {
  min-height: 36px;
  padding: 7px 10px;
}

.family-device-code-input {
  width: 148px;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 7px 9px;
  background: var(--panel-2);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.family-device-self-verification {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}

.family-device-own-code {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--panel-2);
  color: var(--text);
  font: 650 15px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0;
}

.family-access-empty {
  margin: 0;
  padding: 12px 0;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 620px) {
  .family-invitation-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }

  .family-invitation-form label,
  .family-invitation-form .primary,
  .family-invite-result .secondary-button {
    width: 100%;
    max-width: 100%;
  }

  .family-invite-result,
  .family-access-row {
    align-items: stretch;
    flex-direction: column;
  }

  .family-invite-result code {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    word-break: break-all;
  }

  .family-access-actions {
    justify-content: flex-start;
  }

  .family-device-code-input {
    width: min(100%, 220px);
  }
}

.register-panel summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 13px;
  font-weight: 650;
  text-align: center;
}

.register-card {
  margin-top: 18px;
  padding-top: 2px;
}

.status {
  min-height: 18px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.dialogs-pane,
.chat-pane,
.feed-pane,
.photos-pane,
.profile-pane,
.portal-pane {
  height: 100%;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

.mobile-page-head,
.dialogs-home {
  display: none;
}

.desktop-empty-state {
  min-height: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  flex: 1;
  padding: 32px;
  color: var(--muted);
  text-align: center;
  background: var(--panel-2);
}

.desktop-empty-state h2 {
  margin: 16px 0 6px;
  color: var(--text);
  font-size: 19px;
}

.desktop-empty-state p {
  margin: 0;
  font-size: 14px;
}

.empty-state-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--panel-3);
  color: var(--muted);
}

.empty-state-mark .icon {
  width: 28px;
  height: 28px;
}

.chat-head {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
  padding: 10px 18px;
  background: var(--panel);
}

.chat-title-wrap {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}

.chat-back {
  display: none;
}

.chat-heading {
  min-width: 0;
}

.chat-heading h1,
.chat-heading p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.notification-toggle.is-enabled {
  color: var(--primary);
  background: var(--primary-soft);
}

.messages {
  min-height: 0;
  flex: 1;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 20px clamp(18px, 4vw, 54px);
  background: var(--panel-2);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.message {
  width: fit-content;
  max-width: min(680px, 74%);
  margin: 0 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px 8px 8px 2px;
  padding: 9px 11px 7px;
  background: var(--other);
  box-shadow: 0 1px 2px rgba(25, 36, 48, .05);
}

.message.mine {
  margin-left: auto;
  border-color: color-mix(in srgb, var(--primary) 14%, var(--line));
  border-radius: 8px 8px 2px 8px;
  background: var(--mine);
}

.message-head {
  gap: 10px;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}

.message-user-avatar {
  width: 22px;
  height: 22px;
}

.message-body {
  color: var(--text);
  font-size: 14px;
  line-height: 1.42;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-actions,
.attachment-actions,
.feed-card-actions {
  z-index: 5;
}

.message-actions button,
.attachment-actions button,
.feed-card-actions button {
  color: var(--text);
}

.birthday-announcement {
  max-width: 620px;
  margin: 14px auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: none;
}

.composer {
  --composer-button: 42px;
  position: relative;
  width: 100%;
  min-width: 0;
  display: grid;
  gap: 5px;
  flex: 0 0 auto;
  overflow: visible;
  border-top: 1px solid var(--line);
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  background: var(--panel);
}

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

.composer textarea {
  width: 100%;
  height: 42px;
  min-height: 42px;
  max-height: 120px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 21px;
  padding: 10px 14px;
  background: var(--panel-2);
  color: var(--text);
  line-height: 1.35;
  outline: none;
  resize: none;
}

.composer textarea:focus {
  border-color: var(--primary);
  background: var(--panel);
}

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

.attach-button,
.voice-button,
.circle-button,
.cancel-edit,
.send-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  text-decoration: none;
}

.attach-button:hover,
.voice-button:hover,
.circle-button:hover,
.cancel-edit:hover {
  background: var(--panel-2);
  color: var(--text);
}

.attach-button input,
.avatar-file-button input {
  display: none;
}

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

.send-button {
  background: var(--primary-button);
  color: #ffffff;
}

.send-button:hover {
  background: var(--primary-button-hover);
}

.drop-zone {
  position: absolute;
  z-index: 18;
  inset: 8px;
  display: grid;
  min-height: 64px;
  place-items: center;
  border: 2px dashed var(--primary);
  border-radius: 8px;
  padding: 12px;
  background: color-mix(in srgb, var(--primary-soft) 92%, transparent);
  color: var(--primary);
  pointer-events: none;
  opacity: 0;
  text-align: center;
}

.drop-zone.is-dragging {
  opacity: 1;
}

.pending-attachments {
  max-width: 100%;
  overflow-x: auto;
}

.composer.is-protected {
  border-top-color: color-mix(in srgb, var(--primary) 32%, var(--line));
}

.composer.is-protected-blocked .attach-button,
.composer.is-protected-blocked .expression-toggle,
.composer.is-protected-blocked .send-button,
.composer.is-protected #voice-button,
.composer.is-protected #circle-button {
  cursor: not-allowed;
  opacity: .42;
}

.composer.is-protected-blocked textarea {
  background: var(--panel-2);
  color: var(--muted);
}

.protected-pending-chip {
  min-height: 42px;
  border-radius: 7px;
  padding: 4px 7px 4px 4px;
}

.protected-pending-chip img {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 5px;
  object-fit: cover;
}

.protected-message {
  border-color: color-mix(in srgb, var(--primary) 18%, var(--line));
}

.protected-photo {
  width: min(420px, 62vw);
  min-width: 180px;
  aspect-ratio: 4 / 3;
  display: block;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  padding: 0;
  background: var(--panel-2);
  color: var(--muted);
  cursor: zoom-in;
}

.protected-photo:disabled {
  cursor: progress;
  opacity: .72;
}

.protected-photo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.protected-photo-viewer {
  position: fixed;
  z-index: 220;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: max(56px, calc(18px + env(safe-area-inset-top))) 18px max(18px, env(safe-area-inset-bottom));
  background: rgba(10, 12, 15, .94);
}

.protected-photo-viewer > img {
  max-width: 100%;
  max-height: calc(100dvh - 86px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  display: block;
  object-fit: contain;
}

.protected-photo-close {
  position: fixed;
  z-index: 1;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 50%;
  padding: 0;
  background: rgba(20, 22, 26, .82);
  color: #fff;
  cursor: pointer;
  font-size: 25px;
  line-height: 1;
}

.reply-preview {
  border-left: 3px solid var(--primary);
  border-radius: 0;
  background: var(--panel-2);
}

.page-head {
  min-height: 82px;
  padding: 14px clamp(18px, 3vw, 34px);
}

.page-head > div:first-child {
  min-width: 0;
}

.page-scroll,
.portal-scroll {
  min-height: 0;
  flex: 1;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 22px clamp(16px, 3vw, 34px) 40px;
  background: var(--panel-2);
}

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

.portal-tabs {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--panel-2);
}

.portal-tab {
  min-height: 38px;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.portal-tab:last-child {
  border-right: 0;
}

.portal-tab:hover {
  color: var(--text);
}

.portal-tab.is-selected {
  background: var(--panel);
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--primary);
}

#portal-open {
  width: 40px;
  min-width: 40px;
  padding: 0;
}

.feed-scroll,
.profile-scroll {
  width: 100%;
}

.feed-scroll > *,
.profile-scroll > * {
  width: min(760px, 100%);
  margin-right: auto;
  margin-left: auto;
}

.wedding-archive-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  padding: 0 0 16px;
}

.wedding-archive-strip h2 {
  margin: 0;
  font-size: 16px;
}

.archive-shortcuts {
  display: flex;
  gap: 8px;
}

.portal-shortcut {
  min-width: 150px;
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
}

.portal-shortcut:hover {
  border-color: var(--line-strong);
  background: var(--sidebar);
}

.portal-shortcut .icon {
  color: var(--primary);
}

.portal-shortcut span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

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

.portal-shortcut strong {
  font-size: 13px;
}

.portal-shortcut small {
  color: var(--muted);
  font-size: 11px;
}

.feed-composer,
.feed-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: none;
}

.feed-composer {
  position: relative;
  display: grid;
  gap: 13px;
  margin-bottom: 14px;
  padding: 14px;
}

.feed-composer-title {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.compact-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.feed-composer textarea {
  min-height: 74px;
  flex: 1;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 8px 2px;
  background: transparent;
  color: var(--text);
  outline: none;
  resize: vertical;
}

.feed-settings {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.feed-type-option,
.feed-pin-toggle {
  position: relative;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.feed-type-option:has(input:checked),
.feed-pin-toggle:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.feed-actions,
.feed-submit-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

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

.feed-card {
  padding: 15px;
}

.feed-card.is-pinned {
  border-left: 3px solid var(--accent);
}

.feed-card-media img,
.feed-card-media video {
  border-radius: 6px;
}

.photo-album-panel {
  position: relative;
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

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

.photo-toolbar-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.photo-toolbar-copy strong {
  font-size: 16px;
}

.photo-toolbar-copy span {
  color: var(--muted);
  font-size: 12px;
}

.photo-toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 7px;
}

.photo-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  gap: 5px;
}

.photo-tile {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 4px;
  aspect-ratio: 1;
  background: var(--panel-3);
}

.photo-tile-preview {
  width: 100%;
  height: 100%;
  display: block;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: var(--panel-3);
}

.photo-tile-preview img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform .18s ease;
}

.photo-tile-preview > .icon {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  color: var(--subtle);
  transform: translate(-50%, -50%);
}

.photo-tile.is-loaded .photo-tile-preview > .icon {
  display: none;
}

.photo-tile-preview:hover img {
  transform: scale(1.025);
}

.photo-select {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 2px solid #ffffff;
  border-radius: 50%;
  padding: 0;
  background: rgba(20, 27, 35, .55);
  color: #ffffff;
  opacity: 0;
}

.photo-tile:hover .photo-select,
.photo-tile:focus-within .photo-select,
.photo-tile.is-selected .photo-select {
  opacity: 1;
}

.photo-tile.is-selected {
  border-color: var(--primary);
}

.photo-tile.is-selected .photo-select {
  background: var(--primary-button);
}

.photo-select span {
  opacity: 0;
}

.photo-tile.is-selected .photo-select span {
  opacity: 1;
}

.media-badge {
  position: absolute;
  right: 7px;
  bottom: 7px;
  border-radius: 4px;
  padding: 3px 6px;
  background: rgba(20, 27, 35, .74);
  color: #ffffff;
  font-size: 10px;
}

.load-more-button {
  min-width: 170px;
  margin: 18px auto 0;
}

.theme-panel {
  display: grid;
  gap: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: none;
}

.settings-section {
  display: grid;
  gap: 16px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.settings-section:last-child {
  border-bottom: 0;
}

.section-heading h2 {
  margin: 0;
  font-size: 17px;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.profile-avatar-picker {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-avatar-preview {
  width: 64px;
  height: 64px;
  overflow: hidden;
  border-radius: 50%;
  font-size: 20px;
}

.avatar-file-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

.profile-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.profile-fields label:first-child {
  grid-column: 1 / -1;
}

.settings-section > .primary {
  width: fit-content;
}

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

.theme-card {
  min-width: 0;
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
}

.theme-card:hover {
  background: var(--panel-2);
}

.theme-card.is-selected {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.theme-card > span:last-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

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

.theme-preview {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #f4f6f8;
  box-shadow: inset 0 -13px 0 #dceefa, inset 13px 0 0 #1769aa;
}

.theme-preview.red-light {
  background: #f5f3f4;
  box-shadow: inset 0 -13px 0 #f5e4e8, inset 13px 0 0 #a9364d;
}

.theme-preview.blue-dark {
  background: #20272f;
  box-shadow: inset 0 -13px 0 #24465d, inset 13px 0 0 #56a8e5;
}

.theme-preview.red-dark {
  background: #2b2529;
  box-shadow: inset 0 -13px 0 #55313a, inset 13px 0 0 #e27a91;
}

.save-theme {
  width: fit-content;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.portal-scroll {
  padding-top: 16px;
}

.portal-stage {
  width: min(980px, 100%);
  margin: 0 auto;
}

.portal-stage img {
  width: 100%;
  min-height: 260px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-3);
  object-fit: contain;
  object-position: top center;
}

.portal-stage figcaption {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.avatar-viewer,
.photo-viewer,
.user-profile-viewer {
  background: rgba(11, 15, 20, .86);
  backdrop-filter: blur(4px);
}

.avatar-viewer-panel,
.user-profile-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.avatar-viewer-close,
.photo-viewer-close,
.photo-viewer-nav {
  color: #ffffff;
}

.avatar-viewer-panel .avatar-viewer-close,
.user-profile-card .avatar-viewer-close {
  color: var(--muted);
}

.photo-viewer-topbar {
  align-items: center;
}

.photo-viewer-action {
  display: grid;
  place-items: center;
}

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

.conversation-head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.group-list-section {
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
  padding: 2px 6px 8px;
}

.group-list-section h2 {
  margin: 5px 12px 3px;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.group-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.group-dialog-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: center;
  min-width: 0;
}

.group-dialog-button {
  width: 100%;
  min-width: 0;
  min-height: 64px;
}

.group-dialog-button .dialog-preview {
  white-space: nowrap;
}

.group-dialog-settings {
  width: 40px;
  height: 40px;
  justify-self: center;
  color: var(--muted);
}

body.family-dialog-open {
  overflow: hidden;
}

.family-dialog-backdrop {
  position: fixed;
  z-index: 300;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(12, 18, 24, .56);
}

.family-dialog-backdrop[hidden] {
  display: none !important;
}

.family-dialog {
  width: min(680px, 100%);
  max-height: min(820px, calc(100dvh - 32px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.family-dialog-head {
  min-height: 72px;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px 12px 18px;
}

.family-dialog-head h2,
.group-detail-section h3 {
  margin: 0;
  color: var(--text);
}

.family-dialog-head h2 {
  font-size: 20px;
  line-height: 1.25;
}

.family-dialog-head .eyebrow {
  margin-bottom: 2px;
}

.group-create-form,
.group-detail-scroll {
  min-height: 0;
  flex: 1;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.group-create-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
}

.group-create-form > label,
.group-settings-fields label,
.group-avatar-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.group-create-form input,
.group-settings-form input,
.group-member-add select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 9px 11px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

.group-create-form input:focus,
.group-settings-form input:focus,
.group-member-add select:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.group-create-form fieldset {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.group-create-form legend {
  padding: 0 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.group-member-picker {
  max-height: 320px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 12px;
  overflow: auto;
}

.group-member-picker label {
  min-width: 0;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
}

.group-member-picker label:hover {
  background: var(--panel-2);
}

.group-member-picker input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  flex: 0 0 auto;
  accent-color: var(--primary);
}

.group-member-picker label > span,
.group-member-copy,
.group-request-row > div:first-child,
.group-detail-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.group-member-picker small,
.group-member-copy span,
.group-request-row span,
.group-detail-copy p {
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.family-dialog-actions,
.group-detail-footer {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.family-dialog-actions {
  padding-top: 2px;
}

.group-detail-head {
  justify-content: flex-start;
}

.group-detail-head > .icon-button {
  margin-left: auto;
}

.group-detail-avatar {
  width: 48px;
  height: 48px;
}

.group-detail-copy h2,
.group-detail-copy p {
  max-width: 100%;
}

.group-detail-copy h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-detail-scroll {
  padding: 0 18px;
}

.group-settings-form {
  display: flex;
  align-items: end;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
}

.group-settings-form[hidden] {
  display: none !important;
}

.group-settings-fields {
  min-width: 0;
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1.2fr) minmax(190px, .8fr);
  gap: 10px;
}

.group-settings-form input[type="file"] {
  padding: 7px 9px;
}

.group-detail-section {
  padding: 17px 0;
}

.group-detail-section + .group-detail-section {
  border-top: 1px solid var(--line);
}

.group-detail-section h3 {
  font-size: 15px;
  line-height: 1.35;
}

.group-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.group-section-head > span {
  min-width: 28px;
  border-radius: 12px;
  padding: 2px 7px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.group-protection-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.group-protection-actions .secondary-button {
  width: 100%;
  min-height: 42px;
}

.group-protection-actions .secondary-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--text);
}

.group-members-list,
.group-requests-list {
  display: flex;
  flex-direction: column;
}

.group-member-row,
.group-request-row {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 8px 0;
}

.group-member-row:first-child,
.group-request-row:first-child {
  border-top: 0;
}

.group-member-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.group-row-action {
  min-height: 34px;
  padding: 6px 9px;
  font-size: 12px;
}

.group-member-add h3,
#group-requests-title {
  margin-bottom: 10px;
}

.group-member-add form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.group-detail-footer {
  min-height: 66px;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding: 10px 18px;
}

.group-detail-footer .status {
  min-width: 0;
  margin: 0;
}

@media (max-width: 1120px) and (min-width: 961px) {
  :root {
    --dialogs-width: 310px;
  }

  .archive-nav span {
    font-size: 10px;
  }

  .photo-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .photo-toolbar-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 960px) {
  html,
  body {
    overflow: hidden;
  }

  .family-shell.tg-app {
    width: 100%;
    height: 100dvh;
    display: block;
    margin: 0;
  }

  .app-rail.chat-list {
    position: fixed;
    z-index: 80;
    inset: auto 0 0;
    width: 100%;
    height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
    display: block;
    overflow: visible;
    border: 0;
    border-top: 1px solid var(--line);
    padding: 0 4px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--panel) 96%, transparent);
    box-shadow: 0 -3px 14px rgba(25, 36, 48, .06);
    transform: none;
    backdrop-filter: blur(12px);
  }

  .app-rail .brand-row,
  .app-rail .user-mini,
  .app-rail .archive-nav {
    display: none !important;
  }

  .app-rail .main-nav {
    height: var(--mobile-nav-height);
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
  }

  .app-rail .main-nav button {
    width: 100%;
    height: var(--mobile-nav-height);
    min-width: 0;
    min-height: var(--mobile-nav-height);
    border-radius: 0;
    padding: 7px 2px 5px;
    font-size: 10px;
  }

  .app-rail .main-nav button.active::before {
    top: 0;
    right: 28%;
    bottom: auto;
    left: 28%;
    width: auto;
    height: 2px;
    border-radius: 0 0 2px 2px;
  }

  .conversation-panel {
    display: none !important;
  }

  .workspace-pane,
  .auth-screen {
    width: 100%;
    height: 100dvh;
  }

  .workspace-pane {
    padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
  }

  body[data-view="chat"] .app-rail {
    display: none;
  }

  body[data-view="chat"] .workspace-pane {
    padding-bottom: 0;
  }

  .auth-screen {
    z-index: 120;
    padding: 14px;
  }

  .auth-layout {
    max-width: 430px;
    grid-template-columns: 1fr;
  }

  .auth-intro {
    min-height: auto;
    gap: 20px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 24px 22px 20px;
  }

  .auth-intro > div:nth-child(2) {
    display: none;
  }

  .auth-points {
    gap: 8px 14px;
  }

  .auth-panel {
    padding: 24px 22px;
  }

  .desktop-empty-state {
    display: none;
  }

  .mobile-page-head {
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex: 0 0 auto;
    border-bottom: 1px solid var(--line);
    padding: 9px 14px;
  }

  .dialogs-home {
    min-height: 0;
    display: flex;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
    padding-top: 8px;
    background: var(--panel);
  }

  .dialogs-home-search {
    flex: 0 0 auto;
  }

  .main-dialog-list {
    flex: 1;
    padding: 0 8px 14px;
  }

  .chat-head {
    min-height: 64px;
    padding: 8px 10px;
  }

  .chat-back {
    display: inline-grid;
  }

  .chat-title-wrap {
    gap: 7px;
  }

  .chat-title-wrap .dialog-avatar {
    width: 42px;
    height: 42px;
  }

  .chat-heading h1 {
    font-size: 16px;
  }

  .messages {
    padding: 14px 10px;
  }

  .message {
    max-width: 88%;
  }

  .protected-photo {
    width: min(72vw, 390px);
    min-width: 154px;
  }

  .composer {
    --composer-button: 40px;
    padding: 7px 7px calc(7px + env(safe-area-inset-bottom));
  }

  .composer-bar {
    gap: 4px;
  }

  .composer-actions {
    gap: 2px;
  }

  .composer textarea {
    height: 40px;
    min-height: 40px;
    padding: 9px 12px;
  }

  .page-head {
    min-height: 68px;
    padding: 9px 14px;
  }

  .page-head h1 {
    font-size: 19px;
  }

  .page-head > div > p:not(.eyebrow) {
    display: none;
  }

  .page-scroll,
  .portal-scroll {
    padding: 14px 10px 28px;
  }

  .wedding-archive-strip {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .archive-shortcuts {
    width: 100%;
  }

  .portal-shortcut {
    min-width: 0;
    flex: 1;
  }

  .photo-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .photo-toolbar-actions {
    justify-content: flex-start;
  }

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

  .photo-select {
    top: 5px;
    right: 5px;
    opacity: .75;
  }

  .theme-panel {
    border: 0;
    border-radius: 0;
  }

  .settings-section {
    padding: 18px 14px;
  }

  .portal-stage img {
    min-height: 220px;
  }

  #portal-open span {
    display: none;
  }

  #portal-open {
    width: 40px;
    min-width: 40px;
    padding: 0;
    border-radius: 50%;
  }

}

@media (max-width: 620px) {
  .family-dialog-backdrop {
    place-items: stretch;
    padding: 0;
    background: var(--panel);
  }

  .family-dialog {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .family-dialog-head {
    min-height: calc(64px + env(safe-area-inset-top));
    padding: max(10px, env(safe-area-inset-top)) 10px 10px 14px;
  }

  .family-dialog-head h2 {
    font-size: 18px;
  }

  .group-create-form {
    padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
  }

  .group-member-picker {
    max-height: none;
    grid-template-columns: 1fr;
  }

  .family-dialog-actions {
    position: sticky;
    bottom: 0;
    padding: 10px 0 calc(4px + env(safe-area-inset-bottom));
    background: var(--panel);
  }

  .family-dialog-actions > * {
    min-width: 0;
    flex: 1;
  }

  .group-detail-avatar {
    width: 44px;
    height: 44px;
  }

  .group-detail-scroll {
    padding: 0 12px;
  }

  .group-settings-form {
    align-items: stretch;
    flex-direction: column;
  }

  .group-settings-fields {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .group-settings-form > button {
    width: 100%;
  }

  .group-member-row,
  .group-request-row {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding: 11px 0;
  }

  .group-member-actions {
    justify-content: flex-start;
  }

  .group-row-action {
    min-height: 38px;
  }

  .group-member-add form {
    grid-template-columns: 1fr;
  }

  .group-member-add button {
    width: 100%;
  }

  .group-detail-footer {
    min-height: calc(64px + env(safe-area-inset-bottom));
    align-items: stretch;
    flex-direction: column;
    padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
  }

  .group-detail-footer .status:empty {
    display: none;
  }

  .group-detail-footer .danger-button {
    width: 100%;
  }

  .auth-screen {
    align-items: start;
    padding: 0;
    background: var(--panel);
  }

  .auth-layout {
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .auth-intro {
    padding-top: max(22px, env(safe-area-inset-top));
  }

  .auth-panel {
    justify-content: start;
  }

  .auth-points span:last-child {
    display: none;
  }

  .message {
    max-width: 92%;
    font-size: 14px;
  }

  .protected-photo {
    width: min(78vw, 360px);
  }

  .protected-photo-viewer {
    padding-right: 8px;
    padding-left: 8px;
  }

  .message-author-wrap .message-user-avatar {
    display: none;
  }

  .wedding-archive-strip h2 {
    font-size: 15px;
  }

  .portal-shortcut {
    min-height: 50px;
    padding: 7px 8px;
  }

  .portal-shortcut .icon {
    width: 18px;
    height: 18px;
  }

  .portal-shortcut small {
    display: none;
  }

  .portal-pane .page-head > div:first-child {
    display: none;
  }

  .portal-head-actions {
    width: 100%;
  }

  .portal-tabs {
    min-width: 0;
    flex: 1;
  }

  .portal-tab {
    min-width: 0;
    flex: 1;
    padding: 0 8px;
  }

  .feed-composer {
    padding: 12px;
  }

  .feed-settings {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
    padding-bottom: 0;
  }

  .feed-type-option,
  .feed-pin-toggle {
    width: 100%;
    min-width: 0;
    justify-content: center;
    padding: 0 6px;
    font-size: 11px;
    text-align: center;
  }

  .photo-toolbar-copy span {
    display: none;
  }

  .photo-toolbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .photo-toolbar-actions > * {
    min-width: 0;
    width: 100%;
  }

  .download-all {
    grid-column: 1 / -1;
  }

  .profile-fields,
  .theme-grid {
    grid-template-columns: 1fr;
  }

  .profile-fields label:first-child {
    grid-column: auto;
  }

  .settings-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-actions > * {
    width: 100%;
  }

  .photo-viewer-nav {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
  }
}

@media (max-width: 380px) {
  .auth-intro,
  .auth-panel {
    padding-right: 16px;
    padding-left: 16px;
  }

  .app-rail .main-nav button {
    font-size: 9px;
  }

  .chat-title-wrap .dialog-avatar {
    width: 38px;
    height: 38px;
  }

  .composer {
    --composer-button: 38px;
    padding-right: 5px;
    padding-left: 5px;
  }

  .composer textarea {
    padding-right: 10px;
    padding-left: 10px;
  }

  .photo-toolbar-actions {
    grid-template-columns: 1fr;
  }

  .download-all {
    grid-column: auto;
  }
}

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