:root {
  --app-height: 100vh;
  --bg: #060606;
  --bg-elev: #0f0f0f;
  --panel: #151515;
  --panel-soft: #1d1d1d;
  --panel-strong: #262626;
  --text: #f2f2f2;
  --muted: #a5a5a5;
  --accent: #ffffff;
  --accent-ink: #101010;
  --line: rgba(255, 255, 255, 0.045);
  --ok: #3ddc84;
  --danger: #e5e5e5;
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 24px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Spline Sans", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

body[data-theme="graphite"] {
  --bg: #0a0b10;
  --bg-elev: #12141c;
  --panel: #181b24;
  --panel-soft: #202431;
  --panel-strong: #2a3040;
  --text: #eef1ff;
  --muted: #a6afc5;
  --accent: #d8def3;
  --accent-ink: #1a2238;
  --line: rgba(216, 222, 243, 0.055);
}

body[data-theme="ocean"] {
  --bg: #071418;
  --bg-elev: #0c1e24;
  --panel: #122830;
  --panel-soft: #183640;
  --panel-strong: #21505f;
  --text: #e8fbff;
  --muted: #9ac0c9;
  --accent: #c4f6ff;
  --accent-ink: #153844;
  --line: rgba(196, 246, 255, 0.06);
}

body[data-theme="sage"] {
  --bg: #0b130f;
  --bg-elev: #121e17;
  --panel: #1b2c22;
  --panel-soft: #23392d;
  --panel-strong: #2e4c3d;
  --text: #ebf8ef;
  --muted: #a2bdaa;
  --accent: #dbf7e2;
  --accent-ink: #1f3b2d;
  --line: rgba(219, 247, 226, 0.06);
}

body[data-theme="midnight"] {
  --bg: #060912;
  --bg-elev: #0d1221;
  --panel: #121a2f;
  --panel-soft: #1a2741;
  --panel-strong: #26385d;
  --text: #eff4ff;
  --muted: #9fafd3;
  --accent: #d6e3ff;
  --accent-ink: #1b2c52;
  --line: rgba(214, 227, 255, 0.06);
}

body[data-theme="rose"] {
  --bg: #140c12;
  --bg-elev: #1f101a;
  --panel: #2a1422;
  --panel-soft: #381c2d;
  --panel-strong: #4b2640;
  --text: #ffeef8;
  --muted: #d5aebf;
  --accent: #ffd3e8;
  --accent-ink: #521f3d;
  --line: rgba(255, 211, 232, 0.06);
}

body[data-theme="amber"] {
  --bg: #16120b;
  --bg-elev: #221a10;
  --panel: #2e2215;
  --panel-soft: #3b2d1b;
  --panel-strong: #533d22;
  --text: #fff4e6;
  --muted: #d5b88f;
  --accent: #ffd9a2;
  --accent-ink: #4a3217;
  --line: rgba(255, 217, 162, 0.06);
}

body[data-theme="frost"] {
  --bg: #071015;
  --bg-elev: #0d1820;
  --panel: #11212c;
  --panel-soft: #19303e;
  --panel-strong: #25465a;
  --text: #ebf9ff;
  --muted: #9fc5d6;
  --accent: #d1efff;
  --accent-ink: #17394b;
  --line: rgba(209, 239, 255, 0.06);
}

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

.hidden {
  display: none !important;
}

#loading-overlay {
  position: fixed;
  inset: 0;
  background-color: #404456;
  z-index: 1000;
  opacity: 1;
  transition: opacity 220ms ease;
}

#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

#loader {
  position: absolute;
  top: 50%;
  left: 50%;
  margin-top: -2.7em;
  margin-left: -2.7em;
  width: 5.4em;
  height: 5.4em;
  background-color: #404456;
}

#hill {
  position: absolute;
  width: 7.1em;
  height: 7.1em;
  top: 1.7em;
  left: 1.7em;
  background-color: transparent;
  border-left: 0.25em solid whitesmoke;
  transform: rotate(45deg);
}

#hill:after {
  content: "";
  position: absolute;
  width: 7.1em;
  height: 7.1em;
  left: 0;
  background-color: #404456;
}

#box {
  position: absolute;
  left: 0;
  bottom: -0.1em;
  width: 1em;
  height: 1em;
  background-color: transparent;
  border: 0.25em solid whitesmoke;
  border-radius: 15%;
  transform: translate(0, -1em) rotate(-45deg);
  animation: push 2.5s cubic-bezier(0.79, 0, 0.47, 0.97) infinite;
}

@keyframes push {
  0% { transform: translate(0, -1em) rotate(-45deg); }
  5% { transform: translate(0, -1em) rotate(-50deg); }
  20% { transform: translate(1em, -2em) rotate(47deg); }
  25% { transform: translate(1em, -2em) rotate(45deg); }
  30% { transform: translate(1em, -2em) rotate(40deg); }
  45% { transform: translate(2em, -3em) rotate(137deg); }
  50% { transform: translate(2em, -3em) rotate(135deg); }
  55% { transform: translate(2em, -3em) rotate(130deg); }
  70% { transform: translate(3em, -4em) rotate(217deg); }
  75% { transform: translate(3em, -4em) rotate(220deg); }
  100% { transform: translate(0, -1em) rotate(-225deg); }
}

.overlay,
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.88);
  z-index: 900;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 18px;
}

