:root {
  --app-viewport-height: 100vh;
  --page-background: #dfe8ec;
  --panel-background: var(--surface-strong);
  --sidebar-background: #eef4f6;
  --chat-background: #dbe7eb;
  --chat-pattern: rgba(71, 107, 119, 0.08);
  --chat-glow-one: rgba(255, 255, 255, 0.42);
  --chat-glow-two: rgba(79, 127, 143, 0.16);
  --custom-chat-background-image: none;
  --custom-chat-background-size: cover;
  --custom-chat-background-overlay: 0.18;
  --text-primary: #203037;
  --text-secondary: #6c7f87;
  --border-color: #d4e0e4;
  --accent-color: #4f7f8f;
  --accent-color-dark: #3d6876;
  --accent-soft: #d9e9ee;
  --own-message-background: #cfe5ec;
  --own-message-opacity-percent: 88%;
  --partner-message-background: var(--surface-strong);
  --message-text-color: var(--text-primary);
  --message-author-color: var(--accent-color-dark);
  --chat-message-font-family: Arial, sans-serif;
  --chat-message-font-size: 15px;
  --message-bubble-radius: 15px;
  --message-bubble-tail-radius: 5px;
  --message-spacing: 8px;
  --danger-color: #a84848;
  --danger-soft: #f6e4e4;
  --surface-strong: #ffffff;
  --surface-soft: rgba(255, 255, 255, 0.72);
  --surface-floating: rgba(255, 255, 255, 0.78);
  --surface-floating-strong: rgba(255, 255, 255, 0.96);
  --input-background: var(--surface-strong);
  --hover-background: #edf3f5;
  --muted-button-background: #e8eef0;
  --date-background: rgba(255, 255, 255, 0.76);
  --shell-border: rgba(255, 255, 255, 0.75);
  --shadow-soft: 0 18px 45px rgba(32, 58, 68, 0.14);
  --search-highlight-background: #ffe28a;
  --search-current-outline: #d89b22;
}

:where(html, body)[data-theme="ocean"] {
  color-scheme: dark;
  --page-background: #07151c;
  --panel-background: #10242c;
  --sidebar-background: #132b34;
  --chat-background: #0b2028;
  --chat-pattern: rgba(113, 183, 201, 0.12);
  --chat-glow-one: rgba(80, 166, 187, 0.16);
  --chat-glow-two: rgba(17, 78, 95, 0.42);
  --text-primary: #e6f1f3;
  --text-secondary: #9eb5bd;
  --border-color: #29434c;
  --accent-color: #4e9fb3;
  --accent-color-dark: #7bc5d5;
  --accent-soft: #1d4652;
  --own-message-background: #1c5260;
  --partner-message-background: #183640;
  --danger-color: #ef8a8a;
  --danger-soft: #4a292d;
  --surface-strong: #17313a;
  --surface-soft: rgba(29, 62, 73, 0.82);
  --surface-floating: rgba(23, 49, 58, 0.9);
  --surface-floating-strong: rgba(16, 36, 44, 0.97);
  --input-background: #17313a;
  --hover-background: #21434e;
  --muted-button-background: #29434c;
  --date-background: rgba(23, 49, 58, 0.88);
  --shell-border: rgba(255, 255, 255, 0.08);
  --shadow-soft: 0 18px 48px rgba(0, 0, 0, 0.34);
  --search-highlight-background: #9f7624;
  --search-current-outline: #d5a642;
}

:where(html, body)[data-theme="coral"] {
  --page-background: #f2e6df;
  --panel-background: #fffaf7;
  --sidebar-background: #f8eee8;
  --chat-background: #f1dfd5;
  --chat-pattern: rgba(157, 94, 73, 0.09);
  --chat-glow-one: rgba(255, 255, 255, 0.52);
  --chat-glow-two: rgba(194, 116, 91, 0.15);
  --text-primary: #44302a;
  --text-secondary: #8a6c62;
  --border-color: #ead4ca;
  --accent-color: #c17661;
  --accent-color-dark: #9d5947;
  --accent-soft: #f2d9cf;
  --own-message-background: #f1cfc1;
  --partner-message-background: #fffaf7;
  --danger-color: #ad4c4c;
  --danger-soft: #f6dddd;
  --surface-strong: #fffaf7;
  --surface-soft: rgba(255, 250, 247, 0.78);
  --surface-floating: rgba(255, 250, 247, 0.84);
  --surface-floating-strong: rgba(255, 250, 247, 0.97);
  --input-background: #fffaf7;
  --hover-background: #f5e6df;
  --muted-button-background: #f0e0d8;
  --date-background: rgba(255, 250, 247, 0.82);
  --shell-border: rgba(255, 255, 255, 0.75);
  --shadow-soft: 0 18px 45px rgba(91, 58, 46, 0.14);
}

:where(html, body)[data-theme="lavender"] {
  --page-background: #e9e5f1;
  --panel-background: #fdfbff;
  --sidebar-background: #f1edf7;
  --chat-background: #e5def0;
  --chat-pattern: rgba(103, 82, 137, 0.09);
  --chat-glow-one: rgba(255, 255, 255, 0.5);
  --chat-glow-two: rgba(132, 103, 171, 0.15);
  --text-primary: #352f40;
  --text-secondary: #766c83;
  --border-color: #ddd5e8;
  --accent-color: #836da2;
  --accent-color-dark: #65527f;
  --accent-soft: #e2d8ee;
  --own-message-background: #dcd0eb;
  --partner-message-background: #fdfbff;
  --danger-color: #a74f64;
  --danger-soft: #f3dfe5;
  --surface-strong: #fdfbff;
  --surface-soft: rgba(253, 251, 255, 0.76);
  --surface-floating: rgba(253, 251, 255, 0.83);
  --surface-floating-strong: rgba(253, 251, 255, 0.97);
  --input-background: #fdfbff;
  --hover-background: #eee8f4;
  --muted-button-background: #e9e2ef;
  --date-background: rgba(253, 251, 255, 0.8);
  --shell-border: rgba(255, 255, 255, 0.8);
  --shadow-soft: 0 18px 45px rgba(62, 48, 80, 0.14);
}

:where(html, body)[data-theme="graphite"] {
  --page-background: #dadddf;
  --panel-background: #f8f9fa;
  --sidebar-background: #eaedef;
  --chat-background: #d9dee1;
  --chat-pattern: rgba(73, 83, 90, 0.09);
  --chat-glow-one: rgba(255, 255, 255, 0.5);
  --chat-glow-two: rgba(87, 101, 110, 0.14);
  --text-primary: #282f33;
  --text-secondary: #6c767c;
  --border-color: #d0d6da;
  --accent-color: #667680;
  --accent-color-dark: #4d5c65;
  --accent-soft: #d8dfe3;
  --own-message-background: #ced9df;
  --partner-message-background: #f8f9fa;
  --danger-color: #a44b4b;
  --danger-soft: #f1dddd;
  --surface-strong: #f8f9fa;
  --surface-soft: rgba(248, 249, 250, 0.78);
  --surface-floating: rgba(248, 249, 250, 0.84);
  --surface-floating-strong: rgba(248, 249, 250, 0.97);
  --input-background: #f8f9fa;
  --hover-background: #e8ecee;
  --muted-button-background: #e2e6e8;
  --date-background: rgba(248, 249, 250, 0.82);
  --shell-border: rgba(255, 255, 255, 0.78);
  --shadow-soft: 0 18px 45px rgba(39, 48, 54, 0.16);
}

:where(html, body)[data-theme="sage"] {
  --page-background: #dfe5dc;
  --panel-background: #fbfcf8;
  --sidebar-background: #edf2e9;
  --chat-background: #dce6d8;
  --chat-pattern: rgba(83, 108, 77, 0.1);
  --chat-glow-one: rgba(255, 255, 255, 0.48);
  --chat-glow-two: rgba(104, 137, 94, 0.15);
  --text-primary: #2f392c;
  --text-secondary: #73806e;
  --border-color: #d4ded0;
  --accent-color: #708d67;
  --accent-color-dark: #536f4c;
  --accent-soft: #dce8d7;
  --own-message-background: #d2e3cc;
  --partner-message-background: #fbfcf8;
  --danger-color: #a64d4d;
  --danger-soft: #f2dddd;
  --surface-strong: #fbfcf8;
  --surface-soft: rgba(251, 252, 248, 0.78);
  --surface-floating: rgba(251, 252, 248, 0.84);
  --surface-floating-strong: rgba(251, 252, 248, 0.97);
  --input-background: #fbfcf8;
  --hover-background: #e8eee5;
  --muted-button-background: #e2e9df;
  --date-background: rgba(251, 252, 248, 0.82);
  --shell-border: rgba(255, 255, 255, 0.78);
  --shadow-soft: 0 18px 45px rgba(52, 70, 47, 0.14);
}

:where(html, body)[data-theme="sand"] {
  --page-background: #ece4d6;
  --panel-background: #fffdf8;
  --sidebar-background: #f5eee3;
  --chat-background: #e9dfcf;
  --chat-pattern: rgba(133, 104, 67, 0.1);
  --chat-glow-one: rgba(255, 255, 255, 0.5);
  --chat-glow-two: rgba(164, 126, 77, 0.15);
  --text-primary: #40372b;
  --text-secondary: #847565;
  --border-color: #e4d8c7;
  --accent-color: #a47e55;
  --accent-color-dark: #7c5d3c;
  --accent-soft: #eee0cc;
  --own-message-background: #ead7bc;
  --partner-message-background: #fffdf8;
  --danger-color: #a94d4d;
  --danger-soft: #f3dddd;
  --surface-strong: #fffdf8;
  --surface-soft: rgba(255, 253, 248, 0.78);
  --surface-floating: rgba(255, 253, 248, 0.84);
  --surface-floating-strong: rgba(255, 253, 248, 0.97);
  --input-background: #fffdf8;
  --hover-background: #f2e9dc;
  --muted-button-background: #ece2d3;
  --date-background: rgba(255, 253, 248, 0.82);
  --shell-border: rgba(255, 255, 255, 0.8);
  --shadow-soft: 0 18px 45px rgba(76, 60, 39, 0.14);
}

:where(html, body)[data-theme="rose"] {
  --page-background: #eadfe1;
  --panel-background: #fffafb;
  --sidebar-background: #f5ebed;
  --chat-background: #eadbdd;
  --chat-pattern: rgba(128, 82, 91, 0.09);
  --chat-glow-one: rgba(255, 255, 255, 0.5);
  --chat-glow-two: rgba(155, 103, 114, 0.15);
  --text-primary: #423337;
  --text-secondary: #816f73;
  --border-color: #e2d2d6;
  --accent-color: #a16f7a;
  --accent-color-dark: #7d525d;
  --accent-soft: #eedde1;
  --own-message-background: #e7cfd5;
  --partner-message-background: #fffafb;
  --danger-color: #a64754;
  --danger-soft: #f4dfe3;
  --surface-strong: #fffafb;
  --surface-soft: rgba(255, 250, 251, 0.78);
  --surface-floating: rgba(255, 250, 251, 0.84);
  --surface-floating-strong: rgba(255, 250, 251, 0.97);
  --input-background: #fffafb;
  --hover-background: #f2e5e8;
  --muted-button-background: #ece0e3;
  --date-background: rgba(255, 250, 251, 0.82);
  --shell-border: rgba(255, 255, 255, 0.8);
  --shadow-soft: 0 18px 45px rgba(72, 47, 54, 0.14);
}

:where(html, body)[data-theme="night"] {
  color-scheme: dark;
  --page-background: #111820;
  --panel-background: #202a34;
  --sidebar-background: #26323d;
  --chat-background: #18232d;
  --chat-pattern: rgba(153, 182, 203, 0.11);
  --chat-glow-one: rgba(110, 153, 184, 0.16);
  --chat-glow-two: rgba(49, 87, 116, 0.38);
  --text-primary: #edf2f5;
  --text-secondary: #aab8c2;
  --border-color: #3a4854;
  --accent-color: #6f94ad;
  --accent-color-dark: #9fc0d3;
  --accent-soft: #324858;
  --own-message-background: #35566a;
  --partner-message-background: #2a3944;
  --danger-color: #ef9299;
  --danger-soft: #4a3035;
  --surface-strong: #2a3944;
  --surface-soft: rgba(42, 57, 68, 0.82);
  --surface-floating: rgba(38, 50, 61, 0.9);
  --surface-floating-strong: rgba(32, 42, 52, 0.97);
  --input-background: #2a3944;
  --hover-background: #354753;
  --muted-button-background: #3a4854;
  --date-background: rgba(42, 57, 68, 0.88);
  --shell-border: rgba(255, 255, 255, 0.08);
  --shadow-soft: 0 18px 48px rgba(0, 0, 0, 0.34);
}
* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
}

@supports (height: 100dvh) {
  :root {
    --app-viewport-height: 100dvh;
  }
}

body {
  min-width: 320px;
  margin: 0;
  padding: 16px;
  overflow: hidden;
  background: var(--page-background);
  color: var(--text-primary);
  font-family: Arial, sans-serif;
}

button,
select,
textarea {
  font: inherit;
}

button {
  border: none;
  cursor: pointer;
}

button:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(79, 127, 143, 0.28);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  width: min(1180px, 100%);
  height: calc(100vh - 32px);
  min-height: 560px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--panel-background);
  border: 1px solid var(--shell-border);
  border-radius: 22px;
  box-shadow: var(--shadow-soft);
}

.app-sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 22px 16px 16px;
  background: var(--sidebar-background);
  border-right: 1px solid var(--border-color);
}

.brand-block {
  display: grid;
  align-items: center;
  grid-template-columns:
    46px minmax(0, 1fr) auto;
  gap: 12px;
  padding: 0 8px 20px;
}

.brand-text {
  min-width: 0;
}

.sidebar-controls {
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 5px;
}

.sidebar-control-button,
.sidebar-open-button {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  padding: 0;
  border-radius: 9px;
  background: var(--hover-background);
  color: var(--accent-color-dark);
  font-size: 18px;
  font-weight: bold;
  line-height: 1;
}

.sidebar-control-button:hover,
.sidebar-open-button:hover {
  background: var(--accent-soft);
}

.brand-logo {
  display: grid;
  place-items: center;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border-radius: 15px;
  background: linear-gradient(145deg, #6e9eaa, #456f7d);
  box-shadow: 0 8px 18px rgba(61, 104, 118, 0.24);
  font-size: 25px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.1;
}

.brand-block p {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 13px;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--border-color);
  border-radius: 16px;
}

.profile-avatar,
.chat-list-avatar,
.chat-header-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: linear-gradient(145deg, #7aa6b1, #4f7f8f);
  color: #ffffff;
  font-weight: bold;
}

.profile-avatar {
  position: relative;
  flex: 0 0 52px;
  width: 52px;
  min-width: 52px;
  max-width: 52px;
  height: 52px;
  min-height: 52px;
  max-height: 52px;
  aspect-ratio: 1 / 1;
  padding: 0;
  overflow: visible;
  border: none;
  font-size: 20px;
  line-height: 0;
}

.profile-avatar:hover {
  box-shadow: 0 0 0 4px rgba(79, 127, 143, 0.16);
}

#profile-avatar-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
}

#chat-header-avatar-image {
  position: absolute;
  inset: -1px;
  display: block;
  width: calc(100% + 2px);
  height: calc(100% + 2px);
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  clip-path: circle(50% at 50% 50%);
}

#profile-avatar-image[hidden],
#profile-avatar-fallback[hidden],
#chat-header-avatar-image[hidden],
#chat-header-avatar-fallback[hidden] {
  display: none;
}

.profile-avatar-edit-mark {
  position: absolute;
  right: -4px;
  bottom: -4px;
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border: 2px solid var(--sidebar-background);
  border-radius: 50%;
  background: var(--accent-color-dark);
  color: #ffffff;
  font-size: 11px;
  line-height: 1;
}

.profile-controls {
  min-width: 0;
  flex: 1;
}

.profile-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.profile-summary-text {
  min-width: 0;
  flex: 1;
}

#profile-display-name {
  display: block;
  min-width: 0;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#profile-status {
  display: block;
  max-width: 100%;
  margin-top: 4px;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#profile-status[hidden] {
  display: none;
}

.profile-summary-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
}

.profile-edit-button {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--accent-color-dark);
  font-size: 17px;
  line-height: 1;
}

.profile-edit-button:hover {
  background: var(--accent-soft);
}

.profile-controls label {
  display: block;
  margin-bottom: 5px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: bold;
}

#user-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--text-primary);
  font-size: 15px;
}

.sidebar-section-title {
  padding: 0 8px 8px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
}

.chat-list-item {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 11px;
  padding: 11px 10px;
  border: none;
  border-radius: 14px;
  background: transparent;
  color: var(--text-primary);
  text-align: left;
}

.chat-list-item:hover {
  background: var(--surface-soft);
}

.chat-list-item-active,
.chat-list-item-active:hover {
  background: var(--accent-soft);
}

.chat-list-item-unread:not(.chat-list-item-active) {
  background: var(--surface-soft);
  box-shadow:
    inset 3px 0 0 var(--accent-color);
}

.chat-list-item-unread:not(.chat-list-item-active):hover {
  background: var(--surface-strong);
}

.chat-list-item:disabled {
  cursor: wait;
  opacity: 0.72;
}

.chat-list-avatar {
  position: relative;
  width: 46px;
  height: 46px;
  font-size: 18px;
}

.chat-list-avatar-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
}

.chat-list-item-direct .chat-list-avatar {
  box-shadow:
    0 0 0 2px var(--surface-strong),
    0 0 0 3px var(--accent-soft);
}

.chat-list-unread-badge-compact {
  display: none;
}

.chat-list-content {
  display: block;
  min-width: 0;
  flex: 1;
}

.chat-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  gap: 8px;
}

.chat-list-row strong {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-list-row > span,
.chat-list-preview {
  color: var(--text-secondary);
  font-size: 12px;
}

.chat-list-row > span {
  flex: 0 0 auto;
  white-space: nowrap;
}

.chat-list-time:empty {
  display: none;
}

.chat-list-unread-badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent-color);
  color: #ffffff;
  font-size: 11px;
  font-weight: bold;
  line-height: 1;
}

.chat-list-item-unread .chat-list-row strong,
.chat-list-item-unread .chat-list-preview {
  color: var(--text-primary);
  font-weight: bold;
}

.chat-list-preview {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer {
  padding: 14px 8px 0;
}

#connection-status,
#partner-status {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: bold;
}

.status-online {
  background: #dcefdc;
  color: #256029;
}

.status-offline {
  background: #f5dddd;
  color: #8b2e2e;
}

.chat-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: var(--panel-background);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 14px 20px;
  background: var(--surface-floating-strong);
  border-bottom: 1px solid var(--border-color);
}

.sidebar-open-button {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-size: 20px;
}

.sidebar-open-button[hidden] {
  display: none;
}

