:root {
  --bg: #070708;
  --surface: #101012;
  --surface-2: #171719;
  --surface-3: #1d1d20;
  --border: rgba(255,255,255,.09);
  --text: #f5f5f7;
  --muted: #8f8f96;
  --muted-2: #68686f;
  --accent: #b84cff;
  --accent-2: #5d7cff;
  --danger: #ff4567;
  --radius: 18px;
  --online: #22c55e;
}

body.light-mode {
  --bg: #f4f4f6;
  --surface: #ffffff;
  --surface-2: #f0f0f3;
  --surface-3: #e6e6ea;
  --border: rgba(0,0,0,.08);
  --text: #111114;
  --muted: #6b6b73;
  --muted-2: #9a9aa3;
  --accent: #a020f0;
  --accent-2: #4f6ef7;
  --danger: #e11d48;
}

body.light-mode .topbar { background: rgba(244,244,246,.88); }
body.light-mode .bottom-nav {
  background: rgba(255,255,255,.94);
  border-color: rgba(0,0,0,.08);
  box-shadow: 0 15px 45px rgba(0,0,0,.12);
}
body.light-mode .nav-item { color: #8a8a93; }
body.light-mode .nav-item.active { color: #111114; }
body.light-mode .nav-item.active::after { background: #a020f0; }
body.light-mode .auth-screen { background: #f4f4f6; }
body.light-mode .auth-card {
  background: #ffffff;
  border-color: rgba(0,0,0,.08);
  box-shadow: 0 30px 90px rgba(0,0,0,.12);
}
body.light-mode .auth-field input {
  background: #f0f0f3;
  color: #111114;
  border-color: rgba(0,0,0,.1);
}
body.light-mode .auth-subtitle,
body.light-mode .auth-switch { color: #6b6b73; }
body.light-mode .auth-switch button { color: #111114; }
body.light-mode .modal-backdrop { background: rgba(0,0,0,.45); }
body.light-mode .analysis-modal,
body.light-mode .edit-modal,
body.light-mode .post-options-sheet,
body.light-mode .onboarding-card {
  background: #ffffff;
  border-color: rgba(0,0,0,.08);
  box-shadow: 0 30px 80px rgba(0,0,0,.15);
}
body.light-mode .chat-space,
body.light-mode .chat-view { background: var(--bg); }
body.light-mode .chat-header,
body.light-mode .chat-input-row { background: var(--surface); }
body.light-mode .search-panel { background: rgba(244,244,246,.97); }
body.light-mode .profile-cover { border-bottom: 1px solid var(--border); }
body.light-mode .follow-btn { background: #111114; color: #ffffff; }
body.light-mode .follow-btn.following {
  background: var(--surface-3);
  color: var(--text);
}
body.light-mode .post-btn,
body.light-mode .save-profile-btn,
body.light-mode .empty-state .empty-action,
body.light-mode .auth-submit,
body.light-mode .comment-submit,
body.light-mode .reply-submit,
body.light-mode #sendMessageBtn,
body.light-mode .ob-next {
  color: #ffffff;
}
body.light-mode .skeleton {
  background: linear-gradient(90deg, #e8e8ec 25%, #f5f5f7 50%, #e8e8ec 75%);
  background-size: 200% 100%;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: "Inter", sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
  overscroll-behavior: none;
}
button, input, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
.app { min-height: 100vh; padding-bottom: 95px; }

/* ONBOARDING */
.onboarding-screen {
  position: fixed; inset: 0; z-index: 1100;
  display: grid; place-items: center; padding: 20px; background: #070708;
}
.onboarding-screen.hidden { display: none !important; }
body.light-mode .onboarding-screen { background: #f4f4f6; }
.onboarding-card {
  width: min(420px, 100%);
  padding: 28px 26px 30px;
  background: #101012;
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 30px 90px rgba(0,0,0,.55);
}
.onboarding-progress {
  display: flex; justify-content: center; gap: 8px; margin-bottom: 28px;
}
.ob-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--surface-3); transition: .2s ease;
}
.ob-dot.active {
  width: 22px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.ob-step { display: none; text-align: center; }
.ob-step.active { display: block; }
.ob-emoji { font-size: 42px; margin-bottom: 14px; line-height: 1; }
.ob-step h2 { font-size: 22px; letter-spacing: -.4px; margin-bottom: 8px; }
.ob-step p { color: var(--muted); font-size: 14px; line-height: 1.5; margin-bottom: 22px; }
.ob-label {
  display: block; text-align: left; color: var(--muted); font-size: 12px; margin-bottom: 7px;
}
#obName {
  width: 100%; padding: 13px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  outline: none; margin-bottom: 14px;
}
#obName:focus { border-color: rgba(184,76,255,.55); }
.ob-next {
  width: 100%; padding: 13px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white; font-weight: 700; font-size: 14px;
}
.ob-next:active { transform: scale(.98); }
.ob-skip {
  width: 100%; margin-top: 10px; padding: 12px; border-radius: 12px;
  background: transparent; color: var(--muted); font-size: 13px;
}
.ob-skip:hover { color: var(--text); }

/* TOP BAR */
.topbar {
  height: 70px; position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; background: rgba(7,7,8,.82); backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: white; font-weight: 800;
}
.brand-name { font-size: 21px; font-weight: 800; letter-spacing: -.5px; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%;
  background: transparent; color: var(--text);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, #242429, #424249); color: white; font-weight: 700;
  flex-shrink: 0; overflow: hidden; position: relative;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.mini-avatar { width: 36px; height: 36px; }
.avatar.online::after {
  content: "";
  position: absolute; right: 0; bottom: 0;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--online); border: 2px solid var(--bg);
}
.presence-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--online); margin-right: 6px; vertical-align: middle;
}

/* SEARCH */
.search-panel {
  position: fixed; top: 70px; left: 0; right: 0; z-index: 40; padding: 15px 20px;
  background: rgba(7,7,8,.97); border-bottom: 1px solid var(--border);
}
.search-box {
  max-width: 700px; margin: auto; height: 48px; display: flex; align-items: center; gap: 10px;
  padding: 0 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px;
}
.search-box svg { width: 19px; height: 19px; fill: none; stroke: var(--muted); stroke-width: 2; }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; }
.search-results { max-width: 700px; margin: 10px auto 0; }
.search-result {
  padding: 13px; border-radius: 12px; display: flex; align-items: center; gap: 12px; cursor: pointer;
}
.search-result:hover { background: var(--surface-2); }

.main-content { width: min(720px, 100%); margin: auto; padding: 25px 18px; }
.page { display: none; }
.page.active { display: block; }

.home-header, .page-heading {
  display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 22px; gap: 16px;
}
.home-header h1, .page-heading h1 { font-size: 26px; letter-spacing: -.8px; }
.home-header p, .page-heading p { margin-top: 5px; color: var(--muted); font-size: 13px; }

.twyn-category-select, .post-category-select {
  appearance: none; -webkit-appearance: none; min-width: 140px;
  padding: 10px 36px 10px 16px; font-size: 14px; font-weight: 600; color: var(--text);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238f8f96' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 14px center;
  border: 1px solid var(--border); border-radius: 12px; cursor: pointer; outline: none;
}
.post-category-select { width: 100%; margin: 12px 0 4px; }

/* POSTS */
.post { padding: 18px 0; border-bottom: 1px solid var(--border); }
.post-header { display: flex; align-items: center; justify-content: space-between; }
.user-info { display: flex; align-items: center; gap: 11px; cursor: pointer; }
.user-details strong {
  display: inline-flex; align-items: center; gap: 0; font-size: 14px;
}
.user-details span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.post-menu {
  width: 35px; height: 35px; border-radius: 50%; background: transparent; color: var(--muted); font-size: 20px;
}
.post-menu:hover { background: var(--surface-2); color: var(--text); }
.post-category {
  display: inline-block; margin: 10px 0 0; padding: 4px 10px; font-size: 11px; font-weight: 600;
  color: var(--accent); background: rgba(184,76,255,.12); border-radius: 999px;
}
.post-text {
  margin: 12px 0 4px; line-height: 1.55; font-size: 14.5px; white-space: pre-wrap;
}
.post-media {
  width: 100%; max-height: 280px; object-fit: cover; border-radius: 16px;
  border: 1px solid var(--border); margin-top: 12px; cursor: pointer;
}
.post-actions {
  display: flex; align-items: center; gap: 6px; margin-top: 12px;
}
.post-action {
  min-width: 45px; height: 38px; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 10px; border-radius: 10px; color: var(--muted); background: transparent;
  transition: transform .15s ease, color .15s ease, background .15s ease;
}
.post-action:hover { color: var(--text); background: var(--surface-2); }
.post-action.liked { color: #ff5475; }
.post-action.saved { color: #9dffbd; }
body.light-mode .post-action.saved { color: #16a34a; }
.post-action.pop { animation: action-pop .35s ease; }
@keyframes action-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.22); }
  100% { transform: scale(1); }
}
.post-time { margin-left: auto; color: var(--muted-2); font-size: 11px; }

/* VERIFIED BADGE — clean X/Twitter style tick */
.verified-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  margin-left: 4px;
  border-radius: 50%;
  background: #1d9bf0;
  color: #fff;
  flex-shrink: 0;
  vertical-align: middle;
  position: relative;
  top: 0;
  box-shadow: none;
  line-height: 0;
}
.verified-badge::before {
  content: "";
  display: block;
  width: 8px;
  height: 4.5px;
  border-left: 1.8px solid #fff;
  border-bottom: 1.8px solid #fff;
  transform: rotate(-45deg) translateY(-0.5px);
  box-sizing: border-box;
}
/* Feed / post header */
.user-details strong .verified-badge,
.post-user strong .verified-badge {
  width: 15px;
  height: 15px;
  margin-left: 4px;
}
/* Comments */
.comment-author .verified-badge,
.comment-author strong .verified-badge {
  width: 14px;
  height: 14px;
  margin-left: 4px;
}
.comment-author .verified-badge::before {
  width: 7px;
  height: 4px;
  border-left-width: 1.6px;
  border-bottom-width: 1.6px;
}
/* Profile title */
.profile-info h1 .verified-badge {
  width: 20px;
  height: 20px;
  margin-left: 6px;
}
.profile-info h1 .verified-badge::before {
  width: 10px;
  height: 5.5px;
  border-left-width: 2px;
  border-bottom-width: 2px;
}
/* Chat header */
.chat-header-info .verified-badge {
  width: 14px;
  height: 14px;
}
.user-details strong,
.comment-author strong,
.person-info strong,
.conversation-info strong,
.profile-info h1,
.chat-header-info {
  display: inline-flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
}

/* COMMENTS */
.comments-container { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.comments-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.no-comments { color: var(--muted); font-size: 13px; padding: 8px 0; }
.comment { display: flex; gap: 10px; }
.comment-avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, #242429, #424249); font-size: 13px; font-weight: 700;
  flex-shrink: 0; overflow: hidden; cursor: pointer;
}
.comment-avatar img { width: 100%; height: 100%; object-fit: cover; }
.comment-body { flex: 1; min-width: 0; }
.comment-author {
  display: flex; gap: 6px; align-items: center; font-size: 13px; flex-wrap: wrap;
}
.comment-author strong {
  display: inline-flex; align-items: center; gap: 0; cursor: pointer;
}
.comment-author span { color: var(--muted); font-size: 12px; }
.comment-text { margin-top: 3px; font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; }
.comment-meta {
  display: flex; align-items: center; gap: 12px; margin-top: 6px; flex-wrap: wrap;
}
.comment-time { color: var(--muted-2); font-size: 11px; }
.comment-like-btn, .comment-reply-btn, .comment-delete-btn, .replies-toggle {
  background: transparent; color: var(--muted); font-size: 12px; padding: 0; cursor: pointer;
}
.comment-like-btn:hover, .comment-reply-btn:hover, .replies-toggle:hover { color: var(--text); }
.comment-delete-btn:hover { color: var(--danger); }
.comment-like-btn.liked { color: #ff5475; }
.comment-form, .reply-form { display: flex; gap: 8px; margin-top: 8px; }
.comment-input, .reply-input {
  flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); outline: none; font-size: 13px;
}
.comment-submit, .reply-submit {
  padding: 0 14px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white; font-weight: 600; font-size: 13px;
}
.replies {
  margin-top: 10px;
  margin-left: 0;
  padding-left: 0;
  border-left: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.comment-reply {
  /* single indent only — IG/TikTok style */
  margin-left: 44px;
  max-width: calc(100% - 44px);
}
.replies.collapsed { display: none; }
.replies-toggle {
  margin-top: 6px;
  margin-left: 44px;
  padding: 6px 0;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
}
.replies-toggle:hover { color: var(--text); }
.comment-text {
  margin-top: 3px;
  font-size: 13.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.comment-body { flex: 1; min-width: 0; max-width: 100%; }

.replies-toggle { margin-top: 8px; padding: 6px 0; font-weight: 600; color: var(--accent-2); min-height: 32px; }

/* FRIENDS */
.friend-tabs, .inbox-tabs {
  display: flex; gap: 5px; padding: 5px; margin-bottom: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
}
.friend-tab, .inbox-tab {
  flex: 1; padding: 10px; color: var(--muted); background: transparent; border-radius: 10px;
}
.friend-tab.active, .inbox-tab.active { color: var(--text); background: var(--surface-3); }
.person-card {
  display: flex; align-items: center; gap: 13px; padding: 15px 0; border-bottom: 1px solid var(--border);
}
.person-card .avatar, .person-info { cursor: pointer; }
.person-info { flex: 1; }
.person-info strong { display: inline-flex; align-items: center; gap: 0; }
.person-info span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.follow-btn {
  padding: 8px 15px; border-radius: 10px; background: white; color: black; font-weight: 600;
  transition: transform .15s ease;
}
.follow-btn.following {
  background: var(--surface-3); color: var(--text); border: 1px solid var(--border);
}
.follow-btn.pop { animation: action-pop .35s ease; }

/* CREATE */
.create-card {
  padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.create-user { display: flex; align-items: center; gap: 11px; margin-bottom: 20px; }
.create-user strong, .create-user span { display: block; }
.create-user span { margin-top: 3px; color: var(--muted); font-size: 12px; }
#postText, #editPostText {
  width: 100%; min-height: 170px; resize: vertical; border: 0; outline: 0;
  color: var(--text); background: transparent; font-size: 18px; line-height: 1.5;
}
#editPostText { min-height: 120px; font-size: 16px; }
#postText::placeholder, #editPostText::placeholder { color: var(--muted-2); }
.create-preview img {
  width: 100%; max-height: 280px; object-fit: cover; border-radius: 14px; margin-bottom: 15px;
}
.create-tools { display: flex; gap: 8px; padding: 14px 0; border-top: 1px solid var(--border); }
.tool-btn {
  display: flex; align-items: center; gap: 6px; padding: 8px 11px; color: var(--muted);
  background: var(--surface-2); border-radius: 10px; font-size: 12px;
}
.create-bottom { display: flex; justify-content: space-between; align-items: center; }
#characterCount, #editPostCount { color: var(--muted); font-size: 11px; }
.post-btn, .save-profile-btn {
  padding: 10px 19px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white; font-weight: 700;
}

/* INBOX */
.inbox-panel { min-height: 200px; }
.notification {
  display: flex; align-items: center; gap: 13px; padding: 17px 0;
  border-bottom: 1px solid var(--border); cursor: pointer; position: relative;
}
.notification:hover {
  background: var(--surface-2); border-radius: 12px; padding-left: 8px; padding-right: 8px;
}
.notification.unread {
  background: rgba(184, 76, 255, 0.08); border-radius: 12px; padding-left: 8px; padding-right: 8px;
}
.notification.unread::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0;
}
.notification-icon {
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%;
  background: var(--surface-2); font-size: 18px; flex-shrink: 0;
}
.like-icon { color: #ff5475; }
.comment-icon { color: #6c8cff; }
.notification strong, .notification span { display: block; }
.notification span { margin-top: 4px; color: var(--muted); font-size: 11px; }

.messages-layout { position: relative; min-height: 420px; }
.conversations-list {
  display: flex; flex-direction: column;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.conversation-item {
  display: flex; align-items: center; gap: 12px; padding: 14px 0;
  border-bottom: 1px solid var(--border); cursor: pointer;
}
.conversation-item:hover {
  background: var(--surface-2); border-radius: 12px; padding-left: 8px; padding-right: 8px;
}
.conversation-item.unread-chat .conversation-info span {
  color: var(--text); font-weight: 600;
}
.conversation-info { flex: 1; min-width: 0; }
.conversation-info strong {
  display: inline-flex; align-items: center; gap: 0; font-size: 14px;
}
.conversation-info span {
  display: block; margin-top: 3px; color: var(--muted); font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-unread-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex-shrink: 0;
}

/* FULL SCREEN CHAT */
.chat-space {
  position: fixed; inset: 0; z-index: 120; background: var(--bg);
}
.chat-space.hidden { display: none !important; }
.chat-view {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; background: var(--bg);
}
.chat-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.chat-back-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface-2); color: var(--text); font-size: 20px;
  display: grid; place-items: center; flex-shrink: 0; border: none; cursor: pointer;
  position: relative; z-index: 20;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}
.chat-back-btn:active { transform: scale(0.92); background: var(--surface-3); }
.chat-header {
  position: relative;
  z-index: 10;
  pointer-events: auto;
}

.chat-header-info {
  display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; min-width: 0;
}
.chat-header-meta { display: flex; flex-direction: column; min-width: 0; }
.chat-header-meta strong {
  display: inline-flex; align-items: center; gap: 0; font-size: 15px;
}
.chat-header-meta span {
  font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 2px;
}
.chat-header-meta span.is-online { color: var(--online); }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.chat-bubble {
  max-width: 78%; padding: 10px 14px; border-radius: 18px;
  font-size: 14px; line-height: 1.4; animation: bubble-in .22s ease;
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(8px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.chat-bubble.mine {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white; border-bottom-right-radius: 5px;
}
.chat-bubble.theirs {
  align-self: flex-start; background: var(--surface-2); color: var(--text);
  border-bottom-left-radius: 5px;
}
.chat-bubble time {
  display: block; margin-top: 4px; font-size: 10px; opacity: 0.7;
}
.chat-bubble .seen-label {
  display: block; margin-top: 2px; font-size: 10px; opacity: 0.95; font-weight: 600;
}
.chat-bubble img {
  max-width: 220px; border-radius: 14px; display: block; margin-bottom: 4px;
}
.chat-bubble audio { width: 220px; height: 36px; margin-bottom: 4px; }
.chat-input-row {
  display: flex; gap: 8px; padding: 12px 14px;
  border-top: 1px solid var(--border); background: var(--surface); flex-shrink: 0;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  align-items: center;
}
.chat-input-row input[type="text"] {
  flex: 1; padding: 12px 14px; border: 1px solid var(--border); border-radius: 22px;
  background: var(--surface-2); color: var(--text); outline: none;
}
.chat-input-row button#sendMessageBtn {
  padding: 0 18px; height: 42px; border-radius: 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white; font-weight: 600;
}
.chat-input-row button#sendMessageBtn.pop { animation: action-pop .3s ease; }
.chat-media-btn {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); color: var(--text); font-size: 16px;
  cursor: pointer; flex-shrink: 0; border: none;
}
.chat-media-btn.recording {
  background: #ff4567; color: white; animation: pulse-rec 1s infinite;
}
@keyframes pulse-rec {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
body.chat-open .bottom-nav,
body.chat-open .topbar,
body.chat-open .app { visibility: hidden; pointer-events: none; }

/* PROFILE */
.profile-cover {
  height: 150px; margin: -25px -18px 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(184,76,255,.35), transparent 30%),
    radial-gradient(circle at 80% 70%, rgba(93,124,255,.3), transparent 30%),
    #111116;
  background-size: cover; background-position: center;
  position: relative; z-index: 0; overflow: hidden;
}
.profile-cover.has-image { background-image: none; }
.profile-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-main { position: relative; z-index: 2; }
.profile-top {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-top: -40px; gap: 12px; position: relative; z-index: 3;
}
.profile-actions {
  display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; position: relative; z-index: 4;
}
.profile-avatar {
  width: 80px; height: 80px; border: 4px solid var(--bg); font-size: 25px;
  position: relative; z-index: 4;
  background: linear-gradient(135deg, #242429, #424249);
}
.edit-profile-btn {
  padding: 9px 15px; border-radius: 10px; background: var(--surface);
  color: var(--text); border: 1px solid var(--border);
}
.profile-info { margin-top: 13px; }
.profile-info h1 {
  display: inline-flex; align-items: center; gap: 0; font-size: 21px;
}
.profile-info > span { color: var(--muted); font-size: 13px; }
.profile-presence {
  margin-top: 6px; font-size: 12.5px; color: var(--muted);
  display: flex; align-items: center;
}
.profile-presence.is-online { color: var(--online); }
.profile-info p { margin-top: 12px; font-size: 14px; }
.profile-stats { display: flex; gap: 35px; margin: 22px 0; }
.profile-stats strong, .profile-stats span { display: block; }
.profile-stats span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.profile-worlds {
  padding: 17px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.profile-worlds h3 { font-size: 14px; margin-bottom: 10px; }
.profile-chips { display: flex; gap: 7px; flex-wrap: wrap; }
.profile-chips span {
  padding: 7px 11px; border-radius: 999px; background: var(--surface-2);
  color: var(--muted); font-size: 11px;
}
.profile-posts-header {
  display: flex; border-bottom: 1px solid var(--border); margin-top: 10px;
}
.profile-posts-header button {
  flex: 1; padding: 15px; background: transparent; color: var(--muted);
}
.profile-posts-header button.active {
  color: var(--text); border-bottom: 2px solid var(--text);
}
#otherProfileBack { margin-bottom: 4px; }

.cover-edit-section {
  display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 18px;
}
.cover-edit-preview {
  width: 100%; height: 110px; border-radius: 14px; overflow: hidden;
  background:
    radial-gradient(circle at 20% 30%, rgba(184,76,255,.35), transparent 30%),
    radial-gradient(circle at 80% 70%, rgba(93,124,255,.3), transparent 30%),
    #111116;
  border: 1px solid var(--border);
}
.cover-edit-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-edit-section {
  display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 20px;
}
.profile-avatar-edit {
  width: 90px; height: 90px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, #242429, #424249); font-size: 28px; font-weight: 700;
  overflow: hidden; border: 3px solid var(--border);
}
.profile-avatar-edit img { width: 100%; height: 100%; object-fit: cover; }
.avatar-upload-btn {
  padding: 8px 16px; border-radius: 10px; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); font-size: 13px; cursor: pointer;
}

/* SETTINGS */
.settings-list { display: flex; flex-direction: column; gap: 6px; }
.settings-item {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  padding: 16px 18px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; color: var(--text); font-size: 14px; text-align: left;
}
.settings-item:hover { background: var(--surface-2); }
.settings-item.danger { color: #ff5475; margin-top: 18px; }
.settings-item span:last-child { color: var(--muted); }
.toggle-item { cursor: default; }
.toggle-item:hover { background: var(--surface); }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0; background: var(--surface-3);
  border-radius: 999px; transition: .2s;
}
.slider:before {
  position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.switch input:checked + .slider:before { transform: translateX(20px); }

.feed-loader { text-align: center; padding: 28px 16px; color: var(--muted); font-size: 13px; }
.feed-loader.hidden { display: none; }

/* BOTTOM NAV */
.bottom-nav {
  position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 100;
  width: min(680px, calc(100% - 20px)); height: 78px;
  display: grid; grid-template-columns: 1fr 1fr 1.1fr 1fr 1fr; align-items: center;
  padding: 6px 10px; background: rgba(12,12,14,.94); backdrop-filter: blur(22px);
  border: 1px solid rgba(255,255,255,.1); border-radius: 25px;
  box-shadow: 0 15px 45px rgba(0,0,0,.45);
}
.nav-item {
  position: relative; height: 66px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 5px; color: #77777f; background: transparent;
}
.nav-item:hover { color: var(--text); }
.nav-item.active { color: white; }
.nav-item.active::after {
  content: ""; position: absolute; bottom: 2px; width: 5px; height: 5px;
  border-radius: 50%; background: #d54dff;
}
.nav-item svg {
  width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
}
.nav-item span { font-size: 10px; font-weight: 600; }
.create-nav {
  width: 55px; height: 55px; justify-self: center; border-radius: 18px;
  background: linear-gradient(135deg, #d72cff, #556dff); color: white;
  box-shadow: 0 7px 25px rgba(168,62,255,.35);
}
.create-nav span { font-size: 33px; font-weight: 400; line-height: 1; }
.nav-icon-wrap { position: relative; }
.notification-badge {
  position: absolute; top: -8px; right: -12px; min-width: 17px; height: 17px; padding: 0 4px;
  display: none; place-items: center; border-radius: 999px; background: var(--danger);
  color: white; font-size: 9px !important;
}

/* ========== SCROLLABLE SHEET MODALS ========== */
.modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
}
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.72); backdrop-filter: blur(7px);
  touch-action: none;
}
.analysis-modal {
  position: relative; z-index: 2; width: min(450px, 100%);
  margin: 18px; padding: 22px;
  background: #121214; border: 1px solid var(--border); border-radius: 22px;
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
  max-height: min(90vh, 640px); overflow-y: auto;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.edit-modal.sheet-modal {
  position: relative; z-index: 2;
  width: min(480px, 100%);
  max-height: min(92vh, 720px);
  margin: 0;
  padding: 0;
  background: #121214;
  border: 1px solid var(--border);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -10px 60px rgba(0,0,0,.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  touch-action: pan-y;
}
.sheet-handle {
  width: 42px; height: 4px; border-radius: 999px;
  background: rgba(255,255,255,.18);
  margin: 10px auto 0; flex-shrink: 0;
}
body.light-mode .sheet-handle { background: rgba(0,0,0,.15); }
.sheet-modal .modal-header {
  flex-shrink: 0;
  padding: 14px 22px 10px;
  margin-bottom: 0;
}
.sheet-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 8px 22px 16px;
  min-height: 0;
}
.sheet-footer {
  flex-shrink: 0;
  padding: 12px 22px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: #121214;
}
body.light-mode .sheet-footer,
body.light-mode .edit-modal.sheet-modal { background: #ffffff; }
.sheet-footer .save-profile-btn { width: 100%; margin-top: 0; }

.modal-header {
  display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px;
}
.modal-header h2 { font-size: 19px; }
.modal-header span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.close-modal {
  width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2);
  color: var(--text); font-size: 20px;
}
.pulse-card {
  padding: 20px; margin-bottom: 12px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(184,76,255,.13), rgba(93,124,255,.08));
  border: 1px solid rgba(184,76,255,.15);
}
.pulse-card span, .pulse-card strong, .pulse-card p { display: block; }
.pulse-card span { color: var(--muted); font-size: 11px; }
.pulse-card strong { margin-top: 7px; font-size: 31px; }
.pulse-card p { margin-top: 6px; color: var(--muted); font-size: 12px; }
.analytics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.analytics-item {
  padding: 17px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
}
.analytics-item span, .analytics-item strong { display: block; }
.analytics-item span { color: var(--muted); font-size: 11px; }
.analytics-item strong { margin-top: 7px; font-size: 21px; }

.edit-modal label { display: block; margin-bottom: 15px; color: var(--muted); font-size: 12px; }
.edit-modal input, .edit-modal textarea {
  width: 100%; margin-top: 7px; padding: 12px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 11px; outline: 0;
}
.edit-modal textarea { min-height: 90px; resize: vertical; }

.post-options-sheet {
  position: relative; z-index: 2; width: min(420px, 100%);
  margin-top: auto; padding: 12px 12px 20px;
  background: #151518; border: 1px solid var(--border);
  border-radius: 22px 22px 18px 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
  display: flex; flex-direction: column; gap: 4px;
}
.post-options-handle {
  width: 42px; height: 4px; border-radius: 999px;
  background: rgba(255,255,255,.18); margin: 4px auto 10px;
}
.post-option {
  width: 100%; padding: 14px 16px; border-radius: 14px;
  background: transparent; color: var(--text); text-align: left;
  font-size: 15px; font-weight: 500;
}
.post-option:hover { background: var(--surface-2); }
.post-option.danger { color: #ff5475; }
.post-option.cancel {
  margin-top: 6px; text-align: center; color: var(--muted); background: var(--surface-2);
}
.post-option.hidden { display: none; }

.lightbox-content {
  position: relative; z-index: 2; max-width: 95vw; max-height: 90vh;
  display: flex; align-items: center; justify-content: center;
}
.lightbox-content img {
  max-width: 100%; max-height: 85vh; border-radius: 16px; object-fit: contain;
}
.lightbox-close {
  position: absolute; top: -42px; right: 0; width: 36px; height: 36px;
  border-radius: 50%; background: var(--surface-2); color: var(--text);
  font-size: 22px; display: grid; place-items: center; border: none;
}

.hidden { display: none !important; }
.empty-state { padding: 60px 24px; text-align: center; color: var(--muted); }
.empty-state .empty-icon { font-size: 42px; margin-bottom: 16px; opacity: 0.7; }
.empty-state strong { display: block; color: var(--text); font-size: 17px; margin-bottom: 8px; }
.empty-state span {
  display: block; font-size: 13.5px; line-height: 1.5; max-width: 280px; margin: 0 auto 18px;
}
.empty-state .empty-action {
  display: inline-block; padding: 10px 18px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white; font-weight: 600; font-size: 13px; cursor: pointer; border: none;
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.4s ease-in-out infinite;
  border-radius: 8px;
}
@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-post { padding: 18px 0; border-bottom: 1px solid var(--border); }
.skeleton-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.skeleton-avatar { width: 42px; height: 42px; border-radius: 50%; }
.skeleton-lines { flex: 1; }
.skeleton-line { height: 12px; margin-bottom: 8px; }
.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 70%; }
.skeleton-line.long { width: 90%; }
.skeleton-media { width: 100%; height: 280px; border-radius: 16px; margin: 12px 0; }
.skeleton-actions { display: flex; gap: 16px; margin-top: 12px; }
.skeleton-action { width: 50px; height: 18px; border-radius: 6px; }

@media (min-width: 900px) {
  .main-content { width: 760px; }
  .topbar {
    padding-left: calc((100% - 1100px) / 2);
    padding-right: calc((100% - 1100px) / 2);
  }
  .chat-view {
    left: 50%; transform: translateX(-50%);
    width: min(760px, 100%);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
  .modal { align-items: center; padding: 18px; }
  .edit-modal.sheet-modal {
    border-radius: 22px;
    max-height: min(88vh, 680px);
  }
}
@media (max-width: 500px) {
  .topbar { height: 62px; padding: 0 16px; }
  .main-content { padding: 20px 14px; }
  .profile-cover { margin-left: -14px; margin-right: -14px; }
  .bottom-nav { height: 72px; bottom: 7px; border-radius: 22px; }
  .nav-item { height: 60px; }
  .create-nav { width: 52px; height: 52px; }
  .profile-actions { flex-direction: column; align-items: flex-end; }
}

/* ========== STORIES ========== */
.stories-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 4px 0 18px;
  margin-bottom: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
.stories-row::-webkit-scrollbar { display: none; }
.stories-list {
  display: flex;
  gap: 12px;
  flex: 1;
}
.story-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--text);
  min-width: 68px;
  cursor: pointer;
}
.story-item span {
  font-size: 11px;
  color: var(--muted);
  max-width: 68px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.story-ring {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  padding: 2px;
  background: linear-gradient(135deg, #f58529, #dd2a7b, #8134af, #515bd4);
}
.story-ring.seen {
  background: var(--border);
}
.story-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--bg);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-weight: 700;
  font-size: 18px;
}
.story-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.story-add .story-ring {
  background: var(--surface-3);
}
.story-add .story-avatar {
  font-size: 28px;
  color: var(--accent);
  background: var(--surface);
}

.story-viewer {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.story-viewer.hidden { display: none !important; }
.story-viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.story-viewer-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 12px 14px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  z-index: 2;
  background: linear-gradient(to bottom, rgba(0,0,0,.55), transparent);
}
.story-progress {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}
.story-progress span {
  flex: 1;
  height: 3px;
  border-radius: 999px;
  background: rgba(255,255,255,.25);
  overflow: hidden;
}
.story-progress span i {
  display: block;
  height: 100%;
  width: 0%;
  background: #fff;
}
.story-progress span.done i { width: 100%; }
.story-progress span.active i {
  animation: story-bar linear forwards;
}
@keyframes story-bar {
  from { width: 0%; }
  to { width: 100%; }
}
.story-viewer-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}
.story-viewer-close {
  position: absolute;
  top: calc(40px + env(safe-area-inset-top, 0px));
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: 22px;
  border: none;
  cursor: pointer;
}
.story-nav {
  position: absolute;
  top: 0; bottom: 0;
  width: 40%;
  background: transparent;
  border: none;
  cursor: pointer;
}
.story-prev { left: 0; }
.story-next { right: 0; }

/* Smoother post updates — no layout jump */
.post {
  transition: background-color .2s ease;
}
.post-action span {
  transition: transform .15s ease;
}
.post.updating {
  pointer-events: none;
}

/* Story like + reply bar */
.story-viewer-bottom {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, rgba(0,0,0,.7), transparent);
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.story-like-btn {
  align-self: flex-start;
  background: rgba(255,255,255,.12);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.story-like-btn.liked { color: #ff5475; background: rgba(255,84,117,.2); }
.story-reply-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.story-reply-row input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.1);
  color: #fff;
  outline: none;
}
.story-reply-row input::placeholder { color: rgba(255,255,255,.55); }
.story-reply-row button {
  padding: 0 16px;
  height: 42px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 600;
  border: none;
}

/* Replies indent — one clear step to the right */
.comment-like-btn.liked { color: #ff5475; }

/* Mentions */
.mention {
  color: var(--accent-2);
  font-weight: 600;
  cursor: pointer;
}
.mention:hover { text-decoration: underline; }


/* ========== TWYN CHAT BUBBLES ========== */
.chat-messages {
  background: var(--bg);
  gap: 6px;
  padding: 12px 10px 16px;
}
.chat-bubble {
  max-width: 82%;
  padding: 8px 10px 6px 12px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.4;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
.chat-bubble.mine {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-bubble.theirs {
  align-self: flex-start;
  background: var(--surface-2);
  color: var(--text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}
.chat-bubble .chat-reply-quote {
  display: block;
  margin: 0 0 6px;
  padding: 6px 8px;
  border-radius: 8px;
  border-left: 3px solid rgba(255,255,255,.7);
  background: rgba(0,0,0,.18);
  font-size: 12.5px;
  line-height: 1.3;
}
.chat-bubble.theirs .chat-reply-quote {
  border-left-color: var(--accent);
  background: rgba(184,76,255,.1);
}
.chat-reply-quote strong {
  display: block;
  font-size: 12px;
  margin-bottom: 2px;
  opacity: 0.95;
}
.chat-bubble.theirs .chat-reply-quote strong { color: var(--accent-2); }
.chat-reply-quote span {
  display: block;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.chat-bubble .chat-msg-text {
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-bubble .chat-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
}
.chat-bubble time {
  display: inline;
  margin: 0;
  font-size: 11px;
  opacity: 0.75;
}
.chat-bubble .chat-ticks {
  font-size: 12px;
  opacity: 0.9;
}
.chat-bubble .chat-edited {
  font-size: 11px;
  opacity: 0.7;
  font-style: italic;
  margin-right: 4px;
}
.chat-bubble img {
  max-width: 240px;
  border-radius: 10px;
  display: block;
  margin-bottom: 4px;
}
.chat-bubble-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  opacity: 0.85;
}
.chat-bubble-actions button {
  background: rgba(0,0,0,.15);
  border: none;
  color: inherit;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  cursor: pointer;
}
.chat-bubble.theirs .chat-bubble-actions button {
  background: var(--surface-3);
  color: var(--text);
}

.chat-reply-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.chat-reply-preview.hidden { display: none !important; }
.chat-reply-preview-body {
  flex: 1;
  min-width: 0;
  border-left: 3px solid var(--accent);
  padding-left: 10px;
}
.chat-reply-preview-body strong {
  display: block;
  font-size: 12px;
  color: var(--accent-2);
}
.chat-reply-preview-body span {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#chatReplyCancel {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-2); color: var(--text);
  font-size: 18px; border: none;
}

#msgActionSheet { z-index: 250; }

.story-delete-btn {
  position: absolute;
  top: calc(40px + env(safe-area-inset-top, 0px));
  right: 56px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,69,103,.95);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  z-index: 5;
}
.story-delete-btn.hidden { display: none !important; }

/* Daily prompt + MOTW + Lounge chip */
.daily-prompt {
  margin: 0 0 14px;
  padding: 14px 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(184,76,255,.14), rgba(93,124,255,.1));
  border: 1px solid rgba(184,76,255,.22);
}
.daily-prompt-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: 6px;
}
.daily-prompt-text {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 12px;
}
.daily-prompt-btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.motw-banner {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.motw-banner.hidden { display: none !important; }
.motw-banner strong { display: block; font-size: 13px; }
.motw-banner span { font-size: 12px; color: var(--muted); }
.lounge-chip {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.lounge-chip-icon { font-size: 22px; }
.lounge-chip strong { display: block; font-size: 14px; }
.lounge-chip small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.lounge-chip:hover { background: var(--surface-2); }

/* OG badge + frame */
.og-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 5px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .03em;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #fff;
  vertical-align: middle;
  position: relative;
  top: -1px;
}
.avatar.og-frame,
.profile-avatar.og-frame {
  box-shadow: 0 0 0 3px #f59e0b, 0 0 0 5px rgba(245,158,11,.35);
}
.motw-badge {
  display: inline-flex;
  margin-left: 4px;
  font-size: 12px;
}

/* Typing indicator */
.typing-indicator {
  padding: 4px 16px 8px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.typing-indicator.hidden { display: none !important; }
.typing-indicator span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--muted);
  animation: typing-dot 1.2s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: .15s; }
.typing-indicator span:nth-child(3) { animation-delay: .3s; }
@keyframes typing-dot {
  0%, 80%, 100% { opacity: .3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* Message reactions */
.chat-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.chat-reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0,0,0,.15);
  font-size: 12px;
  border: none;
  color: inherit;
  cursor: pointer;
}
.chat-bubble.theirs .chat-reaction-pill {
  background: var(--surface-3);
  color: var(--text);
}
.chat-reaction-pill.mine-react {
  outline: 1px solid rgba(255,255,255,.45);
}
.chat-react-picker {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}
.chat-bubble:hover .chat-react-picker,
.chat-bubble.show-reacts .chat-react-picker {
  opacity: 1;
  pointer-events: auto;
}
.chat-react-picker button {
  border: none;
  background: var(--surface);
  border-radius: 8px;
  padding: 2px 5px;
  font-size: 14px;
  cursor: pointer;
}

.story-react-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.story-react-bar button {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.12);
  font-size: 18px;
  cursor: pointer;
}
.story-views-label {
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  opacity: .9;
}
.story-views-label.hidden { display: none !important; }

.lounge-system {
  align-self: center;
  max-width: 90%;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 6px 10px;
  background: transparent;
  box-shadow: none;
}


/* Founder badge */
.founder-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 5px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .04em;
  background: linear-gradient(135deg, #b84cff, #5d7cff);
  color: #fff;
  vertical-align: middle;
  position: relative;
  top: -1px;
  box-shadow: 0 0 0 1px rgba(184,76,255,.35);
}
.avatar.founder-frame,
.profile-avatar.founder-frame {
  box-shadow: 0 0 0 3px #b84cff, 0 0 0 6px rgba(184,76,255,.3);
}

/* Modern chat bubbles v33 */
.chat-messages {
  background: var(--bg) !important;
  gap: 8px !important;
  padding: 14px 12px 18px !important;
}
.chat-bubble {
  max-width: 78% !important;
  padding: 10px 12px 8px !important;
  border-radius: 18px !important;
  font-size: 15px !important;
  line-height: 1.4 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.08) !important;
  border: none !important;
}
.chat-bubble.mine {
  background: linear-gradient(145deg, #c45cff, #5d7cff) !important;
  color: #fff !important;
  border-bottom-right-radius: 5px !important;
}
.chat-bubble.theirs {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-bottom-left-radius: 5px !important;
}
.chat-react-picker {
  display: none !important;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  gap: 4px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  z-index: 5;
  opacity: 1 !important;
  pointer-events: auto !important;
}
.chat-bubble.mine .chat-react-picker { left: auto; right: 0; }
.chat-bubble.show-reacts .chat-react-picker {
  display: flex !important;
}
.chat-react-picker button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  font-size: 16px;
  cursor: pointer;
}
.chat-react-picker button:active { transform: scale(1.15); }
.chat-bubble { position: relative; }
.messages-layout .lounge-chip { margin-bottom: 12px; }


/* Tonight polish — onboarding + invite + prompt */
.invite-home-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.invite-home-banner strong { display: block; font-size: 13px; }
.invite-home-banner span { font-size: 12px; color: var(--muted); }
.invite-home-banner button {
  padding: 8px 14px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
}
.ob-suggest {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0 16px;
  max-height: 180px;
  overflow-y: auto;
}
.ob-suggest-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.ob-suggest-row .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #242429, #424249);
  font-size: 13px; font-weight: 700; overflow: hidden; flex-shrink: 0;
}
.ob-suggest-row .avatar img { width: 100%; height: 100%; object-fit: cover; }
.ob-suggest-row .meta { flex: 1; min-width: 0; text-align: left; }
.ob-suggest-row .meta strong { display: block; font-size: 13px; }
.ob-suggest-row .meta span { font-size: 11px; color: var(--muted); }
.ob-suggest-row button {
  padding: 6px 12px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.ob-suggest-row button.following {
  background: var(--surface-3);
  color: var(--text);
}
.ob-suggest-loading { color: var(--muted); font-size: 13px; padding: 8px 0; }
.ob-next.secondary {
  background: var(--surface-2) !important;
  color: var(--text) !important;
  border: 1px solid var(--border);
}
.daily-prompt {
  border-color: rgba(184,76,255,.35) !important;
}
.chat-bubble.mine {
  box-shadow: 0 4px 14px rgba(184,76,255,.25) !important;
}

/* Smoothness pass */
.app, .page, .chat-space, .story-viewer, .modal {
  -webkit-font-smoothing: antialiased;
}
.post, .conversation-item, .story-item, .chat-bubble, .nav-item {
  transition: transform .15s ease, opacity .15s ease, background .15s ease;
}
.post-action.liked, .comment-like-btn.liked {
  transition: transform .18s ease, color .15s ease;
}
.page {
  animation: page-in .22s ease;
}
@keyframes page-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-messages, .feed, .conversations-list {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}
.daily-prompt-text {
  min-height: 2.4em;
  transition: opacity .2s ease;
}
.daily-prompt-btn:active {
  transform: scale(0.97);
}
img {
  content-visibility: auto;
}

/* Force clean verified tick everywhere (final) */
.verified-badge {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 15px !important;
  height: 15px !important;
  min-width: 15px !important;
  min-height: 15px !important;
  margin-left: 4px !important;
  border-radius: 50% !important;
  background: #1d9bf0 !important;
  color: transparent !important;
  font-size: 0 !important;
  font-weight: 400 !important;
  line-height: 0 !important;
  vertical-align: middle !important;
  flex-shrink: 0 !important;
  position: relative !important;
  top: 0 !important;
  box-shadow: none !important;
  border: none !important;
}
.verified-badge::before {
  content: "" !important;
  display: block !important;
  width: 8px !important;
  height: 4.5px !important;
  border-left: 1.8px solid #fff !important;
  border-bottom: 1.8px solid #fff !important;
  transform: rotate(-45deg) translateY(-0.5px) !important;
  box-sizing: border-box !important;
  background: none !important;
  font-size: 0 !important;
}
.profile-info h1 .verified-badge {
  width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
  min-height: 20px !important;
  margin-left: 6px !important;
}
.profile-info h1 .verified-badge::before {
  width: 10px !important;
  height: 5.5px !important;
  border-left-width: 2px !important;
  border-bottom-width: 2px !important;
}
.comment-author .verified-badge {
  width: 14px !important;
  height: 14px !important;
  min-width: 14px !important;
  min-height: 14px !important;
}
.comment-author .verified-badge::before {
  width: 7px !important;
  height: 4px !important;
  border-left-width: 1.6px !important;
  border-bottom-width: 1.6px !important;
}

/* Read receipts */
.chat-ticks {
  font-size: 13px !important;
  letter-spacing: -1.5px;
  opacity: 0.85;
  margin-left: 2px;
  font-weight: 600;
}
.chat-ticks.read {
  color: #53bdeb !important;
  opacity: 1 !important;
}
.chat-bubble.mine .chat-ticks {
  color: rgba(255,255,255,.85);
}
.chat-bubble.mine .chat-ticks.read {
  color: #a5e3f7 !important;
}

/* Multi photo posts */
.create-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.create-preview img {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.post-images {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.post-images.imgs-1 { grid-template-columns: 1fr; }
.post-images.imgs-2 { grid-template-columns: 1fr 1fr; }
.post-images.imgs-3,
.post-images.imgs-4 { grid-template-columns: 1fr 1fr; }
.post-images img.post-media {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  margin-top: 0;
  border-radius: 0;
  border: none;
  display: block;
}
/* Smoother */
.post, .chat-bubble, .notification, .conversation-item {
  transition: opacity .18s ease, transform .15s ease;
}
.page.active {
  animation: page-in .2s ease;
}
@keyframes page-in {
  from { opacity: 0.6; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* Post photo carousel / slides */
.post-carousel {
  position: relative;
  margin-top: 12px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  touch-action: pan-y;
}
.post-slides { position: relative; width: 100%; }
.post-slide {
  display: none;
  width: 100%;
}
.post-slide.active { display: block; }
.post-slide img {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  background: #000;
  display: block;
  margin: 0;
  border: none;
  border-radius: 0;
}
.post-slide-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.45);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  display: grid;
  place-items: center;
}
.post-slide-nav.prev { left: 8px; }
.post-slide-nav.next { right: 8px; }
.post-slide-dots {
  position: absolute;
  left: 0; right: 0; bottom: 10px;
  display: flex;
  justify-content: center;
  gap: 5px;
  z-index: 2;
}
.post-slide-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.4);
  padding: 0;
  cursor: pointer;
}
.post-slide-dot.active { background: #fff; }
.post-slide-count {
  position: absolute;
  top: 10px; right: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  z-index: 2;
}

/* Lounge modern send */
.lounge-send-btn,
#loungeSendBtn {
  min-width: 72px !important;
  height: 44px !important;
  padding: 0 18px !important;
  border-radius: 22px !important;
  border: none !important;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)) !important;
  color: #fff !important;
  font-weight: 700 !important;
  font-size: 14px !important;
  box-shadow: 0 6px 18px rgba(184,76,255,.35) !important;
}
.lounge-send-btn:active,
#loungeSendBtn:active { transform: scale(0.97); }