.auth-card,
.modal-card {
  width: min(620px, 92vw);
  background: var(--panel);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--line);
  max-height: min(calc(var(--app-height) - 36px), 900px);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.modal-card.sticker-card {
  width: min(920px, 94vw);
  max-height: min(640px, 86vh);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.sticker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sticker-picker {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sticker-recent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sticker-recent-empty {
  color: var(--muted);
  font-size: 12px;
  padding: 10px 6px;
  white-space: nowrap;
}

.sticker-pack-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.sticker-pack-tabs {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: auto;
  padding: 2px;
  scrollbar-width: none;
}

.sticker-pack-tabs::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.sticker-tab {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.sticker-tab:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.06);
}

.sticker-tab.active {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, rgba(255, 255, 255, 0.03));
}

.sticker-tab.plus {
  background: transparent;
  border-style: dashed;
  color: var(--muted);
}

.sticker-tab-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 14px;
}

.sticker-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 16px;
  text-align: center;
  grid-column: 1 / -1;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.sticker-wizard-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: grid;
  place-items: center;
  z-index: 30;
}

.sticker-wizard-card {
  width: min(560px, 94vw);
  max-height: min(620px, 90vh);
  background: var(--panel);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  animation: slideFadeIn 180ms ease;
}

.sticker-wizard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sticker-wizard-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.sticker-wizard-step {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sticker-wizard-step label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sticker-wizard-step input {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 12px 12px;
  outline: none;
}

.sticker-wizard-step input:focus {
  border-color: color-mix(in srgb, var(--accent) 32%, var(--line));
}

.sticker-drop {
  border-radius: 18px;
  border: 1px dashed var(--line);
  background: rgba(255, 255, 255, 0.02);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.sticker-drop:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.04);
}

.sticker-drop.drag-over {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  background: rgba(255, 255, 255, 0.06);
}

.sticker-drop.disabled {
  opacity: 0.65;
  pointer-events: none;
}

.sticker-drop-title {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.sticker-drop-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.sticker-wizard-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sticker-wizard-count {
  color: var(--muted);
  font-size: 12px;
}

.sticker-cell.wizard .sticker-del,
.sticker-del.always {
  opacity: 1;
  transform: scale(1);
}

.sticker-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 12px;
}

.sticker-sidebar,
.sticker-main {
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  min-height: 0;
}

.sticker-sidebar {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sticker-pack-create {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
}

.sticker-pack-create input {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

.sticker-pack-create input:focus {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
}

.sticker-pack-list {
  overflow: auto;
  min-height: 0;
}

.sticker-main {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sticker-main-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sticker-pack-title {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.sticker-main-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sticker-recent-block {
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 10px;
  display: grid;
  gap: 6px;
}

.sticker-recent-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.sticker-recent-row {
  display: flex;
  gap: 8px;
  overflow: auto;
  padding: 4px 2px;
}

.sticker-recent-item {
  width: 68px;
  height: 68px;
  flex: 0 0 auto;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  padding: 0;
  outline: none;
  overflow: hidden;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 120ms ease, background-color 120ms ease;
}

.sticker-recent-item:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.06);
}

.sticker-recent-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sticker-grid {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 10px;
  padding: 6px;
}

.sticker-cell {
  position: relative;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 120ms ease, background-color 120ms ease;
}

.sticker-cell:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.06);
}

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

.sticker-del {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.45);
  color: var(--text);
  display: grid;
  place-items: center;
  opacity: 0;
  transform: scale(0.94);
  transition: opacity 120ms ease, transform 120ms ease;
}

.sticker-cell:hover .sticker-del {
  opacity: 1;
  transform: scale(1);
}

.sticker-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.auth-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
}

.auth-brand h1 {
  margin: 0;
}

.auth-brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.lang-switch {
  display: inline-flex;
  gap: 4px;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 4px;
  background: var(--panel-soft);
}

.lang-btn {
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  min-width: 74px;
  padding: 6px 10px;
  cursor: pointer;
}