.chat-header-avatar {
  position: relative;
  flex: 0 0 48px;
  width: 48px;
  min-width: 48px;
  max-width: 48px;
  height: 48px;
  min-height: 48px;
  max-height: 48px;
  aspect-ratio: 1 / 1;
  padding: 0;
  overflow: hidden;
  border: none;
  border-radius: 50%;
  font-size: 18px;
  line-height: 0;
  cursor: default;
  transition:
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.chat-header-avatar:disabled {
  cursor: default;
  opacity: 1;
}

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

.chat-header-avatar-clickable:hover {
  box-shadow: 0 0 0 4px rgba(79, 127, 143, 0.16);
  transform: scale(1.03);
}

.chat-header-avatar::after,
.mobile-compact-chat-avatar::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 4;
  width: 11px;
  height: 11px;
  border: 2px solid var(--surface-floating-strong);
  border-radius: 50%;
  background: #99a5aa;
  box-shadow: 0 1px 4px rgba(15, 35, 43, 0.24);
  opacity: 0;
  pointer-events: none;
  transition:
    background 0.18s ease,
    opacity 0.18s ease,
    transform 0.18s ease;
  transform: scale(0.72);
}

.chat-header-avatar.avatar-presence-online::after,
.mobile-compact-chat-avatar.avatar-presence-online::after {
  background: #39b85a;
  opacity: 1;
  transform: scale(1);
}

.chat-header-avatar.avatar-presence-offline::after,
.mobile-compact-chat-avatar.avatar-presence-offline::after {
  background: #98a3a8;
  opacity: 1;
  transform: scale(1);
}

.mobile-room-switcher {
  display: none;
}

.chat-header-info {
  min-width: 0;
  flex: 1;
}

.chat-header-info h2 {
  font-size: 17px;
  line-height: 1.25;
}

.chat-header-statuses {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 27px;
  margin-top: 4px;
  overflow: hidden;
}

#partner-status {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-profile {
  background: var(--accent-soft);
  color: var(--accent-color-dark);
}

.status-typing {
  background: var(--accent-soft);
  color: var(--accent-color-dark);
}

.chat-header-room-actions {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 7px;
}

.chat-header-room-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 11px;
  background: var(--hover-background);
  color: var(--accent-color-dark);
  font-size: 23px;
  font-weight: bold;
  line-height: 1;
}

.chat-header-room-button:hover {
  background: var(--accent-soft);
}

.chat-header-room-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.message-search-toggle-button {
  font-size: 17px;
}

.message-search-toggle-button-active,
.message-search-toggle-button-active:hover {
  background: var(--accent-color);
  color: #ffffff;
}

.chat-workspace {
  position: relative;
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  isolation: isolate;
  background-color: var(--chat-background);
}

/*
  Единый фоновый слой сохраняет исходную высоту окна чата.
  Мобильная клавиатура закрывает его нижнюю часть, но не
  уменьшает и не масштабирует изображение заново.
*/
.chat-workspace::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  width: 100%;
  height: var(--chat-wallpaper-height, 100%);
  min-height: 100%;
  pointer-events: none;
  background-position: center;
  background-repeat: repeat;
  transform: translateZ(0);
  backface-visibility: hidden;
}

:where(html, body)[data-chat-background="bubbles"]
  .chat-workspace::before {
  background-image:
    radial-gradient(
      circle at 15px 15px,
      var(--chat-pattern) 2px,
      transparent 2px
    ),
    radial-gradient(
      circle at 45px 45px,
      var(--chat-pattern) 2px,
      transparent 2px
    );
  background-position: 0 0, 0 0;
  background-size: 60px 60px;
}

:where(html, body)[data-chat-background="waves"]
  .chat-workspace::before {
  background-image:
    radial-gradient(
      ellipse at 0 50%,
      transparent 0 18px,
      var(--chat-pattern) 19px 20px,
      transparent 21px
    ),
    radial-gradient(
      ellipse at 100% 50%,
      transparent 0 18px,
      var(--chat-pattern) 19px 20px,
      transparent 21px
    );
  background-position: 0 0, 26px 14px;
  background-size: 52px 28px;
}

:where(html, body)[data-chat-background="scales"]
  .chat-workspace::before {
  background-image:
    radial-gradient(
      circle at 50% 0,
      transparent 0 16px,
      var(--chat-pattern) 17px 18px,
      transparent 19px
    ),
    radial-gradient(
      circle at 50% 100%,
      transparent 0 16px,
      var(--chat-pattern) 17px 18px,
      transparent 19px
    );
  background-position: 0 0, 18px 18px;
  background-size: 36px 36px;
}

:where(html, body)[data-chat-background="mist"]
  .chat-workspace::before {
  background-image:
    radial-gradient(
      circle at 18% 22%,
      var(--chat-glow-one),
      transparent 36%
    ),
    radial-gradient(
      circle at 82% 72%,
      var(--chat-glow-two),
      transparent 42%
    );
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

:where(html, body)[data-chat-background="ripples"]
  .chat-workspace::before {
  background-image:
    repeating-radial-gradient(
      circle at 24px 24px,
      transparent 0 9px,
      var(--chat-pattern) 10px 11px,
      transparent 12px 24px
    );
  background-size: 48px 48px;
}

:where(html, body)[data-chat-background="current"]
  .chat-workspace::before {
  background-image:
    repeating-linear-gradient(
      145deg,
      transparent 0 18px,
      var(--chat-pattern) 19px 20px,
      transparent 21px 39px
    );
  background-size: 56px 56px;
}

:where(html, body)[data-chat-background="speckles"]
  .chat-workspace::before {
  background-image:
    radial-gradient(
      circle at 10px 14px,
      var(--chat-pattern) 1.5px,
      transparent 1.8px
    ),
    radial-gradient(
      circle at 31px 34px,
      var(--chat-pattern) 1px,
      transparent 1.4px
    ),
    radial-gradient(
      circle at 42px 9px,
      var(--chat-pattern) 1px,
      transparent 1.4px
    );
  background-size: 52px 44px;
}

:where(html, body)[data-chat-background="lights"]
  .chat-workspace::before {
  background-image:
    radial-gradient(
      circle at 20% 18%,
      var(--chat-glow-one),
      transparent 28%
    ),
    radial-gradient(
      circle at 76% 72%,
      var(--chat-glow-two),
      transparent 34%
    ),
    radial-gradient(
      circle at 52% 38%,
      var(--chat-pattern),
      transparent 18%
    );
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

:where(html, body)[data-chat-background="plain"]
  .chat-workspace::before {
  background-image: none;
}

:where(html, body)[data-chat-background="custom"]
  .chat-workspace::before {
  background-image:
    linear-gradient(
      rgb(
        0 0 0 /
        var(--custom-chat-background-overlay)
      ),
      rgb(
        0 0 0 /
        var(--custom-chat-background-overlay)
      )
    ),
    var(--custom-chat-background-image);
  background-position:
    center,
    center;
  background-repeat:
    no-repeat,
    no-repeat;
  background-size:
    100% 100%,
    var(--custom-chat-background-size);
  will-change: transform;
}

.chat-workspace > :not(.scroll-to-bottom-button) {
  position: relative;
  z-index: 1;
}

.message-search-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 14px 0;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--surface-floating-strong);
  box-shadow: 0 5px 16px rgba(44, 72, 82, 0.11);
}

.message-search-panel[hidden] {
  display: none;
}

.message-search-field {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--input-background);
}

.message-search-field > span {
  flex: 0 0 auto;
  font-size: 14px;
}

#message-search-input {
  min-width: 0;
  min-height: 36px;
  flex: 1;
  padding: 7px 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
}

#message-search-input::placeholder {
  color: var(--text-secondary);
}

.message-search-field:focus-within {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(79, 127, 143, 0.16);
}

.message-search-result {
  flex: 0 0 auto;
  min-width: 76px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: bold;
  text-align: center;
  white-space: nowrap;
}

.message-search-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 5px;
}

.message-search-actions button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 9px;
  background: var(--hover-background);
  color: var(--accent-color-dark);
  font-size: 18px;
  font-weight: bold;
  line-height: 1;
}

.message-search-actions button:hover:not(:disabled) {
  background: var(--accent-soft);
}

.message-search-actions button:disabled {
  cursor: default;
  opacity: 0.4;
}

#messages li.message-search-match {
  box-shadow:
    0 2px 6px rgba(41, 69, 79, 0.08),
    0 0 0 1px rgba(216, 155, 34, 0.52);
}

#messages li.message-search-current {
  outline: 3px solid var(--search-current-outline);
  outline-offset: 2px;
}

.message-search-highlight {
  padding: 0 2px;
  border-radius: 3px;
  background: var(--search-highlight-background);
  color: inherit;
}



.message-context-menu {
  position: fixed;
  z-index: 1600;
  display: flex;
  width: max-content;
  min-width: 205px;
  max-width: calc(100vw - 20px);
  padding: 7px;
  flex-direction: column;
  gap: 3px;
  border: 1px solid var(--border-color);
  border-radius: 15px;
  background: var(--surface-floating-strong);
  box-shadow: 0 12px 34px rgba(26, 47, 56, 0.28);
  backdrop-filter: blur(14px);
}

.message-context-menu[hidden] {
  display: none;
}

.message-context-reactions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 1px 1px 3px;
}

.message-context-reactions[hidden],
.message-context-reaction-more[hidden],
.message-context-reactions[hidden] +
  .message-context-reaction-separator {
  display: none;
}

.message-context-reaction-quick,
.message-context-reaction-more {
  display: grid;
  grid-template-columns: repeat(5, 38px);
  justify-content: center;
  gap: 4px;
}

.message-context-reaction-more {
  grid-template-columns: repeat(4, 38px);
  padding-top: 2px;
}

.message-context-reaction-button {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition:
    transform 0.14s ease,
    background 0.14s ease,
    border-color 0.14s ease;
}

.message-context-reaction-button:hover,
.message-context-reaction-button:focus-visible {
  background: var(--hover-background);
  transform: translateY(-1px);
}

.message-context-reaction-button.is-current {
  border-color: var(--accent-color);
  background: var(--accent-soft);
}

.message-context-reaction-more-toggle {
  color: var(--accent-color-dark);
  font-size: 24px;
  font-weight: 700;
}

.message-context-reaction-separator {
  margin-top: 1px;
}

.message-context-option {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 10px;
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.message-context-option:hover,
.message-context-option:focus-visible {
  background: var(--hover-background);
}

.message-context-separator {
  height: 1px;
  margin: 3px 5px;
  background: var(--border-color);
}

.message-context-separator[hidden],
.message-context-option[hidden] {
  display: none;
}

.message-context-danger {
  color: var(--danger-color);
}

#messages li.message-context-active {
  box-shadow:
    0 2px 6px rgba(41, 69, 79, 0.08),
    0 0 0 2px var(--accent-color);
}

#message-selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 14px 0;
  padding: 9px 11px;
  background: var(--surface-floating-strong);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 5px 16px rgba(44, 72, 82, 0.1);
}

#message-selection-bar[hidden] {
  display: none;
}

#message-selection-count {
  color: var(--accent-color-dark);
  font-size: 14px;
  font-weight: bold;
}

.message-selection-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  margin-left: auto;
}

#message-selection-bar button {
  padding: 7px 10px;
  border-radius: 9px;
  background: var(--accent-color);
  color: #ffffff;
  font-size: 13px;
}

#message-selection-select-all {
  background: var(--muted-button-background);
  color: var(--text-primary);
}

#message-selection-select-all:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--accent-color-dark);
}

#message-selection-delete-everyone {
  background: var(--danger-color);
}

#message-selection-bar button:disabled {
  background: #c3cdd1;
  color: #758289;
  cursor: default;
  opacity: 0.8;
}

#messages {
  min-height: 0;
  flex: 1;
  margin: 0;
  padding: 14px 18px 18px;
  overflow-y: auto;
  overflow-wrap: anywhere;
  list-style: none;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#messages::-webkit-scrollbar,
#message-input::-webkit-scrollbar,
.chat-list::-webkit-scrollbar {
  display: none;
}

.scroll-to-bottom-button {
  position: absolute;
  right: 24px;
  bottom: 88px;
  z-index: 45;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  background: var(--surface-floating-strong);
  color: var(--accent-color-dark);
  box-shadow: 0 7px 22px rgba(32, 58, 68, 0.2);
  font-size: 25px;
  font-weight: bold;
  line-height: 1;
}

.scroll-to-bottom-icon {
  display: block;
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: translateY(1px);
}

.scroll-to-bottom-button:hover {
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.scroll-to-bottom-button[hidden] {
  display: none;
}

#messages li {
  position: relative;
  width: fit-content;
  max-width: min(76%, 620px);
  margin-bottom: var(--message-spacing);
  padding: 9px 38px 8px 12px;
  overflow: visible;
  border-radius: var(--message-bubble-radius);
  font-family: var(--chat-message-font-family);
  font-size: var(--chat-message-font-size);
  box-shadow: 0 2px 6px rgba(41, 69, 79, 0.08);
  line-height: 1.4;
  white-space: pre-wrap;
}

#messages li.chat-empty-state {
  width: fit-content;
  max-width: min(88%, 430px);
  margin: 42px auto;
  padding: 10px 14px;
  background: var(--date-background);
  color: var(--text-secondary);
  border-radius: 999px;
  box-shadow: 0 3px 12px rgba(41, 69, 79, 0.08);
  font-size: 13px;
  text-align: center;
}

#messages li.message-anna,
#messages li.message-husband {
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

#messages li.message-anna {
  margin-left: auto;
  background: var(--own-message-background);
  background:
    color-mix(
      in srgb,
      var(--own-message-background)
        var(--own-message-opacity-percent),
      transparent
    );
  border: 1px solid
    color-mix(
      in srgb,
      var(--own-message-background)
        var(--own-message-opacity-percent),
      transparent
    );
  border-bottom-right-radius:
    var(--message-bubble-tail-radius);
}

#messages li.message-husband {
  margin-right: auto;
  background: var(--partner-message-background);
  background:
    color-mix(
      in srgb,
      var(--partner-message-background)
        var(--own-message-opacity-percent),
      transparent
    );
  border: 1px solid
    color-mix(
      in srgb,
      var(--partner-message-background)
        var(--own-message-opacity-percent),
      transparent
    );
  border-bottom-left-radius:
    var(--message-bubble-tail-radius);
}

.date-divider {
  width: fit-content;
  margin: 14px auto 10px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--date-background);
  color: var(--text-secondary);
  box-shadow: 0 2px 8px rgba(44, 72, 82, 0.08);
  font-size: 12px;
  font-weight: bold;
  text-align: center;
}

#messages > .date-divider:first-child {
  margin-top: 0;
}

.message-author {
  margin-bottom: 3px;
  color: var(--message-author-color);
  font-size: 12px;
  font-weight: bold;
}

.message-forwarded-label {
  margin-bottom: 4px;
  color: var(--accent-color-dark);
  font-size: 11px;
  font-style: italic;
  font-weight: bold;
}

.message-reply-reference {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  margin: 1px 0 7px;
  padding: 6px 9px 6px 11px;
  overflow: hidden;
  border: none;
  border-left: 3px solid var(--accent-color-dark);
  border-radius: 7px;
  background: var(--accent-soft);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.message-reply-reference:hover,
.message-reply-reference:focus-visible {
  background: var(--hover-background);
}

.message-reply-author,
.message-reply-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-reply-author {
  color: var(--accent-color-dark);
  font-size: 12px;
  font-weight: 800;
}

.message-reply-text {
  margin-top: 1px;
  color: var(--text-secondary);
  font-size: 12px;
}

#messages li.message-reply-target-highlight {
  animation: message-reply-target-pulse 1.7s ease;
}

@keyframes message-reply-target-pulse {
  0%, 100% {
    box-shadow: var(--shadow-soft);
  }

  35% {
    box-shadow:
      0 0 0 4px var(--accent-soft),
      var(--shadow-soft);
  }
}

#messages li.message-gallery-return-highlight {
  animation: message-gallery-return-pulse 1.7s ease;
}

@keyframes message-gallery-return-pulse {
  0%, 100% {
    box-shadow: 0 2px 6px rgba(41, 69, 79, 0.08);
  }

  35% {
    box-shadow:
      0 0 0 4px var(--accent-soft),
      0 5px 18px rgba(41, 69, 79, 0.16);
  }
}

.message-text {
  color: var(--message-text-color);
  line-height: 1.4;
  white-space: pre-wrap;
}

.message-time {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 10px;
  line-height: 1;
  text-align: right;
}

.message-edited-status {
  margin-left: 5px;
  font-size: 10px;
  font-style: italic;
}

.message-read-status {
  margin-left: 5px;
  color: var(--accent-color-dark);
  font-size: 11px;
  font-weight: bold;
}

.message-reactions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 6px;
}

.message-husband .message-reactions {
  justify-content: flex-start;
}

.message-reaction-pill {
  display: inline-flex;
  min-width: 38px;
  height: 27px;
  padding: 2px 7px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--surface-floating);
  color: var(--text-primary);
  line-height: 1;
  cursor: pointer;
}

.message-reaction-pill:hover,
.message-reaction-pill:focus-visible {
  background: var(--hover-background);
}

.message-reaction-pill.is-mine {
  border-color: var(--accent-color);
  background: var(--accent-soft);
}

.message-reaction-emoji {
  font-size: 17px;
}

.message-reaction-count {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 800;
}

.message-image {
  display: block;
  width: min(340px, 62vw);
  max-width: 100%;
  max-height: 430px;
  margin-top: 6px;
  border-radius: 11px;
  object-fit: contain;
  cursor: zoom-in;
}

.message-smiley {
  width: auto;
  height: 52px;
  max-width: 128px;
  max-height: 72px;
  margin: 5px auto 1px;
  border-radius: 0;
  object-fit: contain;
  cursor: default;
}

.message-sticker {
  width: 156px;
  max-width: min(44vw, 180px);
  height: auto;
  max-height: 180px;
  margin: 3px auto 1px;
  border-radius: 0;
  object-fit: contain;
  cursor: default;
}

#messages li.message-with-smiley {
  min-width: 92px;
}

#messages li.message-with-sticker {
  min-width: 174px;
  padding-top: 7px;
}

.message-delete-area {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 20;
}

.message-delete-button {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  font-size: 21px;
  line-height: 1;
  opacity: 0.62;
}

.message-delete-button:hover,
.message-delete-button:focus,
.message-delete-button[aria-expanded="true"] {
  background: rgba(79, 127, 143, 0.13);
  color: var(--accent-color-dark);
  opacity: 1;
}

.message-delete-menu {
  position: absolute;
  top: 30px;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: max-content;
  min-width: 165px;
  padding: 6px;
  background: var(--surface-strong);
  border: 1px solid var(--border-color);
  border-radius: 11px;
  box-shadow: 0 9px 25px rgba(32, 58, 68, 0.19);
}

.message-delete-menu[hidden] {
  display: none;
}

