:root {
  --bg: #0b141a;
  --header: #202c33;
  --panel: #111b21;
  --panel-2: #1c272e;
  --bubble: #005c4b;
  --bubble-alt: #143c36;
  --text: #e9edef;
  --muted: #8696a0;
  --accent: #00a884;
  --line: rgba(255,255,255,0.08);
  --safe-bottom: max(10px, env(safe-area-inset-bottom));
  --app-height: calc(var(--app-vh, 1vh) * 100);
  --app-width: calc(var(--app-vw, 1vw) * 100);
}

* { box-sizing: border-box; }
html, body { height: 100%; width: 100%; max-width: 100%; overflow-x: hidden; overscroll-behavior-x: none; }
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, system-ui, sans-serif;
  background: #081016;
  color: var(--text);
  overflow-x: hidden;
  overflow-y: auto;
}
button, input, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { -webkit-tap-highlight-color: transparent; }
img, video { max-width: 100%; }

.app-shell {
  width: 100%;
  max-width: 100%;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  height: var(--app-height);
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  min-height: var(--app-height);
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  background: var(--bg);
  overflow: hidden;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #111b21;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.compact-head { padding: 10px 12px; }
.sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.sidebar-head h1 { margin: 0; font-size: 0.98rem; }
.subtle { margin: 2px 0 0; color: var(--muted); font-size: 0.74rem; }
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  background: #202c33;
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.nav-btn { display: none; }

.new-chat-form {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.new-chat-form.hidden { display: none; }
.new-chat-form input,
.new-chat-form button {
  border: 0;
  border-radius: 10px;
  padding: 9px 11px;
}
.new-chat-form input {
  flex: 1;
  background: #202c33;
  color: var(--text);
  min-width: 0;
}
.new-chat-form button {
  background: var(--accent);
  color: #04211b;
  font-weight: 700;
}
.chat-list {
  padding: 4px 0;
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.chat-row {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  text-align: left;
  padding: 8px 10px;
  cursor: pointer;
}
.chat-row:hover { background: rgba(255,255,255,0.05); }
.chat-row.active { background: rgba(0,168,132,0.16); }
.chat-avatar, .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #2d4652, #172127);
  font-weight: 700;
  flex: 0 0 auto;
}
.chat-row-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-row-top, .chat-row-bottom { display: flex; align-items: center; gap: 6px; min-width: 0; }
.chat-row-top strong, .chat-row-top small, .chat-row-bottom small {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-row-top strong { font-size: 0.84rem; flex: 1; }
.chat-row-top small, .chat-row-bottom small { color: var(--muted); font-size: 0.69rem; }
.chat-row-bottom small { flex: 1; }
.chat-count {
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  padding: 0 5px;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  font-size: 0.66rem;
}
.chat-row-delete {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.chat-row-delete:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.chat-row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-row.dragging { opacity: 0.55; }
.chat-row.drop-before { box-shadow: inset 0 2px 0 rgba(0,168,132,0.9); }
.chat-row.drop-after { box-shadow: inset 0 -2px 0 rgba(0,168,132,0.9); }
.chat-drop-overlay {
  position: absolute;
  inset: 110px 12px 92px;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 6;
}
.chat-drop-overlay.visible { pointer-events: none; }
.chat-drop-box {
  width: min(100%, 420px);
  padding: 22px;
  border-radius: 18px;
  border: 2px dashed rgba(0,168,132,0.9);
  background: rgba(8,16,22,0.92);
  text-align: center;
  box-shadow: 0 16px 40px rgba(0,0,0,0.28);
}
.sync-indicator.syncing { color: #ffd166; }
.sync-indicator.synced { color: #7ef0c8; }
.sync-indicator.error { color: #ff8b8b; }

.chat-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
}
.chat-header {
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(32,44,51,0.98);
  border-bottom: 1px solid var(--line);
}
.chat-contact { display: flex; align-items: center; gap: 8px; min-width: 0; }
.contact-copy { min-width: 0; }
.chat-contact h2 {
  margin: 0;
  font-size: 0.96rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.top-search input {
  width: min(220px, 34vw);
  border: 0;
  outline: none;
  background: #111b21;
  color: var(--text);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 0.85rem;
}
.filter-row {
  display: flex;
  gap: 6px;
  padding: 6px 8px;
  overflow-x: auto;
  background: rgba(17,27,33,0.96);
  border-bottom: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
}
.filter-pill {
  white-space: nowrap;
  border: 0;
  background: #182229;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 9px;
  cursor: pointer;
  font-size: 0.73rem;
}
.filter-pill span {
  color: var(--text);
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 1px 5px;
  margin-left: 3px;
}
.filter-pill.active { background: rgba(0,168,132,0.2); color: #d6fff6; }

.message-list {
  overflow-y: auto;
  min-height: 0;
  padding: 10px 10px 88px;
  background: linear-gradient(rgba(11,20,26,0.78), rgba(11,20,26,0.78)), radial-gradient(rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: auto, 18px 18px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.message {
  display: flex;
  justify-content: flex-end;
  margin: 1px 0 8px;
  padding-inline: max(0px, env(safe-area-inset-left)) max(0px, env(safe-area-inset-right));
}
.message-bubble {
  position: relative;
  width: fit-content;
  max-width: min(72%, 560px);
  min-width: 90px;
  background: var(--bubble);
  border-radius: 9px;
  border-top-right-radius: 2px;
  padding: 6px 40px 6px 8px;
  overflow: visible;
}
.message-bubble::after {
  content: '';
  position: absolute;
  top: 0;
  right: -6px;
  border-left: 6px solid var(--bubble);
  border-bottom: 6px solid transparent;
}
.type-file, .type-link, .type-video, .type-audio, .type-image { background: var(--bubble-alt); }
.type-file::after, .type-link::after, .type-video::after, .type-audio::after, .type-image::after { border-left-color: var(--bubble-alt); }
.message-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  opacity: 0;
  transition: opacity .12s ease;
  z-index: 2;
}
.message:hover .message-actions,
.message-bubble:focus-within .message-actions,
.message:active .message-actions { opacity: 1; }
.mini-icon-button {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.18);
  color: rgba(255,255,255,0.88);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 0.76rem;
}
.message-title { font-size: 0.78rem; font-weight: 700; margin: 0 0 3px; }
.message-text { white-space: pre-wrap; word-break: break-word; line-height: 1.32; font-size: 0.89rem; }
.selectable { user-select: text; -webkit-user-select: text; }
.link-card, .file-card {
  margin-top: 6px;
  display: block;
  background: rgba(0,0,0,0.16);
  border-radius: 8px;
  padding: 8px 9px;
}
.link-card { color: #9ad9ff; overflow-wrap: anywhere; font-size: 0.82rem; }
.file-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.file-main { min-width: 0; }
.file-main strong, .file-main small {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-main strong { font-size: 0.81rem; }
.file-main small { color: var(--muted); margin-top: 2px; font-size: 0.7rem; }
.file-open { font-size: 0.74rem; }
.chat-image, .chat-media {
  width: 100%;
  max-height: min(56vh, 420px);
  margin-top: 6px;
  border-radius: 8px;
  display: block;
  background: #000;
  object-fit: contain;
}
.compact-player { height: 36px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.tag {
  border-radius: 999px;
  background: rgba(255,255,255,0.09);
  color: #d4f8f0;
  padding: 2px 5px;
  font-size: 0.66rem;
}
.message-meta-bottom {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
  color: rgba(233,237,239,0.72);
  font-size: 0.68rem;
}
.copy-feedback { color: #c9fff3; }
.empty-chat { display: grid; place-items: center; min-height: 44vh; }
.empty-bubble {
  max-width: 300px;
  text-align: center;
  background: rgba(17,27,33,0.92);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
.empty-bubble p { margin: 4px 0 0; color: var(--muted); font-size: 0.84rem; }

.composer-shell {
  position: sticky;
  bottom: 0;
  z-index: 5;
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: linear-gradient(180deg, transparent, rgba(11,20,26,0.66) 18%, rgba(17,27,33,0.98));
}
.composer-bar { display: flex; align-items: flex-end; gap: 6px; }
.circle-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
}
#attachTrigger, .record-button { background: #202c33; color: var(--text); }
.send-button { background: var(--accent); color: #06231d; font-weight: 700; }
.input-stack {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: #202c33;
  border-radius: 16px;
  padding: 8px 10px 7px;
}
#contentInput {
  width: 100%;
  min-height: 24px;
  max-height: 140px;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  line-height: 1.35;
  padding: 0;
  font-size: 0.92rem;
}
.hidden-input {
  display: none;
  width: 100%;
  border: 0;
  outline: none;
  border-radius: 10px;
  padding: 8px 10px;
  background: #152127;
  color: var(--text);
}
.hidden-input.visible { display: block; }
.quick-modes { display: flex; flex-wrap: wrap; gap: 4px; }
.mode-button {
  border: 0;
  background: #152127;
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.69rem;
  cursor: pointer;
}
.mode-button.active { background: rgba(0,168,132,0.18); color: #d6fff6; }
.file-name {
  color: var(--muted);
  font-size: 0.7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.recording-status, .recording-preview, .form-error { margin-left: 46px; }
.recording-status {
  display: none;
  align-items: center;
  gap: 8px;
  color: #ffd8d8;
  font-size: 0.78rem;
  margin-top: 5px;
}
.recording-status.visible { display: flex; }
.recording-dot { width: 8px; height: 8px; border-radius: 50%; background: #ff6b6b; }
.recording-status.is-recording .recording-dot { animation: pulse 1s infinite; }
.recording-preview.visible { margin-top: 5px; }
.form-error { min-height: 18px; color: #ff9f9f; font-size: 0.78rem; margin-top: 4px; }
.install-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  padding: 0.42rem 0.72rem;
  background: #25d366;
  color: #062b14;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.78rem;
}
.install-button[hidden], .mobile-overlay[hidden] { display: none !important; }
.mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.48);
  z-index: 15;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: 100%;
    height: var(--app-height);
    min-height: var(--app-height);
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, 320px);
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    z-index: 20;
    box-shadow: 18px 0 40px rgba(0, 0, 0, 0.32);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .nav-btn { display: grid; }
  .chat-header {
    gap: 8px;
    padding: 8px;
    width: 100%;
    min-width: 0;
  }
  .chat-contact { gap: 7px; }
  .chat-contact h2 { font-size: 0.92rem; }
  .subtle { font-size: 0.7rem; }
  .header-actions { flex: 1; justify-content: flex-end; }
  .top-search { min-width: 0; }
  .top-search input {
    width: min(42vw, 150px);
    padding: 8px 10px;
  }
  .install-button {
    padding: 0.38rem 0.6rem;
    font-size: 0.72rem;
  }
  .message-list {
    padding: 8px 8px 94px;
  }
  .message-bubble {
    max-width: calc(100% - 2px);
    width: fit-content;
  }
  .chat-image, .chat-media { max-height: 44vh; }
  .composer-shell {
    padding: 6px 6px calc(8px + var(--safe-bottom));
  }
  .composer-bar { gap: 5px; }
  .circle-button {
    width: 38px;
    height: 38px;
  }
  .input-stack {
    border-radius: 18px;
    padding: 8px 9px 7px;
  }
  .quick-modes {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 1px;
  }
  .quick-modes::-webkit-scrollbar { display: none; }
  .mode-button { flex: 0 0 auto; }
  .recording-status, .recording-preview, .form-error { margin-left: 8px; }
}

@media (max-width: 560px) {
  .compact-head { padding: 8px; }
  .avatar, .chat-avatar {
    width: 34px;
    height: 34px;
  }
  .icon-btn {
    width: 32px;
    height: 32px;
  }
  .chat-header {
    align-items: center;
    min-width: 0;
  }
  .chat-contact {
    flex: 1;
    min-width: 0;
  }
  .contact-copy {
    min-width: 0;
  }
  .header-actions {
    flex: 0 1 42%;
    max-width: 42%;
    min-width: 0;
  }
  .top-search input {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .filter-row {
    gap: 5px;
    padding: 6px;
  }
  .filter-pill {
    padding: 6px 8px;
    font-size: 0.71rem;
  }
  .message-list {
    padding: 8px 6px calc(104px + var(--safe-bottom));
  }
  .message {
    margin-bottom: 10px;
  }
  .message-bubble {
    max-width: calc(100% - 2px);
    padding: 8px 82px 8px 10px;
    border-radius: 16px;
  }
  .message-actions {
    opacity: 1;
    top: 8px;
    right: 8px;
    gap: 5px;
  }

  .mini-icon-button {
    width: 24px;
    height: 24px;
    font-size: 0.82rem;
  }
  .message-meta-bottom {
    padding-right: 2px;
  }
  .file-card {
    gap: 6px;
  }
  .message-title { font-size: 0.76rem; }
  .message-text { font-size: 0.86rem; }
  .link-card, .file-card { padding: 8px; }
  .composer-shell {
    padding-inline: 4px;
  }
  .composer-bar {
    align-items: stretch;
  }
  .circle-button {
    align-self: flex-end;
  }
  .input-stack {
    gap: 6px;
    padding: 8px;
  }
  #contentInput { font-size: 16px; }
  .hidden-input { font-size: 16px; }
  .mode-button { font-size: 0.68rem; }
}


.share-sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0,0,0,0.42);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}
.share-sheet[hidden] { display: none !important; }
.share-sheet-card {
  width: min(100%, 520px);
  background: #111b21;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.share-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.share-preview {
  background: #152127;
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
}
.share-preview-title { font-weight: 700; margin-bottom: 4px; word-break: break-word; }
.share-preview-text, .share-preview-link { color: var(--muted); font-size: 0.88rem; word-break: break-word; }
.share-preview-file { display: flex; flex-direction: column; gap: 2px; }
.share-preview-file small { color: var(--muted); }
.share-field { display: flex; flex-direction: column; gap: 6px; }
.share-field span { font-size: 0.82rem; color: var(--muted); }
.share-field select {
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: #202c33;
  color: var(--text);
  padding: 10px 12px;
}
.share-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}
.share-cancel, .share-save {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
}
.share-cancel { background: #202c33; color: var(--text); }
.share-save { background: var(--accent); color: #06231d; }
.share-save:disabled { opacity: .65; }
.share-error { margin: 8px 0 0; min-height: 18px; }

@media (max-width: 860px) {
  .share-sheet { padding: 8px; }
  .share-sheet-card { width: 100%; border-radius: 18px 18px 0 0; padding-bottom: calc(14px + var(--safe-bottom)); }
  .share-buttons { flex-direction: column-reverse; }
  .share-cancel, .share-save { width: 100%; }
}

.share-preview-files { display: flex; flex-direction: column; gap: 8px; max-height: min(40vh, 240px); overflow: auto; }
@media (max-width: 560px) {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { width: 100%; min-height: var(--app-height); overflow-y: auto; }
  .chat-header, .filter-row, .composer-shell, .message-list { max-width: 100%; }
  .share-preview { max-height: min(48vh, 320px); overflow: auto; }
}

.message, .message-bubble, .chat-pane, .composer-shell, .chat-header, .filter-row { min-width: 0; }


.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top, rgba(37, 211, 102, 0.18), transparent 30%), #0b141a;
}

.login-shell {
  width: min(100%, 460px);
  padding: 24px;
}

.login-card {
  background: rgba(17, 27, 33, 0.96);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.35);
}

.login-copy h1 {
  margin: 8px 0 12px;
}

.login-copy p {
  margin: 0 0 22px;
  color: var(--muted);
}

.login-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(37, 211, 102, 0.12);
  color: #9af0b7;
  font-size: 0.85rem;
  font-weight: 700;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-field input {
  width: 100%;
}

.login-submit,
.logout-button {
  min-width: 112px;
}


.viewer-open { overflow: hidden; }

.file-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.mini-action-button {
  border: 0;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.12);
  color: var(--text);
  cursor: pointer;
  font-size: 0.72rem;
}

.mini-action-button.secondary { background: rgba(255,255,255,0.08); }
.mini-action-button.danger { background: rgba(255, 80, 80, 0.16); }
.mini-action-button:hover { background: rgba(255,255,255,0.18); }
.mini-action-button.danger:hover { background: rgba(255, 80, 80, 0.24); }

.file-card {
  width: 100%;
  border: 0;
  cursor: pointer;
  text-align: left;
}

.chat-image.view-file-button { cursor: zoom-in; }

.file-viewer-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.file-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.file-viewer-sheet {
  position: relative;
  z-index: 1;
  width: min(960px, calc(100vw - 24px));
  height: min(88vh, 840px);
  margin: 6vh auto;
  background: #0f171c;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  box-shadow: 0 30px 80px rgba(0,0,0,0.45);
}

.file-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(17,27,33,0.96);
}

.file-viewer-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-viewer-meta strong,
.file-viewer-meta small {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-viewer-meta small { color: var(--muted); }
.file-viewer-actions { display: flex; gap: 8px; }
.viewer-action { background: #1d2a31; }

.file-viewer-content {
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  background: #091116;
}

.file-viewer-image,
.file-viewer-media,
.file-viewer-frame {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 12px;
  background: #0a1014;
}

.file-viewer-image {
  object-fit: contain;
}

.file-viewer-audio {
  width: min(560px, 100%);
}

@media (max-width: 860px) {
  .file-viewer-sheet {
    width: calc(100vw - 12px);
    height: calc(100dvh - 18px);
    margin: 9px auto;
    border-radius: 16px;
  }

  .file-action-row {
    gap: 5px;
  }

  .mini-action-button {
    padding: 6px 9px;
    font-size: 0.69rem;
  }
}


.sync-indicator { display:block; margin-top:2px; opacity:.75; }
.chat-row { cursor:pointer; }
.chat-row.dragging { opacity:.45; }
.chat-row.drop-before { border-top:2px solid var(--accent, #6b8afd); }
.chat-row.drop-after { border-bottom:2px solid var(--accent, #6b8afd); }
.chat-row-rename { border:none; background:transparent; cursor:pointer; opacity:.72; font-size:14px; }
.chat-row-rename:hover { opacity:1; }
.chat-drop-overlay { position:absolute; inset:74px 0 120px 0; display:flex; align-items:center; justify-content:center; pointer-events:none; z-index:15; }
.chat-drop-overlay.visible { pointer-events:auto; }
.chat-drop-box { background:rgba(15,23,42,.88); color:#fff; border:2px dashed rgba(255,255,255,.35); border-radius:18px; padding:24px 28px; text-align:center; max-width:320px; box-shadow:0 20px 50px rgba(0,0,0,.25); }
.chat-pane { position:relative; }
.sync-indicator.syncing::before { content:'⟳ '; }
.sync-indicator.synced::before { content:'✓ '; }
.sync-indicator.error::before { content:'⚠ '; }


.chat-drop-overlay[hidden] { display: none !important; }
.chat-drop-overlay {
  position: absolute;
  inset: 74px 0 120px 0;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 15;
}
.chat-drop-overlay.visible { display: flex; }
.chat-drop-box {
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  border: 2px dashed rgba(255,255,255,0.35);
  border-radius: 18px;
  padding: 24px 28px;
  text-align: center;
  max-width: min(320px, calc(100vw - 36px));
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}

@media (pointer: coarse), (max-width: 860px) {
  .chat-drop-overlay,
  .chat-drop-overlay.visible {
    display: none !important;
  }
}


/* mobile header + swipe sidebar fixes */
.chat-header {
  position: relative;
}

@media (max-width: 860px) {
  .chat-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .chat-contact {
    min-width: 0;
    overflow: hidden;
  }

  .contact-copy {
    min-width: 0;
    overflow: hidden;
  }

  .chat-contact h2,
  #activeChatPreview,
  .sync-indicator {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 560px) {
  .chat-header {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    padding: 6px 8px;
  }

  .chat-contact {
    gap: 6px;
    min-width: 0;
  }

  .contact-copy {
    display: flex;
    flex-direction: column;
    gap: 1px;
  }

  .chat-contact h2 {
    font-size: 0.9rem;
    line-height: 1.15;
    white-space: nowrap;
  }

  #activeChatPreview {
    display: none;
  }

  .sync-indicator {
    margin-top: 0;
    font-size: 0.72rem;
    white-space: nowrap;
  }

  .header-actions {
    flex: 0 0 auto;
    max-width: none;
    gap: 6px;
  }

  .top-search {
    display: none;
  }

  .logout-button {
    padding: 0.38rem 0.85rem;
    min-width: 86px;
    white-space: nowrap;
  }
}

.mobile-swipe-hint {
  position: fixed;
  inset: 0 auto 0 0;
  width: 18px;
  z-index: 9;
  background: transparent;
}

@media (min-width: 861px) {
  .mobile-swipe-hint {
    display: none;
  }
}


.upload-progress {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(18, 32, 39, 0.92);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 10px 24px rgba(0,0,0,0.18);
}

.upload-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.88rem;
  margin-bottom: 8px;
}

.upload-progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,0.08);
}

.upload-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1bd7a6, #2ad870);
  transition: width 120ms ease;
}

.file-viewer-loading,
.file-viewer-error {
  width: min(640px, 100%);
  padding: 18px;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  text-align: center;
}

.file-viewer-error p {
  margin: 8px 0 14px;
  color: var(--muted);
}

.file-viewer-text {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 16px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 12px;
  background: #0a1014;
  color: #ecf1f3;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92rem;
  line-height: 1.45;
}

@media (max-width: 560px) {
  .upload-progress {
    margin-bottom: 8px;
    padding: 9px 10px;
  }
}