.lang-btn.active {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.welcome-screen {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.welcome-screen h2 {
  margin: 0;
  font-size: 28px;
}

.welcome-screen p {
  margin: 0;
  color: var(--muted);
}

.welcome-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.welcome-actions-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.mode-btn,
.primary-btn,
.ghost-btn,
.icon-btn,
.send-btn {
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, background-color 140ms ease;
}

.mode-btn {
  padding: 12px;
  background: var(--panel-soft);
  color: var(--text);
  text-align: left;
  display: grid;
  gap: 4px;
}

.mode-btn strong {
  font-size: 15px;
}

.mode-btn span {
  color: var(--muted);
  font-size: 12px;
}

.mode-btn.active {
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

.auth-form {
  display: grid;
  gap: 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.auth-flow-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.auth-flow-head h3 {
  margin: 0;
}

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

.auth-progress {
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  margin-top: 8px;
}

.auth-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  opacity: 0.92;
  border-radius: 999px;
  transition: width 260ms ease;
}

.auth-step {
  display: grid;
  gap: 8px;
}

.auth-step:not(.hidden) {
  animation: slideFadeIn 220ms ease;
}

.auth-step label {
  font-size: 13px;
  color: var(--muted);
}

.auth-form input,
.auth-form textarea,
.auth-form select,
.settings-form input,
.settings-form textarea,
.settings-form select,
.search-wrap input,
.composer input {
  border: none;
  border-radius: 12px;
  background: var(--panel-soft);
  color: var(--text);
  padding: 12px;
}

.auth-form textarea,
.settings-form textarea {
  min-height: 88px;
  resize: vertical;
}

.auth-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.auth-form input:focus,
.auth-form textarea:focus,
.auth-form select:focus,
.settings-form input:focus,
.settings-form textarea:focus,
.settings-form select:focus,
.search-wrap input:focus,
.composer input:focus {
  outline: 2px solid rgba(255, 255, 255, 0.34);
  outline-offset: 1px;
}

.password-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.password-row button {
  background: var(--panel-strong);
  color: var(--text);
  padding: 0 14px;
}

#email-row {
  display: grid;
  gap: 8px;
}

.server-details {
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 0 10px 10px;
  background: var(--bg-elev);
}

.server-details summary {
  cursor: pointer;
  padding: 10px 0;
  color: var(--muted);
  list-style: none;
}

.server-details summary::-webkit-details-marker {
  display: none;
}

.primary-btn {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  padding: 11px 14px;
}

.ghost-btn {
  background: var(--panel-soft);
  color: var(--text);
  padding: 11px 14px;
}

.mode-btn:hover,
.primary-btn:hover,
.ghost-btn:hover,
.icon-btn:hover,
.send-btn:hover,
.password-row button:hover {
  transform: translateY(-1px);
}

.telegram-auth {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  margin-top: 2px;
  padding-top: 10px;
}

.telegram-auth small {
  color: var(--muted);
  min-height: 26px;
  line-height: 1.2;
}

#telegram-login-btn {
  width: 100%;
}

.auth-reset-btn {
  justify-self: flex-start;
  margin-top: 2px;
}

.login-error {
  color: #dfdfdf;
  min-height: 18px;
  font-size: 13px;
  margin-top: 8px;
}

.password-preview {
  display: grid;
  gap: 1rem;
  margin-top: 0.4rem;
}

.password-preview p {
  margin: 0;
  font-size: 1rem;
  color: hsl(0 0% 40%);
  text-align: center;
  background: linear-gradient(hsl(0 0% 80%), hsl(0 0% 50%));
  color: transparent;
  background-clip: text;
}

.code {
  font-size: 3rem;
  display: flex;
  flex-wrap: nowrap;
  color: hsl(0 0% 100%);
  border-radius: 1rem;
  background: hsl(0 0% 6%);
  justify-content: center;
  box-shadow: 0 1px hsl(0 0% 100% / 0.25) inset;
  user-select: none;
}

.code:hover {
  cursor: grab;
}

.digit {
  display: flex;
  height: 100%;
  padding: 2rem 0.8rem;
}

.digit:focus-visible {
  outline-color: hsl(0 0% 50% / 0.25);
  outline-offset: 1rem;
}

.digit span {
  scale: calc(var(--active, 0) + 0.5);
  filter: blur(calc((1 - var(--active, 0)) * 1rem));
  transition: scale calc(((1 - var(--active, 0)) + 0.2) * 1s), filter calc(((1 - var(--active, 0)) + 0.2) * 1s);
}

.digit:first-of-type {
  padding-left: 3rem;
}

.digit:last-of-type {
  padding-right: 3rem;
}

:root {
  --lerp-0: 1;
  --lerp-1: calc(sin(50deg));
  --lerp-2: calc(sin(45deg));
  --lerp-3: calc(sin(35deg));
  --lerp-4: calc(sin(25deg));
  --lerp-5: calc(sin(15deg));
}

.digit:is(:hover, :focus-visible) {
  --active: var(--lerp-0);
}

.digit:is(:hover, :focus-visible) + .digit,
.digit:has(+ .digit:is(:hover, :focus-visible)) {
  --active: var(--lerp-1);
}

.digit:is(:hover, :focus-visible) + .digit + .digit,
.digit:has(+ .digit + .digit:is(:hover, :focus-visible)) {
  --active: var(--lerp-2);
}

.digit:is(:hover, :focus-visible) + .digit + .digit + .digit,
.digit:has(+ .digit + .digit + .digit:is(:hover, :focus-visible)) {
  --active: var(--lerp-3);
}

.digit:is(:hover, :focus-visible) + .digit + .digit + .digit + .digit,
.digit:has(+ .digit + .digit + .digit + .digit:is(:hover, :focus-visible)) {
  --active: var(--lerp-4);
}

.digit:is(:hover, :focus-visible) + .digit + .digit + .digit + .digit + .digit,
.digit:has(+ .digit + .digit + .digit + .digit + .digit:is(:hover, :focus-visible)) {
  --active: var(--lerp-5);
}

.shell {
  height: var(--app-height);
  min-height: var(--app-height);
  padding: 10px;
  display: grid;
  grid-template-columns: 320px 1fr 300px;
  gap: 10px;
  overflow: hidden;
}

.contacts-panel,
.chat-stage,
.profile-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
}

.contacts-panel {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 10px;
  padding: 12px;
  min-height: 0;
}

.contacts-head h2 {
  margin: 0;
  font-size: 28px;
}

.search-wrap {
  margin-top: 8px;
  position: relative;
}

.search-wrap span {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-wrap input {
  width: 100%;
  padding-left: 40px;
  transition: background-color 160ms ease, transform 160ms ease, box-shadow 180ms ease;
}

.search-wrap input:focus {
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}

.search-wrap.searching input {
  animation: searchPulse 1.2s ease infinite;
}

.panel-block {
  min-height: 0;
}

.search-block {
  max-height: 190px;
  overflow: auto;
  animation: slideFadeIn 180ms ease;
}

.list-block {
  min-height: 0;
}

#conversation-list {
  min-height: 0;
  max-height: 100%;
  overflow: auto;
}

