:root {
  color-scheme: dark;
  --bg: #030303;
  --text: #f4f4f5;
  --muted: #8e8e93;
  --soft: #b7b7bc;
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.18);
  --glass: rgba(25, 25, 26, 0.66);
  --glass-light: rgba(255, 255, 255, 0.075);
  --white-glow: rgba(255, 255, 255, 0.28);
  --shadow: rgba(0, 0, 0, 0.5);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.16), rgba(0, 0, 0, 0.74)),
    url("assets/void-auth-bg.png") center / cover fixed,
    var(--bg);
  overflow-x: hidden;
  overflow-y: auto;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.05), transparent 24%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.45), transparent 40%, rgba(0, 0, 0, 0.36)),
    rgba(0, 0, 0, 0.22);
  pointer-events: none;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

.auth-shell {
  position: relative;
  display: grid;
  grid-template-rows: 1fr;
  width: min(100% - 24px, 1500px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px 0;
}

.void-mark,
.avatar {
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.03)),
    rgba(255, 255, 255, 0.05);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 18px 48px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(20px) saturate(160%);
}

.void-mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 28px;
  border-radius: 8px;
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 900;
}

.auth-stack {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: calc(100vh - 32px);
  padding: 18px 0;
}

.profile-card,
.mode-island,
.app-shell,
.app-island {
  border: 1px solid var(--line);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.035)),
    var(--glass);
  box-shadow:
    0 32px 120px var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(34px) saturate(170%);
}

.auth-card {
  position: relative;
  width: min(100%, 512px);
  min-height: 590px;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: start;
  opacity: 0;
  transform: translateY(16px) scale(0.985);
  pointer-events: none;
  transition:
    opacity 260ms ease,
    transform 360ms cubic-bezier(0.2, 0.9, 0.2, 1);
}

.screen.is-active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

h1,
h2,
p {
  margin-top: 0;
}

.kicker {
  margin: 0 0 8px;
  color: var(--soft);
  font-size: 0.72rem;
  font-weight: 820;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1 {
  margin-bottom: 10px;
  text-align: center;
  font-size: clamp(1.7rem, 4vw, 2rem);
  line-height: 1.12;
  letter-spacing: 0;
}

.hint {
  max-width: none;
  margin-bottom: 26px;
  color: var(--muted);
  text-align: center;
  line-height: 1.55;
}

.hint button {
  padding: 0;
  color: var(--text);
  cursor: pointer;
  background: transparent;
  font-weight: 780;
}

.social-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 30px;
}

.social-button {
  display: inline-flex;
  gap: 14px;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  color: rgba(244, 244, 245, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.035)),
    rgba(28, 28, 29, 0.86);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 14px 34px rgba(0, 0, 0, 0.2);
  opacity: 0.76;
}

.social-button span {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  font-weight: 900;
}

.social-button strong {
  font-size: 0.9rem;
}

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: center;
  margin-bottom: 26px;
  color: var(--muted);
}

.divider::before,
.divider::after {
  height: 1px;
  content: "";
  background: rgba(255, 255, 255, 0.12);
}

.form {
  display: grid;
  gap: 18px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--soft);
  font-size: 0.86rem;
  font-weight: 720;
}

input {
  width: 100%;
  min-height: 52px;
  padding: 0 18px;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  outline: none;
  background: rgba(5, 7, 10, 0.46);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 16px 34px rgba(0, 0, 0, 0.18);
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

input::placeholder {
  color: rgba(136, 147, 159, 0.78);
}

input:focus {
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(7, 10, 14, 0.58);
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.message.is-error {
  color: #ff8d8d;
}

.message.is-success {
  color: #7df0bd;
}

.terms {
  max-width: 420px;
  margin: 24px auto 0;
  color: rgba(183, 183, 188, 0.82);
  text-align: center;
  font-size: 0.78rem;
  line-height: 1.6;
}

.primary-action,
.secondary-action,
.link-action,
.mode-button {
  cursor: pointer;
}

.primary-action,
.secondary-action {
  position: relative;
  min-height: 50px;
  border-radius: 999px;
  font-weight: 820;
  overflow: hidden;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    opacity 180ms ease;
}

.link-action {
  min-height: 42px;
  margin-top: 12px;
  color: var(--soft);
  background: transparent;
  font-weight: 740;
  transition: color 180ms ease;
}

.link-action:disabled {
  cursor: wait;
  opacity: 0.72;
}

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

.primary-action {
  color: rgba(244, 244, 245, 0.64);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.025)),
    rgba(22, 22, 23, 0.74);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 18px 48px rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.primary-action:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.15);
}