.message-delete-option {
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
}

.message-delete-option:hover {
  background: var(--hover-background);
}

.message-delete-everyone {
  color: var(--danger-color);
}

.message-husband .message-delete-menu {
  right: auto;
  left: 0;
}

.message-selection-checkbox {
  position: absolute;
  top: 10px;
  left: 10px;
  display: none;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent-color);
  cursor: pointer;
}

#messages.message-selection-mode li {
  padding-left: 40px;
  cursor: pointer;
}

#messages.message-selection-mode .message-selection-checkbox {
  display: block;
}

#messages.message-selection-mode .message-delete-area {
  display: none;
}

#messages.message-selection-mode li.message-selected {
  box-shadow: 0 0 0 2px var(--accent-color);
}

.composer-area {
  position: relative;
  padding: 0 14px 14px;
}

.smiley-picker-anchor {
  position: relative;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
}

#smiley-picker {
  position: absolute;
  right: -49px;
  bottom: calc(100% + 10px);
  z-index: 140;
  display: flex;
  width: var(
    --smiley-picker-desktop-width,
    min(560px, calc(100vw - 32px))
  );
  max-height: min(430px, 54vh);
  overflow: hidden;
  flex-direction: column;
  background: var(--surface-strong);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 14px 38px rgba(32, 58, 68, 0.24);
}

#smiley-picker[hidden] {
  display: none;
}

.smiley-picker-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 6px;
  border-bottom: 1px solid var(--border-color);
}

.smiley-picker-categories {
  display: flex;
  min-width: 0;
  flex: 1;
  gap: 5px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  touch-action: pan-x;
}

.smiley-picker-categories::-webkit-scrollbar,
.smiley-grid::-webkit-scrollbar {
  display: none;
}

.smiley-category-button {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 9px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: bold;
  white-space: nowrap;
}

.smiley-category-button:hover,
.smiley-category-button-active {
  background: var(--accent-soft);
  color: var(--accent-color-dark);
}

.smiley-picker-close {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 24px;
  line-height: 1;
}

.smiley-picker-close:hover {
  background: var(--hover-background);
  color: var(--text-primary);
}

.smiley-grid {
  display: grid;
  min-height: 190px;
  padding: 8px;
  overflow-y: auto;
  grid-template-columns:
    repeat(auto-fill, minmax(54px, 1fr));
  gap: 5px;
  scrollbar-width: none;
  overscroll-behavior: contain;
}

.smiley-grid.smiley-grid-emojis {
  grid-template-columns:
    repeat(auto-fill, minmax(52px, 1fr));
}

.smiley-grid.smiley-grid-stickers {
  grid-template-columns:
    repeat(auto-fill, minmax(90px, 1fr));
  gap: 7px;
}

.smiley-option {
  display: grid;
  place-items: center;
  min-height: 54px;
  padding: 4px;
  border-radius: 11px;
  background: transparent;
  color: var(--text-primary);
}

.smiley-option:hover,
.smiley-option:focus-visible {
  background: var(--hover-background);
}

.smiley-emoji-option {
  font-size: 29px;
  line-height: 1;
}

.smiley-option img {
  display: block;
  max-width: 48px;
  max-height: 48px;
  object-fit: contain;
  pointer-events: none;
}

.smiley-option.sticker-option {
  min-height: 92px;
  padding: 5px;
}

.smiley-option.sticker-option img {
  width: 84px;
  max-width: 100%;
  height: 84px;
  max-height: 84px;
}

.smiley-picker-message {
  grid-column: 1 / -1;
  align-self: center;
  padding: 24px 12px;
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
}

.smiley-picker-error {
  color: var(--danger-color);
}

.smiley-picker-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  gap: 10px;
  padding: 6px 8px;
  border-top: 1px solid var(--border-color);
  background: var(--surface-floating-strong);
}

.smiley-picker-modes {
  display: flex;
  align-items: center;
  gap: 4px;
}

.smiley-picker-mode-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 10px;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: bold;
}

.smiley-picker-mode-button:hover,
.smiley-picker-mode-button-active {
  background: var(--accent-soft);
  color: var(--accent-color-dark);
}

.smiley-picker-mode-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.smiley-picker-credit {
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 10px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-composer-preview {
  display: grid;
  grid-template-columns: 3px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 9px;
  margin: 0 0 6px;
  padding: 7px 8px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--surface-floating-strong);
  box-shadow: var(--shadow-soft);
}

.reply-composer-preview[hidden] {
  display: none;
}

.edit-composer-preview {
  border-color: var(--accent-color);
}

.edit-composer-preview .reply-composer-accent {
  background: var(--accent-color);
}

.reply-composer-accent {
  align-self: stretch;
  border-radius: 999px;
  background: var(--accent-color-dark);
}

.reply-composer-content {
  min-width: 0;
}

#reply-composer-author,
#reply-composer-text,
#edit-composer-title,
#edit-composer-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#reply-composer-author,
#edit-composer-title {
  color: var(--accent-color-dark);
  font-size: 12px;
  font-weight: 800;
}

#reply-composer-text,
#edit-composer-text {
  margin-top: 1px;
  color: var(--text-secondary);
  font-size: 12px;
}

#reply-composer-cancel,
#edit-composer-cancel {
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
}

#reply-composer-cancel:hover,
#reply-composer-cancel:focus-visible,
#edit-composer-cancel:hover,
#edit-composer-cancel:focus-visible {
  background: var(--accent-soft);
  color: var(--text-primary);
}

#selected-image-preview {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 8px auto;
  padding: 6px;
  background: var(--surface-strong);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 7px 22px rgba(32, 58, 68, 0.13);
}

#selected-image-preview[hidden] {
  display: none;
}

#selected-image-preview-image {
  display: block;
  width: auto;
  max-width: min(220px, 60vw);
  max-height: 180px;
  border-radius: 9px;
  object-fit: contain;
}

#selected-image-preview-image.selected-smiley-preview {
  min-width: 64px;
  max-width: 128px;
  height: 64px;
  border-radius: 0;
}

#selected-image-preview-image.selected-sticker-preview {
  width: 126px;
  max-width: min(42vw, 150px);
  height: 126px;
  max-height: 150px;
  border-radius: 0;
}

#selected-image-remove {
  position: absolute;
  top: -9px;
  right: -9px;
  width: 29px;
  height: 29px;
  padding: 0;
  border-radius: 50%;
  background: var(--accent-color-dark);
  color: #ffffff;
  font-size: 20px;
  line-height: 1;
}

#message-form {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  padding: 8px;
  background: var(--surface-floating-strong);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  box-shadow: 0 7px 22px rgba(32, 58, 68, 0.13);
}

#message-input {
  min-width: 0;
  max-height: 120px;
  flex: 1;
  padding: 10px 8px;
  overflow-y: auto;
  resize: none;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#message-input::placeholder {
  color: #8a9aa0;
}

#message-input:focus {
  outline: none;
}

#smiley-button,
#image-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-secondary);
}

#smiley-button {
  width: 100%;
  height: 100%;
}

#smiley-button:hover,
#image-button:hover {
  background: var(--hover-background);
  color: var(--accent-color-dark);
}

#smiley-button[aria-expanded="true"],
#smiley-button.smiley-button-selected {
  background: var(--accent-soft);
  color: var(--accent-color-dark);
  box-shadow: inset 0 0 0 2px var(--accent-color);
}

.smiley-button-icon {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.smiley-button-icon path:last-child {
  stroke-width: 2.6;
}

.attachment-icon-outline,
.attachment-selected-icon {
  display: grid;
  place-items: center;
}

.attachment-icon-outline svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.attachment-icon-mobile,
.attachment-selected-icon {
  display: none;
}

.attachment-selected-icon {
  font-size: 22px;
  font-weight: bold;
  line-height: 1;
}

#image-button.image-button-selected {
  background: var(--accent-soft);
  color: var(--accent-color-dark);
  box-shadow: inset 0 0 0 2px var(--accent-color);
}

#image-button.image-button-selected
  .attachment-icon-outline,
#image-button.image-button-selected
  .attachment-icon-mobile {
  display: none;
}

#image-button.image-button-selected
  .attachment-selected-icon {
  display: grid;
}

#smiley-button:disabled,
#image-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.send-button {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  min-width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  border-radius: 12px;
  background: var(--accent-color);
  color: #ffffff;
  font-size: 14px;
  font-weight: bold;
}

.send-button:hover {
  background: var(--accent-color-dark);
}

.send-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.send-button-text {
  display: none;
}

.send-button-icon {
  font-size: 18px;
  line-height: 1;
}

.profile-dialog {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(9, 17, 20, 0.58);
}

.profile-dialog[hidden] {
  display: none;
}

.profile-dialog-card {
  width: min(430px, 100%);
  padding: 20px;
  background: var(--surface-strong);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  box-shadow: 0 20px 55px rgba(9, 28, 35, 0.28);
}

.profile-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.profile-dialog-header h2 {
  font-size: 20px;
}

.profile-dialog-header p {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.4;
}

.profile-dialog-close {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  background: var(--hover-background);
  color: var(--text-secondary);
  font-size: 24px;
  line-height: 1;
}

.profile-dialog-card > label {
  display: block;
  margin-bottom: 7px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: bold;
}

#profile-name-input,
#profile-status-input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border-color);
  border-radius: 11px;
  background: var(--surface-strong);
  color: var(--text-primary);
  font: inherit;
}

#profile-status-input {
  margin-bottom: 0;
}

#profile-name-input:focus,
#profile-status-input:focus {
  border-color: var(--accent-color);
  outline: 3px solid rgba(79, 127, 143, 0.18);
}

.profile-dialog-card > label[for="profile-status-input"] {
  margin-top: 14px;
}

.profile-status-note {
  margin-top: 7px;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.4;
}

.profile-name-error {
  min-height: 20px;
  margin-top: 7px;
  color: var(--danger-color);
  font-size: 12px;
}

.profile-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 10px;
}

.profile-dialog-actions button {
  min-height: 39px;
  padding: 0 15px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: bold;
}

.profile-dialog-cancel {
  background: var(--muted-button-background);
  color: var(--text-primary);
}

.profile-dialog-save {
  background: var(--accent-color);
  color: #ffffff;
}

.profile-dialog-save:hover {
  background: var(--accent-color-dark);
}

.profile-dialog-actions button:disabled,
.profile-dialog-close:disabled {
  cursor: default;
  opacity: 0.6;
}

.profile-avatar-editor {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 6px 0 4px;
}

.profile-avatar-preview {
  display: grid;
  place-items: center;
  flex: 0 0 116px;
  width: 116px;
  height: 116px;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(145deg, #7aa6b1, #4f7f8f);
  color: #ffffff;
  box-shadow: 0 10px 25px rgba(32, 58, 68, 0.18);
  font-size: 42px;
  font-weight: bold;
}

#profile-avatar-preview-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#profile-avatar-preview-image[hidden],
#profile-avatar-preview-fallback[hidden] {
  display: none;
}

.profile-avatar-editor-controls {
  min-width: 0;
  flex: 1;
}

.profile-avatar-choose {
  min-height: 40px;
  padding: 0 15px;
  border-radius: 10px;
  background: var(--accent-color);
  color: #ffffff;
  font-size: 14px;
  font-weight: bold;
}

.profile-avatar-choose:hover {
  background: var(--accent-color-dark);
}

.profile-avatar-editor-controls p {
  margin-top: 9px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
}

.profile-avatar-actions {
  align-items: center;
}

.profile-avatar-remove {
  margin-right: auto;
  background: var(--danger-soft);
  color: var(--danger-color);
}

.profile-avatar-remove:disabled,
.profile-avatar-choose:disabled {
  cursor: default;
  opacity: 0.55;
}

.appearance-dialog-card {
  width: min(650px, 100%);
  max-height: calc(100vh - 36px);
  overflow-y: auto;
}

.appearance-section + .appearance-section {
  margin-top: 20px;
}

.appearance-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.appearance-options {
  display: grid;
  grid-template-columns:
    repeat(auto-fit, minmax(106px, 1fr));
  gap: 9px;
}

.appearance-option {
  display: flex;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  flex-direction: column;
  gap: 7px;
  background: var(--surface-strong);
  color: var(--text-primary);
  text-align: left;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.appearance-option:hover {
  border-color: var(--accent-color);
  transform: translateY(-1px);
}

.appearance-option-selected {
  border-color: var(--accent-color);
  box-shadow:
    0 0 0 2px var(--accent-soft);
}

.appearance-option strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-preview,
.background-preview {
  display: block;
  width: 100%;
  height: 50px;
  overflow: hidden;
  border-radius: 9px;
}

.theme-preview {
  display: grid;
  padding: 7px;
  grid-template-columns: 30% 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 5px;
}

.theme-preview i {
  display: block;
  border-radius: 5px;
}

.theme-preview i:first-child {
  grid-row: 1 / 3;
}

.theme-preview-aquarium {
  background: #dbe7eb;
}

.theme-preview-aquarium i:first-child {
  background: #eef4f6;
}

.theme-preview-aquarium i:nth-child(2) {
  background: #ffffff;
}

.theme-preview-aquarium i:nth-child(3) {
  background: #cfe5ec;
}

.theme-preview-ocean {
  background: #0b2028;
}

.theme-preview-ocean i:first-child {
  background: #132b34;
}

.theme-preview-ocean i:nth-child(2) {
  background: #183640;
}

.theme-preview-ocean i:nth-child(3) {
  background: #1c5260;
}

.theme-preview-coral {
  background: #f1dfd5;
}

.theme-preview-coral i:first-child {
  background: #f8eee8;
}

.theme-preview-coral i:nth-child(2) {
  background: #fffaf7;
}

.theme-preview-coral i:nth-child(3) {
  background: #f1cfc1;
}

.theme-preview-lavender {
  background: #e5def0;
}

.theme-preview-lavender i:first-child {
  background: #f1edf7;
}

.theme-preview-lavender i:nth-child(2) {
  background: #fdfbff;
}

.theme-preview-lavender i:nth-child(3) {
  background: #dcd0eb;
}

.theme-preview-graphite {
  background: #d9dee1;
}

.theme-preview-graphite i:first-child {
  background: #eaedef;
}

.theme-preview-graphite i:nth-child(2) {
  background: #f8f9fa;
}

.theme-preview-graphite i:nth-child(3) {
  background: #ced9df;
}

.theme-preview-sage {
  background: #dce6d8;
}

.theme-preview-sage i:first-child {
  background: #edf2e9;
}

.theme-preview-sage i:nth-child(2) {
  background: #fbfcf8;
}

.theme-preview-sage i:nth-child(3) {
  background: #d2e3cc;
}

.theme-preview-sand {
  background: #e9dfcf;
}

.theme-preview-sand i:first-child {
  background: #f5eee3;
}

.theme-preview-sand i:nth-child(2) {
  background: #fffdf8;
}

.theme-preview-sand i:nth-child(3) {
  background: #ead7bc;
}

.theme-preview-rose {
  background: #eadbdd;
}

.theme-preview-rose i:first-child {
  background: #f5ebed;
}

.theme-preview-rose i:nth-child(2) {
  background: #fffafb;
}

.theme-preview-rose i:nth-child(3) {
  background: #e7cfd5;
}

.theme-preview-night {
  background: #18232d;
}

.theme-preview-night i:first-child {
  background: #26323d;
}

.theme-preview-night i:nth-child(2) {
  background: #2a3944;
}

.theme-preview-night i:nth-child(3) {
  background: #35566a;
}

.background-preview {
  background-color: var(--chat-background);
}

.background-preview-bubbles {
  background-image:
    radial-gradient(
      circle at 12px 12px,
      var(--chat-pattern) 2px,
      transparent 2px
    ),
    radial-gradient(
      circle at 34px 34px,
      var(--chat-pattern) 2px,
      transparent 2px
    );
  background-size: 46px 46px;
}

.background-preview-waves {
  background-image:
    radial-gradient(
      ellipse at 0 50%,
      transparent 0 14px,
      var(--chat-pattern) 15px 16px,
      transparent 17px
    ),
    radial-gradient(
      ellipse at 100% 50%,
      transparent 0 14px,
      var(--chat-pattern) 15px 16px,
      transparent 17px
    );
  background-position: 0 0, 22px 12px;
  background-size: 44px 24px;
}

.background-preview-scales {
  background-image:
    radial-gradient(
      circle at 50% 0,
      transparent 0 12px,
      var(--chat-pattern) 13px 14px,
      transparent 15px
    ),
    radial-gradient(
      circle at 50% 100%,
      transparent 0 12px,
      var(--chat-pattern) 13px 14px,
      transparent 15px
    );
  background-position: 0 0, 15px 15px;
  background-size: 30px 30px;
}

.background-preview-mist {
  background-image:
    radial-gradient(
      circle at 20% 22%,
      var(--chat-glow-one),
      transparent 40%
    ),
    radial-gradient(
      circle at 80% 74%,
      var(--chat-glow-two),
      transparent 46%
    );
}

.background-preview-ripples {
  background-image:
    repeating-radial-gradient(
      circle at 18px 18px,
      transparent 0 7px,
      var(--chat-pattern) 8px 9px,
      transparent 10px 18px
    );
  background-size: 36px 36px;
}

.background-preview-current {
  background-image:
    repeating-linear-gradient(
      145deg,
      transparent 0 12px,
      var(--chat-pattern) 13px 14px,
      transparent 15px 27px
    );
  background-size: 40px 40px;
}

.background-preview-speckles {
  background-image:
    radial-gradient(
      circle at 8px 10px,
      var(--chat-pattern) 1.4px,
      transparent 1.7px
    ),
    radial-gradient(
      circle at 24px 27px,
      var(--chat-pattern) 1px,
      transparent 1.3px
    ),
    radial-gradient(
      circle at 34px 7px,
      var(--chat-pattern) 1px,
      transparent 1.3px
    );
  background-size: 42px 34px;
}

.background-preview-lights {
  background-image:
    radial-gradient(
      circle at 18% 20%,
      var(--chat-glow-one),
      transparent 35%
    ),
    radial-gradient(
      circle at 78% 72%,
      var(--chat-glow-two),
      transparent 42%
    );
}

.background-preview-plain {
  background-image: none;
}

.background-preview-custom {
  position: relative;
  display: grid;
  place-items: center;
  background:
    linear-gradient(
      135deg,
      var(--surface-soft),
      var(--chat-background)
    );
  color: var(--accent-color-dark);
  font-size: 29px;
  font-weight: normal;
}

.background-preview-custom img {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.background-preview-custom img[hidden],
#profile-custom-background-option-fallback[hidden] {
  display: none;
}

.custom-background-controls {
  margin-top: 12px;
  padding: 13px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--surface-soft);
}

.custom-background-controls[hidden] {
  display: none;
}

.custom-background-editor {
  display: grid;
  grid-template-columns:
    minmax(190px, 1.2fr)
    minmax(170px, 0.8fr);
  gap: 13px;
}