/* Better notifications list */
.notification {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 12px;
  border-radius: 14px;
  margin-bottom: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s ease, transform .12s ease;
}
.notification:active { transform: scale(0.99); background: var(--surface-2); }
.notification.unread {
  border-color: rgba(184,76,255,.35);
  background: linear-gradient(135deg, rgba(184,76,255,.08), rgba(93,124,255,.05));
}
.notification-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2);
  flex-shrink: 0;
  font-size: 16px;
}
.notification-icon.like-icon { background: rgba(255,84,117,.15); color: #ff5475; }
.notification-icon.comment-icon { background: rgba(93,124,255,.15); color: var(--accent-2); }
.notification div span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

/* Smoother overall */
* { -webkit-tap-highlight-color: transparent; }
.post, .chat-bubble, .page {
  transition: opacity .2s ease;
}

/* Smoother photo slides */
.post-slide {
  display: block !important;
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s ease;
}
.post-slides {
  position: relative;
  width: 100%;
  min-height: 220px;
  aspect-ratio: 1 / 1;
  max-height: 360px;
}
.post-slide.active {
  opacity: 1 !important;
  pointer-events: auto;
  position: relative;
  z-index: 1;
}
.post-slide img {
  width: 100%;
  height: 100%;
  max-height: 360px;
  object-fit: cover;
}
.post-highlight {
  animation: post-flash 1.4s ease;
}
.comment-highlight {
  animation: post-flash 1.4s ease;
  border-radius: 12px;
}
@keyframes post-flash {
  0%, 100% { background: transparent; }
  30% { background: rgba(184,76,255,.12); }
}
.repost-banner {
  margin: 8px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.notification {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 14px 14px !important;
  border-radius: 16px !important;
  margin-bottom: 8px !important;
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
}
.notification-body { flex: 1; min-width: 0; }
.notification-text { font-size: 14px; line-height: 1.35; }
.notification-time { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); }
.notification-chevron { color: var(--muted-2); font-size: 18px; }
.notification-icon.mention-icon { background: rgba(184,76,255,.18); color: var(--accent); }
.notification-icon.repost-icon { background: rgba(34,197,94,.15); color: #22c55e; }
.notification-icon.follow-icon { background: rgba(93,124,255,.15); color: var(--accent-2); }
.notification-icon.msg-icon { background: rgba(93,124,255,.12); }
#profilePostsHeader button.active {
  color: var(--text);
  border-bottom: 2px solid var(--accent);
}

/* Profile tabs clearly clickable */
#profilePostsHeader {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
#profilePostsHeader button {
  flex: 1;
  padding: 12px 8px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
#profilePostsHeader button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
#profilePostsHeader button:active {
  opacity: 0.8;
}
/* Hide OG badge if any leftover */
.og-badge { display: none !important; }
.avatar.og-frame, .profile-avatar.og-frame {
  box-shadow: none !important;
}

