/* ════════════════════════════════════════════════════════════════ RESET ════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  width: 100%;
  min-height: 100%;
  height: auto;
  overflow-y: auto;
}
#app { width: 100%; min-height: 100%; }

.global-loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.45);
  backdrop-filter: blur(2px);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.global-loader-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid #334155;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 0.9rem;
}

.global-loader-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #334155;
  border-top-color: #6366f1;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ════════════════════════════════════════════════════════════════ AUTH ════ */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  overflow: auto;
}
.auth-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 50px rgba(0,0,0,.5);
}
.auth-logo { font-size: 1.8rem; font-weight: 800; color: #6366f1; margin-bottom: 6px; }
.auth-subtitle { font-size: .875rem; color: #94a3b8; margin-bottom: 28px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.form-group label { display: block; font-size: .8rem; color: #94a3b8; margin-bottom: 6px; }
.form-group input, .form-group select {
  width: 100%;
  padding: 10px 14px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #e2e8f0;
  font-size: .95rem;
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: #6366f1; }
.btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity .2s;
}
.btn-primary { background: #6366f1; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #4f46e5; }
.btn:disabled { opacity: .5; cursor: default; }
.error-msg { color: #f87171; font-size: .85rem; margin-top: 10px; text-align: center; }
.link-text { text-align: center; margin-top: 16px; font-size: .875rem; color: #94a3b8; }
.link-text span { color: #6366f1; cursor: pointer; font-weight: 600; }

/* ════════════════════════════════════════════════════════════════ APP ════ */
.app-shell {
  display: flex;
  min-height: 100vh;
  height: auto;
}
.sidebar {
  width: 220px;
  background: #0f172a;
  border-right: 1px solid #334155;
  display: flex;
  flex-direction: column;
  z-index: 100;
}
.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid #334155;
}
.sidebar-logo { font-size: 1.2rem; font-weight: 800; color: #6366f1; }
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-item {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  column-gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .2s;
  color: #cbd5e1;
  font-size: .9rem;
  position: relative;
}
.nav-item:hover { background: #1e293b; }
.nav-item.active { background: #6366f1; color: #fff; font-weight: 600; }
.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: block;
}
.nav-label {
  line-height: 1.1;
  white-space: nowrap;
}
.nav-alert-dot {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 2px #0f172a;
}
.sidebar-user {
  padding: 16px;
  border-top: 1px solid #334155;
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 40px;
  height: 40px;
  background: #334155;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: .85rem;
  object-fit: cover;
  flex-shrink: 0;
}
.avatar-sm { width: 32px; height: 32px; font-size: .75rem; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: .85rem; font-weight: 600; }
.user-status { font-size: .75rem; color: #64748b; }
.btn-logout {
  background: #334155;
  color: #cbd5e1;
  padding: 8px 12px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: .8rem;
}
.btn-logout:hover { background: #475569; }

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: visible;
  min-height: 0;
}
.page-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ═══════════════════════════════════════════════════════════ SETTINGS ════ */
.settings-wrap {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.settings-tab {
  background: #1e293b;
  border: 1px solid #334155;
  color: #cbd5e1;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}

.settings-tab.active {
  background: #6366f1;
  color: #fff;
  border-color: #6366f1;
}

.settings-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 16px;
}

.settings-card h3 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 560px;
}

.profile-label {
  margin-top: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #cbd5e1;
}

.profile-form input {
  width: 100%;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 9px 10px;
}

.profile-form .btn {
  width: fit-content;
  margin-top: 10px;
}

.profile-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.profile-avatar-wrap {
  width: 92px;
  height: 92px;
}

.profile-avatar {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 2px solid #334155;
  background: #0f172a;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
}

.profile-avatar-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-note {
  font-size: 0.8rem;
  color: #94a3b8;
}

.settings-form-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.settings-form-grid.role-grid {
  grid-template-columns: 1fr auto;
}

.settings-form-grid input,
.settings-form-grid select,
.settings-table input,
.settings-table select {
  width: 100%;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px 10px;
}

.settings-table-wrap {
  overflow-x: auto;
}

.settings-toolbar {
  margin-bottom: 10px;
}

.settings-search {
  width: 100%;
  max-width: 420px;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px 10px;
}

.settings-pager {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.82rem;
  color: #94a3b8;
}

.settings-pager-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

.settings-table th,
.settings-table td {
  border-bottom: 1px solid #334155;
  padding: 8px;
  text-align: left;
  font-size: 0.85rem;
}

.settings-table th {
  color: #94a3b8;
  font-weight: 600;
}

.settings-table td .btn {
  margin-right: 6px;
  background: #334155;
  color: #e2e8f0;
}

@media (max-width: 900px) {
  .profile-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .settings-form-grid {
    grid-template-columns: 1fr;
  }

  .settings-form-grid.role-grid {
    grid-template-columns: 1fr;
  }

  .settings-pager {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ════════════════════════════════════════════════════════════════ FEED ════ */
.page-header {
  padding: 16px 20px;
  border-bottom: 1px solid #334155;
  font-size: 1.1rem;
  font-weight: 600;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.page-title {
  min-width: 0;
}

.header-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  font-size: .78rem;
}

@media (min-width: 769px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100dvh;
  }

  .main-content {
    margin-left: 220px;
    width: calc(100% - 220px);
  }

  .page-header {
    position: fixed;
    top: 0;
    left: 220px;
    right: 0;
    z-index: 40;
  }

  .page-content {
    padding-top: 70px;
  }
}

.feed-wrap {
  flex: 1;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  max-width: 100%;
  min-height: 0;
}
.feed-wrap > * {
  width: 100%;
  max-width: 680px;
}
.compose-box {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 16px;
  width: 100%;
  max-width: 680px;
}
.compose-textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #e2e8f0;
  font-family: inherit;
  resize: vertical;
}
.compose-textarea:focus { outline: none; border-color: #6366f1; }
.compose-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.compose-file-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #cbd5e1;
  cursor: pointer;
  font-size: .9rem;
}
.compose-file-label:hover { background: #334155; }
.compose-file-label svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.post-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 680px;
  cursor: pointer;
}
.post-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 0;
}
.post-content {
  font-size: .85rem;
  line-height: 1.5;
  color: #cbd5e1;
  padding: 12px 16px 8px;
  word-wrap: break-word;
}
.feed-user-link {
  cursor: pointer;
}
.feed-user-link:hover {
  text-decoration: underline;
}
.post-img-wrapper {
  width: 100%;
  height: 280px;
  background: #0f172a;
  overflow: hidden;
  cursor: pointer;
}
.post-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .3s;
}
.post-img-wrapper:hover .post-img { transform: scale(1.02); }
.post-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 14px 16px 16px;
  border-top: 1px solid #334155;
  font-size: .8rem;
  min-height: 52px;
  background: #182236;
}
.post-action-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 999px;
  color: #e2e8f0;
  cursor: pointer;
  font-size: .8rem;
  transition: color .2s;
  min-width: 52px;
}
.post-action-btn:hover { color: #fff; border-color: #475569; }
.post-action-btn.liked { color: #ef4444; }
.post-action-btn.share { margin-left: auto; }
.action-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.action-icon.icon-filled {
  fill: currentColor;
}
.post-action-count {
  color: #94a3b8;
  font-weight: 600;
}
.compose-file-label {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ════════════════════════════════════════════════════════════════ POST MODAL ════ */
.post-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, .78);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 9998;
}
.post-modal {
  position: relative;
  width: min(1100px, 100%);
  max-height: 88vh;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.post-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 999px;
  background: rgba(15, 23, 42, .85);
  color: #e2e8f0;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}
.post-modal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr);
  min-height: 560px;
  max-height: 88vh;
}
.post-modal-media {
  background: #020617;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
}
.post-modal-media.is-empty {
  padding: 32px;
}
.post-modal-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.post-modal-empty {
  color: #94a3b8;
  font-size: .95rem;
}
.post-modal-side {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-left: 1px solid #334155;
  background: #0f172a;
}
.post-modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid #1f2a44;
}
.post-modal-likes {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid #1f2a44;
  color: #e2e8f0;
  font-weight: 700;
}
.post-modal-comment-form {
  display: flex;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid #1f2a44;
  background: #0f172a;
}
.post-modal-comment-input {
  flex: 1;
  min-width: 0;
  border: 1px solid #334155;
  border-radius: 10px;
  background: #111c31;
  color: #e2e8f0;
  padding: 10px 12px;
  font-size: .9rem;
}
.post-modal-comment-input:focus {
  outline: none;
  border-color: #6366f1;
}
.post-modal-comment-send {
  padding: 10px 14px;
  white-space: nowrap;
}
.post-modal-comments {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.post-modal-comment {
  background: #111c31;
  border: 1px solid #23314f;
  border-radius: 14px;
  padding: 12px 14px;
}
.post-modal-comment-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  color: #e2e8f0;
}
.post-modal-comment-meta strong {
  line-height: 1.2;
}
.post-modal-comment-meta .avatar {
  width: 28px;
  height: 28px;
  font-size: .68rem;
}
.post-modal-comment-meta span {
  margin-left: auto;
  color: #94a3b8;
  font-size: .72rem;
  white-space: nowrap;
}
.post-modal-comment-body {
  color: #cbd5e1;
  line-height: 1.5;
  font-size: .92rem;
  word-wrap: break-word;
}
.post-modal-state {
  color: #94a3b8;
  font-size: .9rem;
  padding: 8px 2px;
}
.post-modal-state.error {
  color: #f87171;
}

.user-profile-modal {
  position: relative;
  width: min(420px, 100%);
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}

.user-profile-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.user-profile-name {
  font-size: 1.15rem;
  font-weight: 700;
}

.user-profile-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #cbd5e1;
  padding: 8px 0 4px;
}

.user-profile-actions {
  margin-top: 14px;
}

/* ════════════════════════════════════════════════════════════════ CHAT ════ */
.chat-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.chat-thread {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
}
.chat-thread-header {
  padding: 12px 16px;
  border-bottom: 1px solid #334155;
  font-size: .9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
}
.chat-thread-user {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.chat-thread-name {
  font-size: .9rem;
  font-weight: 700;
  line-height: 1.2;
}
.chat-thread-presence {
  font-size: .75rem;
  color: #94a3b8;
}
.chat-thread-presence.typing {
  color: #22c55e;
}
.chat-back-btn {
  display: none;
  border: none;
  background: transparent;
  color: #cbd5e1;
  font-size: 1.1rem;
  line-height: 1;
  margin-right: 10px;
  cursor: pointer;
}
.friend-list {
  width: 220px;
  background: #0f172a;
  border-right: 1px solid #334155;
  display: flex;
  flex-direction: column;
}
.friend-list-header {
  padding: 12px 16px;
  border-bottom: 1px solid #334155;
  font-size: .9rem;
  font-weight: 600;
}
.friend-search-wrap {
  border-bottom: 1px solid #334155;
  padding: 8px;
}
.friend-search-input {
  width: 100%;
  border: 1px solid #334155;
  background: #0b1220;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: .8rem;
}
.friend-search-input:focus {
  outline: none;
  border-color: #6366f1;
}
.friend-search-state {
  margin-top: 6px;
  color: #94a3b8;
  font-size: .72rem;
}
.friend-search-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  margin-top: 6px;
  border-radius: 8px;
  cursor: pointer;
}
.friend-search-item:hover {
  background: #1e293b;
}
.friend-search-meta {
  min-width: 0;
}
.friend-search-email {
  font-size: .72rem;
  color: #94a3b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.friend-search-action .btn {
  padding: 6px 10px;
  font-size: .75rem;
}
.friend-requests-wrap {
  border-bottom: 1px solid #334155;
  margin-bottom: 8px;
  padding: 8px;
}
.friend-requests-title {
  font-size: .72rem;
  color: #94a3b8;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 8px;
}
.friend-request-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}
.friend-request-item:hover {
  background: #1e293b;
}
.friend-request-item + .friend-request-item {
  margin-top: 6px;
}
.friend-request-meta {
  min-width: 0;
}
.friend-request-actions {
  display: flex;
  gap: 6px;
  grid-column: 2;
}
.friend-request-actions .btn {
  padding: 6px 10px;
  font-size: .75rem;
}
.friend-item {
  padding: 12px 14px;
  cursor: pointer;
  transition: background .2s;
  border-left: 3px solid transparent;
  display: flex;
  align-items: center;
  gap: 10px;
}
.friend-item:hover { background: #1e293b; }
.friend-item.active { background: #1e293b; border-left-color: #6366f1; }
.friend-name { font-size: .9rem; }
.friend-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}
.friend-presence {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .72rem;
  color: #94a3b8;
  text-transform: lowercase;
}
.friend-latest {
  text-transform: none;
}
.friend-latest-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  max-width: 120px;
}
.friend-presence.typing {
  color: #22c55e;
}
.friend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.friend-dot.online {
  background: #22c55e;
}
.friend-dot.offline {
  background: #64748b;
}
.friend-dot.typing {
  background: #22c55e;
}
.friend-unread-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ef4444;
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Share Post Modal ─────────────────────────────────────────────────────────── */
.share-post-modal {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 14px;
  width: 100%;
  max-width: 440px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  position: relative;
}
.share-post-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  font-weight: 700;
  font-size: 1rem;
  border-bottom: 1px solid #334155;
  color: #e2e8f0;
}
.share-post-preview {
  margin: 12px 16px;
  padding: 12px;
  border: 1px solid #334155;
  border-radius: 10px;
  background: #1e293b;
  font-size: .875rem;
}
.share-post-preview-author {
  font-weight: 600;
  margin-bottom: 4px;
  font-size: .8rem;
  color: #94a3b8;
}
.share-post-preview-content {
  color: #e2e8f0;
  line-height: 1.45;
  word-break: break-word;
}
.share-post-preview-img {
  width: 100%;
  max-height: 140px;
  object-fit: cover;
  border-radius: 8px;
  margin-top: 8px;
}
.share-post-msg-wrap {
  padding: 0 16px 4px;
}
.share-post-msg-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #334155;
  border-radius: 8px;
  font-size: .875rem;
  background: #1e293b;
  color: #e2e8f0;
  box-sizing: border-box;
}
.share-post-msg-input::placeholder { color: #64748b; }
.share-post-search-wrap {
  padding: 4px 16px 8px;
}
.share-post-friend-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
}
.share-post-friend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: default;
}
.share-post-friend-item:hover {
  background: #1e293b;
}