.custom-background-preview {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 145px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--chat-background);
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
}

#profile-custom-background-preview-image {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#profile-custom-background-preview-image[hidden],
#profile-custom-background-preview-fallback[hidden] {
  display: none;
}

.background-preview-custom.custom-background-has-image::after,
.custom-background-preview.custom-background-has-image::after {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: rgb(
    0 0 0 /
    var(--custom-background-preview-overlay, 0.18)
  );
  content: "";
  pointer-events: none;
}

.background-preview-custom.custom-background-has-image::before,
.custom-background-preview.custom-background-has-image::before {
  position: absolute;
  right: 7px;
  bottom: 7px;
  z-index: 3;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.58);
  color: #ffffff;
  content: attr(data-overlay-label);
  font-size: 10px;
  font-weight: bold;
  line-height: 1;
  pointer-events: none;
}

.custom-background-editor-actions {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 8px;
}

.custom-background-editor-actions button {
  width: 100%;
}

.profile-custom-background-remove {
  min-height: 40px;
  padding: 0 13px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger-color);
  font-size: 13px;
  font-weight: bold;
}

.profile-custom-background-remove:disabled {
  cursor: default;
  opacity: 0.5;
}

.custom-background-editor-actions p {
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.45;
}

.custom-background-fit {
  display: grid;
  margin: 14px 0 0;
  padding: 0;
  border: none;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.custom-background-fit legend {
  grid-column: 1 / -1;
  margin-bottom: 8px;
  padding: 0;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: bold;
}

.custom-background-fit label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 11px;
  background: var(--surface-strong);
  cursor: pointer;
}

.custom-background-fit input {
  flex: 0 0 auto;
  margin-top: 2px;
  accent-color: var(--accent-color);
}

.custom-background-fit span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.custom-background-fit strong {
  font-size: 12px;
}

.custom-background-fit small {
  color: var(--text-secondary);
  font-size: 10px;
  line-height: 1.35;
}

.custom-background-overlay {
  display: block;
  margin-top: 14px;
}

.custom-background-overlay > span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: bold;
}

#profile-custom-background-overlay-value {
  color: var(--accent-color-dark);
}

#profile-custom-background-overlay {
  width: 100%;
  accent-color: var(--accent-color);
}

.message-transparency-control {
  display: block;
}

.message-transparency-control > span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: bold;
}

#profile-own-message-transparency-value {
  color: var(--accent-color-dark);
}

#profile-own-message-transparency {
  width: 100%;
  accent-color: var(--accent-color);
}

.message-transparency-preview {
  display: flex;
  min-height: 112px;
  margin-top: 12px;
  padding: 12px;
  overflow: hidden;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border-color);
  border-radius: 13px;
  background:
    radial-gradient(
      circle at 14px 14px,
      var(--chat-pattern) 2px,
      transparent 2px
    );
  background-color: var(--chat-background);
  background-size: 42px 42px;
}

.message-transparency-preview-bubble {
  max-width: 78%;
  padding: 9px 12px;
  color: var(--text-primary);
  box-shadow: 0 2px 6px rgba(41, 69, 79, 0.08);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  font-size: 13px;
}

.message-transparency-preview-partner {
  align-self: flex-start;
  border: 1px solid
    color-mix(
      in srgb,
      var(--partner-message-background)
        var(--own-message-opacity-percent),
      transparent
    );
  border-radius: 14px 14px 14px 5px;
  background: var(--partner-message-background);
  background:
    color-mix(
      in srgb,
      var(--partner-message-background)
        var(--own-message-opacity-percent),
      transparent
    );
}

.message-transparency-preview-own {
  align-self: flex-end;
  border: 1px solid
    color-mix(
      in srgb,
      var(--own-message-background)
        var(--own-message-opacity-percent),
      transparent
    );
  border-radius: 14px 14px 5px 14px;
  background: var(--own-message-background);
  background:
    color-mix(
      in srgb,
      var(--own-message-background)
        var(--own-message-opacity-percent),
      transparent
    );
}

.appearance-section-note {
  margin-top: 9px;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.4;
}

.appearance-room-note {
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
}

.appearance-room-note[hidden] {
  display: none;
}

.appearance-section-unavailable
  .appearance-background-options,
.appearance-section-unavailable
  .message-transparency-control,
.appearance-section-unavailable
  .message-transparency-preview {
  opacity: 0.52;
}

.appearance-section-unavailable
  .appearance-background-option,
.appearance-section-unavailable
  .message-transparency-control {
  cursor: not-allowed;
}

.contacts-dialog-card {
  width: min(560px, 100%);
  max-height: min(720px, calc(100vh - 36px));
}

.contacts-list {
  display: flex;
  min-height: 0;
  max-height: min(430px, 52vh);
  padding: 2px;
  overflow-y: auto;
  flex-direction: column;
  gap: 7px;
}

.contact-list-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 68px;
  gap: 12px;
  padding: 10px 11px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--text-primary);
  text-align: left;
}

.contact-list-item:hover:not(:disabled),
.contact-list-item:focus-visible {
  border-color: var(--accent-color);
  background: var(--accent-soft);
}

.contact-list-item:disabled {
  cursor: wait;
  opacity: 0.68;
}

.contact-list-avatar {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  overflow: hidden;
  border-radius: 50%;
  background:
    linear-gradient(
      145deg,
      #7aa6b1,
      #4f7f8f
    );
  color: #ffffff;
  font-size: 18px;
  font-weight: bold;
}

.contact-list-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.contact-list-text {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 4px;
}

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

.contact-list-text strong {
  font-size: 15px;
}

.contact-list-text small {
  color: var(--text-secondary);
  font-size: 12px;
}

.contact-list-action {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--accent-color-dark);
  font-size: 11px;
  font-weight: bold;
  white-space: nowrap;
}

.contacts-empty {
  padding: 24px 12px;
  color: var(--text-secondary);
  text-align: center;
}

.contacts-empty[hidden] {
  display: none;
}

.contacts-dialog-actions {
  justify-content: space-between;
}

.contacts-dialog-actions
  #contacts-open-group-create[hidden] {
  display: none;
}

.room-dialog-card {
  width: min(460px, 100%);
}

.room-title-input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border-color);
  border-radius: 11px;
  background: var(--surface-strong);
  color: var(--text-primary);
  font: inherit;
}

.room-title-input:focus {
  border-color: var(--accent-color);
  outline: 3px solid rgba(79, 127, 143, 0.18);
}

.room-protected-note {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
}

.room-protected-note[hidden] {
  display: none;
}

.room-settings-actions {
  align-items: center;
}

.room-delete-button {
  margin-right: auto;
  background: var(--danger-soft);
  color: var(--danger-color);
}

.room-delete-button:hover:not(:disabled) {
  filter: brightness(0.97);
}

.room-delete-button:disabled {
  cursor: default;
  opacity: 0.5;
}


.message-forward-dialog-card {
  width: min(520px, 100%);
  max-height: calc(100vh - 36px);
  overflow: hidden;
}

.message-forward-select-all {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
}

.message-forward-select-all input,
.message-forward-room-option input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent-color);
  cursor: pointer;
}

.message-forward-room-list {
  display: flex;
  max-height: min(410px, 48vh);
  padding: 2px;
  overflow-y: auto;
  flex-direction: column;
  gap: 7px;
  scrollbar-width: thin;
}

.message-forward-room-option {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 11px;
  border: 1px solid var(--border-color);
  border-radius: 13px;
  background: var(--surface-strong);
  cursor: pointer;
  transition:
    border-color 0.16s ease,
    background 0.16s ease;
}

.message-forward-room-option:hover {
  border-color: var(--accent-color);
  background: var(--hover-background);
}

.message-forward-room-option:has(input:checked) {
  border-color: var(--accent-color);
  background: var(--accent-soft);
}

.message-forward-room-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(145deg, #7aa6b1, #4f7f8f);
  color: #ffffff;
  font-size: 15px;
  font-weight: bold;
}

.message-forward-room-text {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 3px;
}

.message-forward-room-text strong,
.message-forward-room-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-forward-room-text strong {
  color: var(--text-primary);
  font-size: 14px;
}

.message-forward-room-text small {
  color: var(--text-secondary);
  font-size: 11px;
}

#image-viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 70px 20px 90px;
  overflow: auto;
  overscroll-behavior: contain;
  background: rgba(9, 17, 20, 0.9);
}

#image-viewer[hidden] {
  display: none;
}

#image-viewer.image-viewer-has-thumbnails {
  padding-top: 98px;
}

.image-viewer-thumbnails {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: 64px;
  left: 64px;
  z-index: 1003;
  width: min(
    760px,
    calc(100vw - 128px),
    var(--image-viewer-thumbnail-width, 760px)
  );
  height: 64px;
  margin: 0 auto;
  padding: 5px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 15px;
  background: rgba(0, 0, 0, 0.58);
  box-shadow: 0 7px 24px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.image-viewer-thumbnails[hidden] {
  display: none;
}

.image-viewer-thumbnail-list {
  display: flex;
  width: 100%;
  height: 100%;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-behavior: smooth;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
}

.image-viewer-thumbnail-list::-webkit-scrollbar {
  display: none;
}

.image-viewer-thumbnail {
  position: relative;
  display: block;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  padding: 2px;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  opacity: 0.64;
  scroll-snap-align: center;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    opacity 0.16s ease,
    transform 0.16s ease;
}

.image-viewer-thumbnail:hover,
.image-viewer-thumbnail:focus-visible {
  opacity: 0.9;
  transform: translateY(-1px);
}

.image-viewer-thumbnail-active {
  border-color: rgba(255, 255, 255, 0.96);
  box-shadow:
    0 0 0 2px rgba(79, 127, 143, 0.9),
    0 4px 12px rgba(0, 0, 0, 0.34);
  opacity: 1;
}

.image-viewer-thumbnail-image {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

#image-viewer-image {
  display: block;
  flex: 0 0 auto;
  max-width: 95vw;
  max-height: 90vh;
  margin: auto;
  border-radius: 9px;
  object-fit: contain;
  cursor: grab;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
}

#image-viewer-image.is-dragging {
  cursor: grabbing;
}

#image-viewer-close {
  position: fixed;
  top: 14px;
  right: 18px;
  z-index: 1004;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  font-size: 32px;
  line-height: 1;
}

#image-viewer-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

#image-viewer-controls {
  position: fixed;
  bottom: 20px;
  left: 50%;
  z-index: 1001;
  display: flex;
  gap: 8px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.65);
  transform: translateX(-50%);
}

#image-viewer-controls button {
  min-width: 44px;
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  font-size: 20px;
}

#image-viewer-controls button:hover {
  background: rgba(255, 255, 255, 0.3);
}

#image-zoom-reset {
  min-width: 68px;
  font-size: 15px;
}

#image-download {
  min-width: 96px;
  font-size: 14px;
}

#image-viewer-close,
#image-viewer-controls,
.image-viewer-navigation,
.image-viewer-thumbnails {
  transition:
    opacity 0.2s ease,
    background 0.14s ease;
}

#image-viewer.image-viewer-origin-opening
  #image-viewer-close,
#image-viewer.image-viewer-origin-opening
  #image-viewer-controls,
#image-viewer.image-viewer-origin-opening
  .image-viewer-navigation,
#image-viewer.image-viewer-origin-opening
  .image-viewer-thumbnails,
#image-viewer.image-viewer-origin-closing
  #image-viewer-close,
#image-viewer.image-viewer-origin-closing
  #image-viewer-controls,
#image-viewer.image-viewer-origin-closing
  .image-viewer-navigation,
#image-viewer.image-viewer-origin-closing
  .image-viewer-thumbnails {
  opacity: 0;
  pointer-events: none;
}

body.image-drag-active::before {
  content: "Отпустите фотографию, чтобы прикрепить";
  position: fixed;
  inset: 12px;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border: 3px dashed var(--accent-color);
  border-radius: 20px;
  background: rgba(239, 246, 248, 0.96);
  color: var(--accent-color-dark);
  font-size: 22px;
  font-weight: bold;
  text-align: center;
  pointer-events: none;
}



/* Единое окно настроек профиля */
.profile-settings-button {
  font-size: 16px;
}

.profile-settings-card {
  display: flex;
  width: min(760px, 100%);
  max-height: calc(100vh - 36px);
  padding: 0;
  overflow: hidden;
  flex-direction: column;
}

.profile-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-color);
}

.profile-settings-summary {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.profile-settings-summary-avatar {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 58px;
  width: 58px;
  height: 58px;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(145deg, #7aa6b1, #4f7f8f);
  color: #ffffff;
  font-size: 22px;
  font-weight: bold;
}

#profile-settings-avatar-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

#profile-settings-avatar-image[hidden],
#profile-settings-avatar-fallback[hidden] {
  display: none;
}

.profile-settings-summary-text {
  min-width: 0;
}

.profile-settings-summary-text h2 {
  overflow: hidden;
  font-size: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-settings-summary-text p {
  margin-top: 4px;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-settings-summary-text p.profile-status-empty {
  font-style: italic;
  opacity: 0.78;
}

.profile-settings-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-color);
  scrollbar-width: none;
}

.profile-settings-tabs::-webkit-scrollbar {
  display: none;
}

.profile-settings-tab {
  flex: 1 0 auto;
  min-height: 39px;
  padding: 0 14px;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: bold;
}

.profile-settings-tab:hover,
.profile-settings-tab-active {
  background: var(--accent-soft);
  color: var(--accent-color-dark);
}

.profile-settings-pages {
  min-height: 0;
  padding: 18px 20px 20px;
  overflow-y: auto;
}

.profile-settings-page[hidden] {
  display: none;
}

.profile-settings-page > .profile-dialog-card {
  width: 100%;
  max-height: none;
  padding: 0;
  overflow: visible;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.profile-settings-page .profile-dialog-header {
  margin-bottom: 16px;
}

.profile-settings-page .profile-dialog-header .profile-dialog-close {
  display: none;
}

.profile-settings-page .profile-dialog-actions {
  padding-top: 4px;
}

.profile-settings-page .appearance-dialog-card {
  max-height: none;
}

.notification-settings-card {
  width: 100%;
  max-width: 680px;
}

.notification-settings-section {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.notification-settings-section:first-of-type {
  margin-top: 0;
}

.notification-sound-setting {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--surface-floating);
  cursor: pointer;
}

.notification-sound-setting:hover {
  background: var(--hover-background);
}

.notification-sound-setting:has(input:disabled) {
  cursor: default;
  opacity: 0.65;
}

.notification-sound-setting input,
.notification-sound-option input {
  width: 21px;
  height: 21px;
  margin: 1px 0 0;
  accent-color: var(--accent-color);
}

.notification-sound-setting-text {
  display: grid;
  gap: 5px;
}

.notification-sound-setting-text strong {
  color: var(--text-primary);
  font-size: 15px;
}

.notification-sound-setting-text small,
.notification-sound-option small,
.notification-sound-note,
.notification-sound-status {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
}

.notification-sound-options {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 9px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.notification-sound-options legend {
  width: 100%;
  margin-bottom: 9px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 800;
}

.notification-sound-option {
  display: grid;
  grid-template-columns: 23px minmax(0, 1fr);
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--surface-floating);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    transform 0.15s ease;
}

.notification-sound-option:hover {
  background: var(--hover-background);
}

.notification-sound-option:has(input:checked) {
  border-color: var(--accent-color);
  background: var(--accent-soft);
}

.notification-sound-option:has(input:disabled) {
  cursor: default;
  opacity: 0.52;
}

.notification-sound-option > span {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.notification-sound-option strong {
  color: var(--text-primary);
  font-size: 14px;
}

.notification-volume-control {
  display: grid;
  gap: 9px;
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--surface-floating);
}

.notification-volume-control > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 800;
}

.notification-volume-control output {
  color: var(--accent-color-dark);
}

.notification-volume-control input[type="range"] {
  width: 100%;
  accent-color: var(--accent-color);
}

.notification-volume-control:has(input:disabled) {
  opacity: 0.55;
}

.notification-sound-test-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.notification-sound-test {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--surface-floating);
  color: var(--text-primary);
  font-weight: 700;
}

.notification-sound-test:hover:not(:disabled) {
  background: var(--hover-background);
}

.notification-sound-test:disabled {
  cursor: default;
  opacity: 0.5;
}

.notification-sound-status {
  min-width: 0;
  margin: 0;
}

.notification-vibration-status {
  padding: 0 4px;
}

.notification-sound-note {
  margin: 14px 0 0;
}

@media (min-width: 821px) {
  .app-shell {
    transition:
      grid-template-columns 0.18s ease;
  }

  .app-sidebar {
    overflow: hidden;
    transition:
      padding 0.18s ease,
      opacity 0.14s ease;
  }

  html[data-sidebar-mode="compact"]
    .app-shell {
    grid-template-columns:
      94px minmax(0, 1fr);
  }

  html[data-sidebar-mode="compact"]
    .app-sidebar {
    padding: 14px 10px 12px;
  }

  html[data-sidebar-mode="compact"]
    .brand-block {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 8px;
    padding: 0 0 15px;
  }

  html[data-sidebar-mode="compact"]
    .brand-text,
  html[data-sidebar-mode="compact"]
    .profile-controls,
  html[data-sidebar-mode="compact"]
    .sidebar-section-title,
  html[data-sidebar-mode="compact"]
    .chat-list-content,
  html[data-sidebar-mode="compact"]
    .sidebar-footer {
    display: none;
  }

  html[data-sidebar-mode="compact"]
    .sidebar-controls {
    width: 100%;
    justify-content: center;
    flex-direction: row;
    gap: 6px;
  }

  html[data-sidebar-mode="compact"]
    .sidebar-control-button {
    width: 30px;
    height: 30px;
  }

  html[data-sidebar-mode="compact"]
    .profile-card {
    justify-content: center;
    margin-bottom: 15px;
    padding: 9px;
  }

  html[data-sidebar-mode="compact"]
    .profile-avatar {
    flex-basis: 48px;
    width: 48px;
    min-width: 48px;
    max-width: 48px;
    height: 48px;
    min-height: 48px;
    max-height: 48px;
  }

  html[data-sidebar-mode="compact"]
    .chat-list-item {
    position: relative;
    justify-content: center;
    gap: 0;
    padding: 9px 8px;
  }

  html[data-sidebar-mode="compact"]
    .chat-list-avatar {
    width: 48px;
    height: 48px;
  }

  html[data-sidebar-mode="compact"]
    .chat-list-unread-badge-compact {
    position: absolute;
    top: -5px;
    right: -7px;
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border: 2px solid var(--sidebar-background);
    border-radius: 999px;
    background: var(--accent-color);
    color: #ffffff;
    font-size: 10px;
    font-weight: bold;
    line-height: 1;
  }

  html[data-sidebar-mode="hidden"]
    .app-shell {
    grid-template-columns:
      0 minmax(0, 1fr);
  }

  html[data-sidebar-mode="hidden"]
    .app-sidebar {
    visibility: hidden;
    padding-right: 0;
    padding-left: 0;
    border-right: none;
    opacity: 0;
    pointer-events: none;
  }
}