.primary-action:hover,
.secondary-action:hover {
  transform: translateY(-1px);
}

.primary-action:disabled,
.secondary-action:disabled {
  cursor: wait;
  opacity: 0.62;
}

.primary-action.is-loading::after,
.link-action.is-loading::after {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 10px;
  vertical-align: -2px;
  content: "";
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  animation: spin 800ms linear infinite;
}

.delivery-status {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  min-height: 38px;
  padding: 0 15px;
  margin: -8px auto 20px;
  color: var(--soft);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(18, 18, 19, 0.68);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 16px 42px rgba(0, 0, 0, 0.2);
  animation: riseIn 380ms cubic-bezier(0.16, 1, 0.3, 1);
}

.delivery-status[hidden] {
  display: none;
}

.delivery-status span {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #f0c75e;
  box-shadow: 0 0 18px rgba(240, 199, 94, 0.6);
  animation: pulseDot 1300ms ease-in-out infinite;
}

.delivery-status.is-sent span {
  background: #7df0bd;
  box-shadow: 0 0 18px rgba(125, 240, 189, 0.62);
}

.delivery-status.is-dev span {
  background: #9b9ba1;
  box-shadow: 0 0 18px rgba(155, 155, 161, 0.5);
}

.delivery-status strong {
  color: rgba(244, 244, 245, 0.86);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.mode-island {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 4px;
  width: min(100%, 332px);
  min-height: 56px;
  padding: 5px;
  margin-top: 24px;
  overflow: hidden;
  border-radius: 999px;
}

.mode-glow {
  position: absolute;
  top: 5px;
  left: 5px;
  width: calc(50% - 7px);
  height: calc(100% - 10px);
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.07)),
    rgba(255, 255, 255, 0.06);
  box-shadow:
    inset 0 1px 0 var(--white-glow),
    0 12px 34px rgba(255, 255, 255, 0.07);
  transition: transform 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

.mode-island[data-active="register"] .mode-glow {
  transform: translateX(calc(100% + 9px));
}

.mode-button {
  position: relative;
  z-index: 1;
  min-height: 46px;
  color: var(--muted);
  border-radius: 999px;
  background: transparent;
  font-weight: 760;
  transition: color 220ms ease;
}

.mode-button.is-active {
  color: var(--text);
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto;
  gap: 16px;
  width: min(100%, 1440px);
  height: min(920px, calc(100vh - 32px));
  min-height: 0;
  padding: 18px;
  border-radius: 28px;
  overflow: hidden;
}

.app-shell[hidden] {
  display: none;
}

.app-shell::before {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.14), transparent 24%),
    radial-gradient(circle at 82% 4%, rgba(255, 255, 255, 0.1), transparent 28%);
  pointer-events: none;
  mask-image: linear-gradient(#000, transparent 70%);
}

.app-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.app-header h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 0.96;
}

.mini-avatar {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.03)),
    rgba(255, 255, 255, 0.06);
  background-position: center;
  background-size: cover;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 14px 34px rgba(0, 0, 0, 0.28);
  font-weight: 880;
}

.app-view {
  position: relative;
  display: none;
  min-height: 100%;
  min-height: 0;
  animation: riseIn 360ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-view.is-active {
  display: grid;
  align-items: stretch;
}

.empty-state {
  width: min(100%, 440px);
  margin: 0 auto;
  padding: 34px 24px;
  text-align: center;
}

.empty-state.compact {
  padding-top: 24px;
}

.messenger-layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 18px;
  min-height: 0;
}

.chat-sidebar,
.chat-panel {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(10, 10, 11, 0.34);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(18px) saturate(140%);
}

.chat-sidebar {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
  padding: 14px;
  border-radius: 24px;
  min-height: 0;
}

.chat-search {
  gap: 9px;
}

.chat-search input {
  min-height: 46px;
}

.chat-list {
  display: grid;
  align-content: start;
  gap: 12px;
  overflow-y: auto;
}

