@property --ang {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

:root {
  --b: 3px;
  --r: 1.9em;
  --app-dvh: 100dvh;
  --text: rgba(245, 245, 245, 0.92);
  --muted: #aaabad;
  --dim: rgba(245, 245, 245, 0.4);
  --c1: #f94144;
  --c2: #f3722c;
  --c3: #f8961e;
  --c4: #f9844a;
  --c5: #f9c74f;
  --c6: #90be6d;
  --c7: #43aa8b;
  --c8: #4d908e;
  --c9: #277da1;
  --c10: #577590;
  --bg0: #000;
  --bg1: #070a10;
  --card-bg: linear-gradient(
    180deg,
    rgba(18, 20, 26, 0.62),
    rgba(8, 10, 14, 0.52)
  );
  --card-border: rgba(255, 255, 255, 0.1);
  --chat-divider-border: rgba(255, 255, 255, 0.1);
  --card-shadow: 0 18px 60px rgba(0, 0, 0, 0.7);
  --pad: clamp(14px, 3dvw, 22px);
  --sidebar-w: 280px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

input,
textarea {
  -webkit-user-select: text !important;
  user-select: text !important;
}

*::-webkit-scrollbar {
  width: 6px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

html.zen-lightbox-open,
html.zen-lightbox-open *,
body.zen-lightbox-open,
body.zen-lightbox-open * {
  scrollbar-width: none !important;
}

html.zen-lightbox-open *::-webkit-scrollbar,
body.zen-lightbox-open *::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

@media (pointer: coarse), (max-width: 700px) {
  * {
    scrollbar-width: none !important;
  }

  *::-webkit-scrollbar {
    width: 0 !important;
    height: 0 !important;
    display: none !important;
  }
}

@font-face {
  font-family: "TiltWarp";
  src: url("../src/TiltWarp.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

html,
body {
  width: 100dvw;
  height: var(--app-dvh);
  overflow: hidden;
  background: #000;
  font-family: "Bahnschrift", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  font-weight: 700;
}

body {
  background: radial-gradient(1200px 900px at 50% 50%, var(--bg1), var(--bg0));
}

input,
button,
select,
textarea {
  font: inherit;
}

a {
  color: var(--c5);
  text-decoration: none;
}

/* ── Auth screen ── */
#authScreen {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  z-index: 100;
  transition:
    opacity 0.4s,
    visibility 0.4s;
}

#authScreen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.auto-login-active .auth-shell {
  display: none !important;
}

.auto-login-active .loader-circle {
  display: block !important;
}

.loader-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
}

.loader-circle::before,
.loader-circle::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  padding: 3px;
  background: conic-gradient(
    from var(--ang),
    var(--c1),
    var(--c2),
    var(--c3),
    var(--c4),
    var(--c5),
    var(--c6),
    var(--c7),
    var(--c8),
    var(--c9),
    var(--c10),
    var(--c1)
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  animation: spin 1.5s linear infinite;
}

.loader-circle::after {
  filter: blur(12px);
  opacity: 0.65;
}

.auth-shell {
  width: min(420px, 92%);
}

.card {
  position: relative;
  border-radius: 22px;
  padding: 22px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow:
    var(--card-shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: border-color 0.2s;
}

.card::before,
.card::after {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--b));
  border-radius: inherit;
  padding: var(--b);
  background: conic-gradient(
    from var(--ang),
    var(--c1),
    var(--c2),
    var(--c3),
    var(--c4),
    var(--c5),
    var(--c6),
    var(--c7),
    var(--c8),
    var(--c9),
    var(--c10),
    var(--c1)
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 1;
  animation: spin 7.5s linear infinite;
}

.card::after {
  filter: blur(var(--r));
  opacity: 0.55;
}

@keyframes spin {
  to {
    --ang: 360deg;
  }
}

.auth-title {
  font-size: 22px;
  letter-spacing: 0.6px;
  margin-bottom: 4px;
}

.auth-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

.auth-remember {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.auth-remember-copy {
  min-width: 0;
}

.auth-remember-title {
  font-size: 12px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.auth-remember-desc {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-size: 13px;
  transition: all 0.25s;
}

.auth-tab.active,
.auth-tab:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.field {
  width: 100%;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  outline: none;
  font-weight: 700;
  transition:
    border-color 0.18s,
    background 0.18s,
    box-shadow 0.18s,
    transform 0.18s;
}

.field:focus {
  border-color: rgba(180, 220, 255, 0.4);
  background: rgba(255, 255, 255, 0.085);
  transform: translateY(-1px);
  box-shadow:
    0 0 0 4px rgba(120, 200, 255, 0.08),
    0 0 22px rgba(120, 200, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.field + .field {
  margin-top: 10px;
}

.btn {
  display: block;
  width: 100%;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 13px 14px;
  font-weight: 900;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  transition:
    color 0.28s,
    border-color 0.28s,
    box-shadow 0.28s;
  margin-top: 12px;
  position: relative;
  overflow: hidden;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.92);
  color: rgba(10, 12, 16, 0.95);
  border-color: rgba(255, 255, 255, 0.3);
}

.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.auth-error {
  color: #ff6b6b;
  font-size: 12px;
  margin-top: 8px;
  min-height: 18px;
}

/* ── Main App ── */
#appScreen {
  display: none;
  width: 100%;
  height: 100%;
  min-height: 0;
  flex-direction: row;
}

#appScreen.active {
  display: flex;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: var(--app-dvh);
  display: flex;
  flex-direction: column;
  border-right: 2px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  backdrop-filter: blur(6px) saturate(115%);
  -webkit-backdrop-filter: blur(6px) saturate(115%);
  padding: 16px 16px 0 16px;
  gap: 12px;
  overflow: hidden;
  position: relative;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
}

.sidebar-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c3), var(--c7));
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 18px;
  flex-shrink: 0;
  position: relative;
  transform-origin: center;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sidebar-avatar::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: conic-gradient(
    var(--c1),
    var(--c3),
    var(--c5),
    var(--c7),
    var(--c9),
    var(--c1)
  );
  z-index: -1;
  animation: spin-avatar 8s linear infinite;
}

@keyframes spin-avatar {
  to {
    transform: rotate(360deg);
  }
}

.sidebar-uname {
  font-size: 14px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  padding-right: 38px;
}

.mode-switch-pop {
  --mode-color: var(--text);
  position: absolute;
  right: 4px;
  top: 22px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--mode-color);
  border-radius: 50%;
  background: color-mix(in srgb, var(--mode-color) 11%, transparent);
  border: 2px solid color-mix(in srgb, var(--mode-color) 18%, transparent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transform: translateY(-50%) scale(0.64);
  pointer-events: none;
  z-index: 2;
}

.mode-switch-pop svg {
  width: 18px;
  height: 18px;
}

.mode-switch-pop.show {
  animation: mode-switch-pop 1.05s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes mode-switch-pop {
  0% {
    opacity: 0;
    transform: translateY(-50%) scale(0.55);
  }

  18% {
    opacity: 1;
    transform: translateY(-50%) scale(1.12);
  }

  34% {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }

  72% {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(-50%) scale(0.74);
  }
}

.sidebar-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 0;
}

/* (Handled by .sidebar-bottom now) */

.folder-info {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  flex: 1;
}

.folder-info strong {
  color: var(--text);
  font-weight: 800;
}

.sidebar-icon-btn {
  --action-color: var(--text);
  position: relative;
  color: var(--muted);
  cursor: pointer;
  padding: 8px;
  background: transparent;
  border: none;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: visible;
}

.sidebar-icon-btn svg {
  position: relative;
  z-index: 1;
  width: 20px;
  height: 20px;
}

.sidebar-icon-btn::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--action-color);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.45);
  transition:
    opacity 0.2s,
    transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.sidebar-icon-btn:hover {
  color: var(--action-color);
}

.sidebar-icon-btn:hover::before {
  opacity: 0.13;
  transform: translate(-50%, -50%) scale(1.28);
}

.sidebar-settings {
  --action-color: var(--text);
}

.sidebar-logout {
  --action-color: #ff6b6b;
}

/* Storage bar */
.storage-wrap {
  padding: 10px 0;
}

.storage-label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}

.storage-bar {
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.storage-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--c1),
    var(--c3),
    var(--c5),
    var(--c7),
    var(--c9),
    var(--c1)
  );
  background-size: 400px 100%;
  animation: slide-bg 8s linear infinite;
  transition:
    width 0.3s,
    background-color 0.3s;
  width: 0;
}