@media (max-width: 820px), (hover: none) and (pointer: coarse) {
  html,
  body {
    width: 100%;
    height: var(--app-viewport-height, 100dvh);
    min-height: 0;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body {
    padding: 0;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    width: 100%;
    height: var(--app-viewport-height, 100dvh);
    min-height: 0;
    max-height: var(--app-viewport-height, 100dvh);
    border: none;
    border-radius: 0;
  }

  .chat-panel,
  .chat-workspace {
    min-height: 0;
    overflow: hidden;
  }

  .app-sidebar {
    display: grid;
    visibility: visible;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-controls,
  .sidebar-open-button {
    display: none !important;
  }

  .brand-block {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 10px;
    padding: 0;
  }

  .brand-logo {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
    border-radius: 13px;
    font-size: 21px;
  }

  h1 {
    font-size: 20px;
  }

  .brand-block p,
  .sidebar-section-title,
  .chat-list,
  .sidebar-footer,
  .profile-controls label {
    display: none;
  }

  .profile-card {
    gap: 8px;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
  }

  .profile-avatar {
  flex-basis: 38px;
  width: 38px;
  min-width: 38px;
  max-width: 38px;
  height: 38px;
  min-height: 38px;
  max-height: 38px;
  font-size: 15px;
}

  .profile-avatar-edit-mark {
    right: -5px;
    bottom: -5px;
    width: 19px;
    height: 19px;
    font-size: 9px;
  }

  .profile-summary {
    align-items: center;
  }

  #profile-display-name {
    max-width: 86px;
    font-size: 12px;
  }

  #profile-status {
    display: none;
  }


  .profile-summary-actions {
    gap: 2px;
  }

  .profile-edit-button {
    width: 22px;
    height: 22px;
    font-size: 15px;
  }

  #user-select {
    min-width: 92px;
    padding: 6px 8px;
    font-size: 13px;
  }

  .chat-header {
    min-height: 64px;
    padding: 9px 12px;
  }

  .chat-header-room-actions {
    gap: 4px;
  }

  .chat-header-room-button {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 20px;
  }

  .chat-header-avatar {
  flex-basis: 42px;
  width: 42px;
  min-width: 42px;
  max-width: 42px;
  height: 42px;
  min-height: 42px;
  max-height: 42px;
}

  .chat-header-info h2 {
    display: none;
  }

  .mobile-room-switcher {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
  }

  .mobile-room-switcher > span {
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: bold;
  }

  #mobile-room-select {
    width: min(220px, 100%);
    min-height: 30px;
    padding: 4px 28px 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 9px;
    background: var(--surface-strong);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: bold;
  }

  #partner-status {
    min-height: 22px;
    padding: 3px 8px;
    font-size: 11px;
  }

  /*
    Личный статус и «печатает…» используют одну строку.
    Высота заголовка остаётся постоянной.
  */
  .chat-header-statuses {
    height: 22px;
    min-height: 22px;
    overflow: hidden;
  }

  #partner-status {
    line-height: 16px;
  }

  .message-search-panel {
    gap: 5px;
    margin: 8px 8px 0;
    padding: 6px;
  }

  .message-search-field {
    gap: 4px;
    padding: 0 7px;
  }

  .message-search-field > span {
    display: none;
  }

  #message-search-input {
    min-height: 34px;
    font-size: 13px;
  }

  .message-search-result {
    min-width: 54px;
    font-size: 11px;
  }

  .message-search-actions {
    gap: 3px;
  }

  .message-search-actions button {
    width: 31px;
    height: 32px;
    font-size: 16px;
  }

  #messages {
    min-height: 0;
    padding: 12px 10px 14px;
    overscroll-behavior: contain;
  }

  #messages li {
    max-width: 86%;
    -webkit-touch-callout: none;
  }

  .message-context-menu {
    min-width: 238px;
  }

  .message-context-reaction-quick {
    grid-template-columns: repeat(5, 40px);
  }

  .message-context-reaction-more {
    grid-template-columns: repeat(4, 40px);
  }

  .message-context-reaction-button {
    width: 40px;
    height: 40px;
    font-size: 23px;
  }

  .message-context-option {
    min-height: 46px;
    font-size: 15px;
  }

  .composer-area {
    position: relative;
    z-index: 30;
    min-width: 0;
    flex: 0 0 auto;
    padding:
      0 8px
      max(8px, env(safe-area-inset-bottom));
  }

  .scroll-to-bottom-button {
    right: 14px;
    bottom: 80px;
    width: 42px;
    height: 42px;
  }

  #message-form {
    width: 100%;
    min-width: 0;
    gap: 3px;
    padding: 6px;
    border-radius: 16px;
  }

  #message-input {
    width: 0;
    min-width: 0;
    min-height: 40px;
    padding: 9px 5px;
  }

  .smiley-picker-anchor {
    flex: 0 0 38px;
    width: 38px;
    height: 40px;
  }

  #smiley-button,
  #image-button {
    width: 38px;
    height: 40px;
  }

  #smiley-picker {
    right: -45px;
    width: min(560px, calc(100vw - 16px));
  }

  .attachment-icon-outline {
    display: none;
  }

  .attachment-icon-mobile {
    display: block;
    font-size: 20px;
    line-height: 1;
  }

  .send-button {
    width: 42px;
    min-width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 50%;
  }

  .send-button-text {
    display: none;
  }

  .send-button-icon {
    font-size: 18px;
  }
}


@media (max-width: 520px) {
  .message-forward-dialog-card {
    max-height: calc(100vh - 20px);
    padding: 16px;
  }

  .message-forward-room-list {
    max-height: min(360px, 46vh);
  }

  .message-forward-room-option {
    padding: 9px;
  }
}

@media (max-width: 520px) {
  .room-settings-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .room-delete-button {
    grid-column: 1 / -1;
    margin-right: 0;
  }
}

@media (max-width: 620px) {
  .appearance-options {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .appearance-dialog-card {
    max-height: calc(100vh - 20px);
    padding: 16px;
  }
}



@media (max-width: 620px) {
  .profile-settings-card {
    max-height: calc(100vh - 20px);
  }

  .profile-settings-header {
    padding: 14px 15px 12px;
  }

  .profile-settings-summary-avatar {
    flex-basis: 50px;
    width: 50px;
    height: 50px;
  }

  .profile-settings-pages {
    padding: 14px 15px 16px;
  }

  .profile-settings-tab {
    min-width: 108px;
  }

  .notification-sound-options {
    grid-template-columns: 1fr;
  }

  .notification-sound-test-row {
    align-items: stretch;
    flex-direction: column;
  }

  .notification-sound-test {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .custom-background-editor {
    grid-template-columns: 1fr;
  }

  .custom-background-fit {
    grid-template-columns: 1fr;
  }

  .profile-avatar-editor {
    flex-direction: column;
    text-align: center;
  }

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

  .profile-avatar-remove {
    margin-right: 0;
    order: 3;
  }


  #message-selection-bar {
    margin: 8px 8px 0;
  }

  .message-selection-actions {
    width: 100%;
    justify-content: stretch;
  }

  #message-selection-bar button {
    flex: 1 1 auto;
  }

  #messages li {
    max-width: 91%;
  }

  .message-image {
    width: min(320px, 72vw);
  }

  #smiley-picker {
    max-height: 52vh;
    border-radius: 14px;
  }

  .smiley-picker-footer {
    gap: 4px;
    padding: 5px 6px;
  }

  .smiley-picker-mode-button {
    padding: 6px 8px;
  }

  .smiley-picker-credit {
    display: none;
  }

  .smiley-grid {
    min-height: 170px;
    grid-template-columns:
      repeat(auto-fill, minmax(48px, 1fr));
  }

  .smiley-option {
    min-height: 50px;
  }

  .smiley-grid.smiley-grid-stickers {
    grid-template-columns:
      repeat(auto-fill, minmax(76px, 1fr));
    gap: 6px;
  }

  .smiley-option.sticker-option {
    min-height: 78px;
  }

  .smiley-option.sticker-option img {
    width: 70px;
    height: 70px;
    max-height: 70px;
  }

  .message-sticker {
    width: 136px;
    max-width: 46vw;
    max-height: 156px;
  }

  #messages li.message-with-sticker {
    min-width: 150px;
  }

  #image-viewer-controls {
    max-width: calc(100vw - 16px);
    gap: 5px;
  }

  #image-viewer-controls button {
    min-width: 38px;
    padding: 0 9px;
  }

  #image-download {
    min-width: 84px;
  }
}


@media (hover: none) and (pointer: coarse) {
  #messages li[data-message-id] {
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
}

@media
  (hover: none) and
  (pointer: coarse) and
  (orientation: landscape) and
  (max-height: 520px) {
  .app-shell {
    grid-template-rows: 54px minmax(0, 1fr);
  }

  .app-sidebar {
    padding: 6px 10px;
  }

  .brand-block {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 7px;
  }

  .brand-logo {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    border-radius: 11px;
    font-size: 18px;
  }

  h1 {
    font-size: 17px;
  }

  .brand-block p {
    display: none;
  }

  .profile-avatar {
    flex-basis: 34px;
    width: 34px;
    min-width: 34px;
    max-width: 34px;
    height: 34px;
    min-height: 34px;
    max-height: 34px;
  }

  #profile-display-name {
    max-width: 74px;
  }

  #user-select {
    min-width: 82px;
    padding: 4px 7px;
  }

  .chat-header {
    min-height: 52px;
    padding: 5px 9px;
  }

  .chat-header-avatar {
    flex-basis: 36px;
    width: 36px;
    min-width: 36px;
    max-width: 36px;
    height: 36px;
    min-height: 36px;
    max-height: 36px;
  }

  .chat-header-room-button {
    width: 32px;
    height: 32px;
  }

  .mobile-room-switcher > span,
  #partner-status {
    display: none;
  }

  #mobile-room-select {
    min-height: 32px;
  }


  #messages {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .composer-area {
    padding:
      0 6px
      max(5px, env(safe-area-inset-bottom));
  }

  #message-form {
    padding: 4px;
  }

  .smiley-picker-anchor {
    flex-basis: 36px;
    width: 36px;
    height: 38px;
  }

  #smiley-button,
  #image-button {
    width: 36px;
    height: 38px;
  }

  #smiley-picker {
    right: -44px;
  }

  .send-button {
    width: 40px;
    min-width: 40px;
    height: 40px;
  }

  #message-input {
    min-height: 38px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
}



/* Этап 24: личные кабинеты и разделение пользователей */
.app-shell[aria-hidden="true"] {
  visibility: hidden;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: 18px;
  overflow-y: auto;
  background:
    radial-gradient(
      circle at 18% 18%,
      rgba(255, 255, 255, 0.65),
      transparent 34%
    ),
    radial-gradient(
      circle at 82% 76%,
      rgba(79, 127, 143, 0.2),
      transparent 40%
    ),
    var(--page-background);
}

.auth-screen[hidden],
.auth-codes-dialog[hidden],
.auth-view[hidden] {
  display: none;
}

.auth-screen.auth-checking-pending
  .auth-card {
  visibility: hidden;
}

.auth-checking-view {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 18px 0 6px;
  text-align: center;
}

.auth-checking-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid var(--accent-soft);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: auth-checking-spin 0.8s linear infinite;
}

@keyframes auth-checking-spin {
  to {
    transform: rotate(360deg);
  }
}

.auth-card {
  width: min(430px, 100%);
  padding: 24px;
  border: 1px solid var(--shell-border);
  border-radius: 22px;
  background: var(--surface-floating-strong);
  box-shadow: var(--shadow-soft);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 24px;
}

.auth-brand-logo {
  display: grid;
  place-items: center;
  flex: 0 0 50px;
  width: 50px;
  height: 50px;
  border-radius: 16px;
  background: linear-gradient(145deg, #6e9eaa, #456f7d);
  box-shadow: 0 8px 18px rgba(61, 104, 118, 0.24);
  font-size: 27px;
}

.auth-brand h1 {
  font-size: 24px;
}

.auth-brand p,
.auth-view-heading p {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
}

.auth-view-heading {
  margin-bottom: 18px;
}

.auth-view-heading h2 {
  font-size: 20px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-form label,
#profile-account-password-form label {
  margin-top: 5px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: bold;
}

.auth-form input,
#profile-account-password-form input {
  width: 100%;
  min-height: 43px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 11px;
  outline: none;
  background: var(--input-background);
  color: var(--text-primary);
  font: inherit;
}

.auth-form input:focus,
#profile-account-password-form input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(79, 127, 143, 0.16);
}

.password-input-wrapper {
  position: relative;
  width: 100%;
}

.password-input-wrapper input {
  padding-right: 48px;
}

.password-visibility-toggle {
  position: absolute;
  top: 50%;
  right: 5px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 34px;
  padding: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 17px;
  line-height: 1;
  transform: translateY(-50%);
}

.password-visibility-toggle:hover:not(:disabled),
.password-visibility-toggle:focus-visible {
  background: var(--hover-background);
  color: var(--accent-color-dark);
}

.password-visibility-toggle:disabled {
  cursor: default;
  opacity: 0.45;
}

.auth-error {
  min-height: 19px;
  color: var(--danger-color);
  font-size: 12px;
  line-height: 1.4;
}

.auth-primary-button {
  min-height: 44px;
  margin-top: 3px;
  border-radius: 11px;
  background: var(--accent-color);
  color: #ffffff;
  font-weight: bold;
}

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

.auth-primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.auth-secondary-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
}

.auth-secondary-actions button,
.auth-back-button {
  padding: 7px 3px;
  background: transparent;
  color: var(--accent-color-dark);
  font-size: 13px;
  font-weight: bold;
}

.auth-secondary-actions button:hover,
.auth-back-button:hover {
  text-decoration: underline;
}

.auth-back-button {
  margin-top: 12px;
}

.auth-codes-dialog {
  position: fixed;
  inset: 0;
  z-index: 3200;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(13, 27, 34, 0.62);
  backdrop-filter: blur(8px);
}

.auth-codes-card {
  width: min(510px, 100%);
  padding: 22px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: var(--surface-floating-strong);
  box-shadow: var(--shadow-soft);
}

.auth-codes-card h2 {
  font-size: 20px;
}

.auth-codes-card > p {
  margin-top: 7px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
}

#auth-recovery-codes-text {
  width: 100%;
  height: 220px;
  margin-top: 16px;
  padding: 13px;
  resize: none;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  outline: none;
  background: var(--input-background);
  color: var(--text-primary);
  font-family: Consolas, monospace;
  font-size: 16px;
  line-height: 1.65;
  text-align: center;
}

.auth-codes-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.auth-codes-actions button {
  min-height: 39px;
  padding: 8px 13px;
  border-radius: 10px;
  background: var(--muted-button-background);
  color: var(--text-primary);
  font-weight: bold;
}

#auth-close-recovery-codes {
  background: var(--accent-color);
  color: #ffffff;
}

.auth-codes-status {
  min-height: 18px;
  margin-top: 8px;
  color: var(--accent-color-dark);
  font-size: 12px;
}

.account-settings-card {
  max-width: 640px;
}

.account-login-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 17px;
  padding: 12px 13px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--surface-soft);
}

.account-login-row span {
  color: var(--text-secondary);
  font-size: 13px;
}

.account-login-row strong {
  overflow-wrap: anywhere;
}

#profile-account-password-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.account-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 7px;
}

.account-action-grid button {
  min-height: 42px;
  border-radius: 10px;
}

.account-security-note {
  margin-top: 13px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
}

.account-logout-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
  padding-top: 15px;
  border-top: 1px solid var(--border-color);
}

.account-logout-row button {
  padding: 9px 13px;
  border-radius: 10px;
}

@media (max-width: 600px) {
  .auth-screen,
  .auth-codes-dialog {
    padding: 10px;
  }

  .auth-card,
  .auth-codes-card {
    padding: 18px;
    border-radius: 17px;
  }

  .auth-secondary-actions,
  .auth-codes-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .auth-secondary-actions button,
  .auth-codes-actions button {
    width: 100%;
  }

  .account-action-grid {
    grid-template-columns: 1fr;
  }
}

/* Этап 25.2 — панель системного администратора */
.profile-settings-tab[hidden],
.profile-settings-page[hidden],
.auth-codes-dialog[hidden] {
  display: none;
}

.admin-users-card {
  gap: 18px;
}

.admin-user-create-form {
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: 15px;
  background: var(--surface-soft);
}

.admin-user-create-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.admin-user-create-fields label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: bold;
}

.admin-user-create-fields input {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  outline: none;
  background: var(--input-background);
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
}

.admin-user-create-fields input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(79, 127, 143, 0.16);
}

.admin-users-note {
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
}

.admin-user-create-actions {
  margin-top: 12px;
}

.admin-users-list-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-users-list-heading h3 {
  margin: 0;
  font-size: 16px;
}

.admin-users-list-heading p {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 12px;
}

.admin-users-list-heading button {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 9px;
}

.admin-users-list {
  display: flex;
  max-height: min(430px, 48vh);
  overflow-y: auto;
  flex-direction: column;
  gap: 10px;
  padding-right: 3px;
}

.admin-user-card {
  padding: 13px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--surface-soft);
}

.admin-user-card-disabled {
  opacity: 0.78;
}

.admin-user-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.admin-user-identity {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 3px;
}

.admin-user-identity strong {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-user-identity span,
.admin-user-identity small {
  color: var(--text-secondary);
  font-size: 12px;
}

.admin-user-badges {
  display: flex;
  max-width: 52%;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.admin-user-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--muted-button-background);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: bold;
  white-space: nowrap;
}

.admin-user-badge-active,
.admin-user-badge-online {
  background: #dcefdc;
  color: #256029;
}

.admin-user-badge-disabled {
  background: var(--danger-soft);
  color: var(--danger-color);
}

.admin-user-badge-setup {
  background: var(--accent-soft);
  color: var(--accent-color-dark);
}

.admin-user-badge-admin {
  background: var(--accent-color);
  color: #ffffff;
}

.admin-user-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 11px;
}

.admin-user-actions button {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 12px;
}

.admin-users-empty {
  padding: 18px;
  border: 1px dashed var(--border-color);
  border-radius: 13px;
  color: var(--text-secondary);
  text-align: center;
}

.admin-setup-code-card {
  width: min(480px, calc(100vw - 28px));
}

.admin-setup-login-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--surface-soft);
}

.admin-setup-login-row span {
  color: var(--text-secondary);
  font-size: 13px;
}

.admin-setup-login-row strong {
  overflow-wrap: anywhere;
}

#admin-setup-code-text {
  min-height: 72px;
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 0.08em;
  text-align: center;
}