.user-search-results {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 22px;
  background: rgba(5, 5, 6, 0.38);
}

.user-search-results[hidden] {
  display: none;
}

.user-result {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 8px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
}

.user-result strong,
.user-result small {
  display: block;
}

.user-result small,
.search-empty {
  color: var(--muted);
}

.search-empty {
  margin: 0;
  padding: 8px;
  font-size: 0.82rem;
}

.chat-item {
  display: flex;
  gap: 16px;
  align-items: center;
  width: 100%;
  min-height: 74px;
  padding: 14px 16px;
  color: var(--text);
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.035)),
    rgba(18, 18, 19, 0.64);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 18px 44px rgba(0, 0, 0, 0.18);
}

.chat-item.is-active {
  border-color: rgba(255, 255, 255, 0.2);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05)),
    rgba(28, 28, 29, 0.72);
}

.chat-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  background-position: center;
  background-size: cover;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.chat-item strong,
.chat-item small {
  display: block;
}

.chat-item strong {
  margin-bottom: 5px;
  font-size: 1rem;
}

.chat-item small {
  color: var(--muted);
  line-height: 1.45;
}

.chat-list-note {
  padding: 4px 8px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  min-width: 0;
  min-height: 0;
  border-radius: 28px;
  overflow: hidden;
}

.chat-panel-header {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.035);
}

.chat-back {
  display: none;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  color: var(--text);
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 1.8rem;
  line-height: 1;
}

.verified-badge {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin-left: 5px;
  color: #fff;
  border-radius: 999px;
  background: linear-gradient(145deg, #4aa7ff, #1677ff);
  box-shadow: 0 0 16px rgba(42, 132, 255, 0.55);
  font-size: 0.68rem;
  font-weight: 900;
  vertical-align: 1px;
}

.presence-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
}

.presence-dot.is-online {
  background: #42f0a2;
  box-shadow: 0 0 12px rgba(66, 240, 162, 0.62);
}

.chat-panel-header h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.chat-panel-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 20px 22px;
  overflow-y: auto;
  scroll-behavior: auto;
}

.message-bubble {
  align-self: flex-end;
  width: fit-content;
  max-width: min(64%, 520px);
  padding: 8px 10px 6px;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px 16px 5px 16px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.04)),
    rgba(30, 30, 31, 0.82);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 16px 34px rgba(0, 0, 0, 0.18);
}

.message-bubble.is-peer {
  align-self: flex-start;
  border-radius: 16px 16px 16px 5px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.035)),
    rgba(12, 12, 13, 0.76);
}

.message-bubble.is-own {
  align-self: flex-end;
}

.message-bubble p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.94rem;
  line-height: 1.38;
}

.message-bubble time {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  text-align: right;
  font-size: 0.68rem;
}

.message-bubble.has-media.media-only {
  padding: 4px;
}

.message-bubble.has-media.media-only time {
  margin: 3px 6px 2px;
}

.message-media {
  display: block;
  max-width: 100%;
  max-height: 340px;
  margin-bottom: 6px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.32);
  cursor: zoom-in;
}

.message-bubble.media-only .message-media {
  margin-bottom: 0;
}

.voice-message {
  display: flex;
  gap: 12px;
  align-items: center;
  width: min(320px, 72vw);
  min-width: min(260px, 68vw);
  padding: 10px;
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.035)),
    rgba(255, 255, 255, 0.045);
}

.voice-play {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  color: var(--text);
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.28), transparent 36%),
    rgba(255, 255, 255, 0.1);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 10px 24px rgba(0, 0, 0, 0.22);
  font-size: 0.86rem;
  font-weight: 900;
}

.voice-message.is-playing .voice-play {
  color: #7df0bd;
  border-color: rgba(125, 240, 189, 0.34);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 0 24px rgba(125, 240, 189, 0.18);
}

.voice-body {
  display: grid;
  gap: 7px;
  flex: 1 1 auto;
  min-width: 0;
}

.voice-wave {
  position: relative;
  display: flex;
  gap: 3px;
  align-items: center;
  width: 100%;
  height: 24px;
  cursor: pointer;
}

.voice-bar {
  width: 3px;
  height: var(--h);
  min-height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  transition:
    background 120ms linear,
    transform 120ms ease;
}