.panel-block h3,
.profile-block h4 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.list-item {
  border-radius: 12px;
  background: var(--panel-soft);
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease;
  animation: listIn 220ms ease both;
}

.list-item:hover {
  transform: translateY(-1px);
  background: var(--panel-strong);
}

.list-item.active {
  background: color-mix(in srgb, var(--panel-strong) 70%, var(--accent) 30%);
}

.list-item.drop-target {
  outline: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: -2px;
  transform: translateY(-1px);
}

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

.list-item-title {
  font-weight: 600;
}

.list-item-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  overflow: hidden;
  display: grid;
  place-items: center;
  position: relative;
  flex: 0 0 auto;
}

.list-avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.list-avatar-letter {
  font-size: 12px;
  font-weight: 700;
}

.dot-online {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--ok);
}

.dot-online.recent {
  background: #4fa0ff;
}

.dot-online.away {
  background: #7498b8;
}

.dot-online.offline {
  background: #8a8f98;
}

.list-item-avatar .dot-online {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 9px;
  height: 9px;
  border: 1px solid var(--panel);
}

.small-btn {
  border: none;
  border-radius: 10px;
  padding: 6px 10px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}

.self-card {
  margin-top: auto;
  border-radius: 14px;
  background: var(--panel-soft);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.self-main,
.self-meta {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: var(--panel-strong);
  overflow: hidden;
}

.avatar-image-small {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.avatar.large {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  margin: 0 auto;
  font-size: 34px;
}

.avatar-image {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  object-fit: cover;
  display: block;
  margin: 0 auto;
}

.self-name,
#profile-nickname {
  font-weight: 700;
}

.self-sub,
#profile-username {
  color: var(--muted);
  font-size: 13px;
}

.pill {
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--muted);
  padding: 6px 10px;
  font-size: 12px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #8a8f98;
  border: 1px solid var(--line);
  flex: 0 0 auto;
}

.status-dot.online {
  background: #2fcf74;
}

.status-dot.offline {
  background: #8a8f98;
}

.chat-stage {
  padding: 12px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}

.chat-header {
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

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

.mobile-only {
  display: none;
}

.mobile-nav {
  display: none;
}

.active-title {
  font-size: 22px;
  font-weight: 700;
}

.active-subtitle {
  font-size: 13px;
  color: var(--muted);
}

.chat-actions,
.call-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.empty-state {
  border-radius: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
}

.empty-state h3 {
  margin: 0;
}

.empty-state p {
  margin: 8px 0 0;
  color: var(--muted);
}

.chat-area {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.selection-bar {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

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

.contact-request-bar {
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  background: color-mix(in srgb, var(--panel-soft) 70%, var(--accent) 30%);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--text);
  animation: slideFadeIn 180ms ease;
}

.contact-request-actions {
  display: flex;
  gap: 8px;
}

.chat-search {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  padding: 8px 10px;
  display: grid;
  grid-template-columns: auto 1fr auto auto auto auto;
  gap: 8px;
  align-items: center;
  animation: slideFadeIn 180ms ease;
}

.chat-search input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  padding: 8px 4px;
  min-width: 0;
}

.chat-search-count {
  font-size: 12px;
  color: var(--muted);
  min-width: 52px;
  text-align: right;
}

.icon-btn.mini {
  width: 34px;
  height: 34px;
  border-radius: 12px;
}

.contact-request-bar .primary-btn,
.contact-request-bar .ghost-btn {
  padding: 6px 10px;
  min-height: 32px;
}

.upload-queue {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  padding: 8px;
  display: grid;
  gap: 8px;
  animation: slideFadeIn 180ms ease;
}

.upload-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.upload-item-title {
  font-size: 12px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.upload-item-title strong {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-progress {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.upload-progress > div {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 120ms ease;
}

.composer-banner {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  animation: slideFadeIn 180ms ease;
}

.composer-banner-text {
  display: grid;
  gap: 2px;
}

.composer-banner-text strong {
  font-size: 12px;
}

.composer-banner-text span {
  font-size: 12px;
  color: var(--muted);
}

.chat-log {
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
}

.load-more-row {
  display: flex;
  justify-content: center;
}

.load-more-btn {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: transform 140ms ease, background-color 140ms ease, opacity 140ms ease;
}

.load-more-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.load-more-btn:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
}

.chat-log.selection-mode .msg-actions {
  display: none;
}

.msg-row {
  max-width: 85%;
  display: flex;
  gap: 10px;
  cursor: pointer;
}

.msg-row.readonly {
  cursor: default;
}

.msg-row.mine {
  margin-left: auto;
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--panel-strong);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  overflow: hidden;
}

.msg-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.msg-body {
  display: grid;
  gap: 5px;
}

.msg-meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.msg-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--muted);
  flex: 0 0 auto;
}

.msg-status .material-icons-round {
  font-size: 14px;
  line-height: 1;
}

.msg-status.delivered {
  color: var(--accent);
}

.msg-status.error {
  color: #ff667a;
  border-color: rgba(255, 102, 122, 0.25);
}

.msg-status.sending .material-icons-round {
  animation: spin 0.9s linear infinite;
}

.msg-status.queued .material-icons-round {
  animation: pulseSoft 1.2s ease infinite;
}