@media (max-width: 680px) {
  .admin-user-create-fields {
    grid-template-columns: 1fr;
  }

  .admin-user-summary {
    flex-direction: column;
  }

  .admin-user-badges {
    max-width: none;
    justify-content: flex-start;
  }

  .admin-user-actions {
    justify-content: stretch;
  }

  .admin-user-actions button {
    flex: 1 1 180px;
  }
}


@media (max-width: 620px) {
  .contacts-dialog-card {
    max-height: calc(
      var(--app-viewport-height, 100vh) - 16px
    );
  }

  .contacts-list {
    max-height: 56vh;
  }

  .contact-list-item {
    min-height: 62px;
    gap: 9px;
    padding: 8px;
  }

  .contact-list-avatar {
    flex-basis: 44px;
    width: 44px;
    height: 44px;
  }

  .contact-list-action {
    max-width: 116px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .contacts-dialog-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .contacts-dialog-actions button {
    width: 100%;
  }
}

/* Этап 25.3.3 — компактная мобильная шапка */
.mobile-compact-chat-header {
  display: none;
}

.mobile-chat-menu[hidden] {
  display: none;
}

@media (max-width: 820px), (hover: none) and (pointer: coarse) {
  .app-shell {
    grid-template-rows: minmax(0, 1fr);
  }

  .app-sidebar {
    display: none;
  }

  .chat-header {
    position: relative;
    z-index: 110;
    min-height: 56px;
    padding: 6px 9px;
    border-bottom:
      1px solid rgba(255, 255, 255, 0.12);
    background: var(--surface-floating);
    box-shadow: 0 5px 18px rgba(20, 43, 52, 0.1);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  .chat-header > .sidebar-open-button,
  .chat-header > .chat-header-avatar,
  .chat-header > .chat-header-info,
  .chat-header > .chat-header-room-actions {
    display: none !important;
  }

  .mobile-compact-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-width: 0;
    gap: 8px;
  }

  .mobile-compact-chat-identity {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1;
    gap: 9px;
  }

  .mobile-compact-chat-avatar {
    position: relative;
    display: grid;
    place-items: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    padding: 0;
    overflow: hidden;
    border: none;
    border-radius: 50%;
    background:
      linear-gradient(145deg, #7aa6b1, #4f7f8f);
    color: #ffffff;
    font-size: 17px;
    font-weight: bold;
    line-height: 1;
    cursor: default;
    transition:
      box-shadow 0.16s ease,
      transform 0.16s ease;
  }

  .mobile-compact-chat-avatar:disabled {
    opacity: 1;
  }

  .mobile-compact-chat-avatar-clickable {
    cursor: zoom-in;
  }

  .mobile-compact-chat-avatar-clickable:active {
    box-shadow:
      0 0 0 4px rgba(79, 127, 143, 0.18);
    transform: scale(0.97);
  }

  #mobile-chat-avatar-image {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
  }

  #mobile-chat-avatar-image[hidden],
  #mobile-chat-avatar-fallback[hidden] {
    display: none;
  }

  .mobile-compact-chat-text {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
  }

  #mobile-chat-title,
  #mobile-chat-subtitle {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #mobile-chat-title {
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.15;
  }

  #mobile-chat-subtitle {
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.2;
  }

  #mobile-chat-subtitle.mobile-chat-subtitle-typing {
    color: var(--accent-color-dark);
    font-weight: bold;
  }

  .mobile-chat-menu-anchor {
    position: relative;
    flex: 0 0 auto;
  }

  .mobile-chat-menu-button {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: var(--surface-soft);
    color: var(--text-primary);
    font-size: 27px;
    line-height: 1;
  }

  .mobile-chat-menu-button[aria-expanded="true"] {
    background: var(--accent-soft);
    color: var(--accent-color-dark);
  }

  .mobile-chat-menu {
    position: absolute;
    top: calc(100% + 7px);
    right: 0;
    z-index: 1500;
    display: flex;
    width: min(310px, calc(100vw - 18px));
    padding: 8px;
    flex-direction: column;
    gap: 3px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--surface-floating-strong);
    box-shadow: 0 15px 38px rgba(15, 34, 42, 0.28);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }

  .mobile-menu-room-switcher {
    display: flex;
    padding: 5px 6px 7px;
    flex-direction: column;
    gap: 5px;
  }

  .mobile-menu-room-switcher > span {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: bold;
  }

  #mobile-room-select {
    width: 100%;
    min-height: 40px;
    padding: 7px 32px 7px 10px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--input-background);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: bold;
  }

  .mobile-chat-menu-separator {
    height: 1px;
    margin: 2px 5px;
    background: var(--border-color);
  }

  .mobile-chat-menu-action {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    align-items: center;
    width: 100%;
    min-height: 43px;
    padding: 8px 10px;
    gap: 7px;
    border-radius: 11px;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    text-align: left;
  }

  .mobile-chat-menu-action[hidden] {
    display: none;
  }

  .mobile-chat-menu-action > span:first-child {
    display: grid;
    place-items: center;
    color: var(--accent-color-dark);
    font-size: 18px;
  }

  .mobile-chat-menu-action:active {
    background: var(--hover-background);
  }

  .mobile-chat-menu-action:disabled {
    cursor: default;
    opacity: 0.42;
  }
}

/* Этап 25.3.3 — перелистывание фотографий */
.image-viewer-navigation {
  position: fixed;
  top: 50%;
  z-index: 1002;
  display: grid;
  place-items: center;
  width: 38px;
  height: 52px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.3);
  color: rgba(255, 255, 255, 0.86);
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.18);
  font-size: 34px;
  line-height: 1;
  opacity: 0.58;
  transform: translateY(-50%);
  transition:
    opacity 0.14s ease,
    background 0.14s ease;
}

.image-viewer-navigation:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.52);
  opacity: 0.94;
}

.image-viewer-navigation:disabled {
  cursor: default;
  opacity: 0.14;
}

.image-viewer-navigation[hidden] {
  display: none;
}

.image-viewer-previous {
  left: 18px;
}

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

#image-viewer-image {
  will-change: transform, opacity;
  transition:
    transform 0.22s ease,
    opacity 0.22s ease;
}

#image-viewer-image.is-dragging {
  transition: none;
}

#image-viewer-image.image-viewer-transition-out-left {
  opacity: 0;
  transform: translateX(-34px);
}

#image-viewer-image.image-viewer-transition-out-right {
  opacity: 0;
  transform: translateX(34px);
}

#image-viewer-image.image-viewer-transition-enter-left {
  opacity: 0;
  transform: translateX(-34px);
  transition: none;
}

#image-viewer-image.image-viewer-transition-enter-right {
  opacity: 0;
  transform: translateX(34px);
  transition: none;
}

@media (hover: none) and (pointer: coarse) {
  .image-viewer-navigation {
    display: none !important;
  }

  .image-viewer-thumbnail:hover {
    opacity: 0.64;
    transform: none;
  }

  .image-viewer-thumbnail-active:hover {
    opacity: 1;
  }
}

@media (max-width: 520px) {
  #image-viewer.image-viewer-has-thumbnails {
    padding-top: 92px;
  }

  .image-viewer-thumbnails {
    right: 66px;
    left: 8px;
    width: auto;
    max-width: none;
    height: 60px;
    padding: 5px;
    border-radius: 14px;
  }

  .image-viewer-thumbnail {
    flex-basis: 48px;
    width: 48px;
    height: 48px;
    border-radius: 9px;
  }
}

@media (max-width: 520px) and (hover: hover) and (pointer: fine) {
  .image-viewer-navigation {
    width: 34px;
    height: 48px;
    border-radius: 12px;
  }

  .image-viewer-previous {
    left: 7px;
  }

  .image-viewer-next {
    right: 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #image-viewer-image,
  #image-viewer-close,
  #image-viewer-controls,
  .image-viewer-navigation,
  .image-viewer-thumbnails,
  .image-viewer-thumbnail {
    transition: none !important;
  }
}

/* Этап 25.3.3 — ответ смахиванием сообщения влево */
#messages li[data-message-id] {
  transition: transform 0.16s ease;
}

#messages li.message-swipe-reply-active {
  z-index: 25;
  transform:
    translateX(
      var(--message-swipe-reply-offset, 0)
    );
  transition: none;
}

#messages li.message-swipe-reply-active::after {
  content: "↩";
  position: absolute;
  top: 50%;
  right: -39px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  background: var(--surface-floating-strong);
  color: var(--accent-color-dark);
  box-shadow: 0 4px 12px rgba(20, 43, 52, 0.16);
  font-size: 18px;
  font-weight: bold;
  opacity:
    var(--message-swipe-reply-progress, 0);
  transform:
    translateY(-50%)
    scale(0.88);
  transition:
    opacity 0.12s ease,
    transform 0.12s ease;
}

#messages li.message-swipe-reply-ready::after {
  border-color: var(--accent-color);
  background: var(--accent-soft);
  transform:
    translateY(-50%)
    scale(1);
}

@media (hover: none) and (pointer: coarse) {
  #messages li[data-message-id] {
    touch-action: pan-y;
  }
}

/* Этап 25.3.4.1 — мобильная панель чатов и плавающая шапка */
.mobile-chat-drawer-header,
.mobile-chat-drawer-search-panel,
.mobile-chat-drawer-empty,
.mobile-chat-drawer-footer,
.mobile-chat-drawer-backdrop,
.mobile-chat-drawer-open-button {
  display: none;
}

.chat-list-item[hidden] {
  display: none !important;
}

.chat-list-avatar-presence::after {
  content: "";
  position: absolute;
  top: 1px;
  right: 1px;
  z-index: 5;
  width: 10px;
  height: 10px;
  border: 2px solid var(--sidebar-background);
  border-radius: 50%;
  background: #98a3a8;
  box-shadow: 0 1px 4px rgba(15, 35, 43, 0.22);
}

.chat-list-avatar-presence-online::after {
  background: #39b85a;
}

.chat-list-avatar-presence-offline::after {
  background: #98a3a8;
}

@media (max-width: 820px), (hover: none) and (pointer: coarse) {
  .app-shell {
    grid-template-rows: minmax(0, 1fr);
  }

  .chat-panel {
    position: relative;
  }

  .chat-header {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    z-index: 110;
    min-height: 66px;
    padding:
      max(7px, env(safe-area-inset-top))
      9px
      5px;
    border: none;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    pointer-events: none;
  }

  .mobile-compact-chat-header {
    align-items: center;
    width: 100%;
    min-width: 0;
    gap: 8px;
    pointer-events: none;
  }

  .mobile-chat-drawer-open-button {
    display: grid;
    place-items: center;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    padding: 0;
    border:
      1px solid
      color-mix(
        in srgb,
        var(--border-color) 68%,
        transparent
      );
    border-radius: 50%;
    background:
      color-mix(
        in srgb,
        var(--surface-floating-strong) 78%,
        transparent
      );
    color: var(--text-primary);
    box-shadow:
      0 5px 17px rgba(18, 39, 47, 0.14);
    font-size: 25px;
    font-weight: 600;
    line-height: 1;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    pointer-events: auto;
    transition:
      transform 0.14s ease,
      background 0.14s ease;
  }

  .mobile-chat-drawer-open-icon {
    display: block;
    width: 30px;
    height: 30px;
    overflow: visible;
  }

  .mobile-chat-drawer-open-icon path {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.7;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-chat-drawer-open-button:active {
    background: var(--accent-soft);
    color: var(--accent-color-dark);
    transform: scale(0.94);
  }

  .mobile-compact-chat-identity {
    display: flex;
    align-items: center;
    width: auto;
    min-width: 0;
    max-width: none;
    flex: 1 1 auto;
    gap: 9px;
    padding: 5px 13px 5px 5px;
    border: 1px solid
      color-mix(
        in srgb,
        var(--border-color) 68%,
        transparent
      );
    border-radius: 999px;
    background:
      color-mix(
        in srgb,
        var(--surface-floating-strong) 78%,
        transparent
      );
    box-shadow:
      0 5px 17px rgba(18, 39, 47, 0.14);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    pointer-events: auto;
    cursor: default;
  }

  .mobile-compact-chat-avatar {
    flex-basis: 40px;
    width: 40px;
    height: 40px;
  }

  .mobile-chat-menu-anchor {
    pointer-events: auto;
  }

  .mobile-chat-menu-button {
    width: 48px;
    height: 48px;
    border:
      1px solid
      color-mix(
        in srgb,
        var(--border-color) 68%,
        transparent
      );
    background:
      color-mix(
        in srgb,
        var(--surface-floating-strong) 78%,
        transparent
      );
    box-shadow:
      0 5px 17px rgba(18, 39, 47, 0.14);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
  }

  .mobile-menu-room-switcher,
  .mobile-menu-room-switcher +
    .mobile-chat-menu-separator {
    display: none !important;
  }

  .chat-workspace {
    padding-top:
      calc(
        66px +
        env(safe-area-inset-top)
      );
  }

  .app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1800;
    display: flex;
    visibility: visible;
    width: min(87vw, 360px);
    height: var(
      --app-viewport-height,
      100dvh
    );
    min-height: 0;
    padding:
      max(12px, env(safe-area-inset-top))
      0
      max(10px, env(safe-area-inset-bottom));
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    overflow: hidden;
    border-right: 1px solid var(--border-color);
    border-bottom: none;
    background:
      color-mix(
        in srgb,
        var(--sidebar-background) 94%,
        transparent
      );
    box-shadow:
      16px 0 42px rgba(12, 31, 39, 0.24);
    opacity: 1;
    transform:
      translate3d(
        calc(-100% - 18px),
        0,
        0
      );
    transition:
      transform 0.25s
      cubic-bezier(0.22, 0.78, 0.2, 1);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    pointer-events: auto;
    touch-action: pan-y;
  }

  body.mobile-chat-drawer-open
    .app-sidebar {
    transform: translate3d(0, 0, 0);
  }

  body.mobile-chat-drawer-gesturing
    .app-sidebar {
    transition: none;
  }

  .app-sidebar > .brand-block,
  .app-sidebar > .profile-card,
  .app-sidebar > .sidebar-section-title,
  .app-sidebar > .sidebar-footer {
    display: none;
  }

  .mobile-chat-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
    gap: 10px;
    padding: 0 12px 10px 16px;
  }

  .mobile-chat-drawer-title {
    min-width: 0;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 22px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-chat-drawer-header-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 6px;
  }

  .mobile-chat-drawer-icon-button {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: var(--surface-soft);
    color: var(--text-primary);
    font-size: 20px;
    line-height: 1;
  }

  #mobile-chat-drawer-close {
    font-size: 27px;
  }

  .mobile-chat-drawer-icon-button:active,
  .mobile-chat-drawer-icon-button[
    aria-expanded="true"
  ] {
    background: var(--accent-soft);
    color: var(--accent-color-dark);
  }

  .mobile-chat-drawer-search-panel {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 5px;
    margin: 0 10px 8px;
    padding: 5px 6px 5px 11px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: var(--input-background);
  }

  .mobile-chat-drawer-search-panel[hidden] {
    display: none;
  }

  #mobile-chat-drawer-search-input {
    min-width: 0;
    min-height: 35px;
    flex: 1;
    padding: 6px 2px;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 14px;
  }

  #mobile-chat-drawer-search-input::placeholder {
    color: var(--text-secondary);
  }

  #mobile-chat-drawer-search-clear {
    display: grid;
    place-items: center;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    font-size: 22px;
    line-height: 1;
  }

  .app-sidebar .chat-list {
    display: block;
    min-height: 0;
    flex: 1 1 auto;
    padding: 3px 9px 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .app-sidebar .chat-list-item {
    min-height: 68px;
    margin-bottom: 3px;
    padding: 9px 9px;
  }

  .app-sidebar .chat-list-avatar {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
  }

  .app-sidebar .chat-list-content {
    display: block;
  }

  .app-sidebar .chat-list-row strong {
    font-size: 15px;
  }

  .app-sidebar .chat-list-preview {
    margin-top: 5px;
    font-size: 12px;
  }

  .mobile-chat-drawer-empty {
    flex: 0 0 auto;
    margin: 12px;
    padding: 13px;
    border: 1px dashed var(--border-color);
    border-radius: 13px;
    color: var(--text-secondary);
    font-size: 13px;
    text-align: center;
  }

  .mobile-chat-drawer-empty[hidden] {
    display: none;
  }

  .mobile-chat-drawer-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex: 0 0 auto;
    gap: 8px;
    padding: 9px 10px 0;
    border-top: 1px solid var(--border-color);
  }

  .mobile-chat-drawer-footer-button {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 46px;
    gap: 7px;
    padding: 8px 10px;
    border-radius: 13px;
    background: var(--surface-soft);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: bold;
  }

  .mobile-chat-drawer-footer-button >
    span:first-child {
    color: var(--accent-color-dark);
    font-size: 18px;
    line-height: 1;
  }

  .mobile-chat-drawer-footer-button-primary {
    background: var(--accent-color);
    color: #ffffff;
  }

  .mobile-chat-drawer-footer-button-primary >
    span:first-child {
    color: #ffffff;
  }

  .mobile-chat-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1750;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: none;
    border-radius: 0;
    background: rgba(5, 15, 19, 0.44);
    opacity: 0;
    transition: opacity 0.24s ease;
    touch-action: none;
  }

  .mobile-chat-drawer-backdrop[hidden] {
    display: none;
  }

  body.mobile-chat-drawer-open
    .mobile-chat-drawer-backdrop {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-sidebar,
  .mobile-chat-drawer-backdrop {
    transition: none !important;
  }
}

/* Этап 25.4 — инструменты: калькулятор, календарь и заметки */
.sidebar-tools-button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: calc(100% - 16px);
  min-height: 42px;
  margin: 10px 8px 0;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: bold;
}

.sidebar-tools-button:hover {
  border-color: var(--accent-color);
  background: var(--accent-soft);
  color: var(--accent-color-dark);
}

@media (min-width: 821px) and (hover: hover) and (pointer: fine) {
  html[data-sidebar-mode="compact"]
    .sidebar-tools-button {
    width: 72px;
    min-height: 48px;
    margin: 10px auto 0;
    padding: 7px 4px;
    border-radius: 14px;
    font-size: 10px;
    line-height: 1.15;
    text-align: center;
  }
}

.tools-dialog {
  z-index: 1950;
}

.tools-dialog-card {
  display: flex;
  width: min(880px, 100%);
  height: min(
    760px,
    calc(var(--app-viewport-height, 100vh) - 36px)
  );
  max-height: min(
    820px,
    calc(var(--app-viewport-height, 100vh) - 36px)
  );
  padding: 0;
  overflow: hidden;
  flex-direction: column;
}

.tools-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex: 0 0 auto;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-color);
}

.tools-dialog-header h2 {
  font-size: 21px;
}

.tools-dialog-header p {
  margin-top: 5px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.4;
}

.tools-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  flex: 0 0 auto;
  gap: 7px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
}

.tools-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 43px;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 11px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: bold;
}

.tools-tab:hover,
.tools-tab-active {
  background: var(--accent-soft);
  color: var(--accent-color-dark);
}

