@import url('./styles.base.css');

body {
  overflow: hidden;
}

body.loading {
  cursor: progress;
}

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

.compact-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.auth-tabs {
  display: flex;
  gap: 8px;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.install-button {
  width: 100%;
  justify-content: center;
  gap: 8px;
}

.folder-chip {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.folder-chip:hover {
  background: rgba(255, 255, 255, 0.08);
}

.modal-card {
  width: min(760px, calc(100vw - 32px));
  max-height: min(88vh, 960px);
  overflow: auto;
}

.modal-head,
.call-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.modal-grid,
.discover-stack,
.call-stack,
.story-stack {
  display: grid;
  gap: 14px;
}

.modal-actions,
.inline-actions-wrap,
.call-actions,
.story-actions,
.profile-actions,
.member-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.inline-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-form input,
.inline-form textarea,
.stack-form textarea,
.stack-form input,
.settings-card input,
.settings-card textarea,
.settings-card select,
.story-composer textarea,
.story-composer input,
.discover-search input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: inherit;
}

.inline-form textarea,
.stack-form textarea,
.story-composer textarea {
  min-height: 120px;
  resize: vertical;
}

.field-hint,
.muted-copy {
  color: var(--muted);
  font-size: 0.85rem;
}

.avatar {
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  background: linear-gradient(135deg, rgba(52, 164, 255, 0.92), rgba(143, 92, 255, 0.92));
  color: white;
}

.avatar.large {
  width: 72px;
  height: 72px;
  border-radius: 24px;
  font-size: 1.3rem;
}

.avatar-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

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

.avatar-meta p,
.avatar-meta strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-view-empty {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.chat-header {
  justify-content: space-between;
}

.chat-header-main,
.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-header-actions {
  flex-wrap: wrap;
}

.chat-heading {
  min-width: 0;
}

.chat-heading h3 {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-heading p {
  color: var(--muted);
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.story-placeholder,
.file-placeholder,
.video-placeholder {
  min-height: 180px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  padding: 18px;
  background: linear-gradient(135deg, rgba(52, 164, 255, 0.16), rgba(139, 92, 246, 0.12));
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  text-align: center;
}

.message-group {
  display: grid;
  gap: 8px;
}

.message-row {
  align-items: flex-end;
}

.message-bubble {
  min-width: 120px;
}

.message-bubble.deleted {
  opacity: 0.72;
  filter: saturate(0.7);
}

.message-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.message-action {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.message-row.outgoing .message-action {
  background: rgba(255, 255, 255, 0.16);
}

.message-media,
.message-audio {
  width: 100%;
  max-width: 360px;
  display: block;
  border-radius: 16px;
  margin-top: 10px;
}

.message-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-top: 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
}

.message-file strong,
.message-file span {
  display: block;
}

.message-file a,
.message-link {
  color: inherit;
  text-decoration: none;
}

.message-file:hover,
.story-pill:hover,
.member-line:hover,
.discover-chat-card:hover,
.result-card:hover {
  background: rgba(255, 255, 255, 0.1);
}

.message-status {
  opacity: 0.8;
}

.reply-banner {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

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

.search-input {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.search-input input {
  width: 100%;
}

.search-block {
  padding: 0 18px 12px;
}

.discover-content,
.calls-content,
.story-content,
.details-body {
  padding: 18px;
}

.discover-stack,
.call-stack {
  padding: 0 4px 18px;
}

.discover-section,
.result-card,
.member-line,
.story-card-lite,
.call-log-item,
.discover-chat-card {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
}

.discover-chat-card,
.member-line,
.result-card,
.story-card-lite {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.result-card .avatar-row,
.member-line .avatar-row,
.story-card-lite .avatar-row,
.discover-chat-card .avatar-row {
  min-width: 0;
  flex: 1;
}

.member-line .role-badge,
.call-chip,
.invite-code,
.info-chip,
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.78rem;
}

.invite-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.04em;
}

.details-panel {
  display: flex;
  flex-direction: column;
}

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

.details-empty {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.member-list,
.result-list,
.discover-list,
.story-list,
.call-log {
  display: grid;
  gap: 10px;
}

.story-preview-media,
.story-modal-media {
  width: 100%;
  border-radius: 18px;
  max-height: 420px;
  object-fit: cover;
}

.story-modal-card {
  display: grid;
  gap: 16px;
}

.story-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.call-modal {
  width: min(960px, calc(100vw - 32px));
  padding: 22px;
}

.call-video-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 14px;
  margin: 18px 0;
}

.call-video-grid video {
  width: 100%;
  min-height: 240px;
  border-radius: 22px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  object-fit: cover;
}

.call-video-grid #localVideo {
  min-height: 180px;
}

.call-actions {
  justify-content: flex-end;
}

.call-note {
  color: var(--muted);
  line-height: 1.5;
}

.call-accent {
  color: var(--accent);
}

.result-meta {
  color: var(--muted);
  font-size: 0.86rem;
}

.user-meta-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.84rem;
}

.primary-button,
.soft-button,
.close-btn,
.icon-only {
  transition: transform 0.2s ease, filter 0.2s ease, background 0.2s ease;
}

.primary-button:hover,
.soft-button:hover,
.close-btn:hover,
.icon-only:hover {
  filter: brightness(1.05);
}

.chat-list .chat-button {
  overflow: hidden;
}

.hidden-file-input {
  display: none;
}

.story-composer,
.profile-form,
.chat-create-form {
  display: grid;
  gap: 14px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

.call-banner,
.warning-banner,
.info-banner {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.typing-user {
  color: var(--text);
  font-weight: 600;
}

.chat-read-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.badge-positive {
  color: var(--success);
}

.badge-danger {
  color: var(--danger);
}

.badge-warning {
  color: var(--warning);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title h3,
.section-title h4 {
  margin: 0;
}

.panel-header {
  padding: 18px 18px 14px;
}

.modal-card .settings-card {
  margin-bottom: 14px;
}

.call-actions .primary-button,
.call-actions .soft-button,
.modal-actions .primary-button,
.modal-actions .soft-button {
  min-width: 132px;
}

.message-bubble.system {
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

.message-bubble.system .author-row {
  margin-bottom: 0;
}

.message-bubble.system .message-actions {
  display: none;
}

@media (max-width: 980px) {
  .call-video-grid {
    grid-template-columns: 1fr;
  }

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

  .modal-card,
  .call-modal,
  .story-modal,
  .settings-modal,
  .auth-card {
    width: min(100vw - 16px, 1000px);
  }

  .panel-header {
    padding: 16px 14px 12px;
  }

  .discover-content,
  .calls-content,
  .story-content {
    padding: 14px;
  }
}

/* Mobile-first polish for iPhone and narrow screens */
body {
  overscroll-behavior: none;
}

.chats-panel,
.chat-panel,
.alt-view,
.details-panel,
.mobile-nav {
  border-radius: 28px;
}

.chat-button,
.folder-chip,
.story-pill,
.mobile-tab,
.soft-button,
.primary-button,
.search-input,
.composer {
  -webkit-tap-highlight-color: transparent;
}

.chat-back-button {
  width: auto;
  height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  font-weight: 600;
}

.details-sheet .details-head {
  padding-top: 8px;
}

.details-head-mobile {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(11, 16, 32, 0.88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.details-body-mobile {
  max-height: min(76vh, 720px);
}

@media (max-width: 980px) {
  :root {
    --radius-xl: 26px;
  }

  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  body {
    background:
      radial-gradient(circle at top, rgba(52, 164, 255, 0.2), transparent 28%),
      linear-gradient(180deg, #08101d 0%, #09111f 100%);
  }

  .background-orb {
    display: none;
  }

  .app-shell {
    width: 100vw;
    height: 100dvh;
    margin: 0;
    gap: 0;
    padding: max(10px, env(safe-area-inset-top)) 0 calc(82px + env(safe-area-inset-bottom));
    background: transparent;
  }

  .chats-panel,
  .main-stack,
  .chat-panel,
  .alt-view {
    height: 100%;
    min-height: 0;
    border-radius: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .panel-header {
    padding: 14px 16px 12px;
    border-bottom-color: rgba(255, 255, 255, 0.06);
    background: rgba(8, 16, 29, 0.92);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }

  .chats-header,
  .chat-header {
    position: sticky;
    top: 0;
    z-index: 4;
  }

  .chats-header {
    padding-top: 8px;
  }

  .chats-header .eyebrow,
  .chat-header .eyebrow,
  .panel-header .eyebrow {
    font-size: 0.68rem;
    letter-spacing: 0.12em;
  }

  .panel-header h2,
  .chat-heading h3 {
    font-size: 1.2rem;
  }

  .header-actions-wrap {
    gap: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-left: 8px;
    padding-bottom: 2px;
  }

  .header-actions-wrap .icon-only,
  .chat-header-actions .icon-only,
  .composer-tools .icon-only {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    flex: 0 0 auto;
  }

  .search-block {
    padding: 10px 16px 8px;
    background: rgba(8, 16, 29, 0.92);
  }

  .search-input {
    min-height: 52px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
  }

  .stories-strip-wrapper {
    padding: 2px 12px 10px;
    background: rgba(8, 16, 29, 0.92);
  }

  .folder-row {
    padding: 0 12px 12px;
    gap: 8px;
    background: rgba(8, 16, 29, 0.92);
  }

  .folder-chip {
    min-height: 38px;
    padding: 0 14px;
    font-size: 0.82rem;
  }

  .chat-list-wrap,
  .message-list,
  .discover-content,
  .calls-content {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  .chat-list-wrap {
    padding: 8px 12px 24px;
  }

  .chat-list {
    gap: 10px;
  }

  .chat-item.active .chat-button,
  .chat-button {
    border-radius: 24px;
  }

  .chat-button {
    padding: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
  }

  .chat-item.active .chat-button {
    background: linear-gradient(135deg, rgba(52, 164, 255, 0.18), rgba(139, 92, 246, 0.12));
    border-color: rgba(82, 168, 255, 0.28);
  }

  .avatar-wrap .avatar {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    font-size: 1rem;
  }

  .chat-title,
  .chat-preview,
  .chat-time {
    font-size: 0.92rem;
  }

  .chat-preview {
    max-width: 100%;
  }

  .chat-view-empty,
  .empty-state {
    min-height: 40vh;
    padding: 24px 20px;
  }

  .main-stack {
    background: transparent;
  }

  .chat-panel,
  .alt-view {
    display: none;
  }

  .chat-panel.active-view,
  .alt-view.active-view {
    display: flex;
  }

  .chat-header {
    padding: 12px 12px 10px;
  }

  .chat-header-main {
    gap: 10px;
    min-width: 0;
  }

  .chat-header-main .avatar.large {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    font-size: 0.95rem;
  }

  .chat-heading p {
    font-size: 0.8rem;
  }

  .pinned-strip,
  .reply-banner {
    margin: 10px 12px 0;
    border-radius: 18px;
  }

  .message-list {
    gap: 14px;
    padding: 14px 12px 16px;
    background:
      radial-gradient(circle at top, rgba(52, 164, 255, 0.1), transparent 25%),
      linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 20%);
  }

  .message-row {
    gap: 8px;
  }

  .message-bubble {
    max-width: 92%;
    border-radius: 20px;
    padding: 11px 13px;
  }

  .message-actions {
    gap: 4px;
  }

  .message-action {
    padding: 5px 9px;
  }

  .composer-wrap {
    position: sticky;
    bottom: 0;
    z-index: 4;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: rgba(8, 16, 29, 0.96);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }

  .composer-tools {
    align-self: stretch;
    gap: 8px;
  }

  .composer {
    min-height: 54px;
    padding: 8px 8px 8px 12px;
    gap: 8px;
    border-radius: 24px;
  }

  .composer textarea {
    min-height: 24px;
    max-height: 110px;
    font-size: 16px;
  }

  .composer .primary-button {
    min-width: 104px;
    min-height: 40px;
    padding: 0 16px;
  }

  .discover-content,
  .calls-content {
    padding: 12px 12px 28px;
  }

  .discover-section,
  .settings-card,
  .call-log-item,
  .discover-chat-card,
  .result-card,
  .story-card-lite,
  .detail-card,
  .member-line {
    border-radius: 22px;
  }

  .details-panel {
    display: none !important;
  }

  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 15;
    padding: 8px;
    border-radius: 24px;
    background: rgba(11, 16, 32, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  .mobile-tab {
    min-width: 0;
    padding: 10px 6px;
    border-radius: 18px;
    gap: 5px;
    justify-content: center;
    font-size: 0.72rem;
    color: rgba(217, 227, 255, 0.74);
  }

  .mobile-tab.active {
    background: linear-gradient(180deg, rgba(52, 164, 255, 0.22), rgba(52, 164, 255, 0.1));
    color: white;
  }

  .modal-card,
  .settings-modal,
  .call-modal,
  .story-modal {
    width: calc(100vw - 18px);
    max-height: calc(100dvh - 18px - env(safe-area-inset-bottom));
    margin-bottom: env(safe-area-inset-bottom);
    border-radius: 28px;
  }
}

@media (max-width: 560px) {
  .auth-overlay {
    padding: 10px;
  }

  .auth-card {
    width: 100%;
    min-height: calc(100dvh - 20px);
    border-radius: 28px;
  }

  .auth-card .detail-grid.compact-grid {
    grid-template-columns: 1fr;
  }

  .header-actions-wrap {
    max-width: 44vw;
  }

  .chat-header-actions {
    gap: 6px;
  }

  .chat-header-actions .soft-button {
    width: 36px;
    height: 36px;
  }

  .composer-wrap {
    gap: 8px;
  }

  .composer-tools {
    flex-direction: row;
  }

  .composer {
    align-items: center;
  }

  .composer .primary-button {
    min-width: 92px;
  }
}

/* v5 polish: cleaner iPhone-first layout */
:root {
  --ios-header: rgba(8, 14, 26, 0.82);
  --ios-card: rgba(255, 255, 255, 0.06);
  --ios-card-strong: rgba(255, 255, 255, 0.08);
}

.chat-list,
.folder-row,
.stories-strip,
.chat-header-actions,
.header-actions-wrap {
  scrollbar-width: none;
}
.chat-list::-webkit-scrollbar,
.folder-row::-webkit-scrollbar,
.stories-strip::-webkit-scrollbar,
.chat-header-actions::-webkit-scrollbar,
.header-actions-wrap::-webkit-scrollbar {
  display: none;
}

@media (max-width: 980px) {
  .nav-rail {
    display: none !important;
  }

  .app-shell {
    width: 100vw;
    height: 100dvh;
    margin: 0;
    gap: 0;
    padding: env(safe-area-inset-top) 0 calc(84px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, #07101d 0%, #0a1324 100%);
  }

  .app-shell[data-mobile-view="content"] .mobile-nav {
    opacity: 1;
  }

  .chats-panel,
  .chat-panel,
  .alt-view,
  .main-stack {
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  .chats-panel,
  .chat-panel,
  .alt-view {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .chats-header,
  .chat-header,
  .panel-header {
    background: linear-gradient(180deg, rgba(9, 16, 30, 0.96), rgba(9, 16, 30, 0.84));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  .chats-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px 16px 8px;
  }

  .chats-header .eyebrow,
  .chat-header .eyebrow,
  .panel-header .eyebrow,
  .brand-block,
  .rail-footer,
  .details-panel {
    display: none !important;
  }

  .chats-header h2,
  .panel-header h2,
  .chat-heading h3 {
    font-size: 1.85rem;
    line-height: 1.05;
    font-weight: 800;
    letter-spacing: -0.03em;
  }

  .header-actions-wrap {
    margin-left: 0;
    gap: 8px;
    padding: 0;
    justify-content: flex-end;
  }

  .header-actions-wrap .icon-only,
  .chat-header-actions .icon-only,
  .composer-tools .icon-only,
  .chat-back-button {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.08);
  }

  .chat-back-button {
    width: auto;
    padding: 0 12px;
    font-size: 0.9rem;
  }

  .search-block,
  .stories-strip-wrapper,
  .folder-row {
    background: var(--ios-header);
  }

  .search-block {
    padding: 8px 16px 10px;
  }

  .search-input {
    min-height: 50px;
    padding: 0 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.075);
    border-color: rgba(255, 255, 255, 0.05);
  }

  .stories-strip-wrapper {
    padding: 0 12px 8px;
  }

  .stories-strip {
    gap: 10px;
    padding: 4px 4px 6px;
  }

  .story-pill {
    width: 72px;
    min-width: 72px;
    padding: 0;
    gap: 6px;
    background: transparent;
    border: 0;
    flex-direction: column;
  }

  .story-pill .story-avatar {
    width: 62px;
    height: 62px;
    border-radius: 22px;
    box-shadow: 0 8px 20px rgba(39, 113, 205, 0.22);
  }

  .story-name {
    font-size: 0.72rem;
    max-width: 68px;
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: rgba(234, 240, 255, 0.82);
  }

  .folder-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 2px 12px 10px;
    gap: 8px;
  }

  .folder-chip {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(230, 236, 252, 0.82);
    border-color: transparent;
  }

  .folder-chip.active {
    background: linear-gradient(180deg, rgba(52, 164, 255, 0.24), rgba(52, 164, 255, 0.12));
    color: #fff;
  }

  .chat-list-wrap {
    padding: 8px 12px 18px;
  }

  .chat-list {
    gap: 8px;
  }

  .chat-button {
    padding: 14px 14px 13px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 10px 24px rgba(4, 10, 20, 0.16);
  }

  .chat-item.active .chat-button {
    background: linear-gradient(180deg, rgba(43, 126, 255, 0.24), rgba(101, 88, 255, 0.16));
    border-color: rgba(82, 168, 255, 0.34);
  }

  .avatar-wrap .avatar {
    width: 54px;
    height: 54px;
    border-radius: 18px;
  }

  .chat-top-line {
    gap: 10px;
    margin-bottom: 4px;
  }

  .chat-title {
    font-size: 0.98rem;
    font-weight: 700;
  }

  .chat-preview-line {
    align-items: center;
    gap: 8px;
  }

  .chat-preview,
  .chat-time,
  .type-pill,
  .unread-pill,
  .user-meta-line,
  .result-meta {
    font-size: 0.78rem;
  }

  .type-pill,
  .unread-pill,
  .call-chip,
  .role-badge,
  .invite-code,
  .info-chip,
  .status-chip {
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
  }

  .chat-header {
    padding: 10px 12px 10px;
  }

  .chat-header-main {
    flex: 1;
    min-width: 0;
    gap: 10px;
  }

  .chat-header-main .avatar.large {
    width: 44px;
    height: 44px;
    border-radius: 15px;
    font-size: 0.92rem;
  }

  .chat-heading p {
    margin-top: 2px;
    font-size: 0.78rem;
    color: rgba(212, 221, 242, 0.72);
  }

  .chat-header-actions {
    flex-wrap: nowrap;
    gap: 8px;
    margin-left: 8px;
  }

  .pinned-strip,
  .reply-banner {
    margin: 8px 12px 0;
    padding: 10px 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.06);
  }

  .message-list {
    padding: 12px 12px 18px;
    background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent 24%);
  }

  .day-separator {
    align-self: center;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 0.76rem;
    color: rgba(223, 232, 255, 0.76);
  }

  .message-row {
    gap: 6px;
  }

  .message-bubble {
    max-width: calc(100% - 34px);
    padding: 12px 14px;
    border-radius: 22px;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.14);
  }

  .message-text {
    font-size: 0.95rem;
    line-height: 1.42;
  }

  .message-meta {
    margin-top: 8px;
    font-size: 0.74rem;
  }

  .composer-wrap {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(8, 16, 29, 0.66), rgba(8, 16, 29, 0.96));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    gap: 8px;
  }

  .composer-tools {
    align-self: flex-end;
    gap: 8px;
  }

  .composer {
    align-items: flex-end;
    min-height: 54px;
    padding: 6px 6px 6px 14px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.06);
  }

  .composer textarea {
    min-height: 24px;
    max-height: 120px;
    padding: 10px 0;
    font-size: 16px;
    line-height: 1.35;
  }

  .composer .primary-button {
    min-width: 96px;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 18px;
  }

  .mobile-nav {
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    padding: 8px;
    gap: 6px;
    border-radius: 22px;
    background: rgba(10, 17, 31, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.3);
  }

  .mobile-tab {
    min-height: 54px;
    border-radius: 16px;
    color: rgba(217, 227, 255, 0.66);
  }

  .mobile-tab.active {
    background: linear-gradient(180deg, rgba(52, 164, 255, 0.24), rgba(52, 164, 255, 0.12));
    color: #fff;
  }

  .discover-content,
  .calls-content,
  .story-content,
  .details-body {
    padding: 12px;
  }

  .discover-section,
  .result-card,
  .member-line,
  .story-card-lite,
  .call-log-item,
  .discover-chat-card,
  .settings-card,
  .detail-card {
    background: var(--ios-card);
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.06);
  }

  .modal-card,
  .settings-modal,
  .call-modal,
  .story-modal {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    padding: 18px;
    border-radius: 28px;
  }

  .call-video-grid video {
    min-height: 180px;
  }
}

@media (max-width: 560px) {
  .header-actions-wrap {
    max-width: none;
  }

  .header-actions-wrap .icon-only:nth-child(n+4) {
    display: none;
  }

  .chat-header-actions .icon-only:nth-child(n+3) {
    display: none;
  }

  .chat-title {
    font-size: 0.95rem;
  }

  .composer-tools {
    flex-direction: row;
  }
}

/* v6 responsive cleanup */
@media (max-width: 1500px) {
  .app-shell {
    grid-template-columns: 88px 320px minmax(0, 1fr);
    width: min(1440px, calc(100vw - 24px));
    height: calc(100vh - 24px);
    margin: 12px auto;
    gap: 12px;
  }

  .details-panel {
    display: none;
  }

  .nav-rail {
    padding: 14px 10px;
  }

  .brand-block h1,
  .brand-block .eyebrow,
  .rail-btn span:last-child,
  .theme-toggle span:last-child,
  .mini-user > div {
    display: none;
  }

  .brand-block,
  .rail-btn,
  .mini-user,
  .theme-toggle,
  .install-button {
    justify-content: center;
  }

  .rail-btn,
  .theme-toggle {
    padding-left: 0;
    padding-right: 0;
  }
}

@media (max-width: 1280px) {
  .app-shell {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .nav-rail {
    display: none;
  }

  .chats-panel,
  .chat-panel,
  .alt-view {
    border-radius: 26px;
  }

  .chat-header-actions {
    gap: 8px;
  }

  .chat-header-actions .soft-button,
  .header-actions-wrap .soft-button {
    width: 40px;
    height: 40px;
    padding: 0;
  }
}

@media (max-width: 1200px) {
  body {
    overflow: auto;
  }

  .background-orb {
    display: none;
  }

  .app-shell {
    width: 100vw;
    height: 100dvh;
    margin: 0;
    gap: 0;
    padding: env(safe-area-inset-top) 0 calc(84px + env(safe-area-inset-bottom));
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    background: linear-gradient(180deg, #07101d 0%, #0a1324 100%);
  }

  .nav-rail,
  .details-panel {
    display: none !important;
  }

  .chats-panel,
  .main-stack,
  .chat-panel,
  .alt-view {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    min-width: 0;
    height: 100%;
    border-radius: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .app-shell[data-mobile-view="list"] .main-stack {
    display: none;
  }

  .app-shell[data-mobile-view="content"] .chats-panel {
    display: none;
  }

  .panel-header,
  .chats-header,
  .chat-header,
  .search-block,
  .stories-strip-wrapper,
  .folder-row,
  .composer-wrap {
    background: linear-gradient(180deg, rgba(9, 16, 30, 0.96), rgba(9, 16, 30, 0.84));
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }

  .panel-header {
    padding: 12px 14px 10px;
    border-bottom-color: rgba(255, 255, 255, 0.06);
  }

  .chats-header,
  .chat-header {
    position: sticky;
    top: 0;
    z-index: 4;
  }

  .chats-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
  }

  .chats-header .eyebrow,
  .panel-header .eyebrow,
  .chat-header .eyebrow {
    display: none;
  }

  .chats-header h2,
  .panel-header h2,
  .chat-heading h3 {
    font-size: 1.45rem;
    line-height: 1.05;
    font-weight: 800;
    letter-spacing: -0.03em;
  }

  .header-actions-wrap,
  .chat-header-actions {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-left: 0;
    gap: 8px;
  }

  .header-actions-wrap .icon-only:nth-child(n+4),
  .chat-header-actions .icon-only:nth-child(n+3) {
    display: none;
  }

  .search-block {
    padding: 8px 14px 10px;
  }

  .stories-strip-wrapper {
    padding: 0 10px 8px;
  }

  .folder-row {
    padding: 2px 10px 10px;
  }

  .chat-list-wrap {
    padding: 8px 10px 16px;
  }

  .chat-list {
    gap: 8px;
  }

  .chat-button {
    padding: 14px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 10px 24px rgba(4, 10, 20, 0.14);
  }

  .chat-item.active .chat-button {
    background: linear-gradient(180deg, rgba(43, 126, 255, 0.24), rgba(101, 88, 255, 0.16));
    border-color: rgba(82, 168, 255, 0.34);
  }

  .avatar-wrap .avatar {
    width: 52px;
    height: 52px;
    border-radius: 18px;
  }

  .chat-top-line {
    gap: 10px;
    margin-bottom: 4px;
  }

  .chat-title {
    font-size: 0.98rem;
    font-weight: 700;
  }

  .chat-preview,
  .chat-time,
  .type-pill,
  .unread-pill {
    font-size: 0.78rem;
  }

  .message-list {
    padding: 12px 12px 18px;
    gap: 14px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 24%);
  }

  .message-bubble {
    max-width: calc(100% - 34px);
    border-radius: 22px;
    padding: 12px 14px;
  }

  .composer-wrap {
    position: sticky;
    bottom: 0;
    z-index: 4;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    gap: 8px;
  }

  .composer {
    align-items: flex-end;
    min-height: 54px;
    padding: 6px 6px 6px 14px;
    border-radius: 24px;
  }

  .composer textarea {
    font-size: 16px;
  }

  .mobile-nav {
    display: grid;
    grid-column: 1;
    grid-row: 2;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 15;
    padding: 8px;
    border-radius: 22px;
    background: rgba(10, 17, 31, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.3);
  }

  .mobile-tab {
    min-height: 54px;
    flex-direction: column;
    gap: 4px;
    padding: 10px 6px;
    border-radius: 16px;
    font-size: 0.72rem;
    color: rgba(217, 227, 255, 0.66);
  }

  .mobile-tab.active {
    background: linear-gradient(180deg, rgba(52, 164, 255, 0.24), rgba(52, 164, 255, 0.12));
    color: #fff;
  }
}


/* v7 mobile cleanup */
@media (max-width: 1200px) {
  body.mobile-shell {
    overflow: hidden;
    background: #08101d;
  }

  .background-orb {
    opacity: 0.24;
    filter: blur(90px);
  }

  .app-shell {
    width: 100vw !important;
    height: 100dvh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
    display: block !important;
    background: linear-gradient(180deg, #08101d 0%, #0a1222 100%) !important;
  }

  .chats-panel,
  .main-stack {
    height: calc(100dvh - 72px - env(safe-area-inset-bottom)) !important;
    min-height: 0 !important;
  }

  .chats-panel,
  .chat-panel,
  .alt-view {
    width: 100% !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    border: 0 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: transparent !important;
  }

  .main-stack {
    display: grid;
    min-height: 0;
  }

  .chat-panel.active-view,
  .alt-view.active-view {
    display: grid !important;
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    min-height: 0 !important;
  }

  .chats-panel {
    display: flex;
    flex-direction: column;
  }

  .chat-list-wrap,
  .message-list {
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .panel-header,
  .search-block,
  .stories-strip-wrapper,
  .folder-row,
  .composer-wrap {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  .chats-header,
  .chat-header {
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .chats-header {
    align-items: center;
  }

  .header-actions-wrap {
    gap: 6px;
    flex-wrap: nowrap;
  }

  .header-actions-wrap .soft-button:nth-child(n+3) {
    display: none !important;
  }

  .chat-header {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
  }

  .chat-header-main,
  .chat-header-actions {
    min-width: 0;
  }

  .chat-header-main {
    gap: 12px;
  }

  .chat-back-button {
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 20px;
  }

  .chat-header-actions {
    gap: 8px;
  }

  .chat-header-actions .soft-button:nth-child(n+3) {
    display: none !important;
  }

  .chat-heading h3 {
    font-size: 1.1rem;
  }

  .chat-heading p {
    font-size: 0.92rem;
  }

  .avatar.large {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    font-size: 1.25rem;
  }

  .stories-strip-wrapper {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
  }

  .folder-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 10px !important;
  }

  .folder-chip {
    flex: 0 0 auto;
  }

  .message-list {
    padding: 12px 16px 18px !important;
  }

  .message-bubble {
    max-width: min(82vw, 360px) !important;
    min-width: 0 !important;
    border-radius: 22px !important;
    padding: 14px 16px !important;
  }

  .message-audio,
  .message-media {
    max-width: 100% !important;
  }

  .message-actions {
    gap: 8px;
  }

  .message-action {
    padding: 8px 12px;
    font-size: 0.76rem;
  }

  .composer-wrap {
    position: sticky;
    bottom: 0;
    z-index: 25;
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    padding-top: 10px !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    border-top: 1px solid rgba(255,255,255,0.08);
  }

  .composer-tools {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-self: end;
  }

  .composer {
    min-height: 56px;
    padding: 8px;
    border-radius: 22px !important;
    align-items: flex-end;
  }

  .composer textarea {
    max-height: 120px;
    padding: 10px 12px !important;
    font-size: 16px;
  }

  .composer .primary-button {
    min-width: 110px;
    border-radius: 18px;
  }

  .mobile-nav {
    position: fixed !important;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex !important;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom)) !important;
    border-radius: 0 !important;
    border: 0 !important;
    border-top: 1px solid rgba(255,255,255,0.08) !important;
    box-shadow: none !important;
    background: rgba(8, 15, 28, 0.96) !important;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }

  .mobile-tab {
    min-width: 0;
    flex: 1 1 0;
  }

  .overlay {
    padding: 16px !important;
    align-items: flex-end !important;
  }

  .modal-card {
    width: 100% !important;
    max-height: min(88dvh, 820px) !important;
    border-radius: 24px 24px 0 0 !important;
  }

  .details-head,
  .details-body {
    overflow: hidden;
  }

  .details-cover {
    padding: 20px !important;
  }
}

@media (max-width: 760px) {
  .header-actions-wrap .soft-button:nth-child(n+2) {
    display: none !important;
  }

  .search-block {
    padding-bottom: 10px !important;
  }

  .stories-strip-wrapper,
  .folder-row {
    display: none !important;
  }

  .chat-list {
    padding-top: 6px;
  }

  .chat-item {
    margin: 0 12px 10px;
  }

  .chat-button {
    padding: 12px !important;
    border-radius: 18px !important;
  }

  .chat-header-actions .soft-button:nth-child(n+2) {
    display: none !important;
  }

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

  .composer .primary-button {
    min-width: 96px;
    padding-inline: 18px;
  }
}


/* v8 mobile polish */
:root {
  --app-side-gap: 12px;
  --mobile-header-height: 76px;
  --mobile-composer-height: 88px;
}

.chat-back-button {
  flex: 0 0 auto;
}

.emoji-action {
  min-width: 36px;
  padding-left: 10px;
  padding-right: 10px;
}

.compact-message-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.message-sheet .soft-button {
  width: 100%;
  min-height: 46px;
}

.details-sheet {
  padding: 0;
}

.details-sheet .details-head-mobile {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.details-sheet .details-body-mobile {
  padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 820px) {
  body {
    overflow: hidden;
  }

  .background-orb {
    opacity: 0.35;
    filter: blur(90px);
  }

  .app-shell {
    width: 100vw;
    height: 100dvh;
    margin: 0;
    gap: 0;
    border-radius: 0;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .glass-panel,
  .mobile-nav,
  .nav-rail,
  .chats-panel,
  .chat-panel,
  .alt-view,
  .details-panel {
    border-radius: 0;
  }

  .chats-panel,
  .chat-panel,
  .alt-view {
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }

  .chats-panel {
    background: linear-gradient(180deg, rgba(8, 14, 28, 0.98), rgba(11, 17, 34, 0.95));
  }

  .panel-header,
  .search-block,
  .folder-row,
  .calls-content,
  .discover-content,
  .details-body,
  .details-head {
    padding-left: var(--app-side-gap);
    padding-right: var(--app-side-gap);
  }

  .panel-header {
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    min-height: var(--mobile-header-height);
  }

  .chats-header {
    align-items: flex-end;
  }

  .chats-header .eyebrow {
    font-size: 0.66rem;
  }

  .chats-header h2 {
    font-size: 2rem;
    line-height: 1;
  }

  .header-actions-wrap {
    gap: 6px;
    flex-wrap: nowrap;
  }

  .header-actions-wrap .soft-button {
    width: 38px;
    height: 38px;
    border-radius: 14px;
  }

  .search-block {
    padding-top: 10px;
    padding-bottom: 8px;
  }

  .search-input {
    height: 48px;
    border-radius: 16px;
    padding: 12px 14px;
  }

  .stories-strip-wrapper {
    padding: 0 10px 8px;
  }

  .story-pill {
    min-width: 64px;
    gap: 6px;
  }

  .story-avatar {
    width: 54px;
    height: 54px;
    border-radius: 18px;
  }

  .story-name {
    font-size: 0.72rem;
  }

  .folder-row {
    padding-top: 2px;
    padding-bottom: 10px;
  }

  .folder-chip {
    padding: 8px 12px;
    font-size: 0.82rem;
  }

  .chat-list-wrap {
    padding: 0 8px calc(90px + env(safe-area-inset-bottom, 0px));
  }

  .chat-list {
    gap: 2px;
  }

  .chat-button {
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 10px;
    padding: 12px 10px;
    border-radius: 18px;
  }

  .avatar-wrap .avatar {
    width: 46px;
    height: 46px;
    border-radius: 16px;
  }

  .chat-preview-line,
  .chat-top-line {
    gap: 8px;
  }

  .chat-preview-line {
    font-size: 0.8rem;
  }

  .chat-panel {
    background: linear-gradient(180deg, rgba(9, 14, 29, 0.98), rgba(10, 16, 32, 0.95));
  }

  .chat-header {
    position: sticky;
    top: 0;
    z-index: 5;
    background: rgba(11, 17, 34, 0.88);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }

  .chat-header-main {
    gap: 12px;
    min-width: 0;
  }

  .chat-header .avatar.large {
    width: 54px;
    height: 54px;
    border-radius: 18px;
    font-size: 1.15rem;
  }

  .chat-heading h3 {
    font-size: 1.2rem;
  }

  .chat-heading p {
    font-size: 0.88rem;
  }

  .chat-header-actions {
    gap: 8px;
    flex-wrap: nowrap;
  }

  .chat-header-actions .soft-button {
    width: 40px;
    height: 40px;
    border-radius: 14px;
  }

  .pinned-strip,
  .reply-banner {
    margin: 10px var(--app-side-gap) 0;
    border-radius: 16px;
  }

  .message-list {
    padding: 12px 12px calc(110px + env(safe-area-inset-bottom, 0px));
    gap: 14px;
  }

  .message-bubble {
    max-width: 84%;
    padding: 11px 12px;
    border-radius: 18px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.16);
  }

  .message-text {
    font-size: 1rem;
    line-height: 1.45;
  }

  .message-meta {
    margin-top: 8px;
    gap: 8px;
  }

  .message-actions {
    margin-top: 8px;
    gap: 6px;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .message-actions::-webkit-scrollbar {
    display: none;
  }

  .message-action {
    flex: 0 0 auto;
    min-height: 32px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
  }

  .message-audio,
  .message-media {
    max-width: 100%;
    border-radius: 14px;
  }

  .composer-wrap {
    position: sticky;
    bottom: 0;
    z-index: 6;
    gap: 8px;
    align-items: center;
    padding: 10px var(--app-side-gap) calc(10px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, rgba(10,16,32,0.35), rgba(10,16,32,0.94) 28%);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .composer-tools {
    flex-direction: row;
    gap: 8px;
    align-self: flex-end;
    margin-bottom: 2px;
  }

  .composer-tools .soft-button,
  .composer-tools .file-label {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    flex: 0 0 40px;
  }

  .composer {
    min-height: 56px;
    gap: 10px;
    padding: 8px 8px 8px 12px;
    border-radius: 20px;
    align-items: center;
  }

  .composer textarea {
    min-height: 24px;
    max-height: 96px;
    font-size: 1rem;
    line-height: 1.35;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .composer .primary-button {
    padding: 11px 16px;
    min-height: 40px;
    white-space: nowrap;
  }

  .mobile-nav {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--line);
    background: rgba(9, 14, 27, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  .mobile-tab {
    min-width: 0;
    padding: 8px 4px;
    color: var(--muted);
    border-radius: 16px;
  }

  .mobile-tab.active {
    background: transparent;
    color: var(--text);
  }

  .mobile-tab span:first-child {
    font-size: 1.05rem;
  }

  .mobile-tab span:last-child {
    font-size: 0.72rem;
  }

  .overlay {
    align-items: end;
  }

  .modal-card,
  .settings-modal,
  .story-modal,
  .auth-card {
    width: 100vw;
    max-width: 100vw;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  .modal-card {
    max-height: min(88dvh, 88vh);
    border-radius: 28px 28px 0 0;
  }

  .settings-modal,
  .story-modal {
    padding: 18px 14px 0;
  }

  .details-cover {
    height: auto;
    min-height: 150px;
    border-radius: 20px;
  }

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

@media (max-width: 480px) {
  .chats-header h2 {
    font-size: 1.85rem;
  }

  .header-actions-wrap .soft-button:nth-child(3),
  .header-actions-wrap .soft-button:nth-child(4) {
    display: none;
  }

  .chat-header .avatar.large {
    width: 48px;
    height: 48px;
    border-radius: 16px;
  }

  .chat-heading h3 {
    font-size: 1.08rem;
  }

  .chat-heading p {
    font-size: 0.82rem;
  }

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

  .composer .primary-button {
    padding: 11px 14px;
  }
}


/* v10 mobile polish */
.chat-item {
  position: relative;
}

.chat-button {
  padding-right: 54px;
}

.chat-row-actions {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  z-index: 2;
}

.chat-menu-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  font-size: 1.1rem;
}

.chat-menu-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text);
}

.danger-button {
  border-color: rgba(255, 99, 132, 0.24) !important;
  color: #ffd7df;
}

.sheet-actions-list {
  display: grid;
  gap: 10px;
}

.sheet-action {
  justify-content: flex-start;
  width: 100%;
  min-height: 48px;
}

@media (max-width: 1200px) {
  .mobile-nav {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    gap: 0;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-tab {
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    text-align: center;
  }

  .panel-header.chats-header {
    align-items: center;
  }

  .chats-header h2 {
    letter-spacing: -0.02em;
  }

  .chat-list {
    gap: 10px;
  }

  .chat-button {
    min-height: 78px;
    padding: 14px 52px 14px 14px;
    border-radius: 20px;
  }

  .chat-top-line {
    align-items: baseline;
    gap: 10px;
  }

  .chat-title {
    font-size: 1.05rem;
    line-height: 1.2;
  }

  .chat-time {
    white-space: nowrap;
    font-size: 0.82rem;
  }

  .chat-preview-line {
    gap: 8px;
    align-items: center;
  }

  .chat-preview {
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .chat-header {
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .chat-header-main {
    min-width: 0;
    gap: 12px;
  }

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

  .chat-heading h3,
  .chat-heading p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .chat-header-actions {
    gap: 8px;
    flex-wrap: nowrap;
  }

  .chat-header-actions .soft-button {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
  }

  .composer-wrap {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: end;
    gap: 10px;
  }

  .composer-tools {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin: 0;
  }

  .composer {
    min-width: 0;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 10px;
    padding: 8px 8px 8px 14px;
  }

  .composer textarea {
    width: 100%;
    min-width: 0;
    min-height: 24px;
    padding: 8px 0;
  }

  .composer .primary-button {
    align-self: center;
    min-width: 108px;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .chat-button {
    min-height: 74px;
  }

  .chat-menu-btn {
    width: 32px;
    height: 32px;
  }

  .chat-header {
    padding-left: 14px;
    padding-right: 14px;
  }

  .chat-header-actions .soft-button:nth-child(n+3) {
    display: inline-flex;
  }

  .composer-wrap {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 10px;
  }

  .composer-tools {
    order: 2;
    flex-direction: row;
    justify-content: flex-start;
  }

  .composer {
    order: 1;
    min-height: 58px;
  }

  .composer .primary-button {
    min-width: 96px;
    padding-inline: 14px;
  }
}

/* v12 mobile polish overrides */
@media (max-width: 1200px) {
  :root {
    --mobile-nav-safe: calc(74px + env(safe-area-inset-bottom, 0px));
  }

  .app-shell {
    padding-bottom: var(--mobile-nav-safe);
  }

  .main-stack,
  .chat-panel,
  .active-view {
    min-height: 0;
  }

  .chat-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .chat-header {
    position: sticky;
    top: 0;
    z-index: 8;
    padding: 14px 14px 12px;
    gap: 10px;
    background: linear-gradient(180deg, rgba(7, 16, 43, 0.96), rgba(8, 18, 50, 0.9));
    backdrop-filter: blur(16px);
  }

  .chat-header-main {
    min-width: 0;
    gap: 12px;
    align-items: center;
  }

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

  .chat-heading h3,
  .chat-heading p {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .chat-header-actions {
    display: flex !important;
    gap: 8px;
    flex-wrap: nowrap;
    flex-shrink: 0;
    overflow: visible;
  }

  .chat-header-actions .soft-button {
    display: inline-flex !important;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
  }

  .message-list {
    flex: 1;
    min-height: 0;
    padding: 12px 14px 8px;
    padding-bottom: 18px;
  }

  .message-row {
    margin-bottom: 14px;
  }

  .message-bubble {
    max-width: min(84%, 320px);
  }

  .composer-wrap {
    position: sticky;
    bottom: var(--mobile-nav-safe);
    z-index: 9;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: end;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, rgba(4, 9, 28, 0.02), rgba(8, 17, 49, 0.96) 22%, rgba(8, 17, 49, 0.99));
    backdrop-filter: blur(14px);
    border-top: 1px solid rgba(255,255,255,0.06);
  }

  .composer-tools {
    display: flex;
    gap: 8px;
    align-self: end;
    margin-bottom: 2px;
  }

  .composer-tools .soft-button,
  .composer-tools .file-label {
    width: 42px;
    height: 42px;
    border-radius: 14px;
  }

  .composer {
    min-width: 0;
    align-items: flex-end;
    gap: 10px;
    padding: 8px 8px 8px 14px;
    border-radius: 22px;
  }

  .composer textarea {
    min-height: 24px !important;
    max-height: 116px;
    height: 24px;
    overflow-y: auto;
    padding: 8px 0;
    line-height: 1.4;
    font-size: 16px;
  }

  .composer .primary-button {
    min-width: 112px;
    height: 44px;
    padding: 0 18px;
    border-radius: 18px;
    flex-shrink: 0;
  }

  .mobile-nav {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: center;
    gap: 8px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-tab {
    width: 100%;
    min-width: 0;
    justify-content: center;
    text-align: center;
  }

  .chat-list-wrap {
    padding-bottom: var(--mobile-nav-safe);
  }

  .chat-list {
    gap: 10px;
  }

  .chat-item {
    position: relative;
  }

  .chat-button {
    padding-right: 50px;
  }

  .chat-row-actions {
    position: absolute;
    top: 14px;
    right: 12px;
    z-index: 2;
  }

  .details-sheet {
    display: flex;
    flex-direction: column;
    max-height: min(86vh, 760px);
  }

  .details-sheet .details-head-mobile {
    position: sticky;
    top: 0;
    z-index: 3;
    background: linear-gradient(180deg, rgba(11, 22, 55, 0.98), rgba(11, 22, 55, 0.9));
    padding-bottom: 12px;
  }

  .details-sheet .member-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .details-sheet .member-actions .soft-button {
    width: 100%;
    min-width: 0;
  }

  .details-sheet .details-body-mobile {
    overflow: auto;
    padding-bottom: 24px;
  }
}


/* v13 mobile cleanup overrides */
@media (max-width: 1200px) {
  .message-list {
    padding: 14px 14px calc(var(--mobile-nav-safe) + 148px) !important;
  }

  .composer-wrap {
    position: fixed !important;
    left: 10px;
    right: 10px;
    bottom: calc(var(--mobile-nav-safe) + 6px);
    z-index: 14;
    grid-template-columns: 1fr auto !important;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 24px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  }

  .composer-tools {
    position: absolute;
    left: 10px;
    bottom: calc(100% + 10px);
    margin: 0 !important;
    padding: 0;
    background: transparent;
  }

  .composer {
    min-height: 56px;
    padding: 6px 6px 6px 14px !important;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .composer textarea {
    min-width: 0;
    width: 100%;
    max-height: 112px;
    padding: 8px 0 !important;
    align-self: center;
  }

  .composer .primary-button {
    align-self: center;
    min-width: 108px;
  }

  .chat-list-wrap {
    padding-bottom: calc(var(--mobile-nav-safe) + 10px) !important;
  }

  .chat-button {
    padding: 14px 52px 14px 14px !important;
    border-radius: 22px;
  }

  .chat-top-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: baseline;
  }

  .chat-preview-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
  }

  .chat-preview,
  .chat-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .chat-badges {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    min-width: 56px;
  }

  .chat-time {
    min-width: 42px;
    text-align: right;
    font-size: 0.8rem;
  }

  .type-pill {
    max-width: 58px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 4px 8px;
    font-size: 0.7rem;
  }

  .chat-row-actions {
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
  }

  .chat-menu-btn {
    width: 28px;
    height: 28px;
    border-radius: 10px;
  }

  .details-sheet {
    max-height: min(88vh, 760px);
  }

  .details-sheet .details-head-mobile {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
  }

  .details-sheet .member-actions-mobile {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    max-width: 184px;
  }

  .detail-icon-button {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    font-size: 1.05rem;
    padding: 0;
  }

  .details-sheet .details-body-mobile {
    padding-top: 12px;
  }

  .details-cover {
    min-height: 0;
  }

  .calls-content {
    padding-top: 8px;
  }
}


/* v14 targeted mobile cleanup */
@media (max-width: 980px) {
  .details-sheet {
    max-height: min(82vh, 700px);
    padding: 12px;
  }

  .details-sheet .details-head-mobile {
    position: sticky;
    top: 0;
    padding: 0 0 10px;
    margin-bottom: 8px;
    align-items: flex-start;
    background: linear-gradient(180deg, rgba(8, 16, 29, 0.98), rgba(8, 16, 29, 0.9));
  }

  .details-head-copy h3 {
    margin: 2px 0 0;
    font-size: 1rem;
    line-height: 1.15;
  }

  .details-sheet .member-actions-mobile {
    display: grid !important;
    grid-template-columns: repeat(3, 42px);
    gap: 8px;
    max-width: none;
    flex: 0 0 auto;
  }

  .detail-icon-button {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    font-size: 1rem;
  }

  .details-body-mobile {
    max-height: min(68vh, 620px);
    padding: 4px 2px 8px;
  }

  .details-cover-compact {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 18px;
    min-height: 0;
    margin-bottom: 12px;
  }

  .details-cover-avatar {
    width: 46px;
    height: 46px;
    border-radius: 15px;
    font-size: 0.95rem;
    flex: 0 0 auto;
  }

  .details-cover-copy {
    min-width: 0;
  }

  .details-cover-copy h3 {
    margin: 0 0 4px;
    font-size: 1rem;
    line-height: 1.1;
  }

  .details-cover-copy p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

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

  .detail-grid-mobile .detail-card {
    padding: 14px 16px;
    border-radius: 18px;
  }

  .detail-grid-mobile .detail-card strong,
  .detail-grid-mobile .detail-card p,
  .member-line .avatar-meta strong,
  .member-line .user-meta-line,
  .role-badge {
    font-size: 0.86rem;
  }

  .member-line {
    padding: 12px 14px;
    border-radius: 18px;
  }

  .message-list {
    padding-bottom: calc(150px + env(safe-area-inset-bottom)) !important;
  }

  .reply-banner:not(.hidden) {
    margin-bottom: 6px;
  }

  .composer-wrap {
    position: sticky;
    bottom: 0;
    z-index: 6;
    padding: 10px 12px calc(18px + env(safe-area-inset-bottom)) !important;
    background: linear-gradient(180deg, rgba(8, 16, 29, 0), rgba(8, 16, 29, 0.94) 28%, rgba(8, 16, 29, 0.98) 100%);
  }

  .composer {
    min-height: 58px;
    display: grid !important;
    grid-template-columns: 42px minmax(0, 1fr) auto 42px;
    align-items: center;
    column-gap: 10px;
    padding: 8px 10px !important;
    border-radius: 24px;
  }

  .composer .composer-attach,
  .composer .composer-voice {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    margin: 0;
  }

  .composer textarea {
    min-height: 24px;
    max-height: 108px;
    padding: 8px 2px !important;
    align-self: center;
  }

  .composer .primary-button {
    min-width: 108px;
    height: 42px;
    padding: 0 18px;
    align-self: center;
  }

  .chat-button {
    padding: 14px 44px 14px 14px !important;
  }

  .chat-top-line {
    grid-template-columns: minmax(0, 1fr) 52px;
    gap: 6px;
    align-items: center;
  }

  .chat-preview-line {
    grid-template-columns: minmax(0, 1fr) 64px;
    gap: 6px;
    align-items: center;
  }

  .chat-title {
    font-size: 0.98rem;
    font-weight: 700;
  }

  .chat-preview {
    font-size: 0.82rem;
    color: var(--muted);
  }

  .chat-time {
    min-width: 0;
    font-size: 0.76rem;
    text-align: right;
    opacity: 0.88;
  }

  .chat-badges {
    min-width: 0;
    gap: 4px;
    justify-content: flex-end;
  }

  .type-pill,
  .unread-pill {
    padding: 4px 7px;
    font-size: 0.66rem;
  }

  .chat-row-actions {
    right: 8px;
  }

  .chat-menu-btn {
    width: 26px;
    height: 26px;
    border-radius: 9px;
    font-size: 0.9rem;
  }
}


/* v15 auth/avatar/group/mobile cleanup */
.auth-hero {
  display: grid;
  justify-items: start;
  gap: 18px;
}

.auth-hero .eyebrow,
.auth-hero > p:not(.auth-note),
.auth-hero .detail-grid {
  display: none !important;
}

.auth-hero h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.6rem);
}

.avatar-image-wrap {
  overflow: hidden;
}

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

.compact-details-head {
  gap: 12px;
  margin-bottom: 8px;
}

.compact-member-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 8px !important;
}

.detail-icon-button {
  min-height: 44px;
}

.details-cover-mini {
  padding: 10px 12px !important;
  margin-bottom: 10px !important;
}

.details-cover-mini .details-cover-avatar {
  width: 40px;
  height: 40px;
  border-radius: 14px;
}

.details-cover-mini .details-cover-copy h3 {
  font-size: 0.96rem;
}

.details-cover-mini .details-cover-copy p {
  font-size: 0.76rem;
}

.member-line-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.member-remove-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
}

@media (max-width: 1200px) {
  .calls-content .section-title,
  .calls-content .discover-section > p,
  .calls-content .eyebrow + p {
    display: none !important;
  }

  .chat-button {
    padding: 14px 48px 14px 14px !important;
    min-height: 86px;
    align-items: center;
  }

  .chat-meta {
    min-width: 0;
    display: grid;
    gap: 6px;
  }

  .chat-top-line,
  .chat-preview-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
  }

  .chat-title {
    display: block;
    font-size: 1rem !important;
    line-height: 1.2;
    height: auto !important;
  }

  .chat-preview {
    display: block;
    font-size: 0.88rem;
    line-height: 1.25;
    color: var(--muted);
    height: auto !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }

  .chat-time {
    font-size: 0.82rem;
    justify-self: end;
  }

  .chat-badges {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    justify-self: end;
  }

  .type-pill,
  .unread-pill {
    height: 24px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-size: 0.72rem;
  }

  .chat-row-actions {
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
  }

  .chat-menu-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 999px;
  }

  .message-list {
    padding-bottom: calc(var(--mobile-nav-safe) + 180px) !important;
  }

  .composer-wrap {
    position: fixed !important;
    left: 10px;
    right: 10px;
    bottom: calc(var(--mobile-nav-safe) + 2px) !important;
    z-index: 20;
    padding: 0 !important;
    background: transparent !important;
    border-top: 0 !important;
    box-shadow: none !important;
  }

  .composer {
    min-height: 56px;
    grid-template-columns: 42px minmax(0, 1fr) auto 42px !important;
    padding: 7px 8px !important;
    border-radius: 22px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  }

  .composer textarea {
    min-height: 24px !important;
    max-height: 96px;
    padding: 8px 2px !important;
    margin: 0 !important;
  }

  .composer .primary-button {
    min-width: 104px;
    height: 40px;
  }

  .composer .composer-attach,
  .composer .composer-voice {
    width: 40px;
    height: 40px;
  }

  .details-sheet .details-head-mobile {
    padding-bottom: 8px;
  }
}


.mobile-new-chat-fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--mobile-nav-safe, 74px) + 16px);
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 18px;
  display: none;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4aa3ff, #2f80ed);
  color: #fff;
  font-size: 1.8rem;
  box-shadow: 0 14px 34px rgba(35, 111, 255, 0.32);
  z-index: 45;
}

.mobile-new-chat-fab.is-visible {
  display: inline-flex;
}

@media (max-width: 900px) {
  .header-actions-wrap {
    display: none !important;
  }
}