.bubble {
  border-radius: 14px;
  border-top-left-radius: 6px;
  background: var(--panel-soft);
  padding: 10px 12px;
  word-break: break-word;
  display: grid;
  gap: 6px;
}

.msg-row.mine .bubble {
  border-top-left-radius: 14px;
  border-top-right-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
}

.msg-row.selected .bubble {
  outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent);
  outline-offset: 1px;
}

.msg-row.search-hit .bubble {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent) inset;
}

.msg-row.search-active .bubble {
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--accent) 80%, transparent) inset,
    0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.reaction-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-left: 2px;
}

.reaction-chip {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 12px;
  padding: 4px 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.reaction-chip:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.06);
}

.reaction-chip.mine {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}

.msg-actions {
  display: flex;
  gap: 6px;
}

.text-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}

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

.attachment-card {
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  padding: 8px;
}

.message-text {
  white-space: normal;
  word-break: break-word;
}

.message-link {
  color: var(--accent);
  text-decoration: none;
}

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

.attachment-image {
  max-width: min(420px, 64vw);
  max-height: 300px;
  border-radius: 8px;
  display: block;
}

.attachment-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.attachment-file a {
  color: var(--text);
  text-decoration: none;
  word-break: break-all;
}

.attachment-file a:hover {
  text-decoration: underline;
}

.attachment-audio {
  width: 100%;
}

.attachment-sticker {
  padding: 0;
  border: none;
  background: transparent;
}

.sticker-image {
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: 22px;
  display: block;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.voice-player {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  min-width: min(340px, 70vw);
}

.voice-play {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease;
}

.voice-play:hover {
  transform: translateY(-1px);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.voice-bar {
  position: relative;
  min-width: 0;
  height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
  cursor: pointer;
  padding: 8px 10px;
}

.voice-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: var(--accent);
  opacity: 0.12;
  transition: width 80ms linear;
}

.voice-wave {
  position: relative;
  z-index: 1;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(28, minmax(0, 1fr));
  align-items: end;
  gap: 3px;
}

.voice-wave-bar {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  min-height: 6px;
  transition: background-color 120ms ease, transform 120ms ease;
}

.voice-wave-bar.active {
  background: color-mix(in srgb, var(--accent) 72%, white 10%);
}

.voice-time {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 84px;
  text-align: right;
}

.voice-actions {
  grid-column: 2 / 4;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.voice-chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  text-decoration: none;
  cursor: pointer;
}

.voice-chip:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
}

.youtube-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 10px;
  margin-top: 8px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  text-decoration: none;
  color: var(--text);
}

.youtube-card:hover {
  border-color: color-mix(in srgb, var(--accent) 25%, var(--line));
}

.youtube-thumb {
  width: 112px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  display: block;
}

.youtube-body {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 4px;
}

.youtube-title {
  font-weight: 700;
}

.youtube-sub {
  color: var(--muted);
  font-size: 12px;
}

.inline-contact {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--line));
  background: color-mix(in srgb, var(--panel-soft) 70%, var(--accent) 30%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  animation: slideFadeIn 180ms ease;
}

.inline-contact .primary-btn {
  min-height: 32px;
  padding: 6px 10px;
}

.ticket-tag {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px 8px;
  width: fit-content;
  font-size: 12px;
}

.sys-msg {
  align-self: center;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  padding: 6px 10px;
}

.typing-indicator {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
}

.drop-zone-hint {
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel-soft) 60%, var(--accent) 40%);
  color: var(--text);
  text-align: center;
  padding: 10px;
  font-size: 12px;
  animation: slideFadeIn 160ms ease;
}

.support-tools {
  display: flex;
  justify-content: flex-end;
}

.composer {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  padding: 8px;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.composer input {
  background: transparent;
  padding: 10px 4px;
}

.composer input:focus {
  outline: none;
}

.icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--panel-strong);
  color: var(--text);
}

.icon-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.icon-btn.danger {
  background: rgba(255, 255, 255, 0.14);
}

.send-btn {
  width: 42px;
  height: 42px;
  background: var(--accent);
  color: var(--accent-ink);
}

.icon-btn.recording {
  animation: pulse 1s ease infinite;
  background: rgba(255, 255, 255, 0.2);
}

.mobile-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 84%, rgba(0, 0, 0, 0.35));
  border-top: 1px solid var(--line);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 -18px 42px rgba(0, 0, 0, 0.22);
}