.tools-tab-icon {
  display: block;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tools-pages {
  min-height: 0;
  flex: 1;
  padding: 18px 20px 20px;
  overflow-y: auto;
}

.tools-page[hidden] {
  display: none;
}

/* Калькулятор */
.calculator-shell {
  width: min(430px, 100%);
  margin: 0 auto;
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: var(--surface-soft);
  box-shadow: 0 10px 28px rgba(22, 48, 58, 0.1);
}

.calculator-screen {
  display: flex;
  min-height: 108px;
  margin-bottom: 13px;
  padding: 14px 16px;
  overflow: hidden;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  border: 1px solid var(--border-color);
  border-radius: 15px;
  background: var(--input-background);
}

.calculator-expression {
  width: 100%;
  min-height: 20px;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 13px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calculator-display {
  display: block;
  width: 100%;
  margin-top: 6px;
  overflow: hidden;
  color: var(--text-primary);
  font-size: clamp(30px, 7vw, 42px);
  font-weight: bold;
  line-height: 1.1;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calculator-keypad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.calculator-key {
  min-height: 56px;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--surface-strong);
  color: var(--text-primary);
  font-size: 20px;
  font-weight: bold;
  transition:
    transform 0.1s ease,
    background 0.12s ease;
}

.calculator-key:hover,
.calculator-key:focus-visible {
  background: var(--hover-background);
}

.calculator-key:active {
  transform: scale(0.96);
}

.calculator-key-muted {
  background: var(--muted-button-background);
  color: var(--accent-color-dark);
}

.calculator-key-operation {
  background: var(--accent-soft);
  color: var(--accent-color-dark);
  font-size: 24px;
}

.calculator-key-equals {
  border-color: var(--accent-color);
  background: var(--accent-color);
  color: #ffffff;
  font-size: 25px;
}

.calculator-key-equals:hover,
.calculator-key-equals:focus-visible {
  background: var(--accent-color-dark);
}

/* Календарь */
.calendar-shell {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: var(--surface-soft);
  box-shadow: 0 10px 28px rgba(22, 48, 58, 0.1);
}

.calendar-toolbar {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 9px;
}

.calendar-toolbar button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 12px;
  background: var(--hover-background);
  color: var(--accent-color-dark);
  font-size: 28px;
  line-height: 1;
}

.calendar-toolbar button:hover {
  background: var(--accent-soft);
}

.calendar-month-title {
  min-width: 0;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 19px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-today-button {
  display: block;
  min-height: 36px;
  margin: 10px auto 13px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--muted-button-background);
  color: var(--accent-color-dark);
  font-size: 13px;
  font-weight: bold;
}

.calendar-today-button:hover {
  background: var(--accent-soft);
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.calendar-weekdays {
  margin-bottom: 5px;
}

.calendar-weekdays span {
  padding: 4px 0;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: bold;
  text-align: center;
}

.calendar-day {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--surface-strong);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: bold;
}

.calendar-day:hover {
  border-color: var(--accent-color);
  background: var(--hover-background);
}

.calendar-day-outside {
  color: var(--text-secondary);
  opacity: 0.55;
}

.calendar-day-today {
  border-color: var(--accent-color);
}

.calendar-day-today::after {
  content: "";
  position: absolute;
  bottom: 5px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent-color);
}

.calendar-day-selected,
.calendar-day-selected:hover {
  border-color: var(--accent-color);
  background: var(--accent-color);
  color: #ffffff;
  opacity: 1;
}

.calendar-day-selected::after {
  background: #ffffff;
}

.calendar-day-number {
  position: relative;
  z-index: 1;
}

.calendar-day-note-count {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent-color);
  color: #ffffff;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
}

.calendar-day-selected
  .calendar-day-note-count {
  background: #ffffff;
  color: var(--accent-color-dark);
}

.calendar-day-outside
  .calendar-day-note-count {
  opacity: 0.8;
}

.calendar-selected-date {
  min-height: 42px;
  margin-top: 13px;
  padding: 11px 13px;
  border: 1px solid var(--border-color);
  border-radius: 13px;
  background: var(--input-background);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: bold;
  text-align: center;
}


.calendar-events {
  display: flex;
  margin-top: 8px;
  flex-direction: column;
  gap: 6px;
}

.calendar-events-heading {
  padding: 3px 2px 1px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: bold;
}

.calendar-events-empty {
  padding: 10px 12px;
  border: 1px dashed var(--border-color);
  border-radius: 11px;
  color: var(--text-secondary);
  font-size: 12px;
  text-align: center;
}

.calendar-event-note {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: stretch;
  gap: 7px;
  padding: 5px;
  border: 1px solid var(--border-color);
  border-radius: 11px;
  background: var(--surface-strong);
  color: var(--text-primary);
}

.calendar-event-note:hover,
.calendar-event-note:focus-within {
  border-color: var(--accent-color);
}

.calendar-event-note-selected,
.calendar-event-note-selected:hover,
.calendar-event-note-selected:focus-within {
  border-color: var(--accent-color);
  background:
    color-mix(
      in srgb,
      var(--accent-color) 16%,
      var(--surface-strong)
    );
  box-shadow:
    inset 4px 0 0 var(--accent-color),
    0 2px 9px rgba(32, 58, 68, 0.1);
}

.calendar-event-note-main {
  display: flex;
  min-width: 0;
  min-height: 48px;
  flex: 1;
  padding: 5px 6px;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  text-align: left;
}

.calendar-event-note-main:hover,
.calendar-event-note-main:focus-visible {
  background: var(--hover-background);
}

.calendar-event-note-main strong,
.calendar-event-note-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-event-note-main strong {
  font-size: 12px;
}

.calendar-event-note-main span {
  color: var(--text-secondary);
  font-size: 11px;
}

.calendar-event-note-selected
  .calendar-event-note-main span {
  display: -webkit-box;
  overflow: hidden;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-height: 1.35;
}

.calendar-event-note-hint {
  margin-top: 4px;
  color: var(--accent-color-dark);
  font-size: 10px;
  font-weight: bold;
}

.calendar-event-note-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
}

.calendar-event-note-action {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  padding: 0;
  border-radius: 9px;
  background: var(--muted-button-background);
  color: var(--accent-color-dark);
}

.calendar-event-note-action:hover,
.calendar-event-note-action:focus-visible {
  background: var(--accent-soft);
}

.calendar-event-note-action svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.calendar-event-note-unlink {
  color: var(--danger-color);
}

.calendar-event-note-unlink:hover,
.calendar-event-note-unlink:focus-visible {
  background: var(--danger-soft);
}

/* Заметки */
.notes-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  gap: 12px;
  margin-bottom: 12px;
}

.notes-toolbar-main {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 9px;
}

.notes-toolbar-status {
  display: flex;
  min-width: 120px;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.notes-search-field {
  display: flex;
  width: min(310px, 100%);
  min-width: 140px;
  min-height: 40px;
  align-items: center;
  gap: 7px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--border-color);
  border-radius: 11px;
  background: var(--input-background);
}

.notes-search-field:focus-within {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(79, 127, 143, 0.14);
}

.notes-search-field svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  fill: none;
  stroke: var(--text-secondary);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#notes-search-input {
  min-width: 0;
  height: 38px;
  flex: 1;
  padding: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 12px;
}

#notes-search-input::placeholder {
  color: var(--text-secondary);
}

#notes-search-input::-webkit-search-cancel-button {
  display: none;
}

#notes-search-clear {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
}

#notes-search-clear:hover {
  background: var(--hover-background);
  color: var(--accent-color-dark);
}

#notes-search-clear[hidden] {
  display: none;
}

.notes-search-status {
  min-height: 14px;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: bold;
  text-align: right;
}

.notes-create-button {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  gap: 7px;
  padding: 0 14px;
  border-radius: 11px;
  background: var(--accent-color);
  color: #ffffff;
  font-size: 13px;
  font-weight: bold;
}

.notes-create-button:hover {
  background: var(--accent-color-dark);
}

.notes-create-button > span:first-child {
  font-size: 19px;
  line-height: 1;
}

.notes-save-status {
  min-height: 18px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: bold;
  text-align: right;
}

.notes-workspace {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  height: min(430px, calc(100vh - 285px));
  min-height: 320px;
  /*
    Не используем overflow:hidden: браузер считает такой блок
    прокручиваемым и при фокусе на календаре мог сдвигать ВСЮ
    рабочую область вверх. overflow:clip обрезает содержимое,
    но принципиально не создаёт общий scroll-container.
  */
  overflow: clip;
  overflow-anchor: none;
  border: 1px solid var(--border-color);
  border-radius: 17px;
  background: var(--surface-soft);
}

.notes-list {
  min-width: 0;
  min-height: 0;
  padding: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  overflow-anchor: none;
  scroll-padding: 7px;
  scrollbar-width: thin;
  border-right: 1px solid var(--border-color);
  background: var(--sidebar-background);
}

.notes-list-item {
  display: flex;
  width: 100%;
  min-width: 0;
  margin-bottom: 6px;
  padding: 10px;
  overflow: hidden;
  flex-direction: column;
  gap: 4px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text-primary);
  text-align: left;
}

.notes-list-item:hover {
  background: var(--surface-soft);
}

.notes-list-item-active,
.notes-list-item-active:hover {
  border-color: var(--accent-color);
  background:
    color-mix(
      in srgb,
      var(--accent-color) 22%,
      var(--surface-strong)
    );
  box-shadow:
    inset 4px 0 0 var(--accent-color),
    0 2px 9px rgba(32, 58, 68, 0.12);
}

.notes-list-item-active strong {
  color: var(--accent-color-dark);
}

.notes-list-item strong,
.notes-list-item span,
.notes-list-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-list-item strong {
  font-size: 13px;
}

.notes-list-item span {
  color: var(--text-secondary);
  font-size: 11px;
}

.notes-list-item small {
  color: var(--text-secondary);
  font-size: 10px;
}

.notes-list-empty {
  padding: 20px 8px;
  color: var(--text-secondary);
  font-size: 12px;
  text-align: center;
}

.notes-editor {
  min-width: 0;
  min-height: 0;
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  overflow-anchor: none;
  scrollbar-width: thin;
  background: var(--surface-strong);
}

.notes-empty {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 30px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.notes-empty[hidden],
.notes-fields[hidden] {
  display: none;
}

.notes-fields {
  display: flex;
  min-height: 100%;
  flex-direction: column;
}

.notes-title-input,
.notes-content-input {
  width: 100%;
  border: 1px solid var(--border-color);
  background: var(--input-background);
  color: var(--text-primary);
  font: inherit;
}

.notes-title-input {
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 11px;
  font-size: 16px;
  font-weight: bold;
}

.notes-content-input {
  min-height: 310px;
  flex: 1;
  margin-top: 10px;
  padding: 12px;
  resize: none;
  border-radius: 13px;
  font-size: 14px;
  line-height: 1.5;
}

.notes-title-input:focus,
.notes-content-input:focus {
  border-color: var(--accent-color);
  outline: 3px solid rgba(79, 127, 143, 0.16);
}

.notes-calendar-link {
  margin-top: 10px;
  padding: 9px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--surface-soft);
}

.notes-calendar-summary {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.notes-calendar-toggle {
  display: inline-flex;
  min-height: 34px;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border-radius: 9px;
  background: var(--muted-button-background);
  color: var(--accent-color-dark);
  font-size: 11px;
  font-weight: bold;
}

.notes-calendar-toggle:hover:not(:disabled) {
  background: var(--accent-soft);
}

.notes-calendar-toggle:disabled {
  cursor: default;
  opacity: 0.5;
}

.notes-calendar-toggle svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.notes-calendar-current {
  min-width: 0;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: bold;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-calendar-quick-remove {
  display: none !important;
  min-height: 30px;
  flex: 0 0 auto;
  padding: 0 9px;
  border-radius: 8px;
  background: transparent;
  color: var(--danger-color);
  font-size: 10px;
  font-weight: bold;
}

.notes-calendar-quick-remove:hover {
  background: var(--danger-soft);
}

.notes-calendar-quick-remove[hidden] {
  display: none;
}

.notes-calendar-controls {
  display: grid;
  grid-template-columns:
    auto minmax(145px, 1fr) auto auto;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

.notes-calendar-controls[hidden] {
  display: none;
}

.notes-calendar-controls label {
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: bold;
}

#notes-calendar-date {
  min-width: 0;
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid var(--border-color);
  border-radius: 9px;
  background: var(--input-background);
  color: var(--text-primary);
  font: inherit;
  font-size: 11px;
}

.notes-calendar-apply,
.notes-calendar-remove {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 9px;
  font-size: 10px;
  font-weight: bold;
}

.notes-calendar-apply {
  background: var(--accent-color);
  color: #ffffff;
}

.notes-calendar-remove {
  background: var(--danger-soft);
  color: var(--danger-color);
}

.notes-calendar-remove[hidden] {
  display: none;
}

.notes-editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

#notes-updated-at {
  color: var(--text-secondary);
  font-size: 11px;
}

.notes-delete-button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger-color);
  font-size: 12px;
  font-weight: bold;
}

.notes-delete-button:hover {
  filter: brightness(0.97);
}

.notes-storage-note {
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.45;
}

@media (max-width: 820px), (hover: none) and (pointer: coarse) {
  .app-sidebar > .sidebar-tools-button {
    display: none;
  }

  .mobile-chat-drawer-footer-button-tools {
    grid-column: 1 / -1;
  }

  .tools-dialog {
    padding:
      max(8px, env(safe-area-inset-top))
      8px
      max(8px, env(safe-area-inset-bottom));
  }

  .tools-dialog-card {
    width: 100%;
    height: calc(
      var(--app-viewport-height, 100dvh) -
      max(16px, env(safe-area-inset-top)) -
      max(16px, env(safe-area-inset-bottom))
    );
    max-height: calc(
      var(--app-viewport-height, 100dvh) -
      max(16px, env(safe-area-inset-top)) -
      max(16px, env(safe-area-inset-bottom))
    );
    border-radius: 18px;
  }

  .tools-dialog-header {
    padding: 14px 15px 11px;
  }

  .tools-dialog-header h2 {
    font-size: 19px;
  }

  .tools-dialog-header p {
    font-size: 12px;
  }

  .tools-tabs {
    gap: 4px;
    padding: 8px;
  }

  .tools-tab {
    min-height: 44px;
    gap: 4px;
    padding: 6px 4px;
    font-size: 11px;
  }

  .tools-tab-icon {
    width: 17px;
    height: 17px;
    flex-basis: 17px;
  }

  .tools-pages {
    padding: 12px;
  }

  .calculator-shell,
  .calendar-shell {
    padding: 11px;
    border-radius: 16px;
  }

  .calculator-screen {
    min-height: 92px;
    padding: 11px 13px;
  }

  .calculator-keypad {
    gap: 7px;
  }

  .calculator-key {
    min-height: 52px;
    border-radius: 12px;
  }

  .calendar-day {
    border-radius: 10px;
    font-size: 13px;
  }

  .calendar-event-note {
    gap: 5px;
  }

  .calendar-event-note-actions {
    gap: 3px;
  }

  .calendar-event-note-action {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .notes-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 9px;
  }

  .notes-toolbar-main {
    width: 100%;
    flex-wrap: wrap;
  }

  .notes-create-button {
    flex: 0 0 auto;
  }

  .notes-search-field {
    min-width: 170px;
    flex: 1;
  }

  .notes-toolbar-status {
    width: 100%;
    min-width: 0;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .notes-search-status,
  .notes-save-status {
    text-align: left;
  }

  .notes-workspace {
    display: flex;
    min-height: 0;
    overflow: visible;
    flex-direction: column;
    border: none;
    background: transparent;
  }

  .notes-list {
    display: flex;
    min-height: 82px;
    max-height: 104px;
    gap: 7px;
    padding: 4px 2px 8px;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
  }

  .notes-list-item {
    flex: 0 0 155px;
    margin: 0;
    padding: 9px;
    border-color: var(--border-color);
    background: var(--surface-soft);
  }

  .notes-list-empty {
    width: 100%;
    padding: 22px 8px;
  }

  .notes-editor {
    min-height: 0;
    padding: 11px 0 0;
    background: transparent;
  }

  .notes-empty {
    min-height: 230px;
    border: 1px dashed var(--border-color);
    border-radius: 14px;
  }

  .notes-content-input {
    min-height: 250px;
    resize: vertical;
  }

  .notes-calendar-summary {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .notes-calendar-toggle {
    width: 100%;
    justify-content: center;
  }

  .notes-calendar-current {
    width: 100%;
    text-align: center;
    white-space: normal;
  }

  .notes-calendar-quick-remove {
    width: 100%;
    min-height: 32px;
  }

  .notes-calendar-controls {
    grid-template-columns: 1fr 1fr;
  }

  .notes-calendar-controls label {
    grid-column: 1 / -1;
  }

  #notes-calendar-date {
    grid-column: 1 / -1;
  }

  .notes-calendar-apply,
  .notes-calendar-remove {
    width: 100%;
  }

  .notes-editor-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .notes-delete-button {
    align-self: stretch;
  }
}

@media (max-width: 420px) {
  .notes-toolbar-main {
    flex-direction: column;
    align-items: stretch;
  }

  .notes-create-button,
  .notes-search-field {
    width: 100%;
    max-width: none;
  }

  .notes-create-button {
    justify-content: center;
  }

  .calendar-day-note-count {
    top: 2px;
    right: 2px;
    min-width: 14px;
    height: 14px;
    padding-inline: 3px;
    font-size: 8px;
  }

  .tools-tab {
    gap: 4px;
    padding-inline: 4px;
    font-size: 10px;
  }

  .tools-tab-icon {
    width: 16px;
    height: 16px;
    flex-basis: 16px;
  }

  .calendar-shell {
    padding: 9px;
  }

  .calendar-weekdays,
  .calendar-grid {
    gap: 3px;
  }

  .calendar-day {
    border-radius: 9px;
    font-size: 12px;
  }

  .calendar-selected-date {
    font-size: 12px;
  }
}



/* Этап 25.5 — точная настройка внешнего вида чатов */
.advanced-appearance-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.advanced-appearance-heading p {
  margin-top: 5px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
}

.advanced-appearance-reset {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--muted-button-background);
  color: var(--accent-color-dark);
  font-size: 12px;
  font-weight: bold;
}

.advanced-appearance-reset:hover {
  background: var(--accent-soft);
}

.advanced-appearance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 15px;
}

.advanced-appearance-field,
.advanced-appearance-range {
  display: flex;
  min-width: 0;
  padding: 12px;
  flex-direction: column;
  gap: 9px;
  border: 1px solid var(--border-color);
  border-radius: 13px;
  background: var(--surface-soft);
}

.advanced-appearance-field > span,
.advanced-appearance-range > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: bold;
}

.advanced-appearance-field select {
  width: 100%;
  min-height: 40px;
  padding: 7px 10px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--input-background);
  color: var(--text-primary);
}