/* ── Shared Post Bubble Card ──────────────────────────────────────────────────── */
.shared-post-card {
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 6px;
  min-width: 200px;
  max-width: 280px;
}
.bubble.mine .shared-post-card {
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.1);
}
.bubble.theirs .shared-post-card {
  border: 1px solid #334155;
  background: #1e293b;
}
.shared-post-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 4px;
}
.shared-post-card-author {
  font-size: .8rem;
  font-weight: 600;
}
.shared-post-card-content {
  font-size: .825rem;
  padding: 0 10px 8px;
  line-height: 1.4;
  word-break: break-word;
}
.shared-post-card-img {
  width: 100%;
  max-height: 150px;
  object-fit: cover;
  display: block;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
.bubble-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.bubble-row.mine { justify-content: flex-end; }
.bubble {
  max-width: 65%;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: .9rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.bubble.theirs { background: #334155; color: #cbd5e1; }
.bubble.mine { background: #6366f1; color: #fff; }
.bubble-seen {
  margin-top: 6px;
  font-size: .7rem;
  opacity: .85;
  text-align: right;
}
.typing-row {
  opacity: .95;
}
.typing-bubble {
  font-style: italic;
  color: #94a3b8;
}
.chat-input-bar {
  padding: 16px;
  border-top: 1px solid #334155;
  display: flex;
  gap: 8px;
}
.chat-input { flex: 1; padding: 10px 14px; background: #0f172a; border: 1px solid #334155; border-radius: 8px; color: #e2e8f0; }
.chat-input:focus { outline: none; border-color: #6366f1; }

/* ════════════════════════════════════════════════════════════════ TOAST ════ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  border: 1px solid #334155;
  border-left: 4px solid #6366f1;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: .875rem;
  z-index: 9999;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.toast.error { border-left-color: #ef4444; }

/* ════════════════════════════════════════════════════════════════ RESPONSIVE ════ */
@media (max-width: 768px) {
  .app-shell {
    flex-direction: column;
    padding-bottom: 65px;
  }

  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 65px;
    border-right: none;
    border-top: 1px solid #334155;
    flex-direction: row;
    padding: 0;
  }

  .sidebar-header {
    display: none;
  }

  .sidebar-user {
    display: none;
  }

  .sidebar-nav {
    flex: 1;
    overflow-y: visible;
    overflow-x: auto;
    padding: 0;
    flex-direction: row;
    gap: 0;
    align-items: center;
  }

  .nav-item {
    flex: 1;
    padding: 12px 8px;
    border-radius: 0;
    font-size: .75rem;
    justify-content: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border-bottom: 3px solid transparent;
    transition: all .2s;
  }

  .nav-item:hover {
    background: #1e293b;
  }

  .nav-item.active {
    background: #0f172a;
    border-bottom-color: #6366f1;
    color: #6366f1;
  }

  .feed-wrap {
    padding-bottom: 40px;
  }

  .page-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
    background: #0f172a;
    padding: 12px 14px;
  }

  .header-logout {
    padding: 7px 9px;
  }

  .header-logout span {
    display: none;
  }

  .page-content {
    padding-top: 70px;
  }

  .chat-layout {
    display: block;
    overflow: hidden;
    height: calc(100dvh - 135px);
  }

  .friend-list,
  .chat-thread {
    width: 100%;
    height: calc(100dvh - 135px);
    min-height: 0;
    overflow: hidden;
  }

  .chat-thread {
    display: flex;
    flex-direction: column;
  }

  .chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }

  .bubble {
    max-width: 78%;
  }

  .friend-list {
    border-right: none;
  }

  .chat-layout.has-active .friend-list {
    display: none;
  }

  .chat-layout:not(.has-active) .chat-thread {
    display: none;
  }

  .chat-thread-header {
    display: flex;
    align-items: center;
  }

  .chat-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .chat-empty-state {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
  }

  .feed-wrap > * { max-width: 100%; }
  .compose-box { max-width: 100%; }
  .post-card { max-width: 100%; }
  .toast { bottom: 80px; }

  .post-modal-backdrop {
    padding: 0;
    align-items: stretch;
  }

  .post-modal {
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .post-modal-layout {
    grid-template-columns: 1fr;
    min-height: 100vh;
    max-height: 100vh;
  }

  .post-modal-media {
    display: none;
  }

  .post-modal-side {
    border-left: none;
  }

  .post-modal-comment-form {
    padding: 14px 12px;
  }
}