/* 3-column media grid */
.media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  margin-top: 8px;
}
.media-grid-item {
  position: relative;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: none;
  background: var(--surface-2);
  overflow: hidden;
  cursor: pointer;
  border-radius: 2px;
}
.media-grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.media-grid-item:active { opacity: 0.85; }
.og-badge, .motw-badge { display: none !important; }
#otherProfilePostsHeader {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
#otherProfilePostsHeader button {
  flex: 1;
  padding: 12px 8px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
#otherProfilePostsHeader button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* Other profile tabs — always tappable */
#otherProfilePostsHeader,
#profilePostsHeader {
  position: relative;
  z-index: 5;
  pointer-events: auto;
}
#otherProfilePostsHeader button,
#profilePostsHeader button {
  pointer-events: auto;
  touch-action: manipulation;
  position: relative;
  z-index: 6;
}
#otherProfilePage .profile-main {
  position: relative;
  z-index: 2;
}

/* Smooth feed append */
#feed {
  min-height: 40vh;
}
article.post {
  content-visibility: auto;
  contain-intrinsic-size: 120px;
}

/* Smooth chat */
.chat-messages {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.chat-bubble {
  animation: bubble-in .18s ease;
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
#loungeReplyPreview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
#loungeReplyPreview.hidden { display: none !important; }

/* Inbox "New" badge — clears only when Inbox is opened */
.notification-badge,
#inboxBadge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  display: none;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 2px 8px rgba(184,76,255,.4);
}
.notification-badge.is-new,
#inboxBadge.is-new {
  display: grid !important;
}