@keyframes slide-bg {
  to {
    background-position: -400px 0;
  }
}

.storage-fill.warn {
  background: linear-gradient(90deg, var(--c1), #ff0000);
  animation: none;
}

/* Search */
.sidebar-search {
  position: relative;
}

.sidebar-search::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
  padding: 2px;
  background: conic-gradient(
    from var(--ang),
    var(--c1),
    var(--c3),
    var(--c5),
    var(--c7),
    var(--c9),
    var(--c1)
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0;
  animation: spin 6s linear infinite;
  transition: opacity 0.28s ease;
}

.sidebar-search:focus-within::before {
  opacity: 1;
}

.sidebar-search input {
  width: 100%;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 9px 12px 9px 34px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  outline: none;
  font-size: 13px;
  transition: all 0.2s;
}

.sidebar-search input:focus {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--dim);
  pointer-events: none;
}

.search-results {
  flex: 1;
  overflow-y: auto;
  display: none;
  flex-direction: column;
  gap: 4px;
}

.search-results.active {
  display: flex;
}

.search-item {
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  transition: background 0.15s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.search-item .s-folder {
  font-size: 10px;
  color: var(--dim);
  display: block;
}

/* Folder tree */
.folder-tree {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.folder-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  transition: all 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 3px solid transparent;
}

.folder-item:hover,
.folder-item.active {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

.folder-item.active {
  background: rgba(255, 255, 255, 0.1);
  border-left: 3px solid
    var(--folder-color, var(--theme, rgba(255, 255, 255, 0.15)));
}

.folder-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--theme, currentColor);
}

/* Folder info */
.folder-info {
  padding: 10px 0;
  font-size: 11px;
  color: var(--dim);
  line-height: 1.6;
}

.folder-info strong {
  color: var(--muted);
}

/* Main content */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  height: var(--app-dvh);
  position: relative;
  background: transparent;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  min-height: 58px;
  position: relative;
  background: transparent;
}

.breadcrumb {
  --breadcrumb-color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0;
  font-size: 13px;
  flex: 0 1 auto;
  max-width: min(52vw, 680px);
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  padding: 7px 12px;
  border-radius: 999px;
  color: color-mix(in srgb, var(--breadcrumb-color) 74%, var(--text));
  background: color-mix(in srgb, var(--breadcrumb-color) 13%, transparent);
  border: 2px solid color-mix(in srgb, var(--breadcrumb-color) 20%, transparent);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.025);
  transform-origin: left center;
  transition:
    background 0.2s,
    border-color 0.2s,
    color 0.2s;
}

.breadcrumb:empty {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.breadcrumb.is-uncolored {
  background: rgba(255, 255, 255, 0.01);
  border-color: rgba(255, 255, 255, 0.075);
}

.breadcrumb::-webkit-scrollbar {
  display: none;
}

.breadcrumb span {
  color: color-mix(in srgb, var(--breadcrumb-color) 52%, var(--dim));
  margin: 0 6px;
}

.breadcrumb a {
  cursor: pointer;
  color: inherit;
  transition: color 0.15s;
}

.breadcrumb a:hover {
  color: var(--text);
}

.breadcrumb.path-pop {
  animation: breadcrumb-pop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.breadcrumb.path-color-jump {
  transition: none;
}

@keyframes breadcrumb-pop {
  0% {
    opacity: 0;
    transform: scale(0.88);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.topbar-center-title {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 800;
  color: #aaabad;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  transition:
    opacity 0.2s,
    transform 0.2s;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  white-space: nowrap;
}

#settingsTitle {
  color: var(--theme, var(--text));
  border-color: color-mix(
    in srgb,
    var(--theme, #ffffff) 30%,
    rgba(255, 255, 255, 0.1)
  );
  background: color-mix(
    in srgb,
    var(--theme, #ffffff) 9%,
    rgba(12, 14, 20, 0.88)
  );
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

#threadTitle {
  left: 20px;
  transform: translateY(-50%) scaleY(0.85);
  transform-origin: left center;
  max-width: calc(100% - 104px);
  box-sizing: border-box;
  gap: 2px;
  padding: 0 8px 0 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-family: "TiltWarp", "Bahnschrift", "Segoe UI", system-ui, sans-serif;
  font-size: 25px;
  font-style: italic;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.1);
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: auto;
  cursor: pointer;
}

#threadTitle::before {
  content: "#";
  flex-shrink: 0;
}

.topbar-center-title.active {
  opacity: 1;
  visibility: visible;
}

.topbar-center-title svg {
  width: 18px;
  height: 18px;
}

#settingsTitle svg {
  color: inherit;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.thread-meta-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-left: 8px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition:
    transform 0.2s,
    filter 0.2s,
    opacity 0.2s;
}

.thread-meta-btn .thread-meta-avatar {
  width: 36px;
  height: 36px;
  font-size: 11px;
}

.thread-meta-btn:hover {
  filter: brightness(1.05);
}

.thread-meta-btn.open {
  transform: scale(1.03);
}

.thread-meta-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.01);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 13px;
  font-weight: 900;
  color: var(--muted);
}

.thread-meta-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thread-meta-presence {
  position: absolute;
  right: 0px;
  bottom: 1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #41d777;
  box-shadow:
    0 0 0 2px rgba(10, 12, 16, 0.95),
    0 0 12px rgba(65, 215, 119, 0.55);
}

.thread-meta-presence.pulsing {
  animation: thread-presence-pulse 1.6s ease-out infinite;
}

@keyframes thread-presence-pulse {
  0% {
    box-shadow:
      0 0 0 2px rgba(10, 12, 16, 0.95),
      0 0 0 0 rgba(65, 215, 119, 0.48);
  }

  70% {
    box-shadow:
      0 0 0 2px rgba(10, 12, 16, 0.95),
      0 0 0 10px rgba(65, 215, 119, 0);
  }

  100% {
    box-shadow:
      0 0 0 2px rgba(10, 12, 16, 0.95),
      0 0 0 0 rgba(65, 215, 119, 0);
  }
}

.thread-meta-panel {
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  width: min(460px, calc(100% - 32px));
  padding: 18px;
  border-radius: 22px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(8, 10, 14, 0.4);
  box-shadow:
    0 22px 60px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(6px) saturate(115%);
  -webkit-backdrop-filter: blur(6px) saturate(115%);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.22s ease,
    transform 0.22s ease;
}

.thread-meta-panel.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.thread-participants-panel {
  left: auto;
  right: 16px;
  transform: translateY(-10px);
  width: min(240px, calc(100% - 32px));
}

.thread-participants-panel.show {
  transform: translateY(0);
}

.thread-meta-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 16px;
}

.thread-meta-head .thread-meta-avatar {
  width: 42px;
  height: 42px;
  font-size: 18px;
}

.thread-meta-headline {
  flex: 1;
  min-width: 0;
}

.thread-meta-name {
  font-size: 16px;
  font-weight: 900;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-meta-sub {
  font-size: 12px;
  color: var(--dim);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.thread-meta-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
}

.thread-meta-status-dot.online {
  background: #41d777;
  box-shadow: 0 0 10px rgba(65, 215, 119, 0.45);
}

.thread-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.thread-meta-stat {
  border-radius: 14px;
  padding: 6px 13px;
}

.thread-meta-label {
  font-size: 11px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 4px;
}

.thread-meta-value {
  font-size: 13px;
  color: var(--text);
  font-weight: 800;
  word-break: break-word;
}

.thread-meta-people {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.thread-meta-actions {
  display: flex;
  gap: 10px;
}

.thread-meta-action {
  flex: 1;
  justify-content: center;
}

.thread-meta-action.danger {
  color: #ff6b6b;
  border-color: rgba(255, 80, 80, 0.25);
  background: rgba(255, 80, 80, 0.08);
}

.thread-meta-action.danger:hover {
  background: #ff6b6b;
  color: #fff;
  border-color: #ff6b6b;
}

.top-btn {
  padding: 8px 14px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.top-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.top-btn svg {
  width: 14px;
  height: 14px;
}

.topbar-actions .top-btn {
  --action-color: var(--text);
  position: relative;
  width: 36px;
  height: 36px;
  padding: 8px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 0;
  gap: 0;
  overflow: visible;
  transition:
    color 0.2s,
    transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.topbar-actions .top-btn::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--action-color);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.45);
  transition:
    opacity 0.2s,
    transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.topbar-actions .top-btn:hover {
  background: transparent;
  border-color: transparent;
  color: var(--action-color);
}

.topbar-actions .top-btn:hover::before {
  opacity: 0.13;
  transform: translate(-50%, -50%) scale(1.28);
}

.topbar-actions .top-btn:active {
  transform: scale(0.95);
}

.topbar-actions .top-btn svg {
  position: relative;
  z-index: 1;
  width: 20px;
  height: 20px;
}

#newFolderBtn {
  --action-color: var(--c7);
}

#uploadBtn {
  --action-color: var(--c9);
}