.advanced-appearance-range output {
  color: var(--accent-color-dark);
  white-space: nowrap;
}

.advanced-appearance-range input[type="range"] {
  width: 100%;
  accent-color: var(--accent-color);
}

.appearance-color-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.appearance-color-control {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 13px;
  background: var(--surface-soft);
}

.appearance-color-control.appearance-color-custom {
  border-color: var(--accent-color);
  box-shadow: inset 0 0 0 1px var(--accent-soft);
}

.appearance-color-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.appearance-color-title strong {
  min-width: 0;
  font-size: 12px;
}

.appearance-color-title button {
  flex: 0 0 auto;
  padding: 4px 7px;
  border-radius: 8px;
  background: var(--muted-button-background);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: bold;
}

.appearance-color-title button:hover {
  background: var(--accent-soft);
  color: var(--accent-color-dark);
}

.appearance-color-inputs {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 9px;
  margin-top: 10px;
}

.appearance-color-inputs input[type="color"] {
  width: 52px;
  height: 42px;
  padding: 3px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--input-background);
  cursor: pointer;
}

.appearance-color-inputs input[type="text"] {
  min-width: 0;
  height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--input-background);
  color: var(--text-primary);
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  font-weight: bold;
  text-transform: uppercase;
}

.appearance-color-inputs input.appearance-color-invalid {
  border-color: var(--danger-color);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.appearance-color-control output {
  display: block;
  min-height: 16px;
  margin-top: 7px;
  color: var(--text-secondary);
  font-size: 10px;
}

.advanced-appearance-preview {
  display: flex;
  min-height: 150px;
  margin-top: 13px;
  padding: 16px;
  flex-direction: column;
  justify-content: center;
  gap: var(--advanced-preview-spacing, 8px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  background:
    radial-gradient(
      circle at 16px 16px,
      var(--chat-pattern) 2px,
      transparent 2px
    ),
    var(--chat-background);
  background-size: 54px 54px;
}

.advanced-preview-bubble {
  width: fit-content;
  max-width: 82%;
  padding: 9px 12px;
  border: 2px solid transparent;
  border-radius: var(--advanced-preview-radius, 15px);
  color: var(--advanced-preview-text-color);
  font-family: var(--advanced-preview-font-family);
  font-size: var(--advanced-preview-font-size);
  line-height: 1.4;
  box-shadow: 0 2px 6px rgba(41, 69, 79, 0.1);
}

.advanced-preview-nickname {
  display: block;
  margin-bottom: 3px;
  color: var(--advanced-preview-nickname-color);
  font-size: 0.8em;
  font-weight: 700;
}

.advanced-preview-partner {
  margin-right: auto;
  border-bottom-left-radius: 5px;
  background: var(--advanced-preview-partner-color);
}

.advanced-preview-own {
  margin-left: auto;
  border-color: var(--advanced-preview-accent-color);
  border-bottom-right-radius: 5px;
  background: var(--advanced-preview-own-color);
}

#message-input {
  font-family: var(--chat-message-font-family);
  font-size: var(--chat-message-font-size);
}

@media (max-width: 700px) {
  .advanced-appearance-heading {
    flex-direction: column;
  }

  .advanced-appearance-reset {
    align-self: stretch;
  }

  .advanced-appearance-grid,
  .appearance-color-grid {
    grid-template-columns: 1fr;
  }
}


.mobile-chat-drawer-footer-button-tools > span:first-child {
  color: inherit;
  font-size: 13px;
  line-height: inherit;
}


/* Этап 25.5.3 — единая встроенная палитра */
.appearance-color-swatch {
  position: relative;
  display: grid;
  width: 52px;
  height: 42px;
  padding: 3px;
  place-items: center;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--input-background);
  cursor: pointer;
}

.appearance-color-swatch > span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 7px;
  background: var(
    --appearance-swatch-color,
    #4f7f8f
  );
  box-shadow:
    inset 0 0 0 1px
      rgba(0, 0, 0, 0.12);
}

.appearance-color-swatch:hover,
.appearance-color-swatch:focus-visible {
  border-color: var(--accent-color);
  box-shadow:
    0 0 0 3px var(--accent-soft);
}

.appearance-custom-color-picker {
  position: relative;
  z-index: 12;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  background: var(--surface-floating-strong);
  box-shadow: 0 12px 30px rgba(24, 46, 56, 0.18);
}

.appearance-custom-color-picker[hidden] {
  display: none;
}

.appearance-custom-color-picker-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.appearance-custom-color-picker-header > div {
  min-width: 0;
}

.appearance-custom-color-picker-header strong,
.appearance-custom-color-picker-header small {
  display: block;
}

.appearance-custom-color-picker-header strong {
  font-size: 14px;
}

.appearance-custom-color-picker-header small {
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: 11px;
}

#appearance-custom-color-picker-close {
  display: grid;
  width: 31px;
  height: 31px;
  padding: 0;
  flex: 0 0 31px;
  place-items: center;
  border-radius: 9px;
  background: var(--muted-button-background);
  color: var(--text-secondary);
  font-size: 21px;
  line-height: 1;
}

#appearance-custom-color-picker-close:hover {
  background: var(--accent-soft);
  color: var(--text-primary);
}

.appearance-color-saturation-value {
  position: relative;
  width: 100%;
  height: 210px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: 13px;
  background:
    linear-gradient(
      to top,
      #000000,
      transparent
    ),
    linear-gradient(
      to right,
      #ffffff,
      transparent
    ),
    var(
      --appearance-picker-hue-color,
      #ff0000
    );
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

.appearance-color-saturation-value-thumb {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.65),
    0 2px 7px rgba(0, 0, 0, 0.32);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.appearance-custom-hue {
  display: block;
  margin-top: 12px;
}

.appearance-custom-hue > span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: bold;
}

#appearance-color-hue {
  width: 100%;
  height: 24px;
  margin-top: 7px;
  appearance: none;
  -webkit-appearance: none;
  border: none;
  outline: none;
  background: transparent;
  cursor: pointer;
}

#appearance-color-hue::-webkit-slider-runnable-track {
  height: 12px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 999px;
  background:
    linear-gradient(
      to right,
      #ff0000,
      #ffff00,
      #00ff00,
      #00ffff,
      #0000ff,
      #ff00ff,
      #ff0000
    );
}

#appearance-color-hue::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  margin-top: -6px;
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--accent-color);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.5),
    0 2px 6px rgba(0, 0, 0, 0.28);
}

#appearance-color-hue::-moz-range-track {
  height: 12px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 999px;
  background:
    linear-gradient(
      to right,
      #ff0000,
      #ffff00,
      #00ff00,
      #00ffff,
      #0000ff,
      #ff00ff,
      #ff0000
    );
}

#appearance-color-hue::-moz-range-thumb {
  width: 19px;
  height: 19px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--accent-color);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.5),
    0 2px 6px rgba(0, 0, 0, 0.28);
}

.appearance-custom-color-values {
  display: grid;
  grid-template-columns:
    46px minmax(0, 1fr)
    minmax(0, 1fr);
  gap: 9px;
  margin-top: 12px;
  align-items: end;
}

.appearance-custom-color-preview {
  display: block;
  width: 46px;
  height: 42px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow:
    inset 0 0 0 1px
      rgba(0, 0, 0, 0.12);
}

.appearance-custom-color-values label {
  min-width: 0;
}

.appearance-custom-color-values label > span {
  display: block;
  margin-bottom: 5px;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: bold;
}

.appearance-custom-color-values input {
  width: 100%;
  height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--input-background);
  color: var(--text-primary);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  font-weight: bold;
}

.appearance-custom-color-values input[readonly] {
  color: var(--text-secondary);
}

.appearance-custom-color-values input.appearance-color-invalid {
  border-color: var(--danger-color);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.appearance-custom-color-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 13px;
}

.appearance-custom-color-actions button {
  min-width: 92px;
  padding: 9px 13px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: bold;
}

#appearance-custom-color-cancel {
  background: var(--muted-button-background);
  color: var(--text-primary);
}

#appearance-custom-color-apply {
  background: var(--accent-color);
  color: #ffffff;
}

/* Этап 25.6.2 — прогресс и надёжное возобновление вложений */
.selected-attachment-upload-state {
  width: min(360px, 76vw);
  max-width: 100%;
  margin-top: 7px;
  padding: 9px 10px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--hover-background);
}

.selected-attachment-upload-state[hidden] {
  display: none;
}

.selected-attachment-upload-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: bold;
}

#selected-attachment-upload-status {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#selected-attachment-upload-percent {
  flex: 0 0 auto;
  color: var(--accent-color-dark);
  font-size: 12px;
}

.selected-attachment-upload-progress {
  height: 8px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
  box-shadow: inset 0 0 0 1px var(--border-color);
}

#selected-attachment-upload-progress-bar {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-color);
  transition: width 0.12s ease;
}

.selected-attachment-upload-state[data-state="processing"]
  #selected-attachment-upload-progress-bar,
.selected-attachment-upload-state[data-state="success"]
  #selected-attachment-upload-progress-bar,
.selected-attachment-upload-state[data-state="sending"]
  #selected-attachment-upload-progress-bar {
  background: #3a9a55;
}

.selected-attachment-upload-state[data-state="error"] {
  border-color: var(--danger-color);
  background: var(--danger-soft);
}

.selected-attachment-upload-state[data-state="error"]
  #selected-attachment-upload-status,
.selected-attachment-upload-state[data-state="error"]
  #selected-attachment-upload-percent {
  color: var(--danger-color);
}

.selected-attachment-upload-state[data-state="error"]
  #selected-attachment-upload-status {
  overflow: visible;
  line-height: 1.35;
  text-overflow: clip;
  white-space: normal;
}

.selected-attachment-upload-state[data-state="error"]
  #selected-attachment-upload-progress-bar {
  background: var(--danger-color);
}

#selected-attachment-upload-retry {
  position: relative;
  z-index: 3;
  width: 100%;
  min-height: 40px;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--accent-color);
  color: #ffffff;
  font-size: 12px;
  font-weight: bold;
  touch-action: manipulation;
}

#selected-attachment-upload-retry[hidden] {
  display: none;
}

#selected-attachment-upload-retry:disabled {
  cursor: wait;
  opacity: 0.65;
}

#selected-image-remove {
  z-index: 12;
  touch-action: manipulation;
}

/* Этап 25.6 — единая система вложений */
#selected-attachment-preview-video {
  display: block;
  width: min(260px, 68vw);
  max-height: 190px;
  border-radius: 9px;
  background: #000000;
  object-fit: contain;
}

#selected-attachment-preview-video[hidden],
#selected-attachment-preview-file[hidden],
#selected-image-preview-image[hidden] {
  display: none;
}

.selected-attachment-preview-file {
  display: flex;
  width: min(360px, 76vw);
  min-width: 230px;
  padding: 10px 40px 10px 10px;
  align-items: center;
  gap: 10px;
  border-radius: 10px;
  background: var(--hover-background);
}

.selected-attachment-preview-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 11px;
  background: var(--accent-soft);
  font-size: 22px;
}

.selected-attachment-preview-details {
  display: block;
  min-width: 0;
}

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

.selected-attachment-preview-details strong {
  font-size: 13px;
}

.selected-attachment-preview-details small {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 10px;
}

.message-video-attachment {
  width: min(420px, 66vw);
  max-width: 100%;
  margin-top: 7px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--surface-soft);
}

.message-video {
  display: block;
  width: 100%;
  max-height: 430px;
  background: #000000;
  object-fit: contain;
}

/*
  У видео используется только кнопка разворачивания «Омута».
  Встроенный fullscreen браузера скрыт, чтобы не появлялся
  второй полноэкранный режим, из которого неудобно выходить
  на телефоне.
*/
.message-video::-webkit-media-controls-fullscreen-button,
.message-video-viewer-player::-webkit-media-controls-fullscreen-button {
  display: none !important;
  width: 0 !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

.message-video::-webkit-media-controls-picture-in-picture-button,
.message-video-viewer-player::-webkit-media-controls-picture-in-picture-button {
  display: none !important;
}

.message-attachment-caption {
  display: flex;
  min-width: 0;
  padding: 8px 10px;
  flex-direction: column;
  gap: 2px;
}

.message-attachment-caption span,
.message-attachment-caption small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-attachment-caption span {
  font-size: 12px;
  font-weight: bold;
}

.message-attachment-caption small {
  color: var(--text-secondary);
  font-size: 10px;
}

.message-video-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.message-video-attachment {
  position: relative;
}

.message-video-frame {
  position: relative;
  overflow: hidden;
}

.message-video-expand {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 7px;
  background: rgba(15, 22, 26, 0.36);
  color: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.message-video-expand:hover,
.message-video-expand:focus-visible {
  background: rgba(15, 22, 26, 0.66);
}

.message-video-expand svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.message-video-expanded-open {
  overflow: hidden;
}

.message-video-viewer {
  position: fixed;
  inset: 0;
  z-index: 2600;
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding:
    max(10px, env(safe-area-inset-top))
    max(8px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom))
    max(8px, env(safe-area-inset-left));
  background: rgba(5, 9, 12, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.message-video-viewer[hidden] {
  display: none;
}

.message-video-viewer-player {
  display: block;
  width: min(1180px, 100%);
  max-width: 100%;
  height: min(86dvh, 820px);
  max-height: calc(100dvh - 20px);
  background: #000000;
  object-fit: contain;
}

.message-video-viewer-close {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 4;
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(20, 24, 27, 0.48);
  color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 3px 16px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.message-video-viewer-close svg {
  display: block;
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.message-video-viewer-close:hover,
.message-video-viewer-close:focus-visible,
.message-video-viewer-close:active {
  background: rgba(20, 24, 27, 0.68);
}

.message-video-download {
  width: fit-content;
  margin-top: 5px;
  color: var(--accent-color-dark);
  font-size: 11px;
  font-weight: bold;
  text-decoration: none;
}

.message-video-download:hover,
.message-video-download:focus-visible {
  text-decoration: underline;
}

.message-file-attachment {
  display: flex;
  width: min(390px, 68vw);
  max-width: 100%;
  min-width: min(250px, 68vw);
  margin-top: 7px;
  padding: 10px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--text-primary);
  text-decoration: none;
}

.message-file-attachment:hover,
.message-file-attachment:focus-visible {
  background: var(--hover-background);
  border-color: var(--accent-color);
}

.message-file-attachment-icon {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 23px;
}

.message-file-attachment-details {
  display: block;
  min-width: 0;
  flex: 1;
}

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

.message-file-attachment-details strong {
  font-size: 12px;
}

.message-file-attachment-details small {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 10px;
}

.message-file-attachment-download {
  display: grid;
  width: 31px;
  height: 31px;
  flex: 0 0 31px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-color);
  color: #ffffff;
  font-size: 18px;
  font-weight: bold;
}

@media (max-width: 620px) {
  .appearance-color-grid {
    grid-template-columns: 1fr;
  }

  .appearance-color-saturation-value {
    height: 190px;
  }

  .appearance-custom-color-values {
    grid-template-columns:
      42px minmax(0, 1fr);
  }

  .appearance-custom-color-values label:last-child {
    grid-column: 2;
  }

  .appearance-custom-color-preview {
    width: 42px;
  }

  .message-video-attachment,
  .message-file-attachment {
    width: min(100%, 76vw);
  }

  .selected-attachment-preview-file {
    min-width: 0;
  }
}


/* =========================================================
   Этап 25.8 — галерея видео по модели фотогалереи
   ========================================================= */

.message-video-viewer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.message-video-viewer-gallery {
  z-index: 3;
  width: min(760px, calc(100vw - 96px));
  max-width: 100%;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 13px;
  background: rgba(20, 24, 27, 0.5);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.message-video-viewer-gallery[hidden] {
  display: none;
}

.message-video-viewer-thumbnail-list {
  display: flex;
  min-width: 0;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
  overscroll-behavior-inline: contain;
  touch-action: pan-x;
}

.message-video-viewer-thumbnail-list::-webkit-scrollbar {
  display: none;
}

.message-video-viewer-thumbnail {
  position: relative;
  display: block;
  flex: 0 0 82px;
  width: 82px;
  height: 52px;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 9px;
  background: #080b0d;
  box-shadow: none;
  opacity: 0.7;
  transition:
    opacity 0.16s ease,
    border-color 0.16s ease,
    transform 0.16s ease;
}

.message-video-viewer-thumbnail:hover,
.message-video-viewer-thumbnail:focus-visible {
  opacity: 1;
  transform: translateY(-1px);
}

.message-video-viewer-thumbnail-active {
  border-color: rgba(255, 255, 255, 0.92);
  opacity: 1;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.34),
    0 3px 11px rgba(0, 0, 0, 0.28);
}

.message-video-viewer-thumbnail-preview {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: #000000;
  object-fit: cover;
}

.message-video-viewer-thumbnail-play {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding-left: 2px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 50%;
  background: rgba(9, 13, 15, 0.55);
  color: rgba(255, 255, 255, 0.94);
  font-size: 10px;
  line-height: 1;
  pointer-events: none;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.message-video-viewer-has-gallery
  .message-video-viewer-player {
  height: min(74dvh, 740px);
  max-height: calc(100dvh - 106px);
}

.message-video-viewer-navigation {
  position: absolute;
  top: 50%;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 44px;
  height: 52px;
  padding: 0 0 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 13px;
  background: rgba(20, 24, 27, 0.46);
  color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.22);
  font-size: 40px;
  font-weight: 300;
  line-height: 1;
  transform: translateY(-50%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.message-video-viewer-navigation:hover:not(:disabled),
.message-video-viewer-navigation:focus-visible:not(:disabled) {
  background: rgba(20, 24, 27, 0.7);
}

.message-video-viewer-navigation:disabled {
  cursor: default;
  opacity: 0.25;
}

.message-video-viewer-navigation[hidden] {
  display: none;
}

.message-video-viewer-previous {
  left: max(12px, env(safe-area-inset-left));
}

.message-video-viewer-next {
  right: max(12px, env(safe-area-inset-right));
}

@media (max-width: 820px),
  (hover: none) and (pointer: coarse) {
  .message-video-viewer {
    gap: 8px;
  }

  .message-video-viewer-gallery {
    width: calc(100vw - 70px);
    padding: 5px;
    border-radius: 11px;
  }

  .message-video-viewer-thumbnail {
    flex-basis: 70px;
    width: 70px;
    height: 46px;
    border-radius: 8px;
  }

  .message-video-viewer-has-gallery
    .message-video-viewer-player {
    height: min(70dvh, 680px);
    max-height: calc(100dvh - 94px);
  }

  .message-video-viewer-navigation {
    width: 36px;
    height: 46px;
    border-radius: 11px;
    font-size: 34px;
  }

  .message-video-viewer-previous {
    left: max(6px, env(safe-area-inset-left));
  }

  .message-video-viewer-next {
    right: max(6px, env(safe-area-inset-right));
  }
}