/* Smooth chat — no flash */
#chatMessages {
  scroll-behavior: auto;
  -webkit-overflow-scrolling: touch;
}
#chatMessages .chat-bubble {
  animation: none;
}
#chatMessages .chat-bubble.chat-bubble-enter {
  animation: bubble-in .15s ease;
}

/* Phone-perfect chat composer */
.chat-input-row {
  gap: 6px !important;
  padding: 8px 10px !important;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
  align-items: center !important;
}
.chat-input-row input[type="text"] {
  flex: 1 !important;
  min-width: 0 !important;
  padding: 10px 12px !important;
  font-size: 15px !important;
  border-radius: 20px !important;
  height: 40px !important;
}
#sendMessageBtn,
.chat-input-row button#sendMessageBtn,
.lounge-send-btn,
#loungeSendBtn {
  flex-shrink: 0 !important;
  min-width: 56px !important;
  width: auto !important;
  height: 40px !important;
  padding: 0 14px !important;
  border-radius: 20px !important;
  font-size: 14px !important;
  font-weight: 700 !important;
}
.chat-input-row button#chatImageBtn,
.chat-input-row button#chatVoiceBtn,
#chatImageBtn,
#chatVoiceBtn {
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  flex-shrink: 0 !important;
}
@media (max-width: 500px) {
  .chat-input-row {
    gap: 5px !important;
    padding: 8px 8px !important;
  }
  #sendMessageBtn,
  .chat-input-row button#sendMessageBtn {
    min-width: 52px !important;
    padding: 0 12px !important;
    font-size: 13px !important;
  }
  .bottom-nav {
    height: 64px !important;
  }
}