/* File area */
.file-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  position: relative;
}

.drop-overlay {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  border: 3px dashed var(--c5);
  border-radius: 16px;
  margin: 8px;
  place-items: center;
  font-size: 18px;
  font-weight: 900;
  color: var(--c5);
  letter-spacing: 1px;
}

.drop-overlay.show {
  display: grid;
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

@keyframes file-enter {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.file-card {
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  animation: file-enter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
  touch-action: manipulation;
}

.file-card.hide-badge-sync {
  overflow: visible;
}

.file-card:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.file-card.ctx-selected {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow:
    0 0 16px rgba(255, 255, 255, 0.08),
    0 8px 24px rgba(0, 0, 0, 0.3);
}

.color-ripple {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  background: var(--folder-color, rgba(255, 255, 255, 0.2));
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  opacity: 0.8;
  pointer-events: none;
  animation: ripple-expand 0.6s cubic-bezier(0.25, 1, 0.5, 1) forwards;
  z-index: 10;
}

@keyframes ripple-expand {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 0.8;
  }

  100% {
    transform: translate(-50%, -50%) scale(15);
    opacity: 0;
  }
}

/* Multi-select badge */
.select-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  background: transparent;
  border-radius: 50%;
  opacity: 0;
  transform: scale(0);
  transition:
    opacity 0.2s,
    transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
    border-radius 0.3s 0.15s ease;
  pointer-events: none;
}

.file-card.hide-badge-sync .select-badge {
  display: none !important;
}

.file-card.ctx-selected .select-badge.multi,
.file-card.ctx-selected.dragging .select-badge {
  opacity: 1;
  transform: scale(1);
  border-radius: 5px;
}

/* Cut-pending (marked for move) */
.file-card.cut-pending {
  opacity: 0.4;
  filter: grayscale(0.4);
  pointer-events: auto;
}

.file-card.cut-pending.ctx-selected,
.file-card.dragging.ctx-selected {
  opacity: 1;
  filter: none;
}

/* Drag-over target folder */
.file-card.drag-over {
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.035);
  box-shadow:
    0 0 20px rgba(255, 255, 255, 0.1),
    inset 0 0 12px rgba(255, 255, 255, 0.04);
  transform: scale(1.03);
}

/* Touch drag ghost indicator (clone of card) */
.touch-drag-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  display: none;
  opacity: 0.8;
  transform: translate(-50%, -50%) scale(1.05);
  /* Reset card styles for ghost container */
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 14px;
  background: #1e1e24;
  /* match body bg roughly */
  min-width: 140px;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4);
}

.touch-drag-ghost.active {
  display: flex;
}

.desktop-drag-image {
  position: fixed;
  left: -10000px;
  top: -10000px;
  pointer-events: none;
  background: transparent;
  box-sizing: content-box;
}

.desktop-drag-image .desktop-drag-ghost-card {
  animation: none !important;
  transform: none !important;
  margin: 0;
  box-sizing: border-box;
  box-shadow: none !important;
}

.desktop-drag-image .select-badge {
  display: none !important;
}

.drag-count-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  background: #ff4757;
  color: #fff;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  box-shadow: none;
  z-index: 2;
}

.file-icon {
  width: 32px;
  height: 32px;
  color: var(--muted);
}

.file-icon svg {
  width: 100%;
  height: 100%;
}

.file-name {
  font-size: 12px;
  line-height: 1.3;
  color: var(--text);
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  font-size: 10px;
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--dim);
  text-align: center;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  opacity: 0.3;
}

.empty-state p {
  font-size: 14px;
}

/* Toast */
.toast {
  position: fixed;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  width: min(480px, 92dvw);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(10, 12, 16, 0.82);
  border: 2px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(18px);
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.55);
  display: grid;
  grid-template-columns: 8px 1fr auto;
  gap: 10px;
  align-items: center;
  z-index: 200;
  font-size: 13px;
  opacity: 0;
  visibility: hidden;
  transition:
    top 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.3s,
    visibility 0.4s;
}

.toast.show {
  top: 18px;
  opacity: 1;
  visibility: visible;
}

.toast .t-bar {
  width: 8px;
  border-radius: 999px;
  align-self: stretch;
  background: rgba(120, 255, 190, 0.9);
}

.toast.error .t-bar {
  background: rgba(255, 120, 120, 0.9);
}

.toast .t-msg {
  color: var(--text);
}

.toast .t-close {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
  font-size: 15px;
  padding: 2px 6px;
  border-radius: 8px;
}

.chat-text-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  outline: none;
  font-size: 14px;
  resize: none;
  max-height: 120px;
  padding: 0;
  line-height: inherit;
  font-weight: 600;
  scrollbar-width: none;
}

.chat-text-input::-webkit-scrollbar {
  display: none;
}

/* Modals */
.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  place-items: center;
}

.modal-bg.show {
  display: grid;
}

.modal {
  width: min(380px, 90%);
  border-radius: 18px;
  padding: 20px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(14, 16, 22, 0.9);
  backdrop-filter: blur(20px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.modal h3 {
  font-size: 16px;
  margin-bottom: 12px;
}

.modal .field {
  margin-top: 0;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.modal-actions button {
  flex: 1;
}

/* Upload progress */
.upload-progress {
  position: fixed;
  bottom: -100px;
  right: 20px;
  width: 280px;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition:
    bottom 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.3s,
    visibility 0.4s;
}

.upload-progress.show {
  bottom: 20px;
  opacity: 1;
  visibility: visible;
}

.direct-connection-badge {
  display: none;
  flex: 0 0 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 13px;
  border: 2px solid rgba(74, 222, 128, 0.28);
  border-radius: 12px;
  background: linear-gradient(
    115deg,
    rgba(34, 197, 94, 0.14),
    rgba(22, 163, 74, 0.07)
  );
  color: #86efac;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.035),
    0 8px 24px rgba(4, 120, 87, 0.08);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.015em;
}

.direct-connection-badge.visible {
  display: flex;
  animation: direct-connection-in 0.3s ease-out both;
}

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

.upload-progress.has-stats {
  right: 164px;
}

.upload-progress .up-main {
  position: relative;
  z-index: 2;
  width: 100%;
  min-width: 0;
  padding: 16px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: rgba(14, 16, 22, 0.9);
  backdrop-filter: blur(20px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.upload-progress .up-title {
  font-size: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 28px), transparent 100%);
  mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 28px), transparent 100%);
}

.upload-progress .up-count {
  margin-bottom: 4px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.upload-progress .up-bar {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.upload-progress .up-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(
    90deg,
    var(--c1),
    var(--c3),
    var(--c5),
    var(--c7),
    var(--c9),
    var(--c1)
  );
  background-size: 400px 100%;
  animation: slide-bg 8s linear infinite;
  transition:
    width 0.3s,
    background-color 0.3s;
  width: 0;
}

.upload-progress .up-stats {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(100% - 20px);
  z-index: 1;
  width: 164px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  box-sizing: border-box;
  padding: 6px 8px 6px 28px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 0 16px 16px 0;
  background: rgba(7, 9, 14, 0.94);
  backdrop-filter: blur(20px);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.42);
  color: rgba(255, 255, 255, 0.48);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
}

.upload-progress .up-stats > span {
  display: block;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: clip;
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 18px), transparent 100%);
  mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 18px), transparent 100%);
}

.upload-progress .up-direct-dot {
  position: absolute;
  right: 12px;
  bottom: 11px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #38f28f;
  opacity: 0;
  transform: scale(0.65);
  box-shadow:
    0 0 0 3px rgba(56, 242, 143, 0.08),
    0 0 10px rgba(56, 242, 143, 0.75),
    0 0 18px rgba(34, 197, 94, 0.38);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  pointer-events: none;
}