.mobile-nav-btn {
  border: 1px solid transparent;
  border-radius: 18px;
  min-height: 58px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  gap: 4px;
  cursor: pointer;
  transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.mobile-nav-btn .material-icons-round {
  font-size: 20px;
}

.mobile-nav-btn span:last-child {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.mobile-nav-btn.active {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
}

.mobile-nav-btn:active {
  transform: scale(0.98);
}

body.mobile-hide-nav .mobile-nav {
  display: none;
}

.call-dock {
  position: fixed;
  inset: 0;
  z-index: 980;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.06), transparent 36%),
    rgba(6, 6, 8, 0.96);
  padding: 24px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
  align-items: stretch;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.call-head {
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
}

.call-head-copy {
  display: grid;
  gap: 5px;
}

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

.call-head-actions .icon-btn.active {
  background: rgba(255, 255, 255, 0.2);
}

.call-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.call-peer {
  font-size: 13px;
  color: var(--muted);
}

.call-status-pill {
  width: fit-content;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.call-status-pill[data-state="ringing"],
.call-status-pill[data-state="incoming"] {
  color: #f6e8b4;
  border-color: rgba(246, 232, 180, 0.24);
  background: rgba(246, 232, 180, 0.08);
}

.call-status-pill[data-state="connecting"] {
  color: #b7d6ff;
  border-color: rgba(183, 214, 255, 0.24);
  background: rgba(183, 214, 255, 0.08);
}

.call-status-pill[data-state="connected"] {
  color: #c7f5cf;
  border-color: rgba(199, 245, 207, 0.22);
  background: rgba(199, 245, 207, 0.08);
}

.call-status-pill[data-state="busy"],
.call-status-pill[data-state="failed"],
.call-status-pill[data-state="ended"] {
  color: #ffd1d1;
  border-color: rgba(255, 209, 209, 0.22);
  background: rgba(255, 209, 209, 0.08);
}

.call-grid {
  position: relative;
  min-height: 0;
}

.call-box {
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px;
  display: grid;
  grid-template-rows: auto 1fr;
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.24);
}

.call-label {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  margin-bottom: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.call-box video {
  grid-row: 2;
  width: 100%;
  height: min(76vh, 84vw);
  min-height: 260px;
  border-radius: 18px;
  object-fit: cover;
  background: #050505;
}

.call-fallback {
  grid-row: 2;
  width: 100%;
  height: min(76vh, 84vw);
  min-height: 260px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.08), transparent 22%),
    #050505;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.call-box-remote {
  min-height: 0;
}

.call-box-local {
  position: absolute;
  right: 20px;
  bottom: 20px;
  width: min(280px, 28vw);
  min-width: 170px;
  z-index: 3;
  padding: 10px;
  border-radius: 22px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.call-box-local .call-fallback,
.call-box-local video {
  height: min(220px, 26vw);
  min-height: 160px;
}

.call-box-local .call-label {
  margin-bottom: 6px;
}

.call-avatar {
  width: min(220px, 50vw);
  height: min(220px, 50vw);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  display: grid;
  place-items: center;
  font-size: 52px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.call-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#call-dock-hangup {
  width: 48px;
  height: 48px;
  background: rgba(255, 80, 80, 0.88);
  color: #fff;
}

#call-dock-hangup:hover {
  transform: translateY(-1px) scale(1.03);
}

.incoming-avatar-wrap {
  display: grid;
  place-items: center;
  margin: 0 auto 8px;
}

.incoming-avatar-wrap .avatar.large,
.incoming-avatar-wrap .avatar-image {
  width: 88px;
  height: 88px;
  border-radius: 24px;
}

.incoming-avatar-wrap .avatar-image {
  object-fit: cover;
}

.profile-panel {
  padding: 14px;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 12px;
  min-height: 0;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.05), transparent 38%),
    color-mix(in srgb, var(--panel) 94%, #040608);
}

.profile-top,
.profile-block {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid color-mix(in srgb, var(--line) 86%, rgba(255, 255, 255, 0.1));
  background: color-mix(in srgb, var(--panel-soft) 92%, rgba(255, 255, 255, 0.02));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 18px 36px rgba(0, 0, 0, 0.16);
}

.profile-top {
  min-height: 214px;
  padding: 0;
  display: grid;
  align-content: end;
}

.profile-top-cover {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 20%, color-mix(in srgb, var(--accent) 28%, transparent), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent 46%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.03), transparent 60%);
  opacity: 0.9;
}

.profile-top-main {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
  padding: 84px 16px 18px;
}

.profile-avatar-shell {
  width: 96px;
  height: 96px;
  padding: 4px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.02)),
    rgba(10, 14, 18, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.26);
}

.profile-avatar-shell .avatar.large,
.profile-avatar-shell .avatar-image {
  width: 100%;
  height: 100%;
  border-radius: 24px;
}

.profile-avatar-shell .avatar-image {
  object-fit: cover;
}

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

.profile-top h3 {
  margin: 0;
  font-size: 28px;
  line-height: 1.04;
  letter-spacing: -0.03em;
}

.profile-top p {
  margin: 0;
  width: fit-content;
  max-width: 100%;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(9, 13, 18, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: color-mix(in srgb, var(--text) 70%, var(--muted));
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.profile-block {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.profile-block p {
  margin: 0;
  color: color-mix(in srgb, var(--text) 76%, var(--muted));
  line-height: 1.6;
  word-break: break-word;
}

.profile-block-about {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 45%),
    color-mix(in srgb, var(--panel-soft) 94%, rgba(255, 255, 255, 0.02));
}

.profile-block-details {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 38%),
    color-mix(in srgb, var(--panel-soft) 90%, rgba(0, 0, 0, 0.08));
}

.profile-kv {
  display: grid;
  gap: 10px;
}

.profile-kv-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  align-items: start;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid color-mix(in srgb, var(--line) 88%, rgba(255, 255, 255, 0.06));
  box-shadow: inset 3px 0 0 color-mix(in srgb, var(--accent) 52%, transparent);
}