/* ========== PHONE CHAT FIX: send never cut off ========== */
.chat-space {
  position: fixed !important;
  inset: 0 !important;
  z-index: 200 !important;
  background: var(--bg) !important;
  width: 100% !important;
  height: 100% !important;
  height: 100dvh !important;
  max-width: 100vw !important;
  overflow: hidden !important;
}
.chat-view {
  position: absolute !important;
  inset: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  overflow: hidden !important;
  background: var(--bg) !important;
}
.chat-messages,
#chatMessages,
#loungeMessages {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  padding: 12px 12px 8px !important;
}
.chat-input-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 6px !important;
  flex-shrink: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  padding: 8px 10px !important;
  padding-bottom: max(8px, env(safe-area-inset-bottom, 8px)) !important;
  border-top: 1px solid var(--border) !important;
  background: var(--surface) !important;
  overflow: visible !important;
}
.chat-input-row input[type="text"],
#chatInput,
#loungeInput {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  max-width: 100% !important;
  height: 40px !important;
  padding: 0 12px !important;
  font-size: 16px !important; /* 16px prevents iOS zoom */
  border-radius: 20px !important;
  border: 1px solid var(--border) !important;
  background: var(--surface-2) !important;
  color: var(--text) !important;
  box-sizing: border-box !important;
}
.chat-media-btn {
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  max-width: 36px !important;
  flex: 0 0 36px !important;
  border-radius: 50% !important;
  display: grid !important;
  place-items: center !important;
  font-size: 15px !important;
  padding: 0 !important;
  margin: 0 !important;
}
#sendMessageBtn,
.chat-input-row #sendMessageBtn,
#loungeSendBtn,
.lounge-send-btn {
  flex: 0 0 40px !important;
  width: 40px !important;
  min-width: 40px !important;
  max-width: 40px !important;
  height: 40px !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 50% !important;
  border: none !important;
  display: grid !important;
  place-items: center !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)) !important;
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(184,76,255,.35) !important;
  overflow: visible !important;
}
@media (max-width: 500px) {
  .chat-input-row {
    gap: 5px !important;
    padding: 6px 8px !important;
    padding-bottom: max(6px, env(safe-area-inset-bottom, 6px)) !important;
  }
  .chat-media-btn {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    flex-basis: 34px !important;
  }
  #sendMessageBtn,
  .chat-input-row #sendMessageBtn,
  #loungeSendBtn {
    width: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
    height: 38px !important;
    flex-basis: 38px !important;
  }
}