.upload-progress.is-direct .up-direct-dot {
  opacity: 1;
  transform: scale(1);
  animation: upload-direct-dot-glow 2s ease-in-out infinite;
}

@keyframes upload-direct-dot-glow {
  0%,
  100% {
    box-shadow:
      0 0 0 3px rgba(56, 242, 143, 0.07),
      0 0 9px rgba(56, 242, 143, 0.62),
      0 0 15px rgba(34, 197, 94, 0.28);
  }
  50% {
    box-shadow:
      0 0 0 4px rgba(56, 242, 143, 0.12),
      0 0 13px rgba(56, 242, 143, 0.9),
      0 0 22px rgba(34, 197, 94, 0.48);
  }
}

.upload-progress .up-count[hidden],
.upload-progress .up-stats[hidden] {
  display: none;
}

@media (max-width: 700px) {
  .upload-progress {
    right: auto;
    left: 50%;
    width: min(340px, calc(100vw - 24px));
    transform: translateX(-50%);
  }

  .upload-progress.has-stats {
    right: auto;
    width: min(280px, calc(100vw - 144px));
    transform: translateX(calc(-50% - 60px));
  }

  .upload-progress .up-stats {
    width: 140px;
    padding-right: 7px;
    padding-left: 26px;
    font-size: 10px;
  }

  body.chat-keyboard-open {
    position: fixed;
    inset: 0;
    width: 100%;
    height: var(--app-dvh);
    overflow: hidden;
  }

  body.chat-keyboard-open .chat-input-area,
  body.chat-keyboard-open .chat-input-wrap,
  body.chat-keyboard-open .chat-text-input {
    overscroll-behavior: none;
    touch-action: none;
  }

  .sidebar {
    position: fixed;
    left: -100%;
    z-index: 90;
    width: 65dvw;
    padding: 24px 20px 0 20px;
    gap: 16px;
    transition: left 0.3s;
  }

  .sidebar.open {
    left: 0;
  }

  :root {
    --sidebar-w: 0px;
  }

  .mobile-toggle {
    display: flex !important;
  }

  .breadcrumb {
    flex: 0 1 auto;
    max-width: calc(100% - 46px);
  }

  #threadTitle {
    left: 66px;
    max-width: calc(100% - 122px);
    transform: translateY(-50%) scaleY(0.92);
    transform-origin: left center;
  }

  .topbar-actions {
    display: none !important;
  }

  .thread-meta-btn {
    display: flex;
    margin-left: auto;
  }

  .thread-meta-panel {
    top: 82px;
    width: calc(100% - 20px);
  }

  .thread-participants-panel {
    right: 10px;
    width: min(220px, calc(100% - 20px));
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 89;
    background: rgba(0, 0, 0, 0.5);
  }

  .sidebar-overlay.show {
    display: block;
  }

  .sidebar-icon-btn {
    margin-bottom: 10px;
    margin-top: 12px;
  }
}

.mobile-toggle {
  --action-color: var(--text);
  position: relative;
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 8px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  flex-shrink: 0;
  overflow: visible;
  transition:
    color 0.2s,
    transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mobile-toggle::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--action-color);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.45);
  transition:
    opacity 0.2s,
    transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.mobile-toggle svg {
  position: relative;
  z-index: 1;
  width: 20px;
  height: 20px;
}

.mobile-toggle:hover {
  color: var(--action-color);
}

.mobile-toggle:hover::before {
  opacity: 0.13;
  transform: translate(-50%, -50%) scale(1.28);
}

.mobile-toggle:active {
  transform: scale(0.95);
}

/* Context menu */
.ctx-menu {
  position: fixed;
  z-index: 180;
  min-width: 200px;
  border-radius: 16px;
  padding: 8px;
  background: rgba(14, 16, 22, 0.92);
  border: 2px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.04);
  display: none;
  opacity: 0;
  transform: scale(0.85);
  transition:
    opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Disable transition during positioning to avoid flying menus */
.ctx-menu.no-trans {
  transition: none !important;
}

.ctx-menu.visible {
  display: block;
}

.ctx-menu.show {
  opacity: 1;
  transform: scale(1);
}

/* Hack to block instant clicks via a temporary invisible overlay */
.ctx-click-blocker {
  position: fixed;
  inset: 0;
  z-index: 190;
  display: none;
  touch-action: none;
}

.ctx-click-blocker.active {
  display: block;
}

.ctx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.ctx-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  transform: scale(1.02);
}

.ctx-item.danger:hover {
  background: rgba(255, 60, 60, 0.12);
  color: #ff6b6b;

  transform: scale(1.02);
}

.bubble-animating {
  animation: bubble-select 0.4s ease forwards;
  pointer-events: none;
}

@keyframes bubble-select {
  0% {
    transform: scale(1);
    opacity: 1;
  }

  100% {
    transform: scale(2.5);
    opacity: 0;
  }
}

.ctx-item svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.ctx-sep {
  height: 1px;
  margin: 5px 10px;
  background: rgba(255, 255, 255, 0.08);
}

/* Mobile back button */
.fab-back {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 80;
  width: 50px;
  height: 50px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(14px);
  color: var(--text);
  cursor: pointer;
  place-items: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  transition: all 0.2s;
}

.fab-back:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.15);
}

.fab-back svg {
  width: 22px;
  height: 22px;
}

@media (max-width: 700px) {
  .fab-back.visible {
    display: grid;
  }
}

/* Settings Area */
.settings-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 30px;
  display: none;
  flex-direction: column;
  gap: 24px;
}

.settings-area.active {
  display: flex;
}

.settings-section {
  --theme: var(--c5);
  background: rgba(255, 255, 255, 0.03);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 24px;
  display: none;
  flex-direction: column;
  animation: file-enter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.settings-section.active {
  display: flex;
}

.settings-section .setting-item {
  animation: file-enter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.setting-item:first-of-type {
  padding-top: 0;
}

.setting-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.setting-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 20px;
}

.setting-name {
  font-size: 15px;
  color: var(--text);
  font-weight: 800;
}

.setting-desc {
  font-size: 13px;
  color: var(--dim);
  line-height: 1.4;
  font-weight: 600;
}

.setting-item.is-disabled {
  opacity: 0.52;
}

.setting-item.is-disabled .setting-info {
  cursor: default;
}

.setting-item-stack {
  align-items: flex-start;
  flex-direction: column;
  gap: 14px;
}

.temp-cleanup-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.16);
}

.temp-cleanup-readout {
  min-width: 0;
}

.temp-cleanup-label {
  color: var(--dim);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.temp-cleanup-size {
  margin-top: 3px;
  color: var(--text);
  font-size: 24px;
  font-weight: 900;
  line-height: 1.1;
}

.temp-cleanup-details {
  margin-top: 5px;
  color: var(--dim);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}

.temp-cleanup-button {
  width: auto;
  min-width: 132px;
  margin: 0;
  flex: 0 0 auto;
}

.temp-cleanup-button:disabled {
  cursor: default;
  opacity: 0.5;
}

@media (max-width: 700px) {
  .temp-cleanup-card {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .temp-cleanup-button {
    width: 100%;
  }
}

.identity-fingerprint-card {
  width: 100%;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.identity-fingerprint-value,
.identity-verify-fingerprint {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.18em;
  line-height: 1.7;
  padding: 12px 14px;
  word-break: break-all;
  font-family: "Consolas", "Courier New", monospace;
  text-transform: uppercase;
}

.identity-fingerprint-copy {
  width: auto;
  align-self: flex-start;
  padding: 10px 14px;
  font-size: 12px;
}

.identity-verify-copy,
.identity-verify-label {
  font-size: 13px;
  color: var(--dim);
  line-height: 1.5;
  font-weight: 600;
}

.identity-verify-copy {
  margin-bottom: 12px;
}

.identity-verify-label {
  display: block;
  margin: 12px 0 8px;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.08);
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 26px;
  border: 2px solid rgba(255, 255, 255, 0.15);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--muted);
  transition: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--theme, var(--c5));
  border-color: var(--theme, var(--c5));
}

.toggle-switch input:disabled + .toggle-slider {
  cursor: not-allowed;
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(22px);
  background-color: #000;
}

.sidebar-user {
  cursor: pointer;
  transition: color 0.2s;
  border-radius: 0;
  padding: 0 0 12px 0;
  margin: 0;
}