.voice-bar.is-active {
  background: rgba(125, 240, 189, 0.95);
}

.voice-message.is-playing .voice-bar.is-active {
  box-shadow: 0 0 10px rgba(125, 240, 189, 0.2);
}

.voice-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 760;
}

.voice-message audio {
  display: none;
}

.attachment-preview {
  position: relative;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 34px;
  gap: 12px;
  align-items: center;
  margin: 0 14px 10px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.03)),
    rgba(18, 18, 19, 0.78);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 16px 36px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  animation: riseIn 260ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

.preview-media {
  width: 54px;
  height: 54px;
  overflow: hidden;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.34);
}

.preview-media img,
.preview-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-meta {
  min-width: 0;
}

.preview-meta strong,
.preview-meta span {
  display: block;
}

.preview-meta strong {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.92rem;
}

.preview-meta span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.preview-remove,
.viewer-close {
  display: grid;
  place-items: center;
  color: var(--text);
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.preview-remove {
  width: 34px;
  height: 34px;
  font-size: 1.2rem;
}

.upload-progress {
  position: absolute;
  right: 12px;
  bottom: 0;
  left: 12px;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.upload-progress[hidden] {
  display: none;
}

.upload-progress span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.9), transparent);
  animation: uploadSweep 900ms ease-in-out infinite;
}

.attachment-preview.is-uploading {
  pointer-events: none;
}

.message-composer {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 46px 46px;
  gap: 10px;
  align-items: center;
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.message-composer input[type="text"] {
  min-height: 46px;
}

.attach-button,
.voice-button,
.send-button {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  color: var(--text);
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.035)),
    rgba(28, 28, 29, 0.86);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  font-weight: 900;
}

.attach-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.send-button {
  font-size: 1.15rem;
}

.voice-button {
  font-size: 0.92rem;
}

.voice-button.is-recording {
  color: #ff8d8d;
  border-color: rgba(255, 141, 141, 0.45);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 0 26px rgba(255, 79, 79, 0.25);
}

.voice-preview-dot {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #ff8d8d;
  font-size: 1.1rem;
}

.composer-message {
  min-height: 24px;
  padding: 0 18px 12px;
}

.media-viewer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(24px) saturate(140%);
  animation: fadeIn 180ms ease;
}

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

.viewer-content {
  display: grid;
  place-items: center;
  width: min(100%, 940px);
  max-height: calc(100vh - 96px);
}

.viewer-content img,
.viewer-content video {
  max-width: 100%;
  max-height: calc(100vh - 96px);
  border-radius: 24px;
  box-shadow: 0 32px 120px rgba(0, 0, 0, 0.56);
  background: #050505;
}

.viewer-close {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 21;
  width: 44px;
  height: 44px;
  font-size: 1.35rem;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 18px 42px rgba(0, 0, 0, 0.22);
  font-size: 1.8rem;
}

.empty-state h3 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 1.35rem;
}

.empty-state p:not(.empty-icon) {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.app-island {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  width: min(100%, 620px);
  min-height: 60px;
  padding: 5px;
  margin: 0 auto;
  border-radius: 999px;
  overflow: hidden;
}

.app-glow {
  position: absolute;
  top: 5px;
  left: 5px;
  width: calc(25% - 6px);
  height: calc(100% - 10px);
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.07)),
    rgba(255, 255, 255, 0.06);
  box-shadow:
    inset 0 1px 0 var(--white-glow),
    0 12px 34px rgba(255, 255, 255, 0.07);
  transition: transform 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-island[data-active="calls"] .app-glow {
  transform: translateX(calc(100% + 8px));
}

.app-island[data-active="chats"] .app-glow {
  transform: translateX(calc((100% + 8px) * 2));
}

.app-island[data-active="profile"] .app-glow {
  transform: translateX(calc((100% + 8px) * 3));
}

.app-nav-button {
  position: relative;
  z-index: 1;
  min-height: 48px;
  padding: 0 10px;
  color: var(--muted);
  cursor: pointer;
  border-radius: 999px;
  background: transparent;
  font-size: 0.88rem;
  font-weight: 760;
  transition: color 220ms ease;
}

.app-nav-button.is-active {
  color: var(--text);
}