.profile-kv-row span:first-child {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.profile-kv-row span:last-child {
  color: var(--text);
  font-weight: 600;
  word-break: break-word;
  text-align: left;
}

.member-list {
  max-height: 240px;
  overflow: auto;
}

.settings-form {
  display: grid;
  gap: 10px;
}

.settings-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.settings-tabs .mode-btn {
  text-align: center;
  display: block;
  padding: 10px;
}

.settings-section {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  padding: 10px;
  display: grid;
  gap: 10px;
  animation: slideFadeIn 220ms ease;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.settings-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.notify-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

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

.notify-card-main strong {
  font-size: 14px;
}

.notify-card-main p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.status-chip {
  align-self: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-chip.active {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: color-mix(in srgb, var(--accent) 26%, var(--line));
}

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

.sessions-list {
  max-height: min(42vh, 340px);
  overflow: auto;
}

.session-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.session-item-title {
  font-weight: 700;
  font-size: 13px;
}

.session-item-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  display: grid;
  gap: 2px;
}

.action-sep {
  height: 1px;
  background: var(--line);
  border-radius: 999px;
  margin: 4px 0;
}

.settings-avatar-top {
  display: flex;
  justify-content: stretch;
}

.avatar-upload {
  border: 1px solid color-mix(in srgb, var(--line) 86%, rgba(255, 255, 255, 0.08));
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 50%),
    color-mix(in srgb, var(--panel-soft) 92%, rgba(255, 255, 255, 0.02));
  border-radius: 18px;
  padding: 14px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  width: 100%;
  cursor: pointer;
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.avatar-upload:hover {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
  color: var(--text);
}

.avatar-upload .avatar.large,
.avatar-upload .avatar-image {
  width: 72px;
  height: 72px;
}

.avatar-upload .avatar-image {
  border-radius: 16px;
  object-fit: cover;
}

.avatar-upload span {
  font-size: 13px;
  font-weight: 600;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.action-card {
  width: min(380px, 92vw);
}

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

.reaction-picker {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 6px 0 10px;
}

.reaction-pick-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 18px;
  transition: transform 120ms ease, background-color 120ms ease;
}

.reaction-pick-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.08);
}

.action-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.action-btn {
  text-align: left;
  padding: 10px 12px;
}

.incoming-card {
  width: min(420px, 92vw);
  text-align: center;
  border-radius: 24px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.08), transparent 34%),
    rgba(12, 12, 14, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.3);
}

.incoming-card p {
  color: var(--muted);
}

.incoming-ring {
  width: 72px;
  height: 72px;
  border-radius: 999px;
  margin: 0 auto 14px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  animation: ring 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.24); }
  50% { box-shadow: 0 0 0 10px rgba(255, 255, 255, 0); }
}

@keyframes ring {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

@keyframes listIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes searchPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  }
  50% {
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
  }
}

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

@keyframes pulseSoft {
  0%,
  100% {
    opacity: 0.65;
  }
  50% {
    opacity: 1;
  }
}

@media (max-width: 1360px) {
  .shell {
    grid-template-columns: 300px 1fr;
  }

  .profile-panel {
    display: none;
  }
}