.sidebar-user:hover {
  background: transparent;
}

.sidebar-user:active .sidebar-avatar {
  transform: scale(0.95);
}

/* ── Threads / Chat ── */
.sidebar-mode-toggle {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}

.sidebar-mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 8px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  transition: all 0.2s;
}

.sidebar-mode-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.sidebar-mode-btn.active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.15);
}

.sidebar-mode-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-mode-btn .unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c1);
  flex-shrink: 0;
  display: none;
}

.sidebar-mode-btn .unread-dot.visible {
  display: block;
}

.thread-sidebar {
  display: none;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.thread-sidebar.active {
  display: flex;
}

.thread-new-btn {
  align-self: flex-start;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin: 4px 0 0 10px;
  padding: 0;
  border-radius: 50%;
  border: 2px dashed currentColor;
  background: transparent;
  color: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  font-size: 30px;
  font-weight: 600;
  line-height: 1;
  transition:
    border-color 0.15s,
    color 0.15s,
    transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.thread-new-btn:hover {
  color: var(--text);
  background: transparent;
}

.thread-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.thread-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.thread-item.active {
  background: rgba(255, 255, 255, 0.08);
}

.thread-item-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 900;
  flex-shrink: 0;
  color: var(--muted);
  overflow: hidden;
}

.thread-item-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thread-item-info {
  flex: 1;
  min-width: 0;
}

.thread-item-name {
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-item-preview {
  font-size: 11px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.thread-item-badge {
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--c1);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  display: none;
  place-items: center;
  padding: 0 5px;
  flex-shrink: 0;
}

.thread-item-badge.visible {
  display: grid;
}

/* Chat area */
.threads-area {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

.threads-area.active {
  display: flex;
}

.chat-drop-overlay {
  display: none;
  position: absolute;
  inset: 8px;
  z-index: 35;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  border: 3px dashed var(--c5);
  border-radius: 16px;
  place-items: center;
  color: var(--c5);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 1px;
  pointer-events: none;
}

.chat-drop-overlay.show {
  display: grid;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
  scrollbar-width: none;
}

.chat-messages::-webkit-scrollbar {
  display: none;
}

.chat-date-sep {
  text-align: center;
  font-family: "TiltWarp", "Bahnschrift", "Segoe UI", system-ui, sans-serif;
  font-size: 18px;
  font-style: italic;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.1);
  text-transform: uppercase;
  transform: scaleY(0.85);
  transform-origin: center;
  padding: 12px 0 6px;
}

.msg-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  word-break: break-word;
  position: relative;
  animation: msg-enter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
  transition:
    background 0.2s,
    border-color 0.2s,
    box-shadow 0.2s,
    transform 0.2s;
}

.msg-bubble,
.msg-bubble .msg-text {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

.msg-bubble .msg-text {
  cursor: default;
}

.msg-bubble .msg-text::selection {
  background: #fff;
  color: #000;
}

.msg-bubble .msg-time {
  -webkit-user-select: none;
  user-select: none;
}

.msg-bubble.msg-deleted,
.msg-bubble.msg-deleted * {
  -webkit-user-select: none;
  user-select: none;
}

@keyframes msg-enter {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }
}

.msg-bubble.sent {
  align-self: flex-end;
  background: rgba(255, 255, 255, 0.03);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-bottom-right-radius: 4px;
}

.msg-bubble.received {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.03);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-bottom-left-radius: 4px;
}

.msg-bubble.personal {
  max-width: 100%;
  border-radius: 16px;
}

.msg-bubble.msg-emoji-only {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  padding: 4px 0;
}

.msg-bubble.msg-emoji-only .msg-text {
  font-size: 32px;
  line-height: 1.2;
}

.msg-bubble.msg-emoji-only.show-time,
.msg-bubble.msg-emoji-only.ctx-selected {
  padding: 10px 14px;
}

.msg-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 75%;
  min-width: 0;
  box-sizing: border-box;
  isolation: isolate;
  overflow: visible;
  position: relative;
}

.msg-stack.sent {
  align-items: flex-end;
}

.msg-stack.received::before {
  content: "";
  position: absolute;
  right: var(--reply-line-right, -28px);
  left: auto;
  top: var(--reply-line-top, 48px);
  width: var(--reply-line-width, 20px);
  height: var(--reply-line-height, 42px);
  border-right: 2px solid rgba(255, 255, 255, 0.1);
  border-left: 0;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  border-bottom-right-radius: 12px;
  border-bottom-left-radius: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
}

.msg-stack.sent::before {
  content: "";
  position: absolute;
  left: var(--reply-line-x, -28px);
  right: auto;
  top: var(--reply-line-top, 48px);
  width: var(--reply-line-width, 20px);
  height: var(--reply-line-height, 42px);
  border-left: 2px solid rgba(255, 255, 255, 0.1);
  border-right: 0;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
}

.msg-stack.reply-connector-ready::before {
  opacity: 1;
}

.msg-stack.personal {
  max-width: 100%;
}

.msg-stack.has-image-reply {
  width: auto;
  max-width: min(210px, 56vw);
}

.msg-stack > .msg-bubble,
.msg-stack > .msg-file-card {
  width: auto;
  max-width: 100%;
  box-sizing: border-box;
  position: relative;
  z-index: 2;
  margin-top: 4px;
}

.msg-stack > .msg-img-preview {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  position: relative;
  z-index: 2;
  margin-top: 4px;
}

.msg-stack:has(.msg-img-preview) {
  max-width: min(75%, 300px);
}

.msg-bubble.ctx-selected,
.msg-file-card.ctx-selected {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.35) !important;
  box-shadow:
    0 0 16px rgba(255, 255, 255, 0.08),
    0 8px 24px rgba(0, 0, 0, 0.3);
}

.msg-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-top: 8px;
  position: relative;
  z-index: 0;
}

.msg-row:has(.msg-emoji-only:not(.show-time):not(.ctx-selected)) {
  align-items: center;
}

.msg-row:has(.msg-emoji-only:not(.show-time):not(.ctx-selected)) .msg-avatar {
  margin-bottom: 0;
}

.msg-row > *:not(.reply-highlight-wave) {
  position: relative;
  z-index: 2;
  transform: translateZ(0); /* Force GPU composite layer to fix Safari/Webkit stacking layout bugs */
}

.msg-row.sent {
  flex-direction: row-reverse;
  gap: 6px;
}

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  flex-shrink: 0;
  overflow: hidden;
  margin-bottom: 2px;
  color: var(--muted);
}

.msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.msg-sender {
  font-size: 11px;
  font-weight: 800;
  color: var(--dim);
  margin-bottom: 3px;
}

.msg-reply-snippet {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: visible;
  margin: 0;
  position: relative;
  z-index: 1;
  cursor: pointer;
}

.msg-reply-snippet.is-deleted .msg-reply-bubble-wrap {
  background: rgba(255, 60, 60, 0.06) !important;
  border-color: rgba(255, 60, 60, 0.18) !important;
  opacity: 0.75;
}

.msg-reply-snippet.is-deleted .thread-reply-text {
  color: #ff6b6b !important;
  font-style: italic;
}

@keyframes reply-swipe {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.reply-highlight-wave {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    rgba(59, 130, 246, 0) 0%,
    rgba(59, 130, 246, 0.08) 25%,
    rgba(59, 130, 246, 0.25) 50%,
    rgba(59, 130, 246, 0.08) 75%,
    rgba(59, 130, 246, 0) 100%
  );
  transform: translateX(-100%);
  animation: reply-swipe 1.2s cubic-bezier(0.25, 1, 0.5, 1) forwards;
  z-index: 1;
}

/* Received (left side messages): avatar and line on the right */
.msg-stack.received .msg-reply-snippet {
  flex-direction: row-reverse;
}

.msg-stack.received .msg-reply-bubble-wrap {
  border-bottom-right-radius: 4px;
  border-bottom-left-radius: 16px;
}

.msg-stack.received .msg-reply-snippet.is-image-preview .msg-reply-bubble-wrap {
  border-bottom-right-radius: 4px;
  border-bottom-left-radius: 16px;
}

.msg-stack.received .msg-reply-snippet > .thread-reply-avatar {
  right: -38px;
  left: auto;
}

/* Sent (right side messages): avatar and line on the left */
.msg-stack.sent .msg-reply-snippet {
  flex-direction: row;
}

.msg-stack.sent .msg-reply-bubble-wrap {
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 16px;
}