.profile-card {
  position: relative;
  width: min(100%, 560px);
  padding: 32px;
  border-radius: 24px;
  overflow: hidden;
}

.profile-card::before {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.18), transparent 24%),
    radial-gradient(circle at 88% 8%, rgba(255, 255, 255, 0.12), transparent 26%);
  pointer-events: none;
  mask-image: linear-gradient(#000, transparent 70%);
}

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

.app-view .profile-card {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  border: 0;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: none;
  backdrop-filter: none;
}

.profile-top {
  position: relative;
  display: flex;
  gap: 18px;
  align-items: center;
  margin-bottom: 28px;
}

.avatar {
  width: 86px;
  height: 86px;
  border-radius: 999px;
  background-position: center;
  background-size: cover;
  font-size: 2rem;
  font-weight: 880;
}

.avatar-picker {
  position: relative;
  display: block;
  flex: 0 0 auto;
  cursor: pointer;
}

.avatar-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.avatar-action {
  position: absolute;
  right: -4px;
  bottom: 0;
  min-height: 28px;
  padding: 6px 10px;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(20, 20, 21, 0.86);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
  font-size: 0.72rem;
  font-weight: 820;
}

.profile-card h2 {
  max-width: 360px;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  letter-spacing: 0;
}

.profile-username {
  margin: 8px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.profile-form {
  position: relative;
  display: grid;
  gap: 18px;
}

.profile-row {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 15px 0;
  color: var(--muted);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.profile-row strong {
  color: var(--text);
  overflow-wrap: anywhere;
  text-align: right;
}

.secondary-action {
  position: relative;
  width: 100%;
  margin-top: 12px;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
}

.profile-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

body.is-authenticated .auth-card,
body.is-authenticated .mode-island {
  display: none;
}

body.is-authenticated {
  overflow: hidden;
}

@media (max-width: 520px) {
  .auth-shell {
    width: min(100% - 20px, 430px);
    padding: 18px 0;
  }

  .auth-stack {
    min-height: calc(100vh - 74px);
    padding-bottom: 28px;
  }

  .auth-card {
    min-height: 648px;
  }

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

  .mode-island {
    width: min(100%, 306px);
  }

  .app-shell {
    width: 100%;
    height: calc(100vh - 36px);
    min-height: 0;
    padding: 14px;
  }

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

  .chat-sidebar {
    min-height: auto;
  }

  .chat-panel {
    min-height: 520px;
  }

  .message-bubble {
    max-width: 82%;
  }

  .app-island {
    grid-template-columns: repeat(2, 1fr);
    border-radius: 28px;
  }

  .app-glow {
    display: none;
  }

  .app-nav-button.is-active {
    background: rgba(255, 255, 255, 0.1);
  }

  .profile-card {
    padding: 24px;
  }

  .profile-top,
  .profile-actions {
    grid-template-columns: 1fr;
  }

  .profile-top {
    align-items: flex-start;
  }
}

@media (max-width: 720px) {
  body.is-authenticated {
    height: 100dvh;
    overflow: hidden;
  }

  body.is-authenticated .auth-shell {
    width: 100%;
    min-height: 100dvh;
    padding: 0;
  }

  body.is-authenticated .auth-stack {
    min-height: 100dvh;
    padding: 0;
  }

  .app-shell {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    padding: 0;
    gap: 0;
    border-width: 0;
    border-radius: 0;
    background:
      linear-gradient(145deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.02)),
      rgba(5, 5, 6, 0.82);
  }

  .app-header {
    min-height: 48px;
    padding: 14px 14px 6px;
  }

  .app-header .kicker {
    margin-bottom: 4px;
    font-size: 0.64rem;
  }

  .app-header h2 {
    font-size: 1.42rem;
    line-height: 1;
  }

  .mini-avatar {
    width: 40px;
    height: 40px;
  }

  .app-view.is-active {
    min-height: 0;
    overflow: hidden;
  }

  .messenger-layout {
    position: relative;
    display: block;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .chat-sidebar {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 10px;
    max-height: none;
    padding: 12px;
    border-width: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    transition:
      opacity 240ms ease,
      transform 320ms cubic-bezier(0.16, 1, 0.3, 1);
  }

  .chat-search span {
    display: none;
  }

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

  .user-search-results {
    max-height: 116px;
    overflow-y: auto;
  }

  .chat-list {
    display: grid;
    gap: 10px;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 2px 0 82px;
  }

  .chat-item {
    width: 100%;
    min-height: 70px;
    padding: 11px 12px;
    border-radius: 22px;
  }

  .chat-icon {
    width: 42px;
    height: 42px;
  }

  .chat-item strong {
    margin-bottom: 3px;
    font-size: 0.92rem;
  }

  .chat-item small {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    font-size: 0.76rem;
  }

  .chat-list-note {
    display: block;
    padding: 10px 4px;
  }

  .chat-panel {
    position: absolute;
    inset: 0;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    min-height: 0;
    border-width: 0;
    border-radius: 0;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.055), transparent 32%),
      rgba(3, 3, 4, 0.52);
    opacity: 0;
    pointer-events: none;
    transform: translateX(100%);
    transition:
      opacity 220ms ease,
      transform 340ms cubic-bezier(0.16, 1, 0.3, 1);
  }

  .app-shell.is-chat-open .chat-panel {
    position: fixed;
    z-index: 30;
    display: grid;
    height: 100dvh;
    max-height: 100dvh;
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
  }

  .app-shell.is-chat-open .chat-sidebar {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-18%);
  }

  .app-shell.is-chat-open .app-header,
  .app-shell.is-chat-open .app-island {
    display: none;
  }

  .chat-panel-header {
    padding: 12px 10px;
    background: rgba(12, 12, 13, 0.54);
    backdrop-filter: blur(22px) saturate(160%);
  }

  .chat-back {
    display: grid;
  }

  .chat-panel-header h3 {
    font-size: 0.98rem;
  }

  .chat-panel-header p {
    font-size: 0.74rem;
  }

  .messages {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    padding: 14px 10px;
    gap: 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .message-bubble {
    max-width: 86%;
    padding: 7px 9px 5px;
    border-radius: 15px 15px 5px 15px;
  }

  .message-bubble.is-peer {
    border-radius: 15px 15px 15px 5px;
  }

  .message-bubble p {
    font-size: 0.9rem;
    line-height: 1.34;
  }

  .message-media {
    max-height: 240px;
    border-radius: 11px;
  }

  .attachment-preview {
    grid-template-columns: 48px minmax(0, 1fr) 32px;
    gap: 9px;
    margin: 0 8px 8px;
    padding: 8px;
    border-radius: 18px;
  }

  .preview-media {
    width: 48px;
    height: 48px;
    border-radius: 14px;
  }

  .message-composer {
    grid-template-columns: 42px minmax(0, 1fr) 42px 42px;
    gap: 8px;
    padding: 10px 10px max(10px, env(safe-area-inset-bottom));
    background: rgba(3, 3, 4, 0.82);
    backdrop-filter: blur(20px) saturate(150%);
  }

  .message-composer input[type="text"] {
    min-height: 42px;
    padding: 0 14px;
  }

  .attach-button,
  .voice-button,
  .send-button {
    width: 42px;
    height: 42px;
  }

  .composer-message {
    min-height: 18px;
    padding: 0 12px max(8px, env(safe-area-inset-bottom));
    background: rgba(3, 3, 4, 0.82);
    font-size: 0.74rem;
  }

  .app-island {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    min-height: 54px;
    padding: 5px;
    margin: 0 auto 10px;
    border-radius: 999px;
  }

  .app-glow {
    display: block;
    width: calc(25% - 6px);
  }

  .app-nav-button {
    min-height: 44px;
    padding: 0 4px;
    font-size: 0.72rem;
  }

  .app-nav-button.is-active {
    background: transparent;
  }

  .profile-page {
    height: 100%;
    max-width: none;
    overflow-y: auto;
    padding: 18px;
  }

  .profile-top {
    gap: 14px;
  }

  .avatar {
    width: 72px;
    height: 72px;
  }

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

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

@keyframes pulseDot {
  0%,
  100% {
    transform: scale(0.82);
    opacity: 0.7;
  }

  50% {
    transform: scale(1.22);
    opacity: 1;
  }
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes uploadSweep {
  from {
    transform: translateX(-120%);
  }

  to {
    transform: translateX(260%);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}