@media (max-width: 980px) {
  .overlay,
  .modal {
    place-items: start center;
    padding: 0;
  }

  html,
  body {
    height: 100%;
  }

  .auth-card,
  .modal-card {
    width: min(100vw, 620px);
    max-height: var(--app-height);
    padding: 16px;
  }

  .auth-card {
    min-height: var(--app-height);
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    padding:
      max(16px, env(safe-area-inset-top))
      16px
      max(18px, env(safe-area-inset-bottom))
      16px;
  }

  .modal-card.sticker-card {
    width: min(96vw, 720px);
    max-height: 92vh;
  }

  .sticker-layout {
    grid-template-columns: 1fr;
  }

  .sticker-sidebar {
    max-height: 220px;
  }

  .sticker-pack-create {
    grid-template-columns: 1fr;
  }

  .auth-top-row {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .welcome-actions-3 {
    grid-template-columns: 1fr;
  }

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

  .mobile-only {
    display: inline-grid;
  }

  .mobile-nav {
    display: grid;
  }

  .shell {
    grid-template-columns: 1fr;
    padding: 0;
    gap: 0;
    position: relative;
    height: var(--app-height);
    min-height: var(--app-height);
  }

  .contacts-panel,
  .chat-stage {
    border: none;
    border-radius: 0;
    box-shadow: none;
    position: absolute;
    inset: 0;
    background: var(--bg);
  }

  .profile-panel {
    display: none;
  }

  body.mobile-show-chat .contacts-panel {
    display: none;
  }

  body:not(.mobile-show-chat) .chat-stage {
    display: none;
  }

  .chat-stage {
    min-height: var(--app-height);
  }

  .contacts-panel,
  .chat-stage {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: calc(82px + env(safe-area-inset-bottom));
  }

  .contacts-panel {
    grid-template-rows: auto auto 1fr auto;
    gap: 12px;
    padding-left: 12px;
    padding-right: 12px;
  }

  body.mobile-hide-nav .chat-stage {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .contacts-head,
  .chat-header {
    position: sticky;
    top: 0;
    z-index: 12;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  .contacts-head {
    margin: 0 -4px;
    padding: 4px 4px 0;
    background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 92%, transparent), transparent);
  }

  .contacts-head h2 {
    font-size: 24px;
  }

  .search-wrap input,
  .composer input,
  .chat-search input,
  .auth-form input,
  .auth-form textarea,
  .auth-form select,
  .settings-form input,
  .settings-form textarea,
  .settings-form select {
    font-size: 16px;
  }

  .search-block,
  .list-block {
    min-height: 0;
  }

  .search-block {
    max-height: min(36vh, 280px);
  }

  #conversation-list {
    padding-bottom: 4px;
  }

  .self-card {
    position: sticky;
    bottom: 0;
    z-index: 10;
    margin-bottom: 0;
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--panel-soft) 88%, rgba(0, 0, 0, 0.1));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .self-main {
    min-width: 0;
  }

  .self-main > div:last-child {
    min-width: 0;
  }

  .self-name,
  .self-sub {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .chat-stage {
    grid-template-rows: auto 1fr;
    gap: 8px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .chat-header {
    margin: 0 -4px;
    padding: 10px 12px;
    border-radius: 18px;
    background: color-mix(in srgb, var(--panel) 88%, rgba(255, 255, 255, 0.03));
  }

  .profile-top {
    min-height: 188px;
  }

  .profile-top-main {
    padding: 72px 14px 16px;
  }

  .profile-avatar-shell {
    width: 84px;
    height: 84px;
  }

  .profile-top h3 {
    font-size: 24px;
  }

  .chat-head-left {
    min-width: 0;
    flex: 1;
  }

  .active-title {
    font-size: 18px;
    line-height: 1.1;
  }

  .active-subtitle {
    font-size: 12px;
    line-height: 1.2;
  }

  .chat-actions {
    gap: 6px;
  }

  .chat-actions .pill {
    display: none;
  }

  .empty-state {
    min-height: 100%;
    align-content: center;
    padding: 24px 18px 32px;
  }

  .chat-area {
    gap: 10px;
    min-height: 0;
    padding-bottom: 0;
  }

  .selection-bar,
  .contact-request-bar {
    flex-wrap: wrap;
  }

  .selection-actions,
  .contact-request-actions {
    width: 100%;
    justify-content: stretch;
  }

  .selection-actions > *,
  .contact-request-actions > * {
    flex: 1;
  }

  .chat-search {
    grid-template-columns: auto 1fr auto auto;
    grid-template-areas:
      "icon input count close"
      "icon input prev next";
    row-gap: 6px;
  }

  .chat-search > .material-icons-round:first-child {
    grid-area: icon;
    align-self: center;
  }

  .chat-search input {
    grid-area: input;
  }

  .chat-search-count {
    grid-area: count;
    min-width: 40px;
  }

  #chat-search-prev {
    grid-area: prev;
  }

  #chat-search-next {
    grid-area: next;
  }

  #chat-search-close {
    grid-area: close;
  }

  .chat-log {
    padding: 12px 8px 10px;
    border-radius: 18px;
  }

  .msg-row {
    max-width: 100%;
    gap: 8px;
  }

  .msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 9px;
  }

  .msg-body {
    max-width: min(84vw, 100%);
  }

  .msg-meta {
    font-size: 11px;
  }

  .bubble {
    padding: 10px 11px;
    border-radius: 16px;
  }

  .attachment-image {
    max-width: min(76vw, 360px);
    max-height: 240px;
  }

  .voice-player {
    min-width: 0;
    width: min(78vw, 100%);
  }

  .voice-player {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .voice-time {
    min-width: 0;
  }

  .voice-actions {
    grid-column: 1 / -1;
  }

  .youtube-card {
    grid-template-columns: 1fr;
  }

  .youtube-thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .support-tools {
    justify-content: stretch;
  }

  .support-tools .ghost-btn,
  #create-ticket-btn {
    width: 100%;
  }

  .composer-banner {
    border-radius: 16px;
  }

  .auth-actions {
    position: sticky;
    bottom: calc(-1 * max(18px, env(safe-area-inset-bottom)));
    z-index: 2;
    margin: 4px -4px -4px;
    padding: 12px 4px max(4px, env(safe-area-inset-bottom));
    background: linear-gradient(to top, color-mix(in srgb, var(--panel) 96%, transparent), transparent);
  }

  .composer {
    position: sticky;
    bottom: 0;
    z-index: 14;
    grid-template-columns: auto auto minmax(0, 1fr) auto auto;
    padding: 8px;
    border-radius: 18px;
    background: color-mix(in srgb, var(--panel-soft) 90%, rgba(255, 255, 255, 0.04));
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.14);
  }

  .composer input {
    min-width: 0;
    padding: 12px 2px;
  }

  .icon-btn,
  .send-btn {
    width: 44px;
    height: 44px;
    border-radius: 14px;
  }

  .call-dock {
    padding:
      max(14px, env(safe-area-inset-top))
      14px
      calc(92px + env(safe-area-inset-bottom))
      14px;
  }

  body.mobile-hide-nav .call-dock {
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }

  .call-grid {
    min-height: 0;
  }

  .call-head {
    padding: 12px;
    border-radius: 16px;
  }

  .call-title {
    font-size: 20px;
  }

  .call-box-remote video,
  .call-box-remote .call-fallback {
    height: min(58vh, 120vw);
    min-height: 220px;
  }

  .call-box-local {
    right: 12px;
    bottom: 12px;
    width: min(160px, 38vw);
    min-width: 120px;
    padding: 8px;
  }

  .call-box-local .call-fallback,
  .call-box-local video {
    height: min(120px, 30vw);
    min-height: 96px;
  }

  .avatar-upload {
    grid-template-columns: 1fr;
    justify-items: start;
  }
}

body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

@media (prefers-reduced-motion: reduce) {
  body:not([data-reduced-motion="0"]) *,
  body:not([data-reduced-motion="0"]) *::before,
  body:not([data-reduced-motion="0"]) *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