.msg-stack.sent .msg-reply-snippet.is-image-preview .msg-reply-bubble-wrap {
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 16px;
}

.msg-stack.sent .msg-reply-snippet > .thread-reply-avatar {
  left: -38px;
  right: auto;
}

/* Shared/Default styling for bubble wrap and avatar placement */
.msg-reply-bubble-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border: 2px solid rgba(255, 255, 255, 0.055);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.01);
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.msg-reply-snippet.is-image-preview {
  width: 100%;
  max-width: 100%;
  min-height: 0;
  padding: 0;
  overflow: visible;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.msg-reply-snippet.is-image-preview .msg-reply-bubble-wrap {
  display: block;
  aspect-ratio: var(--reply-image-aspect, 16 / 9);
  max-width: min(210px, 56vw);
  max-height: 105px;
  width: auto;
  height: 105px;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background-image: var(--reply-image-url);
  background-size: cover;
  background-position: center;
  background-origin: padding-box;
  background-clip: padding-box;
  border: 2px solid rgba(255, 255, 255, 0.055);
  border-radius: 16px;
  box-shadow:
    inset 0 0 0 999px rgba(0, 0, 0, 0.22);
  box-sizing: border-box;
}

.msg-reply-snippet.is-image-preview::before {
  content: none;
}

.msg-reply-snippet.is-image-preview .thread-reply-file-icon {
  display: none;
}

.msg-reply-snippet.is-image-preview .thread-reply-text {
  display: none;
}

.thread-reply-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 900;
  flex-shrink: 0;
  overflow: hidden;
  color: var(--muted);
}

.msg-reply-snippet > .thread-reply-avatar {
  position: absolute;
  right: -38px;
  left: auto;
  bottom: 0;
  top: auto;
  width: 30px;
  height: 30px;
  transform: none;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  z-index: 3;
}

.msg-reply-snippet.is-image-preview > .thread-reply-avatar {
  top: var(--reply-avatar-top);
  bottom: auto;
  transform: translateY(-50%);
}

.thread-reply-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thread-reply-file-icon {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  opacity: 0.85;
}

.thread-reply-file-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

.thread-reply-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
  color: rgba(255, 255, 255, 0.52);
  padding-right: 3px;
}

/* Grouped message rows — tighter spacing */
.msg-row.msg-group-last {
  margin-top: 3px;
}

.msg-row.received.msg-group + .msg-row.received {
  margin-top: 3px;
}

.msg-row.sent.msg-group + .msg-row.sent {
  margin-top: 3px;
}

.msg-row.received.msg-group[data-type="file"]
  + .msg-row.received[data-type="file"],
.msg-row.sent.msg-group[data-type="file"] + .msg-row.sent[data-type="file"] {
  margin-top: 5px;
}

.msg-row.msg-group[data-type="file"]:has(.msg-img-preview),
.msg-row.msg-group[data-type="file"]:has(.msg-file-card),
.msg-row.msg-group-last[data-type="file"]:has(.msg-img-preview),
.msg-row.msg-group-last[data-type="file"]:has(.msg-file-card) {
  margin-top: 5px;
}

.msg-row.received.msg-group + .msg-row.received > .msg-bubble,
.msg-row.received.msg-group + .msg-row.received > .msg-file-card {
  border-top-left-radius: 4px;
}

.msg-row.sent.msg-group + .msg-row.sent > .msg-bubble,
.msg-row.sent.msg-group + .msg-row.sent > .msg-file-card {
  border-top-right-radius: 4px;
}

.msg-row.personal.msg-group[data-type="file"]
  + .msg-row.personal[data-type="text"]
  .msg-bubble {
  border-top-right-radius: 16px;
  border-top-left-radius: 16px;
}

/* Avatar spacer — keeps alignment when avatar is hidden in grouped rows */
.msg-avatar-spacer {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  visibility: hidden;
}

.msg-time {
  font-size: 10px;
  color: var(--dim);
  margin-top: 4px;
  display: none;
  align-items: center;
  gap: 4px;
}

.show-time .msg-time {
  display: flex;
}

.msg-bubble.show-time {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.15);
}

.msg-file-card.show-time {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.15);
}

.msg-bubble.sent .msg-time,
.msg-file-card.sent .msg-time {
  justify-content: flex-end;
}

.msg-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  align-self: center;
  margin: 0;
  flex-shrink: 0;
  transition: all 0.2s;
}

.msg-bubble > .msg-status-dot,
.msg-file-card > .msg-status-dot,
.msg-img-preview > .msg-status-dot {
  position: absolute;
  left: -18px;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
  pointer-events: none;
}

.msg-stack.sent > .msg-status-dot {
  position: absolute;
  left: calc(var(--reply-line-x) - 18px);
  top: var(--reply-status-y);
  transform: translateY(-50%);
  margin: 0;
  pointer-events: none;
  z-index: 3;
}

.msg-status-dot.sending {
  border: 2px solid var(--dim);
  background: transparent;
}

.msg-status-dot.unread {
  background: var(--c9);
}

.msg-status-dot.error {
  background: var(--c1);
}

.msg-status-dot.read {
  display: none;
}

.msg-file-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 14px;
  border-radius: 16px;
  max-width: 75%;
  animation: msg-enter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
  cursor: pointer;
  transition:
    background 0.2s,
    border-color 0.2s,
    box-shadow 0.2s,
    transform 0.2s;
}

.msg-file-card-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.msg-file-card.sent {
  align-self: flex-end;
  background: rgba(255, 255, 255, 0.03);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-bottom-right-radius: 4px;
}

.msg-file-card.sent:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.15);
}

.msg-file-card.received {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.03);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-bottom-left-radius: 4px;
}

.msg-file-card.received:hover {
  background: rgba(255, 255, 255, 0.1);
}

.msg-file-card.personal {
  max-width: 100%;
  border-radius: 16px;
}

.msg-file-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.msg-file-info {
  flex: 1;
  min-width: 0;
}

.msg-file-name {
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.show-time .msg-file-name {
  white-space: normal;
  word-break: break-all;
}

.msg-file-size {
  font-size: 10px;
  color: var(--dim);
  margin-top: 2px;
}

.msg-file-dl {
  width: 28px;
  height: 28px;
  color: var(--c9);
  flex-shrink: 0;
}

.typing-indicator {
  display: none;
  align-self: flex-start;
  margin-top: 8px;
  padding: 10px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-bottom-left-radius: 4px;
  gap: 4px;
  align-items: center;
}

.typing-indicator.visible {
  display: flex;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-bounce 0.6s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }

  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.typing-label {
  font-size: 11px;
  color: var(--dim);
  margin-left: 4px;
  font-weight: 700;
}

.chat-input-area {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 2px solid var(--chat-divider-border);
  flex-shrink: 0;
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.chat-attach-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
  position: relative;
}

.chat-attach-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.chat-attach-btn svg {
  width: 18px;
  height: 18px;
}

.chat-input-wrap {
  flex: 1;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.05);
  position: relative;
  transition: border-color 0.15s;
}

.chat-input-wrap:focus-within {
  border-color: rgba(180, 220, 255, 0.3);
}

.chat-attach-btn.animating::before,
.chat-send-btn.animating::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  padding: 2px;
  background: conic-gradient(
    from var(--ang),
    var(--c1),
    var(--c3),
    var(--c5),
    var(--c7),
    var(--c9),
    var(--c1)
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  animation:
    rgb-border-flash 0.8s ease-out forwards,
    spin 0.8s linear forwards;
}

.chat-input-wrap::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  padding: 2px;
  background: conic-gradient(
    from var(--ang),
    var(--c1),
    var(--c3),
    var(--c5),
    var(--c7),
    var(--c9),
    var(--c1)
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0;
  animation: spin 6s linear infinite;
  transition: opacity 0.28s ease;
}

.chat-input-wrap:focus-within::before {
  opacity: 1;
}

.chat-reply-preview {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 6px 8px;
  border-radius: 14px;
  border: 2px solid var(--chat-divider-border);
  background: rgba(0, 0, 0, 0.38);
  user-select: none;
}

.chat-reply-preview.show {
  display: flex;
}