/* Smoother message list */
#chatMessages .chat-bubble {
  max-width: min(78%, 320px) !important;
  transform: translateZ(0);
  will-change: auto;
}


/* ========== REELS ========== */
.home-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.reels-pill,
button.reels-pill,
#openReelsBtn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  height: 34px !important;
  min-height: 34px !important;
  padding: 0 14px !important;
  margin: 0 !important;
  border: none !important;
  border-radius: 999px !important;
  background: linear-gradient(135deg, #b84cff, #5d7cff) !important;
  color: #ffffff !important;
  font-family: inherit !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  letter-spacing: 0.02em !important;
  line-height: 1 !important;
  cursor: pointer !important;
  box-shadow: 0 6px 16px rgba(184, 76, 255, 0.4) !important;
  white-space: nowrap !important;
  -webkit-appearance: none !important;
  appearance: none !important;
  -webkit-tap-highlight-color: transparent !important;
  position: relative !important;
  z-index: 30 !important;
  pointer-events: auto !important;
  touch-action: manipulation !important;
  user-select: none !important;
}
.reels-pill:active,
#openReelsBtn:active {
  transform: scale(0.96) !important;
  opacity: 0.9 !important;
}
body.light-mode .reels-pill,
body.light-mode #openReelsBtn {
  background: linear-gradient(135deg, #a020f0, #4f6ef7) !important;
  color: #fff !important;
}
.home-header-actions {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex-shrink: 0 !important;
  position: relative !important;
  z-index: 25 !important;
  pointer-events: auto !important;
}
.home-header .twyn-category-select {
  min-width: 110px;
  height: 36px;
  padding: 0 32px 0 12px;
  font-size: 13px;
  border-radius: 999px;
}

.create-mode-tabs {
  display: flex; gap: 8px; margin-bottom: 14px;
}
.create-mode-tab {
  flex: 1; padding: 10px; border-radius: 12px;
  background: var(--surface); color: var(--muted);
  border: 1px solid var(--border); font-weight: 600; font-size: 13px;
}
.create-mode-tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border-color: transparent;
}

.reels-space {
  position: fixed; inset: 0; z-index: 180;
  background: #000;
  display: flex; flex-direction: column;
}
.reels-space.hidden { display: none !important; }
.reels-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: linear-gradient(to bottom, rgba(0,0,0,.55), transparent);
  color: #fff;
}
.reels-close, .reels-create-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,.15); color: #fff;
  border: none; font-size: 18px; display: grid; place-items: center;
}
.reels-viewport {
  flex: 1;
  height: 100%;
  overflow-y: scroll;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: auto;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  background: #000;
}
.reel-slide {
  position: relative;
  height: 100%;
  height: 100dvh;
  min-height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.reel-slide video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  transform: translateZ(0);
  will-change: transform;
}
.reel-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 18px 14px 28px;
  padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, rgba(0,0,0,.65) 0%, transparent 45%);
  pointer-events: none;
}
.reel-overlay * { pointer-events: auto; }
.reel-user {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
  color: #fff; font-weight: 700; font-size: 14px;
}
.reel-user .avatar { width: 36px; height: 36px; font-size: 13px; }
.reel-caption {
  color: #fff; font-size: 13.5px; line-height: 1.4;
  max-width: 78%; margin-bottom: 6px;
}
.reel-actions {
  position: absolute; right: 12px; bottom: 120px;
  display: flex; flex-direction: column; gap: 16px; align-items: center;
}
.reel-action-btn {
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(0,0,0,.35); color: #fff;
  border: none; display: grid; place-items: center;
  font-size: 20px; backdrop-filter: blur(6px);
}
.reel-action-btn span {
  display: block; font-size: 11px; margin-top: 2px; font-weight: 600;
}
.reel-action-btn.liked { color: #ff4567; }
.reels-empty {
  position: absolute; inset: 0;
  display: grid; place-content: center; gap: 8px; text-align: center;
  color: #fff; padding: 24px;
}
.reels-empty.hidden { display: none !important; }
.reels-empty strong { font-size: 18px; }
.reels-empty span { color: rgba(255,255,255,.65); font-size: 13px; margin-bottom: 10px; }
.reels-empty button {
  margin: 8px auto 0; padding: 12px 18px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 700; border: none;
}
body.reels-open .bottom-nav,
body.reels-open .topbar { visibility: hidden; pointer-events: none; }


/* ===== TWYN REELS BUTTON (final) ===== */
.home-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  margin-bottom: 18px !important;
}
.home-header-left h1 {
  font-size: 26px !important;
  letter-spacing: -0.8px !important;
  margin: 0 !important;
}
.home-header-left p {
  margin: 4px 0 0 !important;
  color: var(--muted) !important;
  font-size: 13px !important;
}
/* hide category dropdown everywhere on home */
#twynCategorySelector,
.home-header .twyn-category-select,
.home-header-actions .twyn-category-select {
  display: none !important;
}
.twyn-reels-btn,
button.twyn-reels-btn,
#openReelsBtn {
  all: unset;
  box-sizing: border-box !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 38px !important;
  padding: 0 18px !important;
  border-radius: 999px !important;
  background: linear-gradient(135deg, #b84cff 0%, #5d7cff 100%) !important;
  color: #ffffff !important;
  font-family: "Inter", system-ui, sans-serif !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  letter-spacing: 0.02em !important;
  cursor: pointer !important;
  box-shadow: 0 8px 20px rgba(184, 76, 255, 0.4) !important;
  -webkit-tap-highlight-color: transparent !important;
  user-select: none !important;
  position: relative !important;
  z-index: 50 !important;
  pointer-events: auto !important;
  flex-shrink: 0 !important;
}
.twyn-reels-btn:active,
#openReelsBtn:active {
  transform: scale(0.96) !important;
  opacity: 0.92 !important;
}
body.light-mode .twyn-reels-btn,
body.light-mode #openReelsBtn {
  background: linear-gradient(135deg, #a020f0 0%, #4f6ef7 100%) !important;
  color: #fff !important;
}
.reels-space {
  position: fixed !important;
  inset: 0 !important;
  z-index: 300 !important;
  background: #000 !important;
  display: none;
  flex-direction: column !important;
}
.reels-space.is-open {
  display: flex !important;
}
.reels-space.hidden {
  display: none !important;
}