.chat-reply-content {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.chat-reply-clear {
  appearance: none;
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 10px;
  border: 0;
  background: rgba(255, 255, 255, 0.06);
  color: var(--dim);
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background 0.15s,
    color 0.15s,
    transform 0.15s;
}

.chat-reply-clear:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.chat-reply-clear:active {
  transform: scale(0.94);
}

.chat-reply-clear svg {
  width: 15px;
  height: 15px;
}

.chat-attachments {
  display: none;
  flex-wrap: nowrap;
  gap: 6px;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0 4px;
  scrollbar-width: none;
  cursor: grab;
  user-select: none;
  -webkit-overflow-scrolling: touch;
}

.chat-attachments::-webkit-scrollbar {
  display: none;
}

.chat-attachments.show {
  display: flex;
}

.chat-attachments.dragging {
  cursor: grabbing;
}

.chat-attachments.fade-left {
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0,
    #000 18px,
    #000 100%
  );
  mask-image: linear-gradient(to right, transparent 0, #000 18px, #000 100%);
}

.chat-attachments.fade-right {
  -webkit-mask-image: linear-gradient(
    to right,
    #000 0,
    #000 calc(100% - 18px),
    transparent 100%
  );
  mask-image: linear-gradient(
    to right,
    #000 0,
    #000 calc(100% - 18px),
    transparent 100%
  );
}

.chat-attachments.fade-left.fade-right {
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0,
    #000 18px,
    #000 calc(100% - 18px),
    transparent 100%
  );
  mask-image: linear-gradient(
    to right,
    transparent 0,
    #000 18px,
    #000 calc(100% - 18px),
    transparent 100%
  );
}

.chat-attachment-image {
  appearance: none;
  -webkit-appearance: none;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 2px solid var(--chat-divider-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  background-clip: padding-box;
  box-shadow: none;
  outline: 0;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
  transition:
    transform 0.15s,
    border-color 0.15s,
    opacity 0.15s;
}

.chat-attachment-image:hover {
  border-color: var(--chat-divider-border);
  transform: translateY(-1px);
}

.chat-attachment-image:active {
  opacity: 0.7;
  transform: scale(0.96);
}

.chat-attachment-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-attachment-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-width: 76px;
  min-height: 52px;
  max-width: min(260px, 70vw);
  padding: 6px 8px;
  border-radius: 14px;
  border: 2px solid var(--chat-divider-border);
  background: rgba(0, 0, 0, 0.22);
  background-clip: padding-box;
  cursor: pointer;
  user-select: none;
  transition:
    transform 0.15s,
    border-color 0.15s,
    background 0.15s,
    opacity 0.15s;
}

.chat-attachment-chip:hover {
  border-color: var(--chat-divider-border);
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-1px);
}

.chat-attachment-chip:active {
  opacity: 0.7;
  transform: scale(0.98);
}

.chat-attachment-preview {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
  color: var(--c9);
  background: rgba(255, 255, 255, 0.06);
}

.chat-attachment-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chat-attachment-preview svg {
  width: 17px;
  height: 17px;
}

.chat-attachment-meta {
  min-width: 0;
  flex: 0 1 auto;
  max-width: min(206px, calc(70vw - 54px));
}

.chat-attachment-name {
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-attachment-size {
  font-size: 10px;
  color: var(--dim);
  margin-top: 1px;
}

.chat-text-input {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  outline: none;
  resize: none;
  min-height: 16px;
  max-height: 96px;
  line-height: 1.4;
}

.chat-text-input::placeholder {
  transition: opacity 0.18s ease;
}

.chat-text-input:focus::placeholder {
  opacity: 0;
}

.chat-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
  position: relative;
}

.chat-send-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.chat-send-btn:active {
  transform: scale(0.95);
}

@keyframes rgb-border-flash {
  0% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

.chat-send-btn svg {
  width: 18px;
  height: 18px;
}

.thread-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--dim);
  gap: 12px;
}

.thread-empty-state svg {
  width: 48px;
  height: 48px;
  opacity: 0.3;
}

.thread-empty-state p {
  font-size: 14px;
  font-weight: 700;
}

/* New thread modal */
.thread-user-pick {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}

.thread-user-hint {
  font-size: 12px;
  color: var(--dim);
  font-weight: 700;
  line-height: 1.4;
  margin-top: 2px;
}

.thread-user-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: all 0.15s;
}

.thread-user-option:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
}

.thread-user-option.selected {
  border-color: var(--c7);
  background: rgba(67, 170, 139, 0.1);
}

.thread-user-option-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 900;
  color: var(--muted);
  overflow: hidden;
  flex-shrink: 0;
}

.thread-user-option-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thread-user-option-name {
  font-size: 13px;
  font-weight: 800;
}

.thread-user-option-sub {
  font-size: 11px;
  color: var(--dim);
  font-weight: 700;
  margin-top: 2px;
}

/* Image preview in threads */
.msg-img-preview {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-radius: 16px;
  max-width: 300px;
  animation: msg-enter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
  cursor: pointer;
  transition:
    background 0.2s,
    border-color 0.2s,
    box-shadow 0.2s,
    transform 0.2s;
  overflow: hidden;
}

.msg-img-preview.sent {
  align-self: flex-end;
  background: rgba(255, 255, 255, 0.03);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-bottom-right-radius: 4px;
}

.msg-img-preview.sent:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.15);
}

.msg-img-preview.received {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.03);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-bottom-left-radius: 4px;
}

.msg-img-preview.received:hover {
  background: rgba(255, 255, 255, 0.1);
}

.msg-img-preview.personal {
  max-width: 100%;
  border-radius: 16px;
}

.msg-img-preview .msg-time {
  padding: 0 12px 8px;
  justify-content: space-between;
  width: 100%;
}

.msg-img-preview.sent .msg-time {
  justify-content: space-between;
}

.msg-img-preview.show-time {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.15);
}

.msg-img-preview.ctx-selected {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.35) !important;
  box-shadow:
    0 0 16px rgba(255, 255, 255, 0.08),
    0 8px 24px rgba(0, 0, 0, 0.3);
}

.msg-img-preview > img.thread-preview-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 60vh;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.msg-img-preview > img.thread-preview-img.loaded {
  opacity: 1;
}

.msg-img-loading {
  width: 160px;
  aspect-ratio: 1 / 1;
  background: linear-gradient(
    110deg,
    rgba(255, 255, 255, 0.04) 30%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.04) 70%
  );
  background-size: 200% 100%;
  animation: img-shimmer 1.5s ease-in-out infinite;
  display: flex;
  align-items: center;
  justify-content: center;
}

.msg-img-loading svg {
  width: 28px;
  height: 28px;
  color: #65676a;
}

@keyframes img-shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* Thread image lightbox overlay */
.zen-lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  opacity: 0;
  transition: opacity 0.25s ease;
  cursor: default;
  padding: 24px;
  overflow: hidden;
  scrollbar-width: none;
  overscroll-behavior: none;
}

.zen-lightbox-overlay::-webkit-scrollbar {
  display: none;
}

.zen-lightbox-overlay.is-touch-lightbox {
  padding: 20px;
}

.zen-lightbox-overlay.visible {
  opacity: 1;
}

.zen-lightbox-img {
  max-width: min(90vw, 1200px);
  max-height: 85vh;
  border-radius: 12px;
  box-shadow:
    0 16px 64px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.08);
  object-fit: contain;
  cursor: default;
  transform: scale(0.92);
  opacity: 0;
  transition:
    transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.25s ease;
  touch-action: none;
  will-change: transform;
}

.zen-lightbox-overlay.is-zoomed .zen-lightbox-img {
  cursor: default;
}

.zen-lightbox-overlay.is-panning,
.zen-lightbox-overlay.is-panning .zen-lightbox-img {
  cursor: default;
}

.zen-lightbox-overlay.is-panning .zen-lightbox-img {
  transition: none;
}

.zen-lightbox-overlay.visible .zen-lightbox-img {
  transform: scale(1);
  opacity: 1;
}

.zen-lightbox-info {
  position: absolute;
  left: var(--info-left, 50%);
  top: var(--info-top, 50%);
  background: rgba(255, 255, 255, 0.01);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 16px;
  text-align: left;
  width: max-content;
  max-width: var(--info-max-width, min(80vw, 320px));
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px) scale(0.92);
  transform-origin: top left;
  pointer-events: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  z-index: 2;
}

.zen-lightbox-overlay.is-touch-lightbox .zen-lightbox-info {
  display: none;
  width: max-content;
  max-width: min(82vw, 360px);
  margin-top: 0;
  background: rgba(255, 255, 255, 0.01);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transform: translateX(-50%) translateY(10px) scale(0.92);
  transform-origin: top center;
}

.zen-lightbox-overlay.info-under-image .zen-lightbox-info {
  width: max-content;
  max-width: var(--info-max-width, min(82vw, 360px));
  transform: translateX(-50%) translateY(10px) scale(0.92);
  transform-origin: top center;
}

.zen-lightbox-overlay.info-over-image .zen-lightbox-info {
  width: max-content;
  max-width: var(--info-max-width, min(82vw, 360px));
  background: rgba(8, 10, 14, 0.34);
  border: 0;
  backdrop-filter: blur(14px) saturate(125%);
  -webkit-backdrop-filter: blur(14px) saturate(125%);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
  transform: translate(-100%, -100%) translateY(10px) scale(0.92);
  transform-origin: bottom right;
}

.zen-lightbox-overlay.info-over-image.info-over-image-center
  .zen-lightbox-info {
  transform: translate(-50%, -100%) translateY(10px) scale(0.92);
  transform-origin: bottom center;
}

.zen-lightbox-overlay.info-under-image.show-info .zen-lightbox-info {
  transform: translateX(-50%) translateY(0) scale(1);
  animation: lightbox-info-pop-mobile 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.zen-lightbox-overlay.info-under-image.hide-info .zen-lightbox-info {
  transform: translateX(-50%) translateY(10px) scale(0.92);
  animation: lightbox-info-hide-mobile 0.18s ease forwards;
}

.zen-lightbox-overlay.is-touch-lightbox.show-info .zen-lightbox-info {
  transform: translateX(-50%) translateY(0) scale(1);
  animation: lightbox-info-pop-mobile 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.zen-lightbox-overlay.is-touch-lightbox.hide-info .zen-lightbox-info {
  transform: translateX(-50%) translateY(10px) scale(0.92);
  animation: lightbox-info-hide-mobile 0.18s ease forwards;
}

.zen-lightbox-overlay.is-touch-lightbox.show-info .zen-lightbox-info,
.zen-lightbox-overlay.is-touch-lightbox.hide-info .zen-lightbox-info {
  display: block;
}

.zen-lightbox-overlay.info-over-image.show-info .zen-lightbox-info {
  transform: translate(-100%, -100%) translateY(0) scale(1);
  animation: lightbox-info-pop-over 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.zen-lightbox-overlay.info-over-image.hide-info .zen-lightbox-info {
  transform: translate(-100%, -100%) translateY(10px) scale(0.92);
  animation: lightbox-info-hide-over 0.18s ease forwards;
}

.zen-lightbox-overlay.info-over-image.info-over-image-center.show-info
  .zen-lightbox-info {
  transform: translate(-50%, -100%) translateY(0) scale(1);
  animation: lightbox-info-pop-over-center 0.24s
    cubic-bezier(0.34, 1.56, 0.64, 1);
}

.zen-lightbox-overlay.info-over-image.info-over-image-center.hide-info
  .zen-lightbox-info {
  transform: translate(-50%, -100%) translateY(10px) scale(0.92);
  animation: lightbox-info-hide-over-center 0.18s ease forwards;
}

.zen-lightbox-overlay.show-info .zen-lightbox-info {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  animation: lightbox-info-pop 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.zen-lightbox-overlay.hide-info .zen-lightbox-info {
  opacity: 0;
  transform: translateY(10px) scale(0.92);
  pointer-events: none;
  animation: lightbox-info-hide 0.18s ease forwards;
}

.zen-lightbox-overlay.is-zoomed .zen-lightbox-info {
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.92);
  pointer-events: none;
  animation: none;
}

@keyframes lightbox-info-pop {
  0% {
    opacity: 0;
    transform: translateY(12px) scale(0.88);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes lightbox-info-hide {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(10px) scale(0.92);
  }
}

@keyframes lightbox-info-pop-mobile {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(12px) scale(0.88);
  }

  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

@keyframes lightbox-info-hide-mobile {
  0% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(10px) scale(0.92);
  }
}

@keyframes lightbox-info-pop-over {
  0% {
    opacity: 0;
    transform: translate(-100%, -100%) translateY(12px) scale(0.88);
  }

  100% {
    opacity: 1;
    transform: translate(-100%, -100%) translateY(0) scale(1);
  }
}

@keyframes lightbox-info-hide-over {
  0% {
    opacity: 1;
    transform: translate(-100%, -100%) translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-100%, -100%) translateY(10px) scale(0.92);
  }
}

@keyframes lightbox-info-pop-over-center {
  0% {
    opacity: 0;
    transform: translate(-50%, -100%) translateY(12px) scale(0.88);
  }

  100% {
    opacity: 1;
    transform: translate(-50%, -100%) translateY(0) scale(1);
  }
}

@keyframes lightbox-info-hide-over-center {
  0% {
    opacity: 1;
    transform: translate(-50%, -100%) translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -100%) translateY(10px) scale(0.92);
  }
}

.zen-lightbox-info-name {
  font-size: 12px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.zen-lightbox-info-details {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.35);
}

.zen-lightbox-info-details span + span::before {
  content: "·";
  margin-right: 6px;
}

/* Grouped border radius adjustments for image previews */
.msg-row.received.msg-group + .msg-row.received > .msg-img-preview {
  border-top-left-radius: 4px;
}

.msg-row.sent.msg-group + .msg-row.sent > .msg-img-preview {
  border-top-right-radius: 4px;
}

.msg-row.personal.msg-group + .msg-row.personal .msg-bubble,
.msg-row.personal.msg-group + .msg-row.personal .msg-file-card,
.msg-row.personal.msg-group + .msg-row.personal .msg-img-preview {
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}

.msg-row .msg-stack > .msg-bubble,
.msg-row .msg-stack > .msg-file-card,
.msg-row .msg-stack > .msg-img-preview {
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  margin-top: 4px;
}

/* Deleted messages */
.msg-bubble.msg-deleted,
.msg-file-card.msg-deleted,
.msg-img-preview.msg-deleted {
  background: rgba(255, 60, 60, 0.06) !important;
  border-color: rgba(255, 60, 60, 0.18) !important;
  color: #ff6b6b;
  font-style: italic;
  opacity: 0.75;
}

.msg-bubble.msg-deleted .msg-time,
.msg-file-card.msg-deleted .msg-time,
.msg-img-preview.msg-deleted .msg-time {
  color: rgba(255, 107, 107, 0.5);
}

/* Highlight My Messages Accessibility Setting */
body.zen-highlight-my-messages .chat-messages {
  overflow-x: hidden;
}

body.zen-highlight-my-messages .msg-row.sent:not(.personal) {
  position: relative;
  z-index: 0;
}

body.zen-highlight-my-messages .msg-row.sent:not(.personal)::after {
  content: "";
  position: absolute;
  top: 0;
  right: -20px;
  bottom: 0;
  width: 20px;
  max-width: 80vw;
  background: linear-gradient(
    to left,
    rgba(244, 67, 54, 0.15) 0%,
    transparent 100%
  );
  pointer-events: none;
  z-index: -1;
}

body.zen-highlight-my-messages .msg-row.sent:not(.personal)::before {
  content: "";
  position: absolute;
  top: 0;
  right: -20px;
  bottom: 0;
  width: 20px;
  border-right: 2px solid #f44336;
  pointer-events: none;
  z-index: 0;
}

body.zen-highlight-my-messages
  .msg-row.sent.msg-group
  + .msg-row.sent:not(.personal)::before,
body.zen-highlight-my-messages
  .msg-row.sent.msg-group
  + .msg-row.sent:not(.personal)::after {
  top: -3px;
}

body.zen-highlight-my-messages
  .msg-row.sent.msg-group[data-type="file"]
  + .msg-row.sent[data-type="file"]:has(.msg-img-preview)::before,
body.zen-highlight-my-messages
  .msg-row.sent.msg-group[data-type="file"]
  + .msg-row.sent[data-type="file"]:has(.msg-img-preview)::after,
body.zen-highlight-my-messages
  .msg-row.sent.msg-group[data-type="file"]
  + .msg-row.sent[data-type="file"]:has(.msg-file-card)::before,
body.zen-highlight-my-messages
  .msg-row.sent.msg-group[data-type="file"]
  + .msg-row.sent[data-type="file"]:has(.msg-file-card)::after {
  top: -5px;
}