/* Unread DM — Twyn purple dot */
.conversation-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}
.conversation-time {
  color: var(--muted);
  font-size: 11px;
}
.conversation-item.unread-chat .conversation-time {
  color: #b84cff;
  font-weight: 600;
}
.chat-unread-dot {
  width: 10px !important;
  height: 10px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #b84cff, #5d7cff) !important;
  box-shadow: 0 0 0 3px rgba(184, 76, 255, 0.2);
  flex-shrink: 0 !important;
}
.conversation-item.unread-chat .conversation-info strong {
  font-weight: 800;
}
.conversation-item.unread-chat .unread-preview {
  color: var(--text) !important;
  font-weight: 600 !important;
}

/* Video in posts / create preview */
.post-video,
video.post-media {
  width: 100%;
  max-height: 420px;
  border-radius: 16px;
  background: #000;
  display: block;
}
.create-preview-video {
  width: 100%;
  max-height: 280px;
  border-radius: 14px;
  background: #000;
}

.conversation-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
  min-width: 28px;
}
.conversation-time { color: var(--muted); font-size: 11px; }
.conversation-item.unread-chat .conversation-time {
  color: #b84cff;
  font-weight: 700;
}
.chat-unread-dot {
  width: 10px !important;
  height: 10px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #b84cff, #5d7cff) !important;
  box-shadow: 0 0 0 3px rgba(184, 76, 255, 0.22);
  display: inline-block !important;
}
.conversation-item.unread-chat .unread-preview {
  color: var(--text) !important;
  font-weight: 600 !important;
}
.post-video, video.post-media {
  width: 100%;
  max-height: 420px;
  border-radius: 16px;
  background: #000;
  display: block;
}
.create-preview-video {
  width: 100%;
  max-height: 280px;
  border-radius: 14px;
  background: #000;
}


/* Reels — lock page, snap videos */
html.reels-open,
body.reels-open {
  overflow: hidden !important;
  height: 100% !important;
  overscroll-behavior: none !important;
  touch-action: none !important;
}
.reels-space.is-open {
  position: fixed !important;
  inset: 0 !important;
  z-index: 400 !important;
  display: flex !important;
  flex-direction: column !important;
  background: #000 !important;
  overscroll-behavior: none !important;
}
.reels-viewport {
  flex: 1 !important;
  height: 100% !important;
  overflow-y: scroll !important;
  overflow-x: hidden !important;
  scroll-snap-type: y mandatory !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior-y: contain !important;
  touch-action: pan-y !important;
  background: #000 !important;
}
.reel-slide {
  position: relative !important;
  height: 100% !important;
  height: 100dvh !important;
  min-height: 100% !important;
  max-height: 100dvh !important;
  scroll-snap-align: start !important;
  scroll-snap-stop: always !important;
  background: #000 !important;
  overflow: hidden !important;
}
.reel-slide video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  background: #000 !important;
}
.reel-repost-label {
  position: absolute;
  top: calc(56px + env(safe-area-inset-top, 0px));
  left: 14px;
  z-index: 6;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(8px);
}
.reel-loading {
  display: grid !important;
  place-items: center !important;
  color: #fff !important;
}
.reel-action-btn .reel-ico { display: block; font-size: 22px; line-height: 1; }
.reel-action-btn .reel-count { display: block; font-size: 11px; margin-top: 2px; font-weight: 600; }

/* Comments sheet */
.reel-comments-sheet {
  position: fixed; inset: 0; z-index: 500;
  display: none;
}
.reel-comments-sheet.open { display: block; }
.reel-comments-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.45);
}
.reel-comments-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 55vh;
  background: var(--surface, #101012);
  border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.reel-comments-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border, rgba(255,255,255,.08));
  color: var(--text, #fff);
}
.reel-comments-head button {
  background: transparent; border: 0; color: var(--muted); font-size: 18px; cursor: pointer;
}
.reel-comments-list {
  flex: 1; overflow-y: auto; padding: 12px 16px;
}
.reel-comment-row {
  padding: 10px 0; border-bottom: 1px solid var(--border, rgba(255,255,255,.06));
  color: var(--text, #fff);
}
.reel-comment-row strong { display: block; font-size: 13px; margin-bottom: 3px; }
.reel-comment-row span { font-size: 13.5px; color: var(--muted, #aaa); }
.reel-comments-input-row {
  display: flex; gap: 8px; padding: 10px 14px;
  border-top: 1px solid var(--border, rgba(255,255,255,.08));
}
.reel-comments-input-row input {
  flex: 1; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2, #171719);
  color: var(--text); outline: none;
}
.reel-comments-input-row button {
  padding: 0 16px; border-radius: 12px; border: 0;
  background: linear-gradient(135deg, #b84cff, #5d7cff);
  color: #fff; font-weight: 700; cursor: pointer;
}

.reel-repost-bubble {
  position: absolute;
  left: 14px;
  bottom: calc(118px + env(safe-area-inset-bottom, 0px));
  z-index: 8;
  max-width: 75%;
  padding: 7px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(184,76,255,.92), rgba(93,124,255,.92));
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(184,76,255,.35);
  pointer-events: none;
}
.reel-action-btn.reposted {
  color: #b84cff !important;
}
.reel-tap-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 12;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  backdrop-filter: blur(8px);
}
.post-media, .post-images img {
  content-visibility: auto;
}
