/* 3. App shell */
.app {
  display: flex;
  height: var(--app-viewport-height, 100vh);
  min-height: 0;
  overflow: hidden;
}

.app-main {
  min-width: 0;
  height: 100%;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.page { height: 100%; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }

.content {
  width: min(100%, 900px);
  margin: 0 auto;
  padding: 32px 24px 48px;
}

.content.narrow { width: min(100%, 680px); }

.page-heading {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-heading h1 {
  margin: 2px 0 0;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: -.03em;
}

.page-heading h2,
.feed-toolbar h2,
.conversation-list-section h2,
.people-list-section h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

/* 4. Navigation */
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  height: var(--app-viewport-height, 100vh);
  flex-direction: column;
  padding: 20px 12px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  display: flex;
  height: 48px;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  font-size: 18px;
  font-weight: 750;
}

.main-nav {
  display: grid;
  gap: 4px;
  margin-top: 24px;
}

.main-nav button,
.sidebar-footer > button {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  padding: 0 10px;
  text-align: left;
}

.main-nav button:hover,
.sidebar-footer > button:hover,
.main-nav button.active {
  background: var(--hover);
}

.main-nav button.active { font-weight: 700; }

.sidebar-footer {
  display: grid;
  gap: 4px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.language-control select {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
}

.sidebar-footer .danger { color: var(--danger); }

/* 5. Shared components */
.feed-layout { width: min(100%, 680px); }

.feed-toolbar {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.load-more {
  display: block;
  margin: 20px auto 0;
}

/* 6. Home and feed */
.feed {
  display: grid;
  gap: 0;
  margin-top: 12px;
}

.post {
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  padding: 0 0 16px;
}

.post-head {
  display: flex;
  min-height: 64px;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.post-author {
  display: contents;
  border: 0;
  background: transparent;
}

.post-head .meta {
  display: grid;
  min-width: 0;
  flex: 1;
}

.post-head .meta button {
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  font-weight: 700;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-head small,
.post-body small { color: var(--text-secondary); }

.post-media {
  display: block;
  width: 100%;
  height: auto;
  max-height: 760px;
  aspect-ratio: auto;
  border-radius: var(--radius-md);
  background: var(--surface-secondary);
  object-fit: contain;
}
.post-media-fallback { display: grid; width: 100%; height: 100%; place-items: center; background: var(--surface-secondary); color: var(--text-secondary); padding: 16px; text-align: center; }

video.post-media { object-fit: contain; }

.post-media-frame {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--surface-secondary);
}

.post-media-frame > .post-media { border-radius: 0; }

.media-carousel-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 10;
}

.media-carousel-controls button {
  display: grid;
  min-width: 32px;
  min-height: 32px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  color: #FFFFFF;
  font-size: 14px;
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
  backdrop-filter: blur(4px);
}

.media-carousel-controls button:hover:not(:disabled) {
  transform: scale(1.08);
  background: rgba(0, 0, 0, 0.85);
}

.media-carousel-controls button:disabled {
  opacity: 0;
  pointer-events: none;
}

.carousel-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  padding: 4px 8px;
  border-radius: 12px;
  pointer-events: auto;
}

.carousel-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.carousel-dot.active {
  width: 14px;
  border-radius: 4px;
  background: #ffffff;
}


.post-body { padding: 8px 0 0; }

.post-actions {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 4px;
}

.post-actions button {
  min-width: 36px;
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 6px 8px;
}

.post-actions button:hover,
.post-actions button.active { background: var(--hover); }
.repost-attribution { margin: 8px 0 0; color: var(--text-secondary); font-size: 12px; }

.post-actions .delete {
  width: auto;
  margin-left: auto;
  color: var(--danger);
}

.post-caption {
  margin: 8px 0 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.post-caption.is-collapsed {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.caption-toggle {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 2px 0;
  font-size: 13px;
}

/* 7. Stories */
.stories-section {
  margin: 0 0 20px;
  border-bottom: 1px solid var(--border);
}

.stories {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  padding: 4px 0 18px;
  scrollbar-width: none;
}

.stories::-webkit-scrollbar { display: none; }

.story {
  display: grid;
  width: 68px;
  flex: 0 0 68px;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  text-align: center;
}

.story .avatar {
  width: 60px;
  height: 60px;
  margin: 0 auto;
  border: 3px solid transparent;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    var(--gradient-story) border-box;
}

.story.viewed .avatar {
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(135deg, var(--border), var(--text-secondary)) border-box;
}
.story.unviewed .avatar { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px color-mix(in srgb, var(--accent) 82%, transparent); }

.story span {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 8. Explore media grid */
.post-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-top: 12px;
}

.post-grid button {
  position: relative;
  display: grid;
  overflow: hidden;
  aspect-ratio: 1;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: var(--surface-secondary);
  color: var(--text);
  padding: 0;
}

.post-grid button:hover { opacity: .78; }

.post-grid img,
.post-grid video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.text-tile {
  padding: 12px !important;
  font-size: 13px;
  text-align: center;
}

.user-list {
  display: grid;
  margin-top: 12px;
}

#share-suggested-section {
  min-height: 0;
  margin: 0 0 14px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

#share-suggested-section h3 {
  position: sticky;
  z-index: 1;
  top: 0;
  margin: 0;
  padding: 10px 0 12px;
  background: var(--surface);
  font-size: .88rem;
  font-weight: 650;
}

#share-suggested-section .user-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding-bottom: 14px;
}

.share-post-dialog[open] {
  display: flex;
  width: min(620px, calc(100vw - 32px));
  height: min(610px, 82dvh);
  max-height: min(760px, calc(100dvh - 32px));
  flex-direction: column;
  overflow: hidden;
  border-color: color-mix(in srgb, var(--border) 75%, #fff 8%);
  border-radius: 24px;
  padding: 16px 18px 18px;
  background: var(--surface-elevated, var(--surface));
}

.share-post-dialog > header {
  position: relative;
  min-height: 40px;
  flex: 0 0 auto;
  justify-content: center;
  margin-bottom: 12px;
}

.share-post-dialog > header h2 { margin: 0; font-size: 17px; }
.share-post-dialog > header .icon-button { position: absolute; left: 0; }
.share-post-dialog .share-header-spacer { width: 36px; }
.share-post-dialog > .search-input { min-height: 44px; flex: 0 0 auto; border-radius: 12px; }
.share-post-dialog > #share-post-status { flex: 0 0 auto; margin: 6px 0 0; }
.share-post-dialog > #share-post-people { min-height: 0; flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; }

.share-suggestion-card {
  display: grid;
  min-width: 0;
  justify-items: center;
  align-content: start;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 12px 7px 10px;
  text-align: center;
  transition: background .16s ease, border-color .16s ease;
}
.share-suggestion-card:hover { border-color: var(--border); background: var(--hover); }
.share-suggestion-avatar { width: 68px; height: 68px; border-radius: 50%; }
.share-suggestion-name,
.share-suggestion-username { display: block; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-suggestion-name { font-size: 12px; font-weight: 650; }
.share-suggestion-username { color: var(--text-secondary); font-size: 11px; }
.share-suggestion-send { min-height: 34px; margin-top: 3px; border-radius: 10px; padding: 0 14px; font-size: 12px; }
.share-post-dialog > #share-post-people .user-row { min-height: 60px; }

@media (max-width: 640px) {
  .share-post-dialog[open] {
    position: fixed;
    inset: auto 0 0;
    width: 100vw;
    height: min(82dvh, 700px);
    max-height: calc(100dvh - env(safe-area-inset-top, 0px));
    margin: 0;
    border-radius: 24px 24px 0 0;
    padding: 14px 14px max(16px, env(safe-area-inset-bottom, 0px));
  }
  #share-suggested-section .user-list { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .share-suggestion-card { padding: 10px 4px 9px; }
  .share-suggestion-avatar { width: 62px; height: 62px; }
}

@media (max-width: 360px) {
  #share-suggested-section .user-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.user-row,
.list-item {
  display: flex;
  min-height: 64px;
  align-items: center;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  padding: 10px 4px;
  text-align: left;
}

.user-row:hover,
.list-item:hover { background: var(--hover); }

.user-row .name,
.item-main {
  display: grid;
  min-width: 0;
  flex: 1;
}

.user-row .name {
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  font-weight: 700;
  text-align: left;
}

.user-row small,
.item-status,
.item-preview,
.item-time {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-row > button:not(.name),
.user-row-actions > button {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 6px 10px;
}

.user-row-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

/* 13. Notifications */
.activity-list .user-row { gap: 10px; }
.notification-row.unread { background: var(--surface-secondary); font-weight: 600; }
.notification-row.unread::after { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: var(--text); content: ""; }

.list-item .avatar {
  width: 48px;
  height: 48px;
}

/* 9. Messages */
.messages-layout {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(320px, 370px) minmax(0, 1fr);
}

.people-pane {
  padding: 26px 18px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.inbox-header {
  margin-bottom: 12px;
}

.inbox-header h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -.02em;
}

.inbox-title-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}

.inbox-account-label {
  display: inline-flex;
  align-items: center;
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.02em;
  padding: 0;
}
.inbox-profile-avatar { width: 38px; height: 38px; flex: 0 0 38px; }
.inbox-title-row #new-message-button { margin-left: auto; }

#new-message-button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  padding: 0;
}

#new-message-button .icon {
  width: 22px;
  height: 22px;
}

#new-message-button:hover {
  background: var(--hover);
}

.notes-shelf { margin: 0 -18px 8px; padding: 0 18px 10px; border-bottom: 0; }
.notes-shelf > header { display: none; }
.notes-shelf h2 { margin: 0; font-size: 14px; }
.notes-list { display: flex; gap: 14px; overflow-x: auto; padding: 14px 4px 4px; scrollbar-width: none; }
.notes-list::-webkit-scrollbar { display: none; }
.note-item { display: flex; flex-direction: column; align-items: center; width: 74px; flex: 0 0 74px; position: relative; border: 0; background: transparent; padding: 0; cursor: pointer; text-align: center; }
.note-main { display: flex; flex-direction: column; align-items: center; border: 0; background: transparent; padding: 0; width: 100%; cursor: pointer; position: relative; }
.note-avatar-wrap { position: relative; display: inline-flex; justify-content: center; align-items: center; margin-top: 14px; }
.note-avatar-wrap .avatar { width: 56px; height: 56px; border-radius: 50%; border: 2px solid var(--border); }
.note-bubble {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  background: var(--surface-secondary);
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.25;
  padding: 4px 8px;
  border-radius: 12px;
  white-space: nowrap;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 2px 8px rgb(0 0 0 / 22%);
  border: 1px solid var(--border);
}
.note-bubble::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 4px 4px 0;
  border-style: solid;
  border-color: var(--surface-secondary) transparent transparent;
}
.note-identity {
  margin-top: 5px;
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  margin: 0 0 10px;
  padding: 0 12px;
  height: 36px;
  border-radius: 18px;
  background: var(--surface-secondary);
  border: 1px solid transparent;
}
.inbox-search-wrap:focus-within {
  border-color: #363636;
}
.inbox-search-wrap .search-icon {
  width: 15px;
  height: 15px;
  color: var(--text-secondary);
  margin-right: 8px;
  flex-shrink: 0;
}
.inbox-search-wrap .search-input {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  padding: 0;
}
.inbox-search-wrap .search-input::placeholder {
  color: var(--text-secondary);
}

.inbox-tabs {
  display: flex;
  margin-top: 4px;
  border-bottom: 1px solid var(--border);
  background: transparent;
  padding: 0;
  gap: 0;
  border-radius: 0;
}

.inbox-tabs button {
  flex: 1;
  height: 38px;
  border: 0;
  border-bottom: 1.5px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 0;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color .14s ease, border-color .14s ease;
}

.inbox-tabs button.active {
  background: transparent;
  color: var(--text);
  border-bottom-color: var(--text);
  box-shadow: none;
}

.conversation-list-section,
.people-list-section { margin-top: 6px; }

.conversation-list-section h2,
.people-list-section h2 {
  margin-bottom: 8px;
}

.list-item {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 10px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  text-align: left;
  gap: 12px;
  cursor: pointer;
  transition: background-color .12s ease;
}

.list-item.active,
.list-item[aria-current="true"] { background: var(--surface-secondary); }
.list-item:hover { background: var(--hover); }
.unread-dot {
  width: 8px;
  min-width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 8px;
  margin-left: auto;
}
.unread-count {
  display: grid;
  width: 8px;
  min-width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  color: transparent;
  padding: 0;
  font-size: 0;
  margin-left: auto;
}

.list-item.active .item-main strong { font-weight: 750; }
.list-item.unread-item .item-main strong { font-weight: 750; color: var(--text); }
.list-item.unread-item .item-preview { color: var(--text); font-weight: 600; }

.item-main { gap: 2px; }

.item-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-time {
  align-self: flex-start;
  padding-top: 3px;
  font-size: 11px;
}

.chat-panel {
  min-width: 0;
  background: var(--bg);
}

.conversation-empty {
  display: grid;
  height: 100%;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.conversation-empty > div {
  max-width: 300px;
}

.empty-icon {
  width: 32px;
  height: 32px;
  margin: 0 auto 12px;
}

.conversation-empty h2 { margin: 0; color: var(--text); font-size: 18px; }
.conversation-empty p { margin: 6px 0 0; }

.conversation {
  display: grid;
  height: 100dvh;
  min-height: 620px;
  grid-template-rows: 68px minmax(0, 1fr) auto auto;
}

.conversation > header {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 18px;
}

.conversation-identity {
  display: grid;
  min-width: 0;
}

.conversation-identity b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-identity small {
  overflow: hidden;
  color: var(--text-secondary);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-box {
  display: grid;
  align-content: start;
  grid-auto-rows: max-content;
  gap: 8px;
  overflow-y: auto;
  padding: 24px clamp(18px, 5vw, 72px);
}

.message-row { display: flex; max-width: min(78%, 600px); align-items: flex-end; gap: 8px; }
.message-row.own { justify-self: end; }
.message-avatar { width: 30px; height: 30px; font-size: 11px; }

.message {
  padding: 9px 11px;
  border-radius: 14px;
  background: var(--surface-secondary);
  overflow-wrap: anywhere;
}

.message-row.own .message {
  background: var(--gradient-primary);
  color: var(--accent-contrast);
}

.message img {
  display: block;
  width: auto;
  max-width: min(100%, 300px);
  max-height: 360px;
  border-radius: 10px;
}

.message-time {
  display: block;
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 11px;
}
.shared-post-card { display: grid; width: min(100%, 280px); gap: 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); padding: 8px; text-align: left; }
.shared-post-card img,
.shared-post-card video { width: 100%; max-height: 180px; border-radius: 6px; object-fit: cover; }
.shared-post-card span { overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }

.message-row.own .message-time { color: var(--accent-contrast); opacity: .68; }

.message-status {
  min-height: 0;
  padding: 0 18px;
  color: var(--text-secondary);
  font-size: 12px;
}

.conversation form {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px clamp(12px, 4vw, 48px) max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.conversation form textarea {
  min-height: 42px;
  max-height: 120px;
  flex: 1;
  min-width: 0;
  background: var(--surface-secondary);
}

.message-attachment-preview { position: absolute; bottom: calc(100% + 8px); left: 20px; display: flex; width: 116px; height: 116px; padding: 5px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow); }
.message-attachment-preview img { width: 100%; height: 100%; border-radius: 8px; object-fit: cover; }
.message-attachment-preview .icon-button { position: absolute; top: -10px; right: -10px; width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); }
.emoji-picker { position: absolute; z-index: 2; bottom: calc(100% + 8px); left: 12px; display: flex; gap: 4px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow); }
.emoji-picker button { width: 38px; height: 38px; border: 0; border-radius: 8px; background: transparent; font-size: 20px; }
.emoji-picker button:hover { background: var(--hover); }

.stats {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin: 16px 0;
  font-size: 14px;
}

.post-detail-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  display: flex;
  width: min(900px, calc(100vw - 48px));
  max-width: none;
  min-width: 0;
  min-height: 0;
  height: min(760px, 85vh);
  max-height: 85vh;
  height: min(760px, 85dvh);
  max-height: 85dvh;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
}
.post-detail-dialog:not([open]) { display: none; }
.post-detail-dialog[open] { display: flex; }
.post-detail-dialog::backdrop { background: rgb(0 0 0 / 84%); backdrop-filter: blur(6px); }
.post-detail-dialog > header { position: fixed; z-index: 40; top: max(14px, env(safe-area-inset-top)); right: max(18px, env(safe-area-inset-right)); margin: 0; pointer-events: none; }
.post-detail-dialog > header h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }
.post-detail-dialog > header #post-detail-close { width: 44px; height: 44px; pointer-events: auto; }
#post-detail-content { width: 100%; min-width: 0; min-height: 0; flex: 1 1 auto; overflow: hidden; overscroll-behavior: contain; }
.post-detail-dialog .post {
  display: grid;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  grid-template-columns: minmax(0, .62fr) minmax(320px, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "media head" "media body";
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: none;
  padding: 0;
}
.post-detail-dialog .post-head { grid-area: head; min-width: 0; min-height: 68px; margin: 0; border-bottom: 1px solid var(--border); background: var(--surface); padding: 12px 52px 12px 16px; }
.post-detail-dialog .post-more-trigger { width: 44px; min-width: 44px; height: 44px; }
.post-detail-dialog .post-media-frame { grid-area: media; position: relative; display: grid; width: 100%; height: 100%; max-width: 100%; max-height: 100%; min-width: 0; min-height: 0; align-self: stretch; justify-self: stretch; place-items: center; overflow: hidden; border-right: 1px solid var(--border); border-radius: 0; background: var(--surface-secondary); }
.post-detail-dialog .post-media-frame > .post-media { display: block; width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; }
.post-detail-dialog .post-video-controls { position: absolute; z-index: 4; inset: 0; display: grid; place-items: center; pointer-events: none; }
.post-detail-dialog .post-video-controls button { display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid rgb(255 255 255 / 45%); border-radius: 50%; background: rgb(5 6 10 / 68%); color: #fff; cursor: pointer; pointer-events: auto; transition: opacity .2s ease, background-color .2s ease, transform .2s ease; backdrop-filter: blur(8px); }
.post-detail-dialog .post-video-controls button:hover { background: rgb(5 6 10 / 88%); transform: scale(1.04); }
.post-detail-dialog .post-video-controls button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.post-detail-dialog .post-video-controls .post-video-play { opacity: .92; }
.post-detail-dialog .post-video-controls.is-playing .post-video-play { opacity: 0; }
.post-detail-dialog .post-media-frame:hover .post-video-controls.is-playing .post-video-play,
.post-detail-dialog .post-media-frame:focus-within .post-video-controls.is-playing .post-video-play { opacity: .92; }
.post-detail-dialog .post-video-controls .post-video-sound { position: absolute; right: 14px; bottom: 14px; z-index: 1; width: 38px; height: 38px; opacity: 1; }
.post-detail-dialog .post-video-controls .icon { width: 19px; height: 19px; }
.post-detail-dialog .post-video-status { position: absolute; z-index: 3; right: 62px; bottom: 18px; left: 14px; width: fit-content; max-width: calc(100% - 88px); border: 1px solid rgb(255 255 255 / 24%); border-radius: 999px; background: rgb(0 0 0 / 76%); color: #fff; padding: 6px 10px; font-size: 12px; line-height: 1.3; pointer-events: none; }
.post-detail-dialog .post-video-status[hidden] { display: none; }
.post-detail-dialog .post-video-status.is-error { border-color: rgb(255 255 255 / 38%); }
.post-detail-dialog .post-body { grid-area: body; display: flex; min-width: 0; min-height: 0; flex-direction: column; overflow: hidden; background: var(--surface); padding: 0; }
.post-detail-comments-heading { display: none; }
.post-detail-dialog .post-media-fallback { display: grid; width: 100%; height: 100%; place-items: center; color: #a1a1aa; padding: 24px; text-align: center; }
.post-detail-dialog .post:not(.has-post-media) .post-head { border-bottom: 1px solid #27272a; }
.post-detail-dialog .post-body > .post-caption { flex: 0 0 auto; margin: 12px 14px 4px; }
.post-detail-comment-list { display: flex; min-width: 0; min-height: 0; flex: 1 1 auto; flex-direction: column; gap: 14px; overflow-y: auto; overscroll-behavior: contain; padding: 16px; scrollbar-width: none; }
.post-detail-comment-list::-webkit-scrollbar { display: none; }
.post-detail-caption { display: flex; min-width: 0; align-items: flex-start; gap: 9px; }
.post-detail-caption .post-caption { margin: 0; color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 1.45; }
.post-detail-caption .caption-toggle { font-size: 11px; }
.post-detail-comment { display: flex; min-width: 0; align-items: flex-start; gap: 9px; }
.post-detail-comment-author { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--text); padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 12px; font-weight: 650; cursor: pointer; }
.post-detail-comment-avatar { width: 28px; height: 28px; flex: 0 0 28px; }
.post-detail-comment-copy { min-width: 0; flex: 1 1 auto; overflow-wrap: anywhere; color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 1.45; }
.post-detail-comment-copy p { margin: 0; white-space: pre-wrap; }
.post-detail-comment-copy time { display: block; margin-top: 4px; color: var(--text-tertiary); font-size: 10px; }
.post-detail-comments-empty { display: grid; align-self: center; justify-items: center; gap: 4px; margin: auto; color: var(--text-secondary); padding: 48px 12px; text-align: center; }
.post-detail-comments-empty p { margin: 0; font-size: 12px; }
.post-detail-comments-empty .post-detail-comments-empty-title { color: var(--text); font-size: 14px; font-weight: 700; }
.post-view-all-comments { display: block; width: fit-content; border: 0; background: transparent; color: var(--text-tertiary); margin: 4px 0 0; padding: 2px 0; font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
.post-view-all-comments:hover { color: var(--text-secondary); }
.post-detail-footer { flex: 0 0 auto; border-top: 1px solid var(--border); background: var(--surface); padding: 6px 16px 0; }
.post-detail-footer .post-actions { display: flex; min-height: 48px; align-items: center; gap: 10px; }
.post-detail-footer .post-actions > button { display: inline-flex; width: 44px; min-width: 44px; height: 44px; align-items: center; justify-content: center; border-radius: 8px; padding: 8px; }
.post-detail-footer .post-actions > button .icon { width: 24px; height: 24px; }
.post-detail-footer .post-actions > button[data-post-save] { margin-left: auto; }
.post-detail-footer .post-likes-summary { margin: 0 0 8px; }
.post-detail-date { display: block; margin: 0 0 4px; color: var(--text-tertiary); font-size: 10px; text-transform: uppercase; }
.post-detail-comment-form { display: flex; min-width: 0; flex: 0 0 auto; align-items: center; gap: 12px; border-top: 1px solid var(--border); background: var(--surface); padding: 12px 16px max(12px, env(safe-area-inset-bottom)); }
.post-detail-comment-emoji { display: grid; width: 44px; height: 44px; flex: 0 0 44px; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--text-secondary); padding: 0; cursor: pointer; }
.post-detail-comment-emoji:hover { color: var(--text); }
.post-detail-comment-emoji:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.post-detail-comment-emoji .icon { width: 20px; height: 20px; }
.post-detail-comment-input { width: 100%; min-width: 0; min-height: 24px; flex: 1 1 auto; border: 0; border-radius: 0; outline: 0; background: transparent; color: var(--text); padding: 0; font: inherit; font-size: 12px; box-shadow: none; }
.post-detail-comment-input::placeholder { color: var(--text-tertiary); }
.post-detail-comment-submit { min-width: 44px; min-height: 44px; flex: 0 0 auto; border: 0; background: transparent; color: var(--info); margin-left: 2px; padding: 4px 0; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.post-detail-comment-submit:hover:not(:disabled) { color: var(--text); }
.post-detail-comment-submit:disabled { opacity: .4; cursor: wait; }
.post-detail-comment-status { flex: 0 0 auto; margin: 0; color: #fca5a5; padding: 0 14px 10px; font-size: 11px; }
@media (min-width: 769px) {
  .post-detail-dialog .post {
    display: grid;
    grid-template-columns: minmax(0, .62fr) minmax(320px, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "media head" "media body";
  }
  .post-detail-dialog .post-media-frame > img.post-media { object-fit: contain; }
  .post-detail-dialog .post:not(.has-post-media) {
    display: flex;
    max-width: 550px;
    flex-direction: column;
    margin: 0 auto;
  }
  .post-detail-dialog .post:not(.has-post-media) .post-head { flex: 0 0 auto; }
  .post-detail-dialog .post:not(.has-post-media) .post-body { flex: 1 1 auto; }
}
@media (max-width: 768px) {
  .post-detail-dialog { inset: 0; width: 100%; height: 100vh; max-height: 100vh; height: 100dvh; max-height: 100dvh; margin: 0; overflow: hidden; border: 0; border-radius: 0; padding: 0; }
  .post-detail-dialog > header { position: absolute; z-index: 30; top: max(10px, env(safe-area-inset-top)); right: 12px; display: block; width: auto; margin: 0; pointer-events: none; }
  .post-detail-dialog > header h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }
  .post-detail-dialog > header #post-detail-close { position: relative; z-index: 1; width: 44px; height: 44px; border: 1px solid rgb(255 255 255 / 20%); border-radius: 50%; background: rgb(0 0 0 / 58%); color: #fff; pointer-events: auto; backdrop-filter: blur(8px); }
  #post-detail-content { display: flex; height: 100%; min-height: 0; overflow: hidden; overscroll-behavior: contain; touch-action: pan-y; }
  .post-detail-dialog .post { position: relative; display: flex; width: 100%; height: 100dvh; min-height: 0; flex-direction: column; overflow: hidden; border: 0; border-radius: 0; }
  .post-detail-dialog .post-media-frame { display: flex; width: 100%; height: auto; max-width: none; max-height: 50dvh; min-height: 0; flex: 0 0 auto; align-items: center; justify-content: center; border-right: 0; border-bottom: 1px solid var(--border); background: var(--surface-secondary); }
  .post-detail-dialog .post-media-frame > .post-media { display: block; width: 100%; height: auto; max-width: 100%; max-height: 50dvh; object-fit: contain; }
  .post-detail-dialog .post-head { position: absolute; z-index: 4; top: max(10px, env(safe-area-inset-top)); right: 52px; left: 12px; min-height: 56px; border: 1px solid rgb(255 255 255 / 12%); border-radius: 16px; background: color-mix(in srgb, var(--bg) 78%, transparent); padding: 5px 10px; backdrop-filter: blur(14px); }
  .post-detail-dialog .post-head .post-handle { display: none; }
  .post-detail-dialog .post-body { position: static; z-index: auto; min-height: 0; height: auto; flex: 1 1 auto; overflow: hidden; border: 0; border-radius: 0; box-shadow: none; }
  .post-detail-dialog .post-body::before { display: none; }
  .post-detail-dialog .post-body > .post-caption { margin-top: 12px; }
  .post-detail-comment-list { min-height: 0; flex: 1 1 auto; overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain; touch-action: pan-y; padding: 17px 12px 12px; }
  .post-detail-footer { padding: 4px 12px 0; }
  .post-detail-footer .post-actions { min-height: 44px; gap: 6px; }
  .post-detail-footer .post-actions > button { width: 44px; min-width: 44px; height: 44px; }
  .post-detail-comment-form { gap: 6px; padding: 2px 10px max(4px, env(safe-area-inset-bottom)); }
  .post-detail-comment-emoji { width: 44px; min-width: 44px; flex-basis: 44px; }
  .post-detail-comment-input { font-size: 16px; }
  .post-detail-dialog .post:not(.has-post-media) .post-head { position: relative; top: auto; right: auto; left: auto; }
  .post-detail-dialog .post:not(.has-post-media) .post-body { position: static; height: auto; }
  .post-detail-dialog .post:not(.has-post-media) .post-body::before { display: none; }
}

.follow-list-dialog { width: min(480px, calc(100vw - 32px)); }
.follow-list-dialog .user-list { max-height: min(58vh, 520px); overflow-y: auto; }
.story-viewer-liked { margin-left: auto; color: #ff5268; font-size: 18px; line-height: 1; }
.follow-user-row { gap: 12px; }
.follow-user-name { display: grid; min-width: 0; flex: 1; }
.follow-user-name small { color: var(--text-secondary); }

/* 11. Dialog base */
dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 20px;
}

dialog::backdrop { background: rgb(0 0 0 / 54%); }

dialog > form,
dialog > header {
  display: grid;
  gap: 16px;
}

dialog header {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

dialog h2 { margin: 2px 0 0; font-size: 20px; }

.create-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

/* 14. Create dialog */
.create-options button {
  display: grid;
  min-height: 112px;
  justify-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  padding: 16px;
}

.create-options button:hover { background: var(--hover); }

#create-editor {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.file-picker {
  display: grid;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 13px;
}

.media-previews {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  max-height: 340px;
  overflow: auto;
}

.media-previews img,
.media-previews video {
  width: 100%;
  max-height: 260px;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  background: var(--surface-secondary);
  object-fit: cover;
}
.create-media-item { position: relative; min-width: 0; }
.create-media-controls { position: absolute; right: 6px; bottom: 6px; left: 6px; display: flex; justify-content: flex-end; gap: 4px; }
.create-media-controls button { min-width: 34px; min-height: 34px; border: 0; border-radius: 50%; background: rgb(0 0 0 / 72%); color: #FFFFFF; font-size: 18px; }
.create-media-controls button:disabled { opacity: .45; }

#create-caption { min-height: 116px; }

/* 15. Story dialog */
#story-dialog {
  width: min(520px, calc(100vw - 24px));
  max-width: none;
  max-height: calc(100dvh - 24px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-elevated);
  color: var(--text);
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow-raised);
}

#story-dialog::backdrop {
  background: rgb(0 0 0 / 84%);
}

#story-dialog > .icon-button {
  position: absolute;
  z-index: 1;
  top: 10px;
  right: 10px;
  color: var(--text);
}

#story-viewer {
  display: grid;
  min-height: min(760px, calc(100dvh - 24px));
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
}

.story-progress {
  display: grid;
  gap: 4px;
}

.story-progress span {
  height: 3px;
  border-radius: 99px;
  background: rgb(255 255 255 / 35%);
}

.story-progress span.complete { background: #FFFFFF; }
.story-progress span.current { position: relative; overflow: hidden; }
.story-progress span.current::before { position: absolute; inset: 0; transform: scaleX(0); transform-origin: left; background: #FFFFFF; animation: story-progress-fill var(--story-duration, 7000ms) linear forwards; content: ""; }
@keyframes story-progress-fill { to { transform: scaleX(1); } }

.story-author {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.story-author .avatar { width: 38px; height: 38px; }

.story-identity {
  display: grid;
  min-width: 0;
}

.story-identity small {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.story-stage {
  position: relative;
  display: grid;
  min-height: 0;
  align-content: center;
  justify-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-tertiary);
  touch-action: pan-y;
}

.story-media {
  width: 100%;
  height: min(72vh, 640px);
  max-height: min(72vh, 640px);
  margin: auto;
  object-fit: cover;
}

.story-video-play,
.story-video-loading,
.story-video-error {
  position: absolute;
  z-index: 2;
  left: 50%;
  transform: translateX(-50%);
}
.story-video-play {
  top: 50%;
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 55%);
  border-radius: 50%;
  background: rgb(0 0 0 / 58%);
  color: #fff;
  cursor: pointer;
  transform: translate(-50%, -50%);
}
.story-video-play:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.story-video-play[hidden], .story-video-loading[hidden] { display: none !important; }
.story-video-loading,
.story-video-error {
  bottom: 54px;
  max-width: calc(100% - 32px);
  border-radius: 999px;
  background: rgb(0 0 0 / 72%);
  color: #fff;
  padding: 7px 12px;
  text-align: center;
  pointer-events: none;
}
.story-video-loading { animation: story-video-loading-pulse 1s ease-in-out infinite alternate; }
.story-video-error { bottom: 54px; }
@keyframes story-video-loading-pulse { to { opacity: .55; } }

.story-caption {
  position: absolute;
  right: 48px;
  bottom: 20px;
  left: 48px;
  margin: 0;
  color: #FFFFFF;
  text-align: center;
  text-shadow: 0 1px 4px #000000;
  overflow-wrap: anywhere;
}

.story-step {
  position: absolute;
  top: 50%;
  z-index: 1;
  border: 1px solid rgb(255 255 255 / 32%);
  background: rgb(0 0 0 / 42%);
  color: #FFFFFF;
  transform: translateY(-50%);
}

.story-step.previous { left: 8px; }
.story-step.next { right: 8px; }
.story-step:disabled { opacity: .35; }

.story-tap-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 1;
  width: 38%;
  border: 0;
  background: transparent;
  color: transparent;
}

.story-tap-zone.previous { left: 0; }
.story-tap-zone.next { right: 0; }
.story-actions { position: absolute; z-index: 4; right: 16px; bottom: 16px; left: 16px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.story-actions button { min-height: 38px; padding: 8px 12px; border: 1px solid rgb(255 255 255 / 35%); border-radius: 999px; background: rgb(0 0 0 / 55%); color: #fff; font: inherit; font-size: 13px; }
.story-actions button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.story-actions .form-status { flex-basis: 100%; color: #fff; text-align: center; }

/* 16. Comments dialog */
.comment {
  margin: 0 0 10px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-secondary);
  overflow-wrap: anywhere;
}

.comment p { margin: 8px 0 0; color: var(--text); line-height: 1.5; white-space: pre-wrap; }

#comment-form {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

#comment-input {
  min-width: 0;
  flex: 1;
}

.more-nav { display: grid; }

.more-nav button {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 0 4px;
  text-align: left;
}

.more-nav button:last-child { border-bottom: 0; }
.more-nav button:hover { background: var(--hover); }

.more-nav .danger { color: var(--danger); }

.notification-settings {
  display: grid;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding: 10px 4px 12px;
}
.notification-setting {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  color: var(--text);
  cursor: pointer;
}
.notification-setting > span { display: grid; min-width: 0; gap: 3px; }
.notification-setting strong { font-size: 14px; font-weight: 650; }
.notification-setting small { color: var(--text-secondary); font-size: 12px; line-height: 1.45; }
.notification-setting input {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}
.notification-settings #browser-notifications-status { margin: 0; font-size: 12px; }
.notification-settings #browser-notifications-button { min-height: 42px; }
.notification-setting:focus-within input { outline: 2px solid var(--accent); outline-offset: 3px; }

.more-language {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
}

.presence-setting {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.privacy-settings {
  display: grid;
  gap: 5px;
  border-bottom: 1px solid var(--border);
  padding: 4px 8px 10px;
}
.privacy-settings .presence-setting { min-height: 42px; border: 0; padding: 0; cursor: pointer; }
.privacy-settings .presence-setting input { width: 20px; height: 20px; flex: 0 0 20px; margin: 0; accent-color: var(--accent); }
.privacy-settings .presence-setting:focus-within input { outline: 2px solid var(--accent); outline-offset: 3px; }
.privacy-settings > small { color: var(--text-secondary); font-size: 11px; line-height: 1.45; }
.privacy-settings > .form-status { min-height: 0; margin: 0; color: var(--text-secondary); font-size: 11px; line-height: 1.4; }
.privacy-settings > .mobile-secondary { min-height: 36px; justify-self: start; padding: 6px 10px; font-size: 12px; }

.presence-setting input {
  width: 18px;
  height: 18px;
  accent-color: var(--text);
}

.data-usage-dialog:not([open]) { display: none; }
.data-usage-dialog[open] {
  position: fixed;
  z-index: 50;
  inset: 50% auto auto 50%;
  display: grid;
  width: min(480px, calc(100vw - 32px));
  max-height: min(760px, calc(100dvh - 32px));
  margin: 0;
  transform: translate(-50%, -50%);
  gap: 14px;
  overflow-y: auto;
}
.data-usage-dialog::backdrop { background: rgb(0 0 0 / 70%); backdrop-filter: blur(4px); }
.data-usage-dialog > header { margin-bottom: 0; }
.data-mode-control { display: grid; gap: 8px; color: var(--text); font-size: 14px; }
.data-mode-control select { width: 100%; min-height: 44px; }
.data-mode-description,
.data-connection-status,
.data-usage-note { margin: 0; color: var(--text-secondary); font-size: 13px; line-height: 1.55; }
.data-connection-status { padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-secondary); }
.data-autoplay-setting { display: flex; min-height: 48px; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--border); padding-top: 10px; color: var(--text); font-size: 14px; }
.data-autoplay-setting input { width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--accent, #8b6cff); }
.data-usage-dialog :focus-visible { outline: 3px solid var(--accent, #8b6cff); outline-offset: 2px; }

.mutual-label {
  align-self: center;
  color: var(--text-secondary);
  font-size: 12px;
}

.profile-edit-preview {
  display: grid;
  justify-items: center;
  gap: 16px;
}

.profile-edit-preview .file-picker { width: 100%; }

.recovery-reminder {
  position: fixed;
  z-index: 30;
  top: 20px;
  right: 20px;
  display: grid;
  width: min(420px, calc(100vw - 40px));
  grid-template-columns: 36px minmax(0, 1fr) 32px;
  align-items: start;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 12px 36px rgb(0 0 0 / 16%);
}
.recovery-reminder.hidden { display: none; }
.recovery-reminder-icon { width: 32px; height: 32px; fill: currentColor; }
.recovery-reminder-copy { min-width: 0; }
.recovery-reminder-copy strong { display: block; font-size: 15px; }
.recovery-reminder-copy p { margin: 6px 0 12px; color: var(--text-secondary); font-size: 13px; line-height: 1.45; }
.recovery-reminder-copy .primary { min-height: 38px; }
.recovery-reminder-close { width: 32px; height: 32px; font-size: 22px; line-height: 1; }
.pwa-update-notice { position: fixed; z-index: 70; right: max(16px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); display: flex; width: min(620px, calc(100vw - 32px)); align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border)); border-radius: 18px; background: var(--surface); box-shadow: 0 18px 48px rgb(15 28 48 / 22%); box-sizing: border-box; }
.pwa-update-notice.hidden { display: none; }
.pwa-update-notice > div { min-width: 0; flex: 1; }
.pwa-update-notice strong { display: block; }
.pwa-update-notice p { margin: 4px 0 0; color: var(--text-secondary); font-size: 13px; line-height: 1.4; }
.pwa-update-notice .primary { min-height: 42px; flex: 0 0 auto; white-space: nowrap; }
.pwa-update-notice .icon-button { width: 38px; height: 38px; flex: 0 0 38px; font-size: 22px; }

#profile-edit-dialog label:not(.file-picker) {
  display: grid;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 13px;
}

#profile-edit-dialog input:not([type="file"]),
#profile-edit-dialog textarea { width: 100%; }

.more-language select {
  max-width: 160px;
  min-height: 36px;
  padding: 0 8px;
}

@media (min-width: 769px) {
  .more-nav .mobile-secondary,
  #more-logout { display: none; }
}

/* 17. Mobile */
.mobile-header,
.mobile-nav { display: none; }

@media (max-width: 1180px) {
  .sidebar { width: 76px; flex-basis: 76px; padding-right: 10px; padding-left: 10px; }
  .brand { justify-content: center; padding: 0; }
  .brand > span,
  .main-nav button span,
  .sidebar-footer > button span,
  .language-control { display: none; }
  .main-nav button,
  .sidebar-footer > button { justify-content: center; padding: 0; }
}

@media (max-width: 900px) {
  .messages-layout { grid-template-columns: minmax(270px, 320px) minmax(0, 1fr); }
  .content { padding-right: 20px; padding-left: 20px; }
}

@media (max-width: 768px) {
  .recovery-reminder {
    top: auto;
    right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    left: 12px;
    width: auto;
    max-height: min(40vh, 260px);
    overflow-y: auto;
    gap: 8px;
    padding: 12px;
  }
  .sidebar { display: none; }
  .mobile-header {
    display: flex;
    height: 60px;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    padding: 0 12px 0 16px;
  }
  .mobile-header strong { font-size: 17px; }
  .mobile-header > div { display: flex; gap: 2px; }
  .mobile-nav {
    position: fixed;
    z-index: 10;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    height: 64px;
    grid-template-columns: repeat(5, 1fr);
    border-top: 1px solid var(--border);
    background: var(--surface);
  }
  .mobile-nav button {
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 3px;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    padding: 4px;
  }
  .mobile-nav button.active { color: var(--text); font-weight: 700; }
  .mobile-nav .icon { width: 21px; height: 21px; }
  .mobile-nav span { font-size: 10px; }
  .app-main { padding-bottom: 64px; }
  .page { min-height: calc(100vh - 124px); }
  .content { width: 100%; padding: 24px 16px 32px; }
  .page-heading { margin-bottom: 16px; }
  .page-heading h1 { font-size: 24px; }
  .create-post-button span { display: none; }
  .create-post-button { width: 40px; padding: 0; }
  .messages-layout { display: block; min-height: calc(100vh - 124px); }
  .people-pane { min-height: calc(100vh - 124px); padding: 20px 16px 24px; border-right: 0; }
  .chat-panel {
    position: fixed;
    z-index: 20;
    inset: 0;
    display: block;
    min-height: 100dvh;
    transform: translateX(100%);
    background: var(--bg);
    transition: transform .2s ease;
  }
  .chat-panel.open { transform: none; }
  .conversation,
  .conversation-empty { min-height: 100dvh; }
  .conversation { height: 100dvh; }
  .conversation > header { padding: 10px 12px; }
  .chat-box { padding: 16px; }
  .conversation form { padding: 10px 12px 16px; }
  .stats { gap: 12px; }
  dialog {
    width: min(100% - 20px, 560px);
    max-height: calc(100dvh - 20px);
    overflow-y: auto;
    padding: 16px;
  }
  #story-dialog {
    width: min(100% - 16px, 480px);
    max-height: calc(100dvh - 16px);
    padding: 0;
  }
  #story-viewer { min-height: min(700px, calc(100dvh - 16px)); }
}

/* Instagram inspired home feed and inbox layout. */
@media (min-width: 769px) {
  #home-section .home-layout { width: min(100%, 1010px); grid-template-columns: minmax(0, 675px) minmax(230px, 265px); gap: 28px; padding-top: 26px; }
  #home-section .page-heading { min-height: 54px; margin-bottom: 18px; }
  #home-section .page-heading .eyebrow { margin-bottom: 2px; }
  #home-section .stories-section { border-radius: 0; border: 0; border-bottom: 1px solid var(--border); background: transparent; padding: 0; margin-bottom: 22px; }
  #home-section .stories-heading { padding: 0 2px 10px; }
  #home-section .stories { gap: 18px; }
  #home-section .feed { gap: 14px; margin-top: 14px; }
  #home-section .post { padding: 10px 12px 12px; }
  #home-section .post-media-frame { border-radius: 2px; background: #000; }
  #home-section .post-media-frame > .post-media { max-height: min(72vh, 760px); }
  #home-section .suggested-panel { top: 24px; border: 0; background: transparent; padding: 4px 0; }
  #messages-section .people-pane { background: var(--bg); }
  #messages-section .inbox-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); border: 0; border-radius: 0; border-bottom: 1px solid var(--border); background: transparent; padding: 0; }
  #messages-section .inbox-tabs button { border-radius: 0; }
  #messages-section .inbox-tabs button.active { border-bottom: 2px solid var(--text); background: transparent; box-shadow: none; }
}

@media (max-width: 768px) {
  #home-section .home-layout { padding-top: 12px; }
  #home-section .page-heading { margin-bottom: 12px; }
  #home-section .stories-section { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: transparent; padding: 0; margin-bottom: 14px; }
  #home-section .stories-heading { padding: 0 2px 8px; }
  #home-section .feed { gap: 12px; }
  #home-section .post { border-radius: 4px; padding: 8px 0 12px; }
  #home-section .post-media-frame { border-radius: 0; }
  #home-section .suggested-panel { border-radius: 0; }
}

@media (max-width: 520px) {
  #home-section .content { padding: 14px 12px 28px; }
  #home-section .page-heading h1 { font-size: 21px; }
  #home-section .stories { gap: 13px; padding-bottom: 12px; }
  #home-section .story { width: 62px; flex-basis: 62px; }
  #home-section .story .avatar { width: 56px; height: 56px; }
  #home-section .post-head { padding-inline: 2px; }
  #home-section .post-body { padding-inline: 4px; }
}

@media (max-width: 768px) {
  .page-heading { align-items: flex-start; }
  .story { width: 62px; flex-basis: 62px; }
  .story .avatar { width: 54px; height: 54px; }
  .post-grid { gap: 2px; }
  .message-row { max-width: 88%; }
  .stats { justify-content: space-between; gap: 8px; font-size: 12px; }
  .message-avatar { display: none; }
  .create-options { grid-template-columns: 1fr; }
}

/* 18. Accessibility */
.more-nav button:focus-visible,
.inbox-tabs button:focus-visible,
.list-item:focus-visible {
  outline-offset: -2px;
}

@media (max-width: 375px) {
  .people-pane { padding-right: 12px; padding-left: 12px; }
  .message-row { max-width: 92%; }
  .conversation form { gap: 4px; padding-right: 8px; padding-left: 8px; }
  #send-button { width: 40px; min-width: 40px; padding: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-panel { transition: none; }
  .story-progress span.current::before { animation: none; transform: scaleX(0); }
  .video-feed { scroll-snap-type: none; }
}
.recovery-notification {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--accent, #6b5cff);
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent, #6b5cff) 8%, transparent);
}
.recovery-icon { color: var(--accent, #6b5cff); font-size: 1.25rem; }
.recovery-notification-body { flex: 1; min-width: 0; }
.recovery-notification-body > strong, .recovery-pinned { display: block; }
.recovery-pinned { color: var(--accent, #6b5cff); font-weight: 700; }
.recovery-notification-body p { margin: 8px 0; }
.recovery-code-value { overflow-wrap: anywhere; font-family: monospace; user-select: all; }

/* Suggested people and richer conversation controls. */
.home-layout { display: grid; width: min(100%, 1000px); grid-template-columns: minmax(0, 680px) minmax(210px, 260px); align-items: start; gap: 28px; }
.home-layout .feed-layout { width: 100%; }
.suggested-panel { position: sticky; top: 18px; padding: 18px 14px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.suggested-panel h2 { margin: 0 0 12px; font-size: 15px; }
.suggested-users { display: grid; gap: 8px; }
.suggested-user { display: grid; min-width: 0; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 8px; border-radius: var(--radius-md); padding: 6px; transition: background-color var(--motion-fast); }
.suggested-user:hover { background: var(--hover); }
.suggested-user .avatar { width: 38px; height: 38px; }
.suggested-user .suggested-identity { min-width: 0; }
.suggested-identity strong, .suggested-identity small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggested-identity small { color: var(--text-secondary); }
.suggested-user button { min-height: 32px; padding: 4px 8px; font-size: 12px; }
.conversation-actions { display: flex; margin-left: auto; gap: 2px; }
.conversation-actions .icon-button { width: 38px; height: 38px; }
.conversation-actions .unavailable-call { opacity: .45; cursor: not-allowed; }
.call-unavailable-note { color: var(--text-secondary); font-size: 10px; white-space: nowrap; }
.voice-recording-panel, .voice-preview-panel { position: static; z-index: 2; display: flex; width: 100%; min-width: 0; min-height: 48px; align-items: center; gap: 8px; padding: 0 4px; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.voice-recording-panel.hidden, .voice-preview-panel.hidden, .suggested-panel .hidden { display: none; }
.recording-indicator { width: 10px; height: 10px; border-radius: 50%; background: #df3d58; box-shadow: 0 0 0 4px color-mix(in srgb, #df3d58 18%, transparent); }
.voice-preview-panel audio { width: min(44%, 260px); min-width: 120px; height: 38px; }
.message-audio-player { display: grid; min-width: min(250px, 55vw); gap: 4px; }
.message-audio-player audio { width: 100%; height: 38px; }
.message-audio-player small { font-size: 11px; opacity: .75; }
.note-item { position: relative; display: grid; width: 78px; flex: 0 0 78px; justify-items: center; gap: 6px; border: 0; background: transparent; color: var(--text); padding: 4px; }
.note-main { display: grid; width: 100%; justify-items: center; gap: 6px; border: 0; background: transparent; color: var(--text); padding: 4px; }
.note-audio-control { width: 74px; justify-items: center; }
.note-audio-control progress { width: 100%; height: 3px; }
.audio-play-button { width: 38px; height: 34px; padding: 4px; }
.message-audio-player { grid-template-columns: 38px minmax(48px, 1fr) auto; align-items: center; }
.message-audio-player progress { width: 100%; height: 4px; }
.note-audio-picker { margin: 10px 0; }
.note-audio-preview { display: grid; gap: 8px; }
.note-audio-preview audio { width: 100%; }
.note-compose-dialog { box-sizing: border-box; width: min(470px, calc(100vw - 32px)); max-height: min(88dvh, 760px); overflow: auto; padding: clamp(17px, 4vw, 24px); border: 1px solid color-mix(in srgb, #9b8dff 27%, var(--border)); border-radius: 24px; background: radial-gradient(ellipse at 50% -25%, rgb(118 101 255 / 12%), transparent 58%), var(--surface, #111); color: var(--text); box-shadow: 0 26px 80px rgb(0 0 0 / 52%); }
.note-compose-dialog::backdrop { background: rgb(0 0 0 / 72%); backdrop-filter: blur(7px); }
.note-compose-dialog > form { display: grid; gap: 14px; }
.note-compose-dialog > form > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.note-compose-dialog > form > header h2 { margin: 0; font-size: clamp(1.16rem, 4vw, 1.42rem); letter-spacing: -.025em; }
.note-compose-kicker { margin: 0 0 4px; color: #a89cff; font-size: .64rem; font-weight: 750; letter-spacing: .15em; }
.note-compose-dialog .note-mode-selector { margin: 0; border-color: color-mix(in srgb, var(--border) 76%, transparent); background: color-mix(in srgb, var(--surface-secondary) 86%, #08080d); }
.note-compose-dialog .note-mode-selector button { min-height: 42px; font-size: .84rem; font-weight: 650; }
.note-compose-field { display: grid; gap: 7px; padding: 13px 15px 10px; border: 1px solid color-mix(in srgb, #9b8dff 29%, var(--border)); border-radius: 17px; background: linear-gradient(145deg, color-mix(in srgb, #7665ff 7%, var(--surface)), var(--surface-secondary)); transition: border-color .18s ease, box-shadow .18s ease; }
.note-compose-field:focus-within { border-color: color-mix(in srgb, #9b8dff 76%, var(--border)); box-shadow: 0 0 0 3px rgb(118 101 255 / 12%); }
.note-compose-field-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.note-compose-field-heading label { color: var(--text); font-size: .8rem; font-weight: 700; }
.note-compose-field-heading small { color: var(--text-secondary); font-size: .7rem; font-variant-numeric: tabular-nums; }
.note-compose-field textarea#note-content { display: block; width: 100%; min-height: 96px; resize: vertical; border: 0; border-radius: 0; outline: 0; background: transparent; box-shadow: none; color: var(--text); padding: 4px 0; font: inherit; font-size: .95rem; line-height: 1.55; }
.note-compose-field textarea#note-content:focus-visible { outline: 0; box-shadow: none; }
.note-compose-field textarea#note-content::placeholder { color: var(--text-tertiary); opacity: 1; }
.note-compose-dialog .note-music-attachment { margin-top: 0; gap: 8px; padding: 12px 14px; border-radius: 17px; }
.note-compose-dialog .note-music-attachment-heading { font-size: .82rem; }
.note-compose-dialog .note-music-attachment-heading small { font-size: .68rem; }
.note-compose-dialog .note-music-privacy, .note-compose-dialog .note-music-attachment > small { font-size: .68rem; }
.note-compose-dialog .note-music-select { min-height: 38px; border-radius: 999px; padding-inline: 15px; font-size: .8rem; font-weight: 700; }
.note-music-upload-progress-wrap { display: flex; align-items: center; gap: 10px; color: var(--text-secondary); font-size: .76rem; font-variant-numeric: tabular-nums; }
.note-music-upload-progress-wrap.hidden { display: none; }
.note-music-upload-progress-wrap progress { display: block; width: 100%; height: 7px; flex: 1 1 auto; overflow: hidden; border: 0; border-radius: 99px; background: color-mix(in srgb, var(--text) 13%, transparent); accent-color: var(--accent); }
.note-music-upload-progress-wrap progress::-webkit-progress-bar { border-radius: 99px; background: color-mix(in srgb, var(--text) 13%, transparent); }
.note-music-upload-progress-wrap progress::-webkit-progress-value { border-radius: 99px; background: linear-gradient(90deg, #7965ff, #d85cba); transition: width .16s ease; }
.note-music-upload-progress-wrap progress::-moz-progress-bar { border-radius: 99px; background: linear-gradient(90deg, #7965ff, #d85cba); }
.note-compose-dialog .note-form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 3px; }
.note-compose-dialog .note-form-actions > .primary { min-width: 108px; min-height: 42px; border-radius: 12px; font-weight: 700; }
.note-mode-selector { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-block: 12px; padding: 4px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-secondary); }
.note-mode-selector button { min-height: 40px; border: 0; border-radius: 999px; background: transparent; color: var(--text-secondary); font: inherit; cursor: pointer; }
.note-mode-selector button.active, .note-mode-selector button[aria-selected="true"] { background: var(--gradient-primary); color: #fff; box-shadow: 0 5px 16px color-mix(in srgb, var(--accent) 24%, transparent); }
.note-mode-selector button:disabled { opacity: .5; cursor: not-allowed; }
.note-music-attachment { display: grid; gap: 9px; margin-top: 12px; padding: 13px; border: 1px solid color-mix(in srgb, #9b8dff 30%, var(--border)); border-radius: 16px; background: linear-gradient(145deg, color-mix(in srgb, #7665ff 9%, var(--surface)), var(--surface-secondary)); }
.note-music-attachment-heading { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 10px; color: var(--text); font-size: 13px; font-weight: 650; }
.note-music-attachment-heading small, .note-music-privacy, .note-music-attachment > small { color: var(--text-secondary); font-size: 11px; line-height: 1.45; }
.note-music-select { justify-self: start; min-height: 40px; }
.note-music-select:disabled { opacity: .55; cursor: not-allowed; }
.note-music-preview { width: 100%; }
.note-music-preview audio { width: 100%; height: 38px; accent-color: var(--accent); }
.note-music-indicator { display: inline-flex; width: 17px; height: 17px; flex: 0 0 17px; align-items: center; justify-content: center; margin-inline-start: 6px; color: var(--accent); vertical-align: -3px; }
.note-music-indicator .icon { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.note-record-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.note-recording-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding-block: 10px; }
.note-recording-panel.hidden, .note-audio-preview.hidden { display: none; }
.note-recording-panel strong { font-variant-numeric: tabular-nums; }
.note-avatar-wrap { position: relative; }
.note-avatar-wrap .avatar { width: 54px; height: 54px; outline: 2px solid color-mix(in srgb, var(--accent) 52%, transparent); outline-offset: 2px; }
.note-bubble { position: absolute; top: -20px; left: 50%; z-index: 1; width: max-content; max-width: 150px; transform: translateX(-50%); overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); padding: 5px 8px; font-size: 11px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.note-identity { width: 100%; overflow: hidden; color: var(--text-secondary); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.note-item.unread .note-avatar-wrap .avatar { outline-color: var(--accent); outline-width: 3px; }
.note-audio-preview { display: grid; gap: 8px; }
.note-audio-preview audio { width: 100%; }
.story-reactions { display: flex; justify-content: center; gap: 6px; }
.story-reactions button { width: 42px; height: 42px; border: 1px solid transparent; border-radius: 50%; background: rgb(255 255 255 / 14%); font-size: 22px; }
.story-reactions button[aria-pressed="true"] { border-color: #fff; background: rgb(255 255 255 / 28%); }
.story-reply-form { display: flex; gap: 6px; }
.story-reply-form input { min-width: 0; flex: 1; border-color: rgb(255 255 255 / 45%); background: rgb(0 0 0 / 35%); color: #fff; }
.story-reply-form input::placeholder { color: rgb(255 255 255 / 75%); }
.story-reply-form button { flex: 0 0 auto; }
.story-progress.paused span.current::before { animation-play-state: paused; }
.post-media-frame { position: relative; touch-action: pan-y; }
.double-tap-heart { position: absolute; z-index: 2; top: 50%; left: 50%; color: #fff; font-size: clamp(72px, 18vw, 150px); line-height: 1; pointer-events: none; text-shadow: 0 4px 24px rgb(0 0 0 / 45%); animation: double-tap-heart-pop 850ms ease-out both; }
@keyframes double-tap-heart-pop { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.25) rotate(-18deg); } 22% { opacity: 1; transform: translate(-50%, -50%) scale(1.08) rotate(0); } 72% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(.92); } }
.hashtag-link { display: inline; min-height: 0; border: 0; padding: 0; background: transparent; color: var(--accent); font: inherit; cursor: pointer; }
.hashtag-link:hover { text-decoration: underline; }
.explore-layout .page-heading { align-items: center; }
.explore-layout .page-heading button { flex: 0 0 auto; }
.search-content { width: min(100%, 1100px); }
.follow-content { width: min(100%, 760px); }
.follow-content > .page-heading { margin-bottom: 18px; }
.follow-mode { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 16px; }
.follow-directory-list { margin-top: 8px; }
.follow-directory-row { min-height: 76px; gap: 14px; padding: 12px 8px; }
.follow-directory-row > .avatar { width: 48px; height: 48px; flex: 0 0 48px; }
.follow-directory-row .name { gap: 2px; }
.follow-directory-row .name small { font-weight: 450; }
.follow-directory-row .follow-directory-bio { max-width: 100%; font-size: 12px; }
.follow-directory-row > button:last-child { min-width: 112px; min-height: 40px; border-radius: 12px; font-weight: 700; }
#follow-directory-more { display: block; margin: 18px auto 0; }
#follow-directory-more.hidden { display: none; }
.search-brand-sign { display: inline-flex; align-items: center; gap: 8px; margin: 12px 0 6px; padding: 6px 14px; border-radius: 999px; background: rgb(98 86 232 / 10%); border: 1px solid rgb(98 86 232 / 20%); color: var(--text); font-size: 13px; font-weight: 600; letter-spacing: -.01em; width: fit-content; }
.search-brand-sign.hidden { display: none !important; }
.search-brand-sign .search-brand-mark { display: inline-grid; place-items: center; width: 22px; height: 22px; overflow: hidden; border-radius: 6px; background: transparent; }
.search-brand-sign .search-brand-mark img { width: 100%; height: 100%; display: block; object-fit: contain; }
.search-brand-sign .search-brand-name { color: var(--text); font-weight: 700; }
.search-brand-sign .search-brand-badge { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); background: rgb(98 86 232 / 12%); padding: 2px 7px; border-radius: 999px; }
#search-explore-panel .page-heading { margin: 20px 0 8px; }
@media (prefers-reduced-motion: reduce) { .double-tap-heart { animation-duration: 1ms; } }

.video-tile-indicator { position: absolute; top: 8px; right: 8px; display: grid; width: 28px; height: 28px; place-items: center; border-radius: 9px; background: rgb(0 0 0 / 56%); color: #fff; }
.video-tile-indicator .icon { width: 16px; height: 16px; }
.story-actions { justify-content: flex-end; }
.story-actions .story-viewers-control { margin-right: auto; }
.story-actions .story-reactions { justify-content: center; flex-basis: 100%; }
.story-reply-form { display: flex; width: 100%; min-width: 0; gap: 0; padding: 4px; border: 1px solid rgb(255 255 255 / 42%); border-radius: 999px; background: rgb(0 0 0 / 45%); }
.story-reply-form input { min-width: 0; flex: 1; border: 0; border-radius: 999px; background: transparent; color: #fff; }
.story-reply-form input::placeholder { color: rgb(255 255 255 / 78%); }
.story-reply-form .story-reply-send { display: grid; width: 42px; min-width: 42px; height: 42px; min-height: 42px; place-items: center; border: 0; border-radius: 50%; background: transparent; color: #fff; }
.story-reply-send .icon { width: 20px; height: 20px; }
.story-reply-status { flex-basis: 100%; padding: 2px 10px 4px; color: #fff; font-size: 12px; }
.story-actions .story-reply-form { flex-wrap: wrap; }
.story-reply-form:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 38%, transparent); }
.story-reply-form button:focus-visible,
.story-reply-form input:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.story-reply-form button:disabled { opacity: .55; }
.message-story-reply-preview { display: flex; width: fit-content; max-width: 100%; align-items: center; gap: 6px; margin: 0 0 7px; padding: 4px 7px; border: 1px solid color-mix(in srgb, var(--border) 75%, transparent); border-radius: 10px; background: color-mix(in srgb, var(--surface-secondary) 88%, #000); }
.message-story-reply-profile,
.message-story-reply-text { display: inline-flex; min-width: 0; align-items: center; gap: 6px; border: 0; background: transparent; color: inherit; padding: 0; text-align: left; }
.message-story-reply-profile { flex: 0 0 auto; }
.message-story-reply-text { overflow: hidden; color: var(--text-secondary); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.message-story-reply-avatar { width: 24px; height: 24px; flex: 0 0 24px; }
.message-story-reply-author { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.message-story-reply-preview button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 5px; }
.message-composer-bar { position: relative; display: flex; width: 100%; min-width: 0; align-items: center; gap: 5px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-secondary); }
.message-composer-controls { display: flex; width: 100%; min-width: 0; align-items: center; gap: 5px; }
.message-composer-controls > .icon-button { width: 40px; height: 40px; flex: 0 0 40px; }
.message-composer-controls textarea { min-height: 40px; max-height: 100px; border: 0; background: transparent; box-shadow: none; padding: 9px 6px; }
.message-composer-controls textarea:focus { box-shadow: none; }
.conversation, .chat-panel, .chat-box, #composer-form, .message-composer-bar, .message-composer-controls { min-width: 0; max-width: 100%; box-sizing: border-box; }
.chat-panel { overflow: hidden; }
.chat-box { overflow-x: hidden; }
.message { max-width: min(78%, 520px); overflow-wrap: anywhere; }
.message-image-button { display: block; width: fit-content; max-width: 100%; border: 0; border-radius: 10px; background: transparent; padding: 0; line-height: 0; }
.message-image-button img { width: auto; max-width: min(100%, 300px); max-height: 360px; object-fit: cover; }
.message.shared-story-message { width: fit-content; max-width: min(300px, 100%); border: 1px solid var(--border); border-radius: 14px; background: #202020; padding: 6px; }
.message.shared-story-message .message-image-button { overflow: hidden; border-radius: 9px; }
.message.shared-story-message .message-image-button img { max-height: 280px; }
.message.shared-story-message > div:not(.message-footer) { padding: 6px 4px 2px; color: var(--text-secondary); font-size: 12px; }
.message > a { display: block; max-width: 100%; }
.message > a img { display: block; max-width: 100%; height: auto; border-radius: 14px; }
.message-audio-player { display: flex; width: min(100%, 310px); max-width: 100%; min-width: 0; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 18px; background: var(--gradient-primary); color: #fff; box-sizing: border-box; }
.message-audio-player .audio-play-button { width: 34px; min-width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: rgb(255 255 255 / 22%); color: #fff; }
.message-audio-player progress { width: 100%; min-width: 44px; height: 5px; accent-color: #fff; }
.message-audio-player small { flex: 0 0 auto; color: #fff; font-size: 11px; }
.chat-box { row-gap: 12px; }
.message-row.no-avatar:not(.own) { margin-left: 38px; }
.media-dialog { display: none; grid-template-rows: 56px minmax(0, 1fr) 56px; width: min(96vw, 1100px); max-width: none; height: min(92vh, 920px); height: min(92dvh, 920px); max-height: none; overflow: hidden; padding: 0; border: 1px solid var(--border-strong); border-radius: 20px; background: var(--bg); color: var(--text); }
.media-dialog[open] { display: grid; }
.media-dialog::backdrop { background: rgb(0 0 0 / 78%); backdrop-filter: blur(12px) saturate(.8); }
.media-dialog > header { display: flex; min-height: 0; align-items: center; justify-content: flex-end; gap: 0; box-sizing: border-box; margin: 0; padding: 6px 10px; }
.media-dialog > header .icon-button,
.media-dialog > footer .icon-button { display: grid; width: 44px; min-width: 44px; height: 44px; place-items: center; border: 1px solid var(--border); border-radius: 50%; background: color-mix(in srgb, var(--surface) 86%, transparent); color: var(--text); }
.media-dialog > header .icon-button:hover,
.media-dialog > footer .icon-button:hover:not(:disabled) { background: var(--hover); }
.media-viewer { position: relative; display: grid; min-width: 0; min-height: 0; place-items: center; overflow: hidden; padding: 0 56px; background: #000; }
.media-viewer-media { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 12px; }
.media-viewer-status { position: absolute; z-index: 2; bottom: 14px; left: 50%; max-width: calc(100% - 24px); margin: 0; transform: translateX(-50%); border: 1px solid rgb(255 255 255 / 18%); border-radius: 999px; background: rgb(0 0 0 / 78%); color: #fff; padding: 7px 12px; font-size: 12px; line-height: 1.3; text-align: center; pointer-events: none; }
.media-viewer-status[hidden] { display: none; }
.media-viewer-status.is-error { border-color: rgb(255 255 255 / 30%); }
.media-dialog > footer { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 6px 10px; color: var(--text-secondary); font-size: 12px; font-variant-numeric: tabular-nums; }
.media-dialog > footer .icon-button:disabled { opacity: .35; }
.media-dialog.has-private-video > footer { visibility: hidden; }
html.media-overlay-open,
body.media-overlay-open { overflow: hidden !important; overscroll-behavior: none; }
.feed-state-message { grid-column: 1 / -1; display: grid; min-height: 180px; place-items: center; margin: 0; color: var(--text-secondary); }
.composer-send { color: var(--accent); }
.voice-preview-panel audio { width: auto; min-width: 0; flex: 1 1 auto; height: 36px; }
.voice-recording-panel > button, .voice-preview-panel > button { width: 40px; height: 40px; flex: 0 0 40px; }
.video-note-capture-panel { display: flex; width: 100%; min-width: 0; align-items: center; gap: 7px; padding: 3px; }
.video-note-capture-panel.hidden { display: none; }
.video-note-capture-panel video { width: min(190px, 42vw); min-width: 84px; max-height: 112px; aspect-ratio: 16 / 9; flex: 1 1 auto; border-radius: 10px; background: #000; object-fit: cover; }
.video-note-capture-panel #video-note-preview { object-fit: contain; }
.video-note-capture-panel > button { width: 38px; height: 38px; flex: 0 0 38px; }
#video-note-recording-time { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.message-video-note-player { position: relative; width: min(100%, 340px); max-width: min(100%, 68vw); }
.video-note-play-button { min-height: 40px; }
.message-video-note-player video { display: block; width: 100%; max-height: 360px; border-radius: 12px; background: #000; }
.message-video-note-player video[hidden] { display: none; }
.video-note-expand-button { position: absolute; right: 10px; bottom: 10px; z-index: 2; width: 44px; height: 44px; border: 1px solid rgb(255 255 255 / 24%); border-radius: 50%; background: rgb(0 0 0 / 66%); color: #fff; backdrop-filter: blur(8px); }
.video-note-expand-button .icon { width: 19px; height: 19px; }
.video-note-expand-button[hidden] { display: none; }
@media (max-width: 520px) {
  .conversation form { display: block; padding: 8px 10px max(10px, env(safe-area-inset-bottom)); }
  .message-composer-bar { gap: 2px; padding: 3px 5px; }
  .message-composer-controls { gap: 2px; }
  .message-composer-controls > .icon-button { width: 36px; height: 40px; flex-basis: 36px; }
  .message-composer-controls textarea { font-size: 14px; }
  #emoji-button { display: grid; }
}
@media (max-width: 375px) { #emoji-button { display: grid; } }

@media (max-width: 1050px) {
  .home-layout { grid-template-columns: minmax(0, 680px); justify-content: center; }
  .suggested-panel { position: static; display: grid; grid-template-columns: 1fr; }
  .suggested-users { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
}
@media (max-width: 620px) {
  .home-layout { display: flex; flex-direction: column; gap: 16px; }
  .suggested-panel { width: 100%; order: 2; padding: 12px; }
  .suggested-users { display: flex; overflow-x: auto; }
  .suggested-user { min-width: 190px; }
  .conversation-actions { gap: 0; }
  .conversation-actions .icon-button { width: 32px; height: 36px; }
  .call-unavailable-note { display: none; }
  .voice-preview-panel { flex-wrap: nowrap; }
  .voice-preview-panel audio { flex: 1 1 auto; width: auto; }
  .pwa-update-notice { right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); width: calc(100vw - 20px); flex-wrap: wrap; gap: 8px; padding: 12px; }
  .pwa-update-notice > div { flex-basis: calc(100% - 48px); }
  .pwa-update-notice .primary { margin-left: auto; }
  .story-reactions { gap: 2px; }
  .story-reactions button { width: 36px; height: 36px; }
}
@media (max-width: 375px) {
  #emoji-button { display: grid; }
  #send-button { width: 36px; min-width: 36px; padding: 4px; }
}

/* Ihuza social presentation refresh */
.sidebar { border-right-color: color-mix(in srgb, var(--border) 78%, var(--accent)); }
.brand .mark { filter: drop-shadow(0 4px 12px color-mix(in srgb, var(--accent) 24%, transparent)); }
.main-nav { gap: 6px; }
.main-nav button { position: relative; min-height: 48px; border-radius: 14px; transition: background-color .16s ease, transform .16s ease; }
.main-nav button:hover { transform: translateX(2px); }
.main-nav button.active { color: var(--accent); }
.main-nav button.active .icon { stroke-width: 2.5; }
.nav-badge { position: absolute; top: 6px; right: 8px; display: grid; min-width: 17px; height: 17px; place-items: center; border: 2px solid var(--surface); border-radius: 999px; background: var(--accent); color: var(--accent-contrast); padding: 0 4px; font-size: 9px; font-weight: 800; line-height: 1; }

.stories-section {
  overflow: hidden;
  margin-bottom: 20px;
  border: 1px solid color-mix(in srgb, var(--border) 80%, var(--accent) 15%);
  border-radius: 20px;
  background: color-mix(in srgb, var(--surface) 95%, var(--accent) 3%);
  padding: 14px 16px 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
.stories-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 0 2px 10px; }
.stories-heading h2 { margin: 0; font-size: 14px; font-weight: 750; letter-spacing: -0.01em; color: var(--text); }
.stories-heading > span { color: var(--text-secondary); font-size: 11.5px; }
.stories { display: flex; gap: 16px; overflow-x: auto; scrollbar-width: none; padding: 2px 4px 6px; }
.stories::-webkit-scrollbar { display: none; }
.story {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: transform .18s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
  width: 66px;
  flex: 0 0 66px;
}
.story:hover { transform: translateY(-3px) scale(1.03); }
.story .avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--surface);
  transition: transform 0.15s ease;
}
.story-add .avatar {
  display: grid;
  place-items: center;
  border: 2px dashed color-mix(in srgb, var(--accent) 60%, var(--border));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent);
}
.story-add .avatar .icon { width: 22px; height: 22px; stroke-width: 2.2; }
.story.unviewed .avatar {
  border: 2.5px solid transparent;
  background-origin: border-box;
  background-clip: content-box, border-box;
  background-image: linear-gradient(var(--surface), var(--surface)), linear-gradient(135deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  box-shadow: 0 0 0 2px var(--surface);
}
.story span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed { gap: 18px; margin-top: 14px; }
.post {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
  padding: 12px 14px 14px;
  transition: border-color .2s ease, transform .2s ease;
}
.post:hover {
  border-color: color-mix(in srgb, var(--border) 75%, var(--accent) 25%);
}
.post-head { min-height: 52px; gap: 12px; padding: 2px 2px 10px; }
.post-head .meta { gap: 2px; }
.post-head .meta button { font-size: 14px; }
.post-head .meta small { font-size: 11px; }
.post-head .post-handle { display: inline; }
.post-media-frame { border-radius: 14px; overflow: hidden; }
.post-media-frame > .post-media { max-height: min(68vh, 720px); }
.post-body { padding: 8px 2px 0; }
.post-actions { min-height: 42px; gap: 6px; }
.post-actions button {
  min-width: 38px;
  min-height: 38px;
  border-radius: 12px;
  transition: transform .18s cubic-bezier(0.4, 0, 0.2, 1), background-color .15s ease, color .15s ease;
}
.post-actions button:hover {
  transform: scale(1.1);
  background: var(--hover);
}
.post-actions button:active {
  transform: scale(0.92);
}
.post-actions button:first-child .icon { color: var(--danger); }
.post-caption { line-height: 1.5; font-size: 14px; }

.people-pane { background: color-mix(in srgb, var(--surface) 93%, var(--accent)); }
.inbox-header { padding: 0 4px 8px; }
.inbox-header h1 { font-size: 26px; }
.people-pane > .search-input { border-radius: 13px; background: var(--bg); }
.list-item { min-height: 68px; border-radius: 14px; transition: background-color .15s ease; }
.list-item:hover { background: var(--hover); }
.list-item.active, .list-item[aria-current="true"] { box-shadow: inset 3px 0 0 var(--accent); }
.item-main strong { font-size: 13px; }
.item-preview { line-height: 1.35; }
.chat-panel { background: color-mix(in srgb, var(--bg) 96%, var(--accent)); }
.conversation > header { min-height: 68px; background: var(--surface); }
.message { box-shadow: 0 2px 8px rgb(20 30 50 / 5%); }

.search-field { position: relative; display: flex; align-items: center; margin: 0 0 14px; }
.search-field > .icon { position: absolute; left: 14px; width: 18px; height: 18px; color: var(--text-secondary); pointer-events: none; }
.search-field .search-input { width: 100%; min-height: 50px; border-radius: 15px; background: var(--surface); padding-left: 44px; }
.search-mode { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin-bottom: 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-secondary); padding: 4px; }
.search-mode button { min-height: 38px; border: 0; border-radius: 10px; background: transparent; color: var(--text-secondary); font: inherit; font-weight: 650; }
.search-mode button.active { background: var(--surface); color: var(--text); box-shadow: 0 2px 8px rgb(20 30 50 / 8%); }
#search-results:has(.post) { display: grid; gap: 16px; }
#search-results > .post { margin: 0; }

.activity-list { gap: 8px; }
.notification-day-heading { grid-column: 1 / -1; margin: 14px 2px 2px; color: var(--text-secondary); font-size: 12px; font-weight: 700; }
.activity-list .notification-row { min-height: 66px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); padding: 10px 14px; }
.activity-list .notification-row.unread { border-color: color-mix(in srgb, var(--accent) 36%, var(--border)); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.notification-target { min-width: 0; flex: 1; text-align: left; line-height: 1.4; }
.notification-row time { flex: 0 0 auto; color: var(--text-secondary); font-size: 11px; font-weight: 500; }

.mobile-header { position: sticky; top: 0; z-index: 9; }
.mobile-header-actions { display: flex; gap: 6px; }
.mobile-notifications { position: relative; }
.mobile-notifications .nav-badge { top: 0; right: 0; }
.mobile-messages { position: relative; }
.mobile-messages .nav-badge { top: 0; right: 0; }
.mobile-nav { grid-template-columns: repeat(5, minmax(0, 1fr)); height: calc(66px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
.mobile-nav button { min-width: 0; }
.mobile-nav button.active { color: var(--accent); }
.mobile-nav button .icon { width: 20px; height: 20px; }
.mobile-nav button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-main { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }

@media (max-width: 900px) {
  .messages-layout { grid-template-columns: minmax(258px, 310px) minmax(0, 1fr); }
}

@media (max-width: 768px) {
  .stories-section { margin-right: -2px; margin-left: -2px; border-radius: 16px; padding: 12px 13px 0; }
  .feed { gap: 14px; }
  .post { border-radius: 16px; padding: 9px; }
  .activity-list .notification-row { gap: 9px; padding: 9px; }
}

@media (max-width: 520px) {
  .mobile-nav { height: calc(62px + env(safe-area-inset-bottom)); }
  .mobile-nav .icon { width: 19px; height: 19px; }
  .mobile-nav span { font-size: 9px; }
  .app-main { padding-bottom: calc(62px + env(safe-area-inset-bottom)); }
  .post { padding: 7px; }
  .post-actions { gap: 1px; }
  .post-actions button { min-width: 36px; min-height: 36px; padding: 5px; }
}

@media (max-width: 430px) {
  .mobile-header { padding-inline: 12px; }
  .mobile-header-actions { gap: 2px; }
  .mobile-header-actions .icon-button { width: 42px; height: 42px; }
  .message-composer-bar { width: 100%; max-width: 100vw; padding: 4px 7px; }
  .message-composer-controls > .icon-button { width: 34px; flex-basis: 34px; }
  .message-composer-controls textarea { min-width: 0; padding-inline: 3px; }
  .media-dialog { position: fixed; inset: 0; width: 100%; height: 100vh; height: 100dvh; max-height: none; margin: 0; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); border: 0; border-radius: 0; }
  .media-dialog > header { padding-right: max(10px, env(safe-area-inset-right)); }
  .media-dialog > footer { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .media-viewer { padding: 0 8px; }
  .media-viewer-media { border-radius: 8px; }
  .media-dialog.has-private-video > header { position: absolute; z-index: 2; inset: max(8px, env(safe-area-inset-top)) 8px auto auto; }
  .media-dialog.has-private-video .media-viewer { grid-row: 1 / -1; padding: 0; }
  .media-dialog.has-private-video .media-viewer-media { border-radius: 0; }
}

@media (max-width: 360px) {
  .mobile-nav span { font-size: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .main-nav button, .story, .list-item { transition: none; }
}

/* Chat and comment interactions */
.install-notice {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
  align-items: flex-start;
  gap: 10px;
  margin: 14px 0 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  padding: 12px;
  box-shadow: 0 8px 24px rgb(15 23 42 / 14%);
}
.install-notice-copy { display: grid; min-width: 0; flex: 1; gap: 6px; }
.install-notice-copy > strong { padding-right: 24px; font-size: 14px; }
.install-notice-copy > p { margin: 0; color: var(--text-secondary); font-size: 12px; line-height: 1.4; }
.install-notice-copy > .primary { width: fit-content; min-height: 34px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-contrast); padding: 0 12px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.install-notice-close { position: absolute; top: 8px; right: 8px; display: grid; width: 34px; height: 34px; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--text-secondary); font: inherit; font-size: 24px; line-height: 1; cursor: pointer; }
.install-notice-close:hover { background: var(--surface-secondary); color: var(--text); }
.install-notice :focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* Media-first short video feed */
.video-feed {
  display: flex;
  width: min(100%, 680px);
  margin-inline: auto;
  height: calc(100dvh - 168px);
  max-height: 900px;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-snap-type: y mandatory;
  padding: 4px 8px 20px;
}
.video-feed:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.video-reel { display: flex; width: min(100%, 520px); flex: 0 0 auto; flex-direction: column; align-items: center; overflow: visible; border: 0; padding: 0; scroll-snap-align: start; }
.video-reel .post-media-frame { width: min(100%, 430px); height: min(78dvh, 780px); aspect-ratio: 9 / 16; margin: 0 auto; overflow: hidden; border: 1px solid color-mix(in srgb, var(--border) 70%, transparent); border-radius: 22px; background: #000; box-shadow: var(--shadow); }
.video-reel .post-media-frame > video.post-media { width: 100%; height: 100%; max-height: none; border-radius: 0; object-fit: contain; background: #000; }
.video-reel .reel-info { position: absolute; z-index: 2; right: 72px; bottom: 14px; left: 14px; display: grid; gap: 8px; color: #fff; padding: 42px 8px 8px; background: linear-gradient(transparent, rgb(0 0 0 / 68%)); pointer-events: none; }
.video-reel .reel-author { display: flex; min-width: 0; align-items: center; gap: 9px; border: 0; color: #fff; padding: 0; }
.video-reel .reel-author > .post-author { flex: 0 0 auto; }
.video-reel .reel-author > .post-author .avatar { width: 38px; height: 38px; border: 1px solid rgb(255 255 255 / 75%); }
.video-reel .reel-author .meta { min-width: 0; flex: 1; }
.video-reel .reel-author .meta > button { color: #fff; font-weight: 750; }
.video-reel .reel-author .meta small { color: rgb(255 255 255 / 80%); }
.video-reel .reel-author > button, .video-reel .reel-message-share { pointer-events: auto; }
.video-reel .reel-follow { min-height: 34px; border: 1px solid rgb(255 255 255 / 78%); border-radius: 10px; background: rgb(0 0 0 / 18%); color: #fff; padding: 5px 10px; font: inherit; font-size: 12px; font-weight: 700; }
.video-reel .reel-info .post-caption { display: -webkit-box; margin: 0; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; color: #fff; font-size: 13px; line-height: 1.4; pointer-events: auto; }
.video-reel .reel-info .post-caption.is-expanded { display: block; overflow: auto; max-height: 30vh; }
.video-reel .reel-info .caption-toggle { justify-self: start; border: 0; background: transparent; color: #fff; padding: 0; font: inherit; font-size: 12px; pointer-events: auto; }
.video-reel .reel-message-share { justify-self: start; min-height: 30px; border: 1px solid rgb(255 255 255 / 50%); border-radius: 999px; background: rgb(0 0 0 / 22%); color: #fff; padding: 4px 10px; font: inherit; font-size: 12px; }
.video-reel .reel-actions { position: absolute; z-index: 3; right: 8px; bottom: 18px; display: grid; width: 48px; gap: 8px; pointer-events: auto; }
.video-reel .reel-actions button { display: grid; min-width: 44px; min-height: 46px; justify-items: center; align-content: center; gap: 3px; border: 1px solid rgb(255 255 255 / 28%); border-radius: 14px; background: rgb(0 0 0 / 40%); color: #fff; padding: 4px; font: inherit; font-size: 11px; line-height: 1.1; }
.video-reel .reel-actions .icon { width: 20px; height: 20px; color: #fff; }
.video-reel .reel-sound-toggle { position: absolute; z-index: 3; top: 12px; right: 12px; min-height: 36px; border: 1px solid rgb(255 255 255 / 38%); border-radius: 999px; background: rgb(0 0 0 / 48%); color: #fff; padding: 6px 10px; font: inherit; font-size: 12px; }
.video-reel-navigation { display: flex; width: min(100%, 430px); justify-content: space-between; margin: 4px auto 0; }
.video-reel-navigation button { border: 1px solid var(--border); background: var(--surface); }

.message-row { flex-wrap: wrap; }
.message-row.own { justify-self: stretch; justify-content: flex-end; }
.message-row.grouped-before:not(.own) { margin-left: 38px; }
.message-row.grouped-before .message { border-top-left-radius: 6px; }
.message-row.grouped-before.own .message { border-top-left-radius: 14px; border-top-right-radius: 6px; }
.message-row.grouped-after .message { border-bottom-left-radius: 6px; }
.message-row.grouped-after.own .message { border-bottom-left-radius: 14px; border-bottom-right-radius: 6px; }
.message-reaction-tray { display: flex; flex-basis: 100%; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.message-reaction { min-height: 28px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); padding: 3px 9px; font: inherit; font-size: 12px; }
.message-reaction.mine { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.message-reply-reference { display: block; max-width: min(100%, 320px); margin: 0 0 7px; overflow: hidden; border: 0; border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); color: inherit; padding: 6px 9px; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.message-reply-reference:disabled { cursor: default; opacity: .72; }
.message-forwarded { display: block; margin-bottom: 4px; opacity: .72; font-size: 11px; }
.message-date-separator { display: flex; justify-content: center; margin: 14px 0; color: var(--text-secondary); font-size: 11px; }
.message-date-separator span { border: 1px solid var(--border); border-radius: 999px; background: var(--surface); padding: 4px 10px; }
.message-highlight .message { outline: 2px solid var(--accent); outline-offset: 3px; }
.message-compose-context { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; border-left: 3px solid var(--accent); border-radius: 9px; background: var(--surface-secondary); }
.message-compose-context > div { display: grid; min-width: 0; gap: 2px; }
.message-compose-context strong, .message-compose-context span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-compose-context span { color: var(--text-secondary); font-size: 12px; }
.message-action-content { display: grid; gap: 16px; }
.message-quick-reactions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.message-quick-reactions button { width: 42px; height: 42px; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); font-size: 20px; }
.message-action-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.message-action-list button {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  appearance: none;
  background: var(--surface-secondary);
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}
.message-action-list button:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: var(--hover); }
.message-action-list button .icon { width: 18px; height: 18px; flex: 0 0 auto; color: var(--text-secondary); }
.message-action-list button.danger { color: var(--danger); }
.message-action-list button.danger .icon { color: currentColor; }
.message-pinned-label { display: block; margin: -2px 0 6px; color: var(--text-secondary); font-size: 11px; font-weight: 650; }
.message-highlight .message { outline: 2px solid color-mix(in srgb, var(--accent) 65%, transparent); outline-offset: 3px; }

/* Story controls follow the compact Instagram viewer layout. */
.story-actions {
  right: 14px;
  bottom: 14px;
  left: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.story-actions .story-reply-form {
  order: 0;
  width: auto;
  min-width: 0;
  flex: 1 1 150px;
  padding: 3px 5px 3px 12px;
}
.story-actions .story-reply-form input { min-height: 38px; padding: 7px 4px; }
.story-actions .story-reply-form .story-reply-send { width: 36px; min-width: 36px; height: 36px; min-height: 36px; }
.story-actions .story-like-button,
.story-actions .story-share-button {
  display: grid;
  width: 42px;
  min-width: 42px;
  height: 42px;
  min-height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border: 0;
  background: transparent;
  padding: 7px;
}
.story-actions .story-like-button .icon,
.story-actions .story-share-button .icon { width: 26px; height: 26px; }
.story-actions .story-like-button .icon { fill: transparent; transition: fill .15s ease, color .15s ease, transform .15s ease; }
.story-actions .story-like-button.liked { color: #ff3040; }
.story-actions .story-like-button.liked .icon { fill: #ff3040; transform: scale(1.06); }
.story-actions .story-viewers-control { margin-right: auto; }
.story-actions #story-status { flex-basis: 100%; }
.story-stage { isolation: isolate; }
.chat-box { overscroll-behavior-y: contain; scrollbar-gutter: stable; }
.people-pane { overscroll-behavior-y: contain; }
.message-action-dialog header { position: sticky; top: 0; z-index: 1; }
.message-quick-reactions button { transition: transform .14s ease, background-color .14s ease; }
.message-quick-reactions button:hover { transform: translateY(-2px) scale(1.06); }
@media (max-width: 480px) {
  .story-actions { right: 10px; bottom: 10px; left: 10px; gap: 5px; }
  .story-actions .story-reply-form { flex-basis: 120px; }
  .story-actions .story-like-button, .story-actions .story-share-button { width: 38px; min-width: 38px; height: 40px; min-height: 40px; flex-basis: 38px; padding: 6px; }
}

@media (min-width: 769px) {
  #story-dialog { width: min(356px, calc(100vw - 24px)); height: min(760px, calc(100dvh - 32px)); max-height: calc(100dvh - 32px); border-radius: 12px; }
  #story-viewer { height: 100%; min-height: 0; grid-template-rows: auto auto minmax(0, 1fr); gap: 10px; padding: 18px 16px 14px; }
  .story-media { height: 100%; max-height: 100%; min-height: 0; object-fit: cover; }
  .message-action-list { grid-template-columns: 1fr; gap: 4px; }
  .message-action-list button { justify-content: flex-start; border: 0; background: transparent; padding-inline: 12px; text-align: left; }
  .message-action-list button:hover { background: var(--hover); }
}
.forward-message-preview { overflow-wrap: anywhere; border-left: 3px solid var(--accent); background: var(--surface-secondary); padding: 10px 12px; }
.forward-destination { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.forward-destination > span { display: grid; min-width: 0; flex: 1; }
.forward-destination small { color: var(--text-secondary); }
.comments-dialog { width: min(560px, calc(100vw - 32px)); }
#comments-list { max-height: min(58vh, 540px); overflow-y: auto; overscroll-behavior: contain; }
.comment-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.comment-head strong { min-width: 0; overflow-wrap: anywhere; }
.comment-author { display: flex; min-width: 0; align-items: center; gap: 8px; border: 0; background: transparent; color: var(--text); padding: 0; text-align: left; }
.comment-author > span { display: grid; min-width: 0; }
.comment-author small { color: var(--text-secondary); font-size: 11px; }
.comment-avatar { width: 32px; height: 32px; flex: 0 0 32px; }
.comment-head time, .comment-edited { color: var(--text-secondary); font-size: 11px; }
.comment-reply { margin-left: clamp(16px, 5vw, 42px); padding-left: 12px; border-left: 2px solid var(--border); }
.comment-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.comment-actions button { min-height: 36px; border: 0; border-radius: 999px; background: transparent; color: var(--text-secondary); padding: 5px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.comment-actions button:hover, .comment-actions button.active { background: var(--surface-secondary); color: var(--accent); }
.comment-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.comment-compose-context { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border-left: 3px solid var(--accent); background: var(--surface-secondary); color: var(--text-secondary); font-size: 12px; }
.comment-composer { display: flex; gap: 8px; }
.comment-composer button { width: 44px; flex: 0 0 44px; }
@media (max-width: 520px) {
  .install-notice { margin: 12px 0; }
  .video-feed { width: 100%; height: calc(100dvh - 184px - env(safe-area-inset-bottom)); gap: 10px; padding: 2px 0 12px; }
  .video-reel { width: min(100%, 430px); }
  .video-reel .post-media-frame { width: 100%; height: min(74dvh, 720px); border-radius: 16px; }
  .video-reel-navigation { padding-inline: 8px; }
  .forward-message-dialog { position: fixed; inset: auto 0 0; width: 100%; max-width: none; max-height: min(82dvh, 680px); margin: 0; border-radius: 20px 20px 0 0; padding: 18px 16px max(16px, env(safe-area-inset-bottom)); }
  #comments-list { max-height: min(58dvh, 540px); }
  .message-row { max-width: 92%; }
  .message-row.grouped-before:not(.own) { margin-left: 0; }
  .message-action-list { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .video-feed { scroll-snap-type: none; }
}

/* IhuzaChat product shell and inbox system */
.app :where(button, input, textarea, select):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.app .primary { border-color: transparent; background: var(--gradient-primary); color: var(--accent-contrast); }
.app .main-nav button,
.app .sidebar-footer > button { min-height: 48px; border-radius: 13px; transition: background-color .16s ease, color .16s ease; }
.app .main-nav button.active {
  background: color-mix(in srgb, var(--accent) 11%, var(--surface));
  color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.app .main-nav button.active .icon { stroke-width: 2.25; }
.app .sidebar { z-index: 3; height: var(--app-viewport-height, 100vh); border-right-color: var(--border); }
.app .brand .mark { background: transparent; box-shadow: none; filter: drop-shadow(0 4px 12px rgb(0 168 232 / 22%)); }

@media (min-width: 769px) {
  .app { height: var(--app-viewport-height, 100vh); min-height: 0; overflow: hidden; }
  .app-main { height: var(--app-viewport-height, 100vh); min-height: 0; overflow: hidden; padding-bottom: 0; }
  .app-main > .page { height: 100%; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
  .app-main > #videos-section { overflow: hidden; }
  .app-main > #messages-section { overflow: hidden; }
  .app-main > #messages-section .messages-layout {
    height: 100%; min-height: 0; grid-template-columns: minmax(300px, var(--inbox-width)) minmax(0, 1fr);
  }
  .app-main > #messages-section .people-pane {
    height: 100%; min-height: 0; padding: 24px 18px 18px; overscroll-behavior: contain;
  }
  .app-main > #messages-section .chat-panel { height: 100%; min-height: 0; }
  .app-main > #messages-section .conversation-empty { min-height: 100%; }
  .app-main > #messages-section .conversation { height: 100%; min-height: 0; grid-template-rows: 70px minmax(0, 1fr) auto auto; }
  .app-main > #messages-section .conversation > header { position: relative; z-index: 1; }
  .app-main > #messages-section .chat-box { min-height: 0; overscroll-behavior: contain; scroll-behavior: smooth; }
  .inbox-header { margin: 0 0 18px; padding: 0 2px; }
  .inbox-header .eyebrow { margin-bottom: 4px; }
  .inbox-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .inbox-header h1 { margin: 0; font-size: 23px; line-height: 1.2; letter-spacing: -.035em; }
  #new-message-button { width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
  #new-message-button:hover { background: var(--hover); color: var(--accent); }
  .people-pane > .search-input { min-height: 42px; border: 1px solid transparent; border-radius: 11px; background: var(--surface-secondary); padding: 8px 12px; }
  .people-pane > .search-input:focus { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: var(--surface); }
  .inbox-tabs { margin-top: 14px; }
  .conversation-list-section, .people-list-section { margin-top: 10px; }
  .conversation-list { margin-top: 0; }
  .conversation-list .list-item { min-height: 70px; gap: 12px; padding: 9px 10px; border: 0; border-radius: 12px; }
  .conversation-list .list-item.active,
  .conversation-list .list-item[aria-current="true"] { background: color-mix(in srgb, var(--accent) 9%, var(--surface)); box-shadow: none; }
  .conversation-list .list-item.active .item-main strong { color: var(--accent); }
  .conversation-list .list-item > .avatar { width: 50px; height: 50px; flex: 0 0 50px; }
  .conversation-list .item-main { gap: 3px; }
  .conversation-list .item-main strong { font-size: 13px; line-height: 1.3; }
  .conversation-list .item-preview { font-size: 12px; line-height: 1.35; }
  .conversation-list .item-time { padding-top: 1px; font-size: 11px; }
  .notes-shelf { margin-inline: -18px; padding-inline: 18px; }
  .notes-list { overscroll-behavior-inline: contain; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
  .note-item { min-height: 82px; }
  .note-main { min-height: 68px; border-radius: 12px; }
  .note-main:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .conversation > header { padding-inline: clamp(18px, 3vw, 42px); }
  .conversation > header > .avatar { width: 42px; height: 42px; flex: 0 0 42px; }
  .conversation-identity { gap: 2px; }
  .conversation-identity b { font-size: 14px; }
  .conversation-identity small { font-size: 12px; }
  .conversation-actions { gap: 5px; }
  .conversation-actions .icon-button { width: 40px; height: 40px; border-radius: 50%; }
  .call-unavailable-note { display: none; }
  .chat-box { gap: 5px; padding: 22px clamp(24px, 6vw, 92px) 28px; }
  .message-row { width: fit-content; max-width: min(72%, 620px); }
  .message-row.own { width: auto; max-width: min(72%, 620px); justify-self: end; }
  .message-row.grouped-before:not(.own) { margin-left: 38px; }
  .message { max-width: min(100%, 520px); padding: 9px 13px; border-radius: 18px; line-height: 1.45; }
  .message-footer { display: flex; min-height: 0; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 2px; }
  .message-footer:has(.message-time) { min-height: 18px; }
  .message-actions-trigger { position: absolute; top: 50%; width: 32px; height: 32px; transform: translateY(-50%); background: var(--surface); box-shadow: 0 2px 10px rgb(0 0 0 / 9%); }
  .message-row:not(.own) .message-actions-trigger { right: -38px; }
  .message-row.own .message-actions-trigger { left: -38px; }
  .message-actions-trigger .icon { width: 17px; height: 17px; }
  .message-footer .message-actions-trigger { color: var(--text-secondary); }
  .message-reaction-tray { margin-top: -2px; }
  .message-row:not(.own) .message-reaction-tray { justify-content: flex-start; margin-left: 38px; }
  .message-row:not(.own) .message { border-bottom-left-radius: 6px; }
  .message-row.own .message { border-bottom-right-radius: 6px; }
  .message-row.grouped-before:not(.own) .message { border-top-left-radius: 8px; }
  .message-row.grouped-before.own .message { border-top-right-radius: 8px; }
  .message-row.grouped-after:not(.own) .message { border-bottom-left-radius: 8px; }
  .message-row.grouped-after.own .message { border-bottom-right-radius: 8px; }
  .message-row.own .message { background: var(--gradient-primary); color: var(--accent-contrast); }
  .message-time { font-size: 10px; }
  .message-row.own .message-time { color: currentColor; opacity: .75; }
  .message-actions-trigger { opacity: 0; transition: opacity .14s ease; }
  .message-row:hover .message-actions-trigger, .message-actions-trigger:focus-visible { opacity: 1; }
  .conversation form { padding: 12px clamp(20px, 5vw, 72px) max(16px, env(safe-area-inset-bottom)); }
  .message-composer-bar { border-radius: 24px; background: var(--surface); }
}

@media (min-width: 769px) and (max-width: 1023px) {
  .app-main > #messages-section .messages-layout { grid-template-columns: minmax(280px, var(--inbox-width)) minmax(0, 1fr); }
  .message-row, .message-row.own { max-width: min(82%, 560px); }
}

@media (max-width: 768px) {
  .app-main > #messages-section { height: calc(100dvh - 60px - 66px - env(safe-area-inset-bottom)); min-height: 0; overflow: hidden; }
  .app-main > #messages-section .messages-layout { height: 100%; min-height: 0; }
  .app-main > #messages-section .people-pane { height: 100%; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-top: 18px; }
  .inbox-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
  .inbox-header > .eyebrow { display: none; }
  .inbox-title-row { display: contents; }
  .inbox-header h1 { font-size: 23px; }
  #new-message-button { width: 42px; height: 42px; }
  .conversation-list .list-item { min-height: 68px; border: 0; border-radius: 12px; }
  .app .chat-panel.open { height: 100dvh; }
  .app .chat-panel.open .conversation { height: 100dvh; min-height: 0; grid-template-rows: 64px minmax(0, 1fr) auto auto; }
  .app .chat-panel.open .chat-box { min-height: 0; padding: 14px 14px 20px; overscroll-behavior: contain; }
  .app .chat-panel.open .conversation > header { min-height: 64px; }
  .app .chat-panel.open .conversation form { padding: 8px 10px max(10px, env(safe-area-inset-bottom)); }
  .app .chat-panel.open .message-row { max-width: min(86%, 520px); }
  .app .chat-panel.open .message { max-width: 100%; border-radius: 18px; }
  .app .chat-panel.open .message-row.own .message { background: var(--gradient-primary); color: var(--accent-contrast); }
  .app .chat-panel.open .message-actions-trigger { opacity: 1; }
  .app .chat-panel.open .message-actions-trigger { width: 38px; height: 38px; }
  .app .chat-panel.open .message-row:not(.own) .message-actions-trigger { right: -40px; }
  .app .chat-panel.open .message-row.own .message-actions-trigger { left: -40px; }
  .app .chat-panel.open .conversation-actions { gap: 0; }
  .app .chat-panel.open .conversation-actions .icon-button { width: 36px; height: 38px; }
  .app .chat-panel.open .unavailable-call { display: none; }
  .app .chat-panel.open .message-composer-bar { background: var(--surface-secondary); }
}

@media (prefers-reduced-motion: reduce) {
  .app .main-nav button, .message-actions-trigger { transition: none; }
}

/* Compact message action menu, anchored beside its message on every device. */
.message-action-dialog.anchored[open] {
  position: fixed;
  inset: auto;
  width: min(236px, calc(100vw - 16px));
  max-width: none;
  max-height: min(440px, calc(100dvh - 16px));
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid color-mix(in srgb, var(--border) 82%, var(--accent));
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 93%, transparent);
  color: var(--text);
  padding: 8px;
  box-shadow: var(--shadow-raised);
  backdrop-filter: blur(16px);
  transform-origin: top left;
  animation: message-menu-in 150ms ease-out both;
}
.message-action-dialog.anchored::backdrop { background: transparent; }
.message-action-dialog.anchored > header { display: none; }
.message-action-dialog.anchored .message-action-content { gap: 6px; }
.message-action-dialog.anchored .message-action-meta { padding: 5px 10px 8px; border-bottom: 1px solid color-mix(in srgb, var(--border) 72%, transparent); color: var(--text-secondary); font-size: 11px; }
.message-action-dialog.anchored .message-quick-reactions { flex-wrap: nowrap; justify-content: space-between; gap: 3px; padding: 3px 2px 7px; border-bottom: 1px solid color-mix(in srgb, var(--border) 72%, transparent); }
.message-action-dialog.anchored .message-quick-reactions button { width: 30px; height: 30px; border-color: transparent; background: var(--surface-secondary); font-size: 16px; }
.message-action-dialog.anchored .message-action-list { grid-template-columns: 1fr; gap: 2px; margin-top: 2px; }
.message-action-dialog.anchored .message-action-list button { min-height: 36px; justify-content: space-between; border-color: transparent; border-radius: 10px; background: transparent; padding: 6px 10px; font-size: 13px; }
.message-action-dialog.anchored .message-action-list button:hover { border-color: transparent; background: var(--hover); }
.message-action-dialog.anchored .message-action-list button .icon { width: 17px; height: 17px; }
@keyframes message-menu-in { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .message-action-dialog.anchored[open] { animation: none; } }
.message-new-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1;
}
.message-new-divider::before, .message-new-divider::after { height: 1px; flex: 1; background: var(--border); content: ""; }
.message-row.own .message-reply-reference {
  border-left-color: color-mix(in srgb, currentColor 60%, var(--accent));
  background: color-mix(in srgb, #000 14%, var(--accent));
  color: inherit;
}
.message-row .message.audio-message,
.message-row.own .message.audio-message {
  width: fit-content;
  max-width: min(100%, 330px);
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}
.message.audio-message .message-audio-player { width: min(280px, 68vw); }
.message.audio-message .message-footer { padding-inline: 5px; }
.message-composer-controls textarea { resize: none; overflow-y: auto; }

.message { position: relative; }
.message-footer { display: flex; min-height: 0; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 2px; }
.message-footer:has(.message-time) { min-height: 18px; }
.message-footer .message-time { margin: 0 auto 0 0; }
.message-actions-trigger { position: absolute; z-index: 2; top: 50%; width: 38px; height: 38px; transform: translateY(-50%); border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--text-secondary); opacity: .92; box-shadow: 0 2px 10px rgb(0 0 0 / 10%); }
.message-row:not(.own) .message-actions-trigger { right: -40px; }
.message-row.own .message-actions-trigger { left: -40px; }
.message-actions-trigger .icon { width: 17px; height: 17px; }
.message-reaction-tray { margin-top: -2px; }
.message-row:not(.own) .message-reaction-tray { justify-content: flex-start; margin-left: 38px; }
.optimistic-message-status { color: var(--text-secondary); }
.optimistic-message-status.failed { color: var(--danger); }
.message-pending-media { color: var(--text-secondary); font-size: 12px; }
.message-inline-retry { min-height: 24px; border: 0; border-radius: 999px; background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent); padding: 2px 9px; font-size: 11px; font-weight: 700; }
.message-inline-retry:hover, .message-inline-retry:focus-visible { background: color-mix(in srgb, var(--accent) 24%, var(--surface)); outline: 2px solid color-mix(in srgb, var(--accent) 65%, transparent); outline-offset: 1px; }
@media (min-width: 769px) {
  .message-actions-trigger { width: 32px; height: 32px; opacity: 0; }
  .message-row:not(.own) .message-actions-trigger { right: -38px; }
  .message-row.own .message-actions-trigger { left: -38px; }
  .message-row:hover .message-actions-trigger, .message-actions-trigger:focus-visible { opacity: 1; }
}

/* Screenshot driven social shell refinement, using IhuzaChat tokens. */
@media (min-width: 769px) {
  .app { --sidebar-width: 76px; --inbox-width: 405px; }
  .app .sidebar { width: var(--sidebar-width); flex-basis: var(--sidebar-width); }
  .app .brand { justify-content: center; padding: 0; }
  .app .brand > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .app .main-nav button, .app .sidebar-footer > button { justify-content: center; padding-inline: 0; }
  .app .main-nav button > span:not(.nav-badge), .app .sidebar-footer > button > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .app .conversation > header #mobile-chat-back { display: none; }
  .app .conversation-actions .unavailable-call, .app .call-unavailable-note { display: none; }
  .app .message-composer-controls #emoji-button { order: 0; }
  .app .message-composer-controls #message-input { order: 1; }
  .app .message-composer-controls #voice-record-button { order: 2; }
  .app .message-composer-controls #video-note-record-button { order: 3; }
  .app .message-composer-controls #attach-button { order: 4; }
  .app .message-composer-controls #send-button { order: 5; }
  #home-section > .content { width: min(100%, 1060px); padding-top: 24px; }
  #home-section .home-layout { width: 100%; grid-template-columns: minmax(420px, 1fr) minmax(220px, 264px); gap: clamp(22px, 3vw, 34px); }
  #home-section .feed-layout { max-width: 690px; }
  #home-section .page-heading { margin-bottom: 18px; }
  #home-section .stories-section { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); padding: 14px 16px 0; }
  #home-section .feed-toolbar { margin-top: 2px; }
  #home-section .post { padding: 10px 12px 12px; }
  #home-section .post-media-frame { background: var(--surface-secondary); }
  #home-section .suggested-panel { top: 20px; }
  #messages-section .people-pane { background: var(--bg); }
  #messages-section .people-pane { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
  #messages-section .inbox-header { flex: 0 0 auto; }
  #messages-section .inbox-search-wrap { order: 3; flex: 0 0 auto; min-height: 40px; height: 40px; }
  #messages-section .notes-shelf { order: 4; flex: 0 0 auto; }
  #messages-section .inbox-tabs { order: 2; }
  #messages-section .conversation-list-section,
  #messages-section .people-list-section { order: 5; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  #messages-section .inbox-search-wrap { margin-top: 10px; }
  #messages-section .notes-shelf { margin-top: 0; }
  #messages-section .inbox-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 10px 0 0; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: transparent; padding: 0; }
  #messages-section .inbox-tabs button { min-height: 42px; border-radius: 0; color: var(--text-secondary); }
  #messages-section .inbox-tabs button.active { border-bottom: 2px solid var(--accent); background: transparent; color: var(--text); box-shadow: none; }
  #messages-section .conversation-list-section, #messages-section .people-list-section { margin-top: 10px; }
  #messages-section .notes-shelf { margin: 4px -18px 8px; padding: 0 18px 8px; }
  #messages-section .notes-list { gap: 12px; padding-top: 10px; }
  #messages-section .note-item { width: 72px; flex-basis: 72px; }
  #messages-section .note-avatar-wrap .avatar { width: 54px; height: 54px; }
  #messages-section .note-bubble { max-width: 72px; font-size: 10px; }
  #messages-section .chat-box { gap: 12px; padding-top: 18px; padding-bottom: 22px; }
  #messages-section .chat-box { padding-inline: clamp(24px, 4vw, 72px); }
  #messages-section .message-row { max-width: min(76%, 620px); gap: 6px; }
  #messages-section .message { padding: 8px 12px; border-radius: 18px; }
  #messages-section .message-row.grouped-before .message { border-top-left-radius: 8px; border-top-right-radius: 8px; }
  #messages-section .message-row.grouped-after .message { border-bottom-left-radius: 8px; border-bottom-right-radius: 8px; }
  #messages-section .message-time { margin-top: 2px; font-size: 10px; }
  #messages-section .message-actions-trigger { width: 34px; height: 34px; }
  #messages-section .conversation form { padding-top: 10px; }
  #messages-section .conversation form { padding-inline: clamp(18px, 2vw, 32px); }
  #messages-section .message-composer-bar { min-height: 48px; border-radius: 999px; }
}

@media (min-width: 769px) and (max-width: 1180px) {
  .app { --sidebar-width: 76px; }
  #home-section > .content { padding-inline: clamp(18px, 3vw, 28px); }
  #home-section .home-layout { grid-template-columns: minmax(0, 1fr) minmax(210px, 250px); }
}

@media (min-width: 769px) and (max-width: 950px) {
  #home-section .home-layout { grid-template-columns: minmax(0, 1fr); }
  #home-section .suggested-panel { display: none; }
  #home-section .feed-layout { width: min(100%, 680px); margin-inline: auto; }
  #messages-section .messages-layout { grid-template-columns: minmax(265px, 405px) minmax(0, 1fr); }
  #messages-section .people-pane { padding-inline: 14px; }
  #messages-section .call-unavailable-note { display: none; }
}

/* Compact, anchored message actions and an expandable desktop navigation rail. */
@media (min-width: 769px) {
  .app-main { padding-bottom: 0; }
  .app .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width, 76px);
    height: 100dvh;
    padding-inline: 10px;
    overflow-x: hidden;
    overflow-y: auto;
    transition: width .2s ease, box-shadow .2s ease;
    z-index: 30;
  }
  .app .sidebar:hover,
  .app .sidebar:focus-within { width: var(--sidebar-expanded); box-shadow: var(--shadow-raised); }
  .app-main { margin-left: var(--sidebar-width, 76px); }
  .app .sidebar:hover .brand,
  .app .sidebar:focus-within .brand { justify-content: flex-start; padding-inline: 10px; }
  .app .sidebar:hover .brand > span,
  .app .sidebar:focus-within .brand > span,
  .app .sidebar:hover .main-nav button > span:not(.nav-badge),
  .app .sidebar:focus-within .main-nav button > span:not(.nav-badge),
  .app .sidebar:hover .sidebar-footer > button > span,
  .app .sidebar:focus-within .sidebar-footer > button > span {
    position: static; width: auto; height: auto; overflow: visible; clip-path: none; white-space: nowrap;
  }
  .app .sidebar:hover .main-nav button,
  .app .sidebar:focus-within .main-nav button,
  .app .sidebar:hover .sidebar-footer > button,
  .app .sidebar:focus-within .sidebar-footer > button { justify-content: flex-start; padding-inline: 10px; }
  #more-dialog {
    position: fixed; inset: auto auto 16px 88px; width: min(320px, calc(100vw - 104px));
    max-height: min(620px, calc(100dvh - 32px)); margin: 0; overflow-y: auto; padding: 16px;
    border-radius: 16px; box-shadow: 0 16px 48px rgb(0 0 0 / 35%);
  }
  #more-dialog .more-nav .mobile-secondary,
  #more-dialog #more-logout { display: flex; }
  #more-dialog .more-nav button { min-height: 42px; padding-inline: 8px; }
  #more-dialog .more-nav .icon { width: 18px; height: 18px; }
  #messages-section .message-row,
  #messages-section .message-row.own { width: fit-content; max-width: min(76%, 620px); }
  #messages-section .message-row.own { justify-self: end; }
  #messages-section .message { width: fit-content; max-width: 100%; overflow-wrap: anywhere; }

}

/* Feed, story ring, profile header and story viewer refinements from the latest references. */
.post-actions [data-post-like] { transition: color .16s ease, transform .16s ease; }
.post-actions [data-post-like] .icon { fill: transparent; color: var(--text); transition: fill .16s ease, color .16s ease, transform .16s ease; }
.post-actions [data-post-like].active { color: #ff3040; background: transparent; }
.post-actions [data-post-like].active .icon { fill: #ff3040; color: #ff3040; transform: scale(1.06); }
.post-actions [data-post-like]:active { transform: scale(.94); }
.post-likes-summary { margin: 1px 0 4px; font-size: 13px; font-weight: 650; }
.post-likes-summary.hidden { display: none; }

.home-trending-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  margin-top: 14px;
}
.home-trending-header h2 {
  font-size: 14px;
  font-weight: 750;
  color: var(--text);
  margin: 0;
}
.home-trending-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.home-trend-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background-color .15s ease, transform .15s ease;
  width: 100%;
}
.home-trend-item:hover {
  background: var(--hover);
  transform: translateX(2px);
}
.home-trend-item small {
  font-size: 11px;
  color: var(--text-secondary);
}
.home-trend-item strong {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--accent);
}
.home-trend-item span {
  font-size: 11.5px;
  color: var(--text-secondary);
}
.home-sidebar-footer {
  margin-top: 16px;
  padding: 0 4px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.home-sidebar-links {
  font-size: 11px;
  color: var(--text-secondary);
}
.home-sidebar-links a {
  color: inherit;
  text-decoration: none;
}
.home-sidebar-links a:hover {
  text-decoration: underline;
  color: var(--text);
}
.home-sidebar-copyright {
  font-size: 11px;
  color: var(--text-secondary);
  opacity: .8;
  margin: 0;
}

#home-messages-shortcut {
  position: fixed;
  z-index: 28;
  right: 24px;
  bottom: 24px;
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  gap: 9px;
  border: 1px solid color-mix(in srgb, var(--border) 60%, var(--accent) 40%);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-elevated) 86%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--text);
  padding: 6px 16px 6px 14px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 40%), 0 0 0 1px rgb(255 255 255 / 6%);
  cursor: pointer;
  transition: all .25s cubic-bezier(0.4, 0, 0.2, 1);
}
#home-messages-shortcut:hover {
  background: color-mix(in srgb, var(--surface-elevated) 95%, var(--accent) 12%);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 14px 38px rgb(0 0 0 / 50%), 0 0 14px color-mix(in srgb, var(--accent) 35%, transparent);
}
#home-messages-shortcut > .icon { width: 20px; height: 20px; color: var(--accent); flex-shrink: 0; }
.home-messages-label { font-size: 13.5px; font-weight: 700; letter-spacing: -.01em; }
.home-message-avatars { display: flex; align-items: center; margin-left: 2px; }
.home-message-avatar {
  display: inline-grid;
  place-items: center;
  width: 25px;
  height: 25px;
  flex: 0 0 25px;
  margin-left: -8px;
  border: 2px solid var(--surface-elevated);
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 25%, var(--surface-secondary));
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  overflow: hidden;
  box-shadow: 0 2px 6px rgb(0 0 0 / 30%);
}
.home-message-avatar:first-child { margin-left: 0; }
#home-messages-shortcut .nav-badge {
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 19px;
  border-radius: 999px;
  background: #ff3b30;
  color: #fff;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 2px 8px rgb(255 59 48 / 45%);
}
.home-messages-panel { position: fixed; z-index: 30; right: 24px; bottom: 88px; display: none; width: min(376px, calc(100vw - 32px)); height: min(530px, calc(100dvh - 112px)); min-height: 240px; flex-direction: column; overflow: hidden; border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border)); border-radius: 18px; background: var(--surface-secondary); box-shadow: 0 18px 56px rgb(0 0 0 / 48%), 0 0 0 1px rgb(255 255 255 / 2%); }
.home-messages-panel.open { display: flex; }
.home-messages-panel > header { display: flex; min-height: 58px; flex: 0 0 58px; align-items: center; gap: 9px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface-secondary) 92%, #fff); padding: 0 14px 0 18px; }
.home-messages-panel > header > strong { font-size: 17px; font-weight: 750; letter-spacing: -.02em; }
.home-panel-unread { display: grid; min-width: 19px; height: 19px; place-items: center; border-radius: 99px; background: var(--accent); color: #fff; padding-inline: 5px; font: 700 11px/1 system-ui, sans-serif; box-shadow: 0 2px 9px color-mix(in srgb, var(--accent) 38%, transparent); }
.home-messages-panel > header > div { display: flex; gap: 4px; margin-left: auto; }
.home-messages-panel > header .icon-button { width: 34px; height: 34px; }
.home-messages-panel > header .icon-button:hover { border-radius: 50%; background: var(--hover); color: var(--accent); }
.home-messages-panel > header[data-home-panel-drag] { cursor: grab; touch-action: none; }
.home-messages-panel > header[data-home-panel-drag]:active { cursor: grabbing; }
.home-messages-search { display: flex; min-height: 42px; align-items: center; gap: 9px; margin: 12px 12px 7px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-secondary); padding: 0 13px; transition: border-color .16s, box-shadow .16s; }
.home-messages-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
.home-messages-search .icon { width: 16px; height: 16px; flex: 0 0 16px; }
.home-messages-search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; }
.home-messages-panel.minimized { height: 56px; min-height: 56px; }
.home-messages-panel.minimized .home-messages-search, .home-messages-panel.minimized .home-messages-list, .home-messages-panel.minimized .home-messages-compose { display: none; }
.suggested-heading > button { display: none; }
.home-messages-list { min-height: 0; flex: 1; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 2px 8px 74px; }
.home-message-row { position: relative; display: flex; width: 100%; min-height: 76px; align-items: center; gap: 12px; border: 0; border-radius: 12px; background: transparent; padding: 9px 10px; text-align: left; transition: background .16s, transform .16s; }
.home-message-row:hover, .home-message-row:focus-visible { background: color-mix(in srgb, var(--accent) 9%, var(--hover)); }
.home-message-row:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: -2px; }
.home-message-row-avatar { width: 54px; height: 54px; flex: 0 0 54px; }
.home-message-row-copy { display: grid; min-width: 0; flex: 1; gap: 5px; }
.home-message-row-heading { display: flex; min-width: 0; align-items: center; gap: 8px; }
.home-message-row-copy strong { overflow: hidden; flex: 1; font: 650 14px/1.25 system-ui, sans-serif; text-overflow: ellipsis; white-space: nowrap; }
.home-message-row-time { flex: 0 0 auto; color: var(--text-tertiary, var(--text-secondary)); font: 11px/1.2 system-ui, sans-serif; }
.home-message-row-copy small { overflow: hidden; color: var(--text-secondary); font: 12px/1.35 system-ui, sans-serif; text-overflow: ellipsis; white-space: nowrap; }
.home-message-row.has-unread .home-message-row-copy strong, .home-message-row.has-unread .home-message-row-copy small { color: var(--text); }
.home-message-row-unread { width: 8px; height: 8px; flex: 0 0 8px; margin: 0 7px 0 0; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 52%, transparent); }
.home-messages-compose { position: absolute; right: 16px; bottom: 16px; display: grid; width: 52px; height: 52px; place-items: center; border: 0; border-radius: 50%; background: var(--accent); color: #fff; box-shadow: 0 7px 20px color-mix(in srgb, var(--accent) 35%, transparent); transition: transform .16s, box-shadow .16s, filter .16s; }
.home-messages-compose:hover { transform: translateY(-2px); filter: brightness(1.08); box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 45%, transparent); }
.home-messages-compose:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, #fff); outline-offset: 3px; }
.home-messages-compose .icon { width: 22px; height: 22px; }
.home-account-switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 2px 0 24px; }
.home-account-identity { display: flex; min-width: 0; align-items: center; gap: 10px; }
.home-account-identity > .avatar { width: 42px; height: 42px; flex: 0 0 42px; }
.home-account-identity > span:last-child { display: grid; min-width: 0; gap: 3px; }
.home-account-identity strong, .home-account-identity small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-account-identity strong { font-size: 13px; }
.home-account-identity small { color: var(--text-secondary); font-size: 12px; }
.home-account-switch > button { color: var(--accent); font-size: 12px; font-weight: 700; }

#messages-section.quick-chat-overlay { position: fixed !important; z-index: 40; right: 24px; bottom: 88px; display: flex !important; width: min(390px, calc(100vw - 32px)); height: min(620px, calc(100dvh - 144px)); min-height: 320px; overflow: hidden; border: 1px solid var(--border); border-radius: 18px; background: var(--surface-secondary); box-shadow: 0 18px 60px rgb(0 0 0 / 48%); }
#messages-section.quick-chat-overlay .messages-layout { display: block; width: 100%; height: 100%; min-height: 0; }
#messages-section.quick-chat-overlay .people-pane,
#messages-section.quick-chat-overlay .conversation-empty { display: none !important; }
#messages-section.quick-chat-overlay .chat-panel { position: relative; inset: auto; display: block; width: 100%; height: 100%; min-height: 0; transform: none; background: var(--surface-secondary); }
#messages-section.quick-chat-overlay .conversation { height: 100%; min-height: 0; grid-template-rows: 68px minmax(0, 1fr) auto auto; }
#messages-section.quick-chat-overlay .conversation > header { min-height: 68px; padding: 8px 12px; }
#quick-chat-close, #quick-chat-minimize { display: none; }
#messages-section.quick-chat-overlay #mobile-chat-back { display: grid; }
#messages-section.quick-chat-overlay #quick-chat-close,
#messages-section.quick-chat-overlay #quick-chat-minimize { display: grid; }
#messages-section.quick-chat-overlay .unavailable-call, #messages-section.quick-chat-overlay .call-unavailable-note { display: none; }
#messages-section.quick-chat-overlay .chat-box { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px; }
#messages-section.quick-chat-overlay .conversation form { padding: 8px 10px max(10px, env(safe-area-inset-bottom)); }
#messages-section.quick-chat-overlay .message-row { max-width: min(86%, 520px); }
#messages-section.quick-chat-overlay .message-actions-trigger { opacity: 1; }
.message-status-line { display: flex; align-items: center; gap: 10px; }
.message-status-line .message-status { flex: 1; }
.message-retry-button { margin: 2px 14px; border: 0; background: transparent; color: var(--accent); font: 700 12px/1.4 system-ui, sans-serif; cursor: pointer; }

@media (max-width: 768px) {
  #messages-section.quick-chat-overlay { z-index: 80; inset: 0; width: 100vw; height: 100dvh; min-height: 0; max-height: 100dvh; border: 0; border-radius: 0; padding-top: env(safe-area-inset-top); }
  #messages-section.quick-chat-overlay .chat-panel { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; }
  #messages-section.quick-chat-overlay .conversation { height: 100%; min-height: 0; grid-template-rows: calc(64px + env(safe-area-inset-top)) minmax(0, 1fr) auto auto; }
  #messages-section.quick-chat-overlay .conversation > header { min-height: calc(64px + env(safe-area-inset-top)); padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); }
  #messages-section.quick-chat-overlay .conversation form { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}

#story-dialog { height: min(760px, calc(100dvh - 32px)); }
#story-viewer { height: 100%; min-height: 0; grid-template-rows: auto auto minmax(0, 1fr); gap: 8px; padding: 14px 14px 12px; }
.story-author { align-items: center; gap: 9px; border: 0; border-radius: 0; background: transparent; padding: 2px 36px 4px 2px; color: var(--text); }
.story-author > .avatar { width: 34px; height: 34px; flex: 0 0 34px; border: 1px solid rgb(255 255 255 / 45%); }
.story-identity { display: grid; min-width: 0; gap: 1px; }
.story-identity strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story-identity small { overflow: hidden; color: var(--text-secondary); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.story-stage { border-radius: var(--radius-md); background: var(--surface-tertiary); }
.story-media { width: 100%; height: 100%; max-height: 100%; object-fit: cover; }

@media (max-width: 768px) {
  #home-messages-shortcut { right: 14px; bottom: calc(76px + env(safe-area-inset-bottom)); min-height: 48px; gap: 8px; padding: 6px 12px; }
  .home-messages-label { font-size: 13px; }
  .home-message-avatar { width: 25px; height: 25px; flex-basis: 25px; }
  .home-messages-panel { right: 10px; bottom: calc(132px + env(safe-area-inset-bottom)); width: min(366px, calc(100vw - 20px)); height: min(530px, calc(100dvh - 170px - env(safe-area-inset-bottom))); }
  .home-message-row-avatar { width: 50px; height: 50px; flex-basis: 50px; }
  #story-dialog { width: 100vw; height: min(100dvh, var(--story-viewport-height, 100dvh)); max-width: none; max-height: min(100dvh, var(--story-viewport-height, 100dvh)); margin: 0; border: 0; border-radius: 0; }
  #story-viewer { height: 100%; padding: max(14px, env(safe-area-inset-top)) 14px max(12px, env(safe-area-inset-bottom)); }
  #story-dialog > .icon-button { top: max(10px, env(safe-area-inset-top)); right: 10px; }
}

.message-row:not(.own) .message { background: var(--participant-bubble, var(--surface-secondary)); color: var(--participant-text, var(--text)); }
.message-row.own { width: fit-content; justify-self: end; }
.message { width: fit-content; max-width: 100%; }
#messages-section.participant-tone-0 { --participant-bubble: #e5edff; --participant-text: #20375f; }
#messages-section.participant-tone-1 { --participant-bubble: #e4f2e8; --participant-text: #244a32; }
#messages-section.participant-tone-2 { --participant-bubble: #f8e8df; --participant-text: #633b2b; }
#messages-section.participant-tone-3 { --participant-bubble: #f0e7f7; --participant-text: #4b315f; }
#messages-section.participant-tone-4 { --participant-bubble: #e0f0f2; --participant-text: #20484c; }
#messages-section.participant-tone-5 { --participant-bubble: #f4edda; --participant-text: #59491f; }
html.dark #messages-section.participant-tone-0 { --participant-bubble: #25385c; --participant-text: #eaf0ff; }
html.dark #messages-section.participant-tone-1 { --participant-bubble: #214432; --participant-text: #e8f7ec; }
html.dark #messages-section.participant-tone-2 { --participant-bubble: #553626; --participant-text: #fff0e8; }
html.dark #messages-section.participant-tone-3 { --participant-bubble: #43304f; --participant-text: #f4eaff; }
html.dark #messages-section.participant-tone-4 { --participant-bubble: #1f4548; --participant-text: #e4fbfd; }
html.dark #messages-section.participant-tone-5 { --participant-bubble: #4c421f; --participant-text: #fff7df; }

@media (prefers-reduced-motion: reduce) {
  .app .sidebar { transition: none; }
}

@media (max-width: 768px) {
  #home-section .content { padding-top: 14px; }
  #home-section .home-layout { gap: 12px; }
  #home-section .stories-section { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: transparent; padding: 0 0 0; }
  #home-section .stories-heading { padding: 0 2px 8px; }
  #home-section .feed { gap: 10px; }
  #home-section .post { border-right: 0; border-left: 0; border-radius: 0; padding: 8px 0 12px; box-shadow: none; }
  #home-section .post-media-frame { border-radius: 3px; }
  #messages-section .people-pane { padding-inline: 14px; }
  #messages-section .notes-shelf { margin: 0 -14px 8px; padding-inline: 14px; }
  #messages-section .notes-list { gap: 8px; padding-top: 8px; }
  #messages-section .note-item { width: 68px; flex-basis: 68px; }
  #messages-section .note-avatar-wrap .avatar { width: 52px; height: 52px; }
  #messages-section .conversation > header { min-height: 68px; }
  #messages-section .chat-box { gap: 12px; }
  #messages-section .conversation form { border-top: 1px solid var(--border); }
  #messages-section .message-composer-bar { min-height: 48px; border-radius: 999px; }
}

@media (max-width: 390px) {
  #home-section .content { padding-inline: 10px; }
  #home-section .stories { gap: 10px; }
  #messages-section .people-pane { padding-inline: 10px; }
  #messages-section .inbox-tabs button { padding-inline: 4px; font-size: 12px; }
  #messages-section .note-item { width: 64px; flex-basis: 64px; }
  #messages-section .conversation-actions .icon-button { width: 32px; }
}

@media (min-width: 769px) {
  #messages-section .messages-layout { grid-template-columns: minmax(340px, var(--inbox-width)) minmax(0, 1fr); }
  #messages-section .conversation > header { gap: 14px; }
  #messages-section .conversation > header #mobile-chat-back { display: none; }
  #messages-section .conversation-actions .unavailable-call,
  #messages-section .call-unavailable-note { display: none; }
  #messages-section .message-composer-controls #emoji-button { order: 0; }
  #messages-section .message-composer-controls #message-input { order: 1; }
  #messages-section .message-composer-controls #voice-record-button { order: 2; }
  #messages-section .message-composer-controls #video-note-record-button { order: 3; }
  #messages-section .message-composer-controls #attach-button { order: 4; }
  #messages-section .message-composer-controls #send-button { order: 5; }
}

.note-add-indicator { position: absolute; right: 0; bottom: -1px; display: grid; width: 20px; height: 20px; place-items: center; border: 2px solid var(--bg); border-radius: 50%; background: var(--accent); color: var(--accent-contrast); }
.note-add-indicator .icon { width: 12px; height: 12px; stroke-width: 3; }
.note-add-item .note-main:focus-visible .note-add-indicator { outline: 2px solid var(--accent); outline-offset: 2px; }
.conversation-actions .unavailable-call, .call-unavailable-note { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  #home-section .story, .app .main-nav button { transition: none; }
}

/* Responsive product layout: portrait discovery grids and content-led device layouts. */

/* The collapsed desktop rail expands without shifting the main canvas. */
@media (min-width: 1024px) {
  .app { --sidebar-width: var(--sidebar-collapsed); }
  .app .sidebar {
    z-index: 60;
    width: var(--sidebar-collapsed);
    flex-basis: var(--sidebar-collapsed);
    transition: width .18s ease, box-shadow .18s ease;
  }
  .app .sidebar:hover,
  .app .sidebar:focus-within {
    width: var(--sidebar-expanded);
    box-shadow: 10px 0 32px rgb(0 0 0 / 22%);
  }
  .app .sidebar:hover .brand,
  .app .sidebar:focus-within .brand { justify-content: flex-start; padding-inline: 10px; }
  .app .sidebar:hover .brand > span,
  .app .sidebar:focus-within .brand > span,
  .app .sidebar:hover .main-nav button > span:not(.nav-badge),
  .app .sidebar:focus-within .main-nav button > span:not(.nav-badge),
  .app .sidebar:hover .sidebar-footer > button > span,
  .app .sidebar:focus-within .sidebar-footer > button > span {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
    white-space: nowrap;
  }
  .app .sidebar:hover .main-nav button,
  .app .sidebar:focus-within .main-nav button,
  .app .sidebar:hover .sidebar-footer > button,
  .app .sidebar:focus-within .sidebar-footer > button { justify-content: flex-start; padding-inline: 10px; }
}

/* Reel layout: portrait media is the focal column, with floating actions alongside. */
#videos-section .video-feed {
  position: relative;
  width: min(100%, 960px);
  height: calc(100dvh - 160px);
  max-height: 820px;
  align-items: center;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
}
#videos-section .video-reel {
  position: relative;
  display: grid;
  width: min(100%, 540px);
  grid-template-columns: minmax(0, min(400px, calc((100dvh - 190px) * 9 / 16))) 48px;
  align-items: center;
  justify-content: center;
  column-gap: 14px;
  scroll-snap-align: start;
}
#videos-section .video-reel .post-media-frame {
  grid-column: 1;
  grid-row: 1;
  width: 100%;
  height: auto;
  aspect-ratio: 9 / 16;
  border-radius: 16px;
  background: #000;
  box-shadow: none;
}
#videos-section .video-reel .post-media-frame > video.post-media { object-fit: cover; }
#videos-section .video-reel .reel-info { right: 8px; bottom: 8px; left: 8px; padding: 44px 8px 10px; }
#videos-section .video-reel .reel-actions {
  position: static;
  grid-column: 2;
  grid-row: 1;
  display: flex;
  width: 48px;
  flex-direction: column;
  align-self: end;
  gap: 16px;
  padding-bottom: 46px;
}
#videos-section .video-reel .reel-actions button {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  padding: 2px;
  font-size: 11px;
}
#videos-section .video-reel .reel-actions button:hover { background: rgb(255 255 255 / 10%); }
#videos-section .video-reel .reel-actions .icon { width: 24px; height: 24px; }
#videos-section .video-reel .reel-sound-toggle {
  top: auto;
  right: 12px;
  bottom: 12px;
  display: grid;
  width: 38px;
  min-height: 38px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 55%);
  padding: 0;
}
#videos-section .reel-sound-toggle .icon { width: 20px; height: 20px; }
#videos-section .video-reel-navigation {
  position: absolute;
  top: 50%;
  right: -58px;
  display: grid;
  width: 42px;
  gap: 12px;
  margin: 0;
  transform: translateY(-50%);
}
#videos-section .video-reel-navigation button {
  width: 42px;
  height: 42px;
  min-height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-secondary);
  box-shadow: var(--shadow);
}
#videos-section .video-reel-navigation button:disabled { visibility: hidden; }
@media (max-width: 768px) {
  #videos-section .video-feed { width: 100%; height: calc(100dvh - 116px - env(safe-area-inset-bottom)); padding: 0 0 12px; }
  #videos-section .video-reel {
    width: min(100%, 430px);
    grid-template-columns: minmax(0, min(430px, calc((100dvh - 150px) * 9 / 16)));
    column-gap: 0;
  }
  #videos-section .video-reel .reel-actions {
    position: absolute;
    right: 8px;
    bottom: 18px;
    display: grid;
    width: 44px;
    gap: 10px;
    padding: 0;
  }
  #videos-section .video-reel-navigation { display: none; }
}

/* Shared story media stays compact and uses the dark message surface. */
#messages-section .message.shared-story-message { background: #202020; }

/* At medium tablet widths, use one messaging pane; split view returns only when both panes fit. */
@media (min-width: 769px) and (max-width: 1099px) {
  .app-main > #messages-section .messages-layout { display: block; height: 100%; min-height: 0; }
  #messages-section .people-pane { width: 100%; height: 100%; min-height: 0; border-right: 0; }
  #messages-section .chat-panel {
    position: fixed;
    z-index: 70;
    inset: 0 0 0 var(--sidebar-width, 76px);
    display: block;
    height: 100dvh;
    transform: translateX(105%);
    transition: transform .2s ease;
    background: var(--bg);
  }
  #messages-section .chat-panel.open { transform: none; }
  #messages-section .conversation,
  #messages-section .conversation-empty { height: 100dvh; min-height: 0; }
  #messages-section .conversation { grid-template-rows: 68px minmax(0, 1fr) auto auto; }
  #messages-section .conversation > header #mobile-chat-back { display: grid; }
}

@media (min-width: 1100px) {
  #messages-section .messages-layout { grid-template-columns: minmax(330px, clamp(340px, 30vw, 410px)) minmax(0, 1fr); }
}

/* Desktop video view gets room for portrait media and an adjacent supporting column. */
@media (min-width: 1100px) {
  #videos-section .video-layout { width: min(100%, 1240px); }
  #videos-section .video-feed { width: min(100%, 920px); margin-inline: auto; }
  #videos-section .video-reel { width: min(100%, 760px); }
  #videos-section .video-reel .post-media-frame { width: min(100%, 500px); height: min(82dvh, 860px); }
}

@media (min-width: 1440px) {
  #home-section > .content { width: min(100%, 1460px); }
  #home-section .home-layout { grid-template-columns: minmax(0, 920px) minmax(280px, 320px); }
}

@media (max-width: 768px) {
  #videos-section .video-reel .post-media-frame { width: min(100%, 480px); height: min(76dvh, 780px); border-radius: 10px; }
  #home-section .post-media-frame { aspect-ratio: auto !important; }
  #home-section .post-media-frame > .post-media { max-height: min(78dvh, 820px); }
  .home-messages-panel { overscroll-behavior: contain; }
}

@media (max-width: 390px) {
  #videos-section .video-reel .post-media-frame { height: min(72dvh, 680px); }
}

@media (prefers-reduced-motion: reduce) {
  .app .sidebar { transition: none; }
  #messages-section .chat-panel { transition: none; }
}

/* The application inherits the same palette as the rest of the product. */
.app {
  background: var(--bg);
  color: var(--text);
}
.app :where(.content, .messages-layout, .people-pane, .chat-panel, .conversation, .chat-box) { min-width: 0; }
.app :where(button, input, textarea, select) { scroll-margin-block: 12px; }
.app :where(.main-nav button, .sidebar-footer > button, .mobile-nav button, .mobile-header-actions button, #new-message-button, #send-button) { min-height: var(--touch-target); }
.app .sidebar,
.app .mobile-header,
.app .mobile-nav,
.app .people-pane,
.app .conversation > header,
.app .message-composer-bar,
.app .search-field .search-input,
.app .suggested-panel,
.app .stories-section,
.app .post,
.app .activity-list .notification-row { background-color: var(--surface); }
.app .chat-panel, .app .chat-box { background-color: var(--bg); }
.app input, .app textarea, .app select { border-color: var(--border); background-color: var(--surface-secondary); }
.app .feed-layout,
.app .home-layout,
.app .video-layout,
.app .explore-layout { min-width: 0; }

@media (min-width: 1440px) {
  #home-section > .content { width: min(100%, 1420px); }
  #home-section .home-layout { grid-template-columns: minmax(0, 900px) minmax(270px, 310px); justify-content: center; gap: clamp(30px, 4vw, 56px); }
  #home-section .feed-layout { max-width: 900px; }
  #home-section .post-media-frame > .post-media { max-height: min(78vh, 900px); }
  .app-main > #messages-section .messages-layout { grid-template-columns: minmax(390px, 440px) minmax(0, 1fr); }
  .app .chat-box { padding-inline: clamp(48px, 8vw, 160px); }
  .app .video-feed { width: min(100%, 800px); }
}

/* Tablet: preserve the rail, use a stacked feed, and promote the open conversation to its own pane. */
@media (min-width: 769px) and (max-width: 950px) {
  #home-section .home-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
  #home-section .feed-layout { width: min(100%, 720px); margin-inline: auto; }
  #home-section .suggested-panel { display: block; width: min(100%, 720px); position: static; margin: 0 auto 24px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); padding: 16px; }
  #home-section .suggested-users { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #messages-section .messages-layout { display: block; height: 100%; min-height: 0; }
  #messages-section .people-pane { width: 100%; height: 100%; min-height: 0; border-right: 0; }
  #messages-section .chat-panel { position: fixed; z-index: 40; inset: 0 0 0 var(--sidebar-width, 76px); display: block; height: 100dvh; transform: translateX(105%); transition: transform .2s ease; background: var(--bg); }
  #messages-section .chat-panel.open { transform: none; }
  #messages-section .conversation, #messages-section .conversation-empty { height: 100dvh; min-height: 0; }
  #messages-section .conversation { grid-template-rows: 68px minmax(0, 1fr) auto auto; }
  #messages-section .conversation > header #mobile-chat-back { display: grid; }
  #messages-section .conversation-actions .unavailable-call { display: none; }
  #messages-section .chat-box { padding-inline: clamp(24px, 5vw, 80px); }
}

/* Wide desktop feed and inbox keep their content centered instead of stretching with the monitor. */
@media (min-width: 951px) and (max-width: 1439px) {
  #home-section > .content { width: min(100%, 1200px); }
  #home-section .home-layout { grid-template-columns: minmax(0, 760px) minmax(240px, 290px); justify-content: center; gap: clamp(24px, 3vw, 42px); }
  #home-section .feed-layout { max-width: 760px; }
  .app-main > #messages-section .messages-layout { grid-template-columns: minmax(340px, clamp(340px, 31vw, 405px)) minmax(0, 1fr); }
}

@media (max-width: 768px) {
  .app { min-height: var(--app-viewport-height, 100vh); }
  .app-main { min-width: 0; }
  .app-main > .page { min-width: 0; overflow-x: clip; }
  .app-main > #home-section { padding-bottom: env(safe-area-inset-bottom); }
  .app .mobile-header { position: sticky; top: 0; z-index: 12; min-height: 56px; height: 56px; padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); }
  .app .mobile-nav { height: calc(60px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
  .app-main { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  .app .page { min-height: calc(var(--app-viewport-height, 100vh) - 56px - 60px - env(safe-area-inset-bottom)); }
  .app .content { padding-inline: clamp(12px, 4vw, 22px); }
  #home-section > .content { padding-top: 14px; }
  #home-section .home-layout { display: flex; flex-direction: column; gap: 16px; }
  #home-section .feed-layout { width: 100%; max-width: 720px; margin-inline: auto; }
  #home-section .suggested-panel { display: block; order: 2; width: min(100%, 720px); margin: 0 auto 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); padding: 14px; }
  #home-section .suggested-users { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); overflow: visible; }
  #home-section .suggested-user { min-width: 0; }
  #home-section .page-heading h1 { font-size: clamp(21px, 5vw, 25px); }
  #home-section .create-post-button { width: auto; min-width: var(--touch-target); padding-inline: 12px; }
  #home-section .create-post-button span { display: inline; }
  #home-section .stories-section { background: transparent; }
  #home-section .post-media-frame { background: var(--surface-secondary); }
  .app .mobile-nav button, .app .mobile-header .icon-button { min-width: var(--touch-target); min-height: var(--touch-target); }
  .app .mobile-nav button { gap: 2px; }
  .app .mobile-nav span { font-size: 10px; }
  #search-section .search-mode { position: sticky; top: 56px; z-index: 4; background: var(--surface-secondary); }
  #notifications-section .content,
#search-section .content,
#videos-section .content { width: 100%; }
  #videos-section .video-feed { width: 100%; height: calc(100dvh - 122px - env(safe-area-inset-bottom)); max-height: none; padding-inline: 0; }
  #videos-section .video-feed .video-reel { width: min(100%, 640px); }
  #messages-section .people-pane { padding-bottom: 24px; }
  #messages-section .chat-panel.open { z-index: 50; }
  #home-messages-shortcut { right: max(12px, env(safe-area-inset-right)); bottom: calc(72px + env(safe-area-inset-bottom)); }
  .home-messages-panel { right: max(10px, env(safe-area-inset-right)); bottom: calc(128px + env(safe-area-inset-bottom)); width: min(390px, calc(100vw - 20px)); height: min(560px, calc(100dvh - 158px - env(safe-area-inset-bottom))); }
}

@media (max-width: 520px) {
  #home-section .content { padding-inline: 12px; }
  #home-section .stories-section { margin-inline: -12px; padding-inline: 12px; }
  #home-section .stories { gap: 13px; }
  #home-section .post { margin-inline: -12px; padding-inline: 12px; }
  #home-section .post-media-frame { border-radius: 0; }
  #home-section .suggested-panel { padding: 12px; }
  #home-section .suggested-users { grid-template-columns: minmax(0, 1fr); }
  #home-section .suggested-user { grid-template-columns: 38px minmax(0, 1fr) auto; }
  #messages-section .conversation > header { gap: 6px; padding-inline: 8px; }
  #messages-section .conversation-identity b { max-width: 34vw; }
  #messages-section .app .chat-panel.open .message-row { max-width: 84%; }
  #messages-section .chat-box { padding-inline: 12px; }
  #messages-section .conversation-actions .icon-button { min-width: 38px; }
  #notifications-section .notification-row { align-items: flex-start; padding: 10px; }
  #search-section .search-field .search-input { min-height: 46px; }
}

@media (max-width: 360px) {
  .app .mobile-nav span { font-size: 9px; }
  .app .mobile-nav .icon { width: 19px; height: 19px; }
  #home-section .page-heading { gap: 8px; }
  #home-section .create-post-button { min-width: 40px; padding-inline: 8px; }
  #home-section .create-post-button span { font-size: 12px; }
  #messages-section .conversation-identity b { max-width: 29vw; }
  #messages-section .conversation-actions .icon-button { min-width: 34px; width: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  .app .chat-panel { transition: none; }
}

/* Phase 2 messaging state. Keep typing and privacy status compact on every pane width. */
#messages-section .conversation-identity .presence-status,
#messages-section .conversation-identity .typing-indicator { min-height: 0; font-size: 11px; line-height: 1.25; }
#messages-section .conversation-identity .presence-status { color: #a1a1aa; }
#messages-section .conversation-identity .typing-indicator { color: var(--accent); font-weight: 600; }
#messages-section .conversation-identity .typing-indicator[hidden] { display: none; }
#messages-section .item-main { display: grid; min-width: 0; }
#messages-section .muted-conversation-marker { color: var(--text-secondary); font-size: 10px; font-weight: 500; }
.contact-info-phase2-actions { display: grid; width: min(100%, 260px); gap: 8px; }
.contact-info-phase2-actions .secondary { min-height: 40px; }
@media (max-width: 520px) {
  #messages-section .conversation-identity .presence-status,
  #messages-section .conversation-identity .typing-indicator { font-size: 10px; }
  .contact-info-phase2-actions { width: 100%; }
}

/* Final desktop rail state, after the base breakpoint rules. */
@media (min-width: 1024px) {
  .app .sidebar:hover,
  .app .sidebar:focus-within { width: var(--sidebar-expanded); }
  .app .sidebar:hover .brand,
  .app .sidebar:focus-within .brand { justify-content: flex-start; padding-inline: 10px; }
  .app .sidebar:hover .brand > span,
  .app .sidebar:focus-within .brand > span,
  .app .sidebar:hover .main-nav button > span:not(.nav-badge),
  .app .sidebar:focus-within .main-nav button > span:not(.nav-badge),
  .app .sidebar:hover .sidebar-footer > button > span,
  .app .sidebar:focus-within .sidebar-footer > button > span {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
    white-space: nowrap;
  }
  .app .sidebar:hover .main-nav button,
  .app .sidebar:focus-within .main-nav button,
  .app .sidebar:hover .sidebar-footer > button,
  .app .sidebar:focus-within .sidebar-footer > button { justify-content: flex-start; padding-inline: 10px; }
}

/* Final reel overrides: clear the inherited post card and keep the overlay readable. */
#videos-section .video-reel { width: min(100%, 540px); grid-template-columns: minmax(0, min(400px, calc((100dvh - 190px) * 9 / 16))) 48px; align-items: center; justify-content: center; column-gap: 14px; border: 0; background: transparent; padding: 0; box-shadow: none; }
#videos-section .video-reel .post-media-frame { grid-column: 1; grid-row: 1; width: 100%; height: auto; aspect-ratio: 9 / 16; align-self: center; margin: 0; background: #000; }
#videos-section .video-reel .reel-info {
  right: 56px;
  bottom: 8px;
  left: 8px;
  display: grid;
  gap: 8px;
  padding: 56px 10px 18px;
  background: linear-gradient(transparent, rgb(0 0 0 / 82%));
}
#videos-section .video-reel .reel-author { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 10px; }
#videos-section .video-reel .reel-author-profile { display: flex; min-width: 0; align-items: center; gap: 9px; border: 0; background: transparent; color: #fff; padding: 0; text-align: left; }
#videos-section .video-reel .reel-author-avatar { width: 40px; height: 40px; flex: 0 0 40px; border: 1px solid rgb(255 255 255 / 75%); }
#videos-section .video-reel .reel-identity { display: grid; min-width: 0; gap: 3px; }
#videos-section .video-reel .reel-identity strong { overflow: hidden; color: #fff; font: 650 14px/1.2 system-ui, sans-serif; text-overflow: ellipsis; white-space: nowrap; }
#videos-section .video-reel .reel-identity small { overflow: hidden; color: rgb(255 255 255 / 78%); font: 12px/1.2 system-ui, sans-serif; text-overflow: ellipsis; white-space: nowrap; }
#videos-section .video-reel .reel-follow { flex: 0 0 auto; min-height: 32px; border-radius: 999px; }
#videos-section .video-reel .reel-info .post-caption { max-width: 100%; margin: 0; color: #fff; font: 13px/1.4 system-ui, sans-serif; text-shadow: 0 1px 3px rgb(0 0 0 / 70%); }
#videos-section .video-reel .reel-info .caption-toggle { justify-self: start; color: #fff; }
#videos-section .video-reel-navigation button:disabled { visibility: visible; opacity: .42; cursor: not-allowed; }
#videos-section .video-reel .reel-loading {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  background: rgb(5 6 10 / 34%);
  color: rgb(255 255 255 / 86%);
  font: 13px/1.4 system-ui, sans-serif;
  text-align: center;
  pointer-events: none;
}
#videos-section .reel-loading-spinner { width: 32px; height: 32px; border: 3px solid rgb(255 255 255 / 24%); border-top-color: var(--accent); border-radius: 50%; animation: reel-spinner .8s linear infinite; }
#videos-section .reel-loading.is-error { background: rgb(5 6 10 / 92%); color: #fff; }
@keyframes reel-spinner { to { transform: rotate(360deg); } }
@media (max-width: 768px) {
  #videos-section .video-reel { width: min(100%, 430px); grid-template-columns: minmax(0, min(430px, calc((100dvh - 150px) * 9 / 16))); column-gap: 0; background: transparent; }
  #videos-section .video-reel .reel-info { right: 56px; bottom: 8px; left: 8px; padding: 48px 8px 14px; }
  #videos-section .video-reel .reel-actions { background: transparent; }
}
@media (prefers-reduced-motion: reduce) { #videos-section .reel-loading-spinner { animation-duration: 1.8s; } }

/* Compact Home feed shelf and empty-suggestion action. */
#home-section > .content { padding-top: 8px; }
#home-section .page-heading { min-height: 0; margin-bottom: 6px; }
#home-section .page-heading h1 { font-size: 20px; line-height: 1.2; }
#home-section .stories-section {
  position: relative;
  overflow: visible;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}
#home-section .stories-heading {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
#home-section .stories { gap: 16px; padding: 2px 4px; }
#home-section .story { width: 70px; flex-basis: 70px; gap: 5px; }
#home-section .story .avatar { width: 58px; height: 58px; }
#home-section .story-add .avatar { border: 2px dashed var(--accent); background: var(--surface); }
#home-section .feed-toolbar { min-height: 34px; margin-top: 0; border-bottom: 0; }
#home-section .feed { gap: 12px; margin-top: 6px; }
#home-section .post-media-frame { width: min(100%, 680px); max-width: 100%; margin-inline: auto; overflow: hidden; border-radius: 12px; background: transparent; transition: width .2s ease; }
#home-section .post-media-frame > .post-media { width: 100%; height: 100%; max-height: none; object-fit: contain; }
#home-section .post-media-frame.is-portrait-crop > .post-media { object-fit: cover; }
#home-section .feed-layout { max-width: 680px; }
#home-section #feed-list > .post { width: min(100%, 576px); margin: 0 auto 18px; padding: 12px 8px 16px; border-radius: 18px; overflow: visible; }
@media (min-width: 769px) {
  #home-section #feed-list > .post.has-media-fit { width: min(calc(var(--post-media-width) + 18px), 576px, 100%); }
}
#home-section #feed-list .post-head { min-height: 48px; align-items: center; padding: 0 0 10px; }
#home-section #feed-list .post-body { padding: 8px 0 0; }
#home-section #feed-list .post-actions { min-height: 42px; gap: 8px; padding: 2px 0 5px; }
#home-section #feed-list .post-actions > button { display: inline-flex; min-width: 38px; min-height: 38px; align-items: center; justify-content: center; gap: 5px; border-radius: 10px; padding: 6px; transition: color .2s ease, background-color .2s ease, transform .2s ease; }
#home-section #feed-list .post-actions > button .icon { width: 20px; height: 20px; }
#home-section #feed-list .post-actions [data-post-like] { color: var(--text-secondary); }
#home-section #feed-list .post-actions [data-post-like].active { color: #ff3040; }
#home-section #feed-list .post-actions [data-post-like].active .icon { fill: #ff3040; color: #ff3040; }
#home-section #feed-list .post-actions > button:hover { color: var(--accent); }
#home-section #feed-list .post-actions > button[data-post-like].active:hover { color: #ff3040; }
#home-section #feed-list .post-likes-summary { display: none; }
#home-section .post-video-controls { position: absolute; z-index: 3; inset: 0; display: grid; place-items: center; pointer-events: none; }
#home-section .post-video-status { position: absolute; z-index: 2; right: 58px; bottom: 14px; left: 12px; width: fit-content; max-width: calc(100% - 76px); border: 1px solid rgb(255 255 255 / 20%); border-radius: 999px; background: rgb(0 0 0 / 68%); color: #fff; padding: 6px 10px; font-size: 12px; line-height: 1.3; pointer-events: none; }
#home-section .post-video-status[hidden] { display: none; }
#home-section .post-video-status.is-error { border-color: rgb(255 255 255 / 34%); }
#home-section .post-video-controls button { display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid rgb(255 255 255 / 45%); border-radius: 50%; background: rgb(5 6 10 / 52%); color: #fff; cursor: pointer; pointer-events: auto; transition: opacity .2s ease, background-color .2s ease, transform .2s ease; backdrop-filter: blur(8px); }
#home-section .post-video-controls button:hover { background: rgb(5 6 10 / 78%); transform: scale(1.04); }
#home-section .post-video-controls .post-video-play { opacity: .92; }
#home-section .post-video-controls.is-playing .post-video-play { opacity: 0; }
#home-section .post-media-frame:hover .post-video-controls.is-playing .post-video-play,
#home-section .post-media-frame:focus-within .post-video-controls.is-playing .post-video-play { opacity: .92; }
#home-section .post-video-controls .post-video-sound { position: absolute; right: 10px; bottom: 10px; width: 36px; height: 36px; }
#home-section .post-video-controls .icon { width: 18px; height: 18px; }
#home-section .post-video-feedback { position: absolute; left: 50%; top: 50%; display: grid; width: 64px; height: 64px; place-items: center; border-radius: 50%; background: rgb(0 0 0 / 54%); color: #fff; opacity: 0; pointer-events: none; transform: translate(-50%, -50%) scale(.88); }
#home-section .post-video-feedback .icon { width: 28px; height: 28px; }
#home-section .post-video-controls.show-manual-feedback .post-video-feedback { animation: post-video-manual-feedback 650ms ease-out both; }
@keyframes post-video-manual-feedback { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.88); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.12); } }
@media (prefers-reduced-motion: reduce) { #home-section .post-video-controls.show-manual-feedback .post-video-feedback { animation-duration: 350ms; } }
/* Reels reuse the Feed play control, but have their own outside-frame sound
   toggle. Keep the play affordance visible when autoplay is unavailable. */
#videos-section .video-reel .post-video-controls { position: absolute; z-index: 4; inset: 0; display: grid; place-items: center; pointer-events: none; }
#videos-section .video-reel .post-video-controls button { display: grid; width: 48px; height: 48px; place-items: center; border: 1px solid rgb(255 255 255 / 48%); border-radius: 50%; background: rgb(5 6 10 / 68%); color: #fff; cursor: pointer; pointer-events: auto; backdrop-filter: blur(8px); }
#videos-section .video-reel .post-video-controls .post-video-play { opacity: .92; }
#videos-section .video-reel .post-video-controls.is-playing .post-video-play { opacity: 0; }
#videos-section .video-reel .post-media-frame:hover .post-video-controls.is-playing .post-video-play,
#videos-section .video-reel .post-media-frame:focus-within .post-video-controls.is-playing .post-video-play { opacity: .92; }
#videos-section .video-reel .post-video-controls .icon { width: 20px; height: 20px; }
#suggested-panel.has-no-suggestions #suggested-title,
#suggested-panel.has-no-suggestions #suggested-status,
#suggested-panel.has-no-suggestions #suggested-users { display: none; }
#home-section .create-post-button { min-height: 36px; padding-block: 6px; }
#home-section .post-head { position: relative; }
#home-section .post-more-menu { position: relative; z-index: 5; margin-left: auto; }
#home-section .post-more-menu > summary { display: grid; width: 38px; height: 38px; place-items: center; border: 0; border-radius: 50%; color: var(--text-secondary); cursor: pointer; list-style: none; transition: background-color .2s ease, color .2s ease; }
#home-section .post-more-menu > summary::-webkit-details-marker { display: none; }
#home-section .post-more-menu > summary:hover { background: var(--hover); color: var(--text); }
#home-section .post-more-menu .icon { width: 20px; height: 20px; }
#home-section .post-more-items { position: absolute; top: calc(100% + 4px); right: 0; display: grid; min-width: 150px; padding: 5px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
#home-section .post-more-items button { min-height: 38px; border: 0; border-radius: 8px; background: transparent; color: var(--text); padding: 8px 10px; text-align: left; transition: background-color .2s ease; }
#home-section .post-more-items button:hover { background: var(--hover); }
#home-section .post-more-items button.danger { color: var(--danger); }
@media (max-width: 768px) {
  #home-section > .content { padding-top: 6px; }
  #home-section .page-heading { margin-bottom: 4px; }
  #home-section .stories-section { margin: 0; }
  #home-section .stories { padding: 2px; }
  #home-section .feed-toolbar { min-height: 32px; }
  #home-section .feed { margin-top: 4px; }
  #home-section .story { width: 66px; flex-basis: 66px; }
  #home-section .story .avatar { width: 54px; height: 54px; }
  #home-section .post-media-frame { width: 100%; }
}

/* Feed sizing: stable Instagram-style post width and a mobile suggestions carousel. */
@media (min-width: 769px) {
  #home-section .home-layout {
    width: min(100%, 1000px);
    grid-template-columns: minmax(0, 480px) minmax(240px, 264px);
    justify-content: center;
    gap: clamp(24px, 3vw, 40px);
  }
  #home-section .feed-layout { width: 100%; max-width: 480px; margin-inline: auto; }
  #home-section #feed-list > .post { width: min(100%, 480px); }
  #home-section #feed-list > .post.has-media-fit { width: min(calc(var(--post-media-width) + 18px), 480px, 100%); }
  #home-section .post-media-frame { max-width: 100%; }
}

@media (max-width: 768px) {
  #home-section .home-layout { gap: 10px; }
  #home-section .feed-layout { width: 100%; max-width: 480px; }
  #home-section .suggested-panel {
    width: min(100%, 480px);
    margin: 2px auto 18px;
    padding: 12px;
    overflow: hidden;
  }
  #home-section .suggested-panel h2 { margin: 0 0 8px; }
  #home-section #suggested-status { margin: 0 0 6px; }
  #home-section .suggested-users {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 1px 6px;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
  }
  #home-section .suggested-users::-webkit-scrollbar { display: none; }
  #home-section .suggested-user {
    flex: 0 0 min(78%, 230px);
    min-width: 0;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    gap: 7px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-secondary);
  }
  #home-section .suggested-user .avatar { width: 36px; height: 36px; }
  #home-section .suggested-user button { min-height: 30px; padding: 4px 8px; }
}

/* Pitch-black video surfaces with a compact, centered vertical canvas. */
#home-section,
#videos-section { background: #000; }
#home-section > .content,
#videos-section > .content { background: transparent; border: 0; border-radius: 0; box-shadow: none; }
#home-section #feed-list > .post,
#home-section #feed-list > .post.has-video-media,
#home-section #feed-list > .post.has-media-fit {
  width: min(100%, 470px);
  max-width: 470px;
  margin: 0 auto 32px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
#home-section .post-media-frame {
  width: min(100%, 470px);
  aspect-ratio: 4 / 5 !important;
  border-radius: 6px;
  background: #000;
}
#home-section .post-media-frame > .post-media {
  width: 100%;
  height: 100%;
  max-height: none;
  border-radius: inherit;
  object-fit: cover;
  background: #000;
}
@media (min-width: 769px) {
  #home-section .post-media-frame { aspect-ratio: 1 !important; }
}
#home-section #feed-list .post-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 4px;
  color: #cbd5e1;
}
#home-section #feed-list .post-actions > button {
  display: inline-flex;
  min-width: 36px;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 4px;
  color: #cbd5e1;
  font-size: 12px;
  transition: color .2s ease, background-color .2s ease;
}
#home-section #feed-list .post-actions > button:hover { color: #fff; }
#home-section #feed-list .post-actions > button[data-post-like].active { color: #ff3040; }
#home-section #feed-list .post-actions > button[data-post-like].active .icon { fill: #ff3040; }
#home-section #feed-list .post-actions .icon { width: 20px; height: 20px; }
#home-section #feed-list .post-actions > button[data-post-save] { margin-left: auto; }
#home-section #feed-list .post-body { padding: 0; }
#home-section #feed-list .post-likes-summary { display: none; }
#home-section #feed-list .post-caption,
#home-section #feed-list .caption-toggle { margin-inline: 4px; }
#videos-section .video-reel {
  width: min(100%, 530px);
  grid-template-columns: minmax(0, min(470px, calc((100dvh - 190px) * 9 / 16))) 48px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
#videos-section .video-reel .post-media-frame {
  width: min(100%, 470px);
  height: auto;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  background: #000;
  box-shadow: none;
}
#videos-section .video-reel .post-media-frame > video.post-media {
  width: 100%;
  height: 100%;
  max-height: none;
  border-radius: 0;
  object-fit: cover;
  background: #000;
}
#videos-section .video-reel .reel-sound-toggle {
  top: auto;
  right: 12px;
  bottom: 12px;
  display: grid;
  width: 38px;
  min-height: 38px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 60%);
  padding: 8px;
}
#videos-section .video-reel .reel-sound-toggle .icon { width: 18px; height: 18px; }
@media (max-width: 768px) {
  #videos-section .video-reel {
    width: min(100%, 470px);
    grid-template-columns: minmax(0, min(470px, calc((100dvh - 150px) * 9 / 16))) 48px;
  }
  #videos-section .video-reel .post-media-frame { width: 100%; }
}

/* Full-screen Reels viewer: centered canvas with actions layered over the video. */
#videos-section { min-height: 100dvh; background: #000; }
#videos-section > .content { width: 100%; max-width: none; background: #000; }
#videos-section .video-layout { width: 100%; max-width: none; }
#videos-section .video-feed {
  display: flex;
  width: 100%;
  max-width: none;
  align-items: center;
  justify-content: flex-start;
  scroll-snap-type: y mandatory;
  scroll-padding-block: 8px;
  padding-inline: 16px;
  background: #000;
}
#videos-section .video-reel {
  position: relative;
  display: block;
  width: min(100%, 470px);
  min-height: 0;
  margin-inline: auto;
  padding: 0;
  background: transparent;
  scroll-snap-align: center;
}
#videos-section .video-reel .post-media-frame {
  position: relative;
  width: min(100%, 470px, 47.8125dvh);
  height: auto;
  max-height: 85vh;
  aspect-ratio: 9 / 16;
  margin-inline: auto;
  overflow: hidden;
  border-radius: 12px;
  background: #000;
  box-shadow: 0 6px 18px rgb(0 0 0 / 24%);
}
#videos-section .video-reel .post-media-frame::after {
  position: absolute;
  z-index: 1;
  right: 0;
  bottom: 0;
  left: 0;
  height: 10rem;
  background: linear-gradient(to top, rgb(0 0 0 / 82%), transparent);
  content: "";
  pointer-events: none;
}
#videos-section .video-reel .post-media-frame::before {
  position: absolute;
  z-index: 1;
  top: 0;
  right: 0;
  left: 0;
  height: 7rem;
  background: linear-gradient(to bottom, rgb(0 0 0 / 72%), transparent);
  content: "";
  pointer-events: none;
}
#videos-section .video-reel .reel-info {
  z-index: 2;
  position: absolute;
  right: 4rem;
  bottom: 1rem;
  left: 1rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #fff;
  padding: 0;
  background: transparent;
}
#videos-section .video-reel .reel-actions {
  position: absolute;
  z-index: 4;
  right: 1rem;
  bottom: 2rem;
  display: flex;
  width: 44px;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 0;
  pointer-events: auto;
}
#videos-section .video-reel .reel-actions button {
  display: grid;
  width: 42px;
  min-width: 42px;
  min-height: 44px;
  place-items: center;
  gap: 2px;
  border: 0;
  border-radius: 12px;
  background: rgb(0 0 0 / 28%);
  color: #fff;
  padding: 4px 2px;
  text-shadow: 0 1px 4px rgb(0 0 0 / 70%);
}
#videos-section .video-reel .reel-actions .icon { width: 23px; height: 23px; }
#videos-section .video-reel .reel-sound-toggle {
  position: static;
  z-index: auto;
  width: 42px;
  height: 42px;
  min-width: 42px;
  min-height: 42px;
  border-radius: 50%;
  background: rgb(0 0 0 / 60%);
  padding: 8px;
}
#videos-section .video-reel .reel-sound-toggle .icon { width: 20px; height: 20px; }
#videos-section .video-reel .reel-loading {
  z-index: 3;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  border-radius: 12px;
  background: #000;
}
#videos-section .video-reel .post-media-frame.is-loading::before,
#videos-section .video-reel .post-media-frame.is-loading::after { display: none; }
#videos-section .video-reel .post-media-frame.is-loading .reel-info,
#videos-section .video-reel .post-media-frame.is-loading .reel-actions,
#videos-section .video-reel .post-media-frame.is-loading .video-reel-navigation {
  visibility: hidden;
  opacity: 0;
}
#videos-section .video-reel .video-reel-navigation {
  position: absolute;
  z-index: 5;
  top: 12px;
  right: 12px;
  display: flex;
  width: auto;
  gap: 8px;
  margin: 0;
  transform: none;
}
#videos-section .video-reel .video-reel-navigation button {
  width: 38px;
  height: 38px;
  min-height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 42%);
  color: #fff;
  box-shadow: none;
}
@media (max-width: 768px) {
  #videos-section .video-feed { padding-inline: 8px; }
  #videos-section .video-reel { width: min(100%, 470px); }
  #videos-section .video-reel .post-media-frame { width: min(100%, 47.8125dvh); max-height: 85dvh; }
}

/* Final Home Feed micro-polish: trim header/story whitespace without adding card surfaces. */
#home-section > .content { padding-top: 4px; }
#home-section .page-heading { margin-bottom: 2px; }
#home-section .stories-section { margin: 0; padding: 0; border: 0; background: transparent; }
#home-section .stories { gap: 12px; padding: 0 4px; }
#home-section .feed-toolbar { min-height: 30px; }
#home-section .feed { margin-top: 2px; }

/* Unified social shell: responsive navigation, focused feed, and consistent surfaces. */
.app {
  --social-content-width: 1180px;
  --social-feed-width: 660px;
  background: var(--bg);
}
.app .mobile-header {
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px);
}
.mobile-brand { display: inline-flex; align-items: center; gap: 9px; font-size: 17px; font-weight: 760; letter-spacing: -.025em; }
.mobile-brand .mark { width: 32px; height: 32px; border-radius: 10px; background: transparent; }
.app .primary { background: var(--accent); transition: background-color .18s ease, transform .18s ease; }
.app .primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
.app :where(.primary, .secondary, .icon-button, .post-actions button, .mobile-nav button) { transition: background-color .18s ease, color .18s ease, border-color .18s ease, transform .18s ease; }
.app :where(button, input, textarea, select):focus-visible { outline-offset: 3px; }

@media (min-width: 769px) {
  .app > .sidebar { border-right: 1px solid var(--border); background: var(--surface); }
  .app .main-nav button { border-radius: 13px; }
  .app .main-nav button.active { box-shadow: inset 3px 0 0 var(--accent); }
  #home-section > .content { width: min(100%, var(--social-content-width)); padding: 30px clamp(28px, 4vw, 56px) 48px; }
  #home-section .home-layout { grid-template-columns: minmax(0, var(--social-feed-width)) minmax(230px, 280px); justify-content: center; gap: clamp(28px, 4vw, 48px); }
  #home-section .feed-layout { max-width: var(--social-feed-width); }
  #home-section .page-heading { min-height: 48px; margin-bottom: 18px; }
  #home-section .stories-section { margin: 0 0 20px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: transparent; padding: 0 0 10px; }
  #home-section .stories-heading { padding: 0 2px 8px; }
  #home-section .stories { gap: 15px; padding: 4px 4px 8px; }
  #home-section .post { width: min(100%, 540px); margin-inline: auto; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); padding: 12px; box-shadow: 0 3px 14px rgb(10 14 28 / 4%); }
  #home-section .post-media-frame { border-radius: 12px; }
  #home-section .suggested-panel { top: 26px; border: 0; background: transparent; padding: 4px 0; }
  #videos-section .video-layout { width: min(100%, 1100px); }
  #videos-section .video-feed { width: min(100%, 700px); }
#videos-section .video-reel { width: min(100%, 540px); }

/* Inbox note bubbles and the interactive note viewer. */
#messages-section .note-bubble {
  top: -27px;
  z-index: 10;
  max-width: 110px;
  border-color: var(--border-strong);
  border-radius: 999px;
  background: var(--surface-elevated);
  color: var(--text);
  padding: 4px 12px;
  pointer-events: none;
}
#messages-section .note-bubble::after { border-top-color: var(--surface-elevated); }
.note-view-dialog {
  position: fixed;
  width: min(392px, calc(100vw - 28px));
  max-width: 392px;
  max-height: min(90dvh, 620px);
  overflow: visible;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--surface);
  color: var(--text);
  padding: 26px;
  box-shadow: var(--shadow-raised);
}
.note-view-dialog[open] { display: flex; flex-direction: column; align-items: center; }
.note-view-dialog::backdrop { background: rgb(0 0 0 / 70%); backdrop-filter: blur(4px); }
.note-view-close {
  position: absolute;
  top: 10px;
  right: 14px;
  z-index: 2;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  padding: 0;
  font: 24px/1 system-ui, sans-serif;
  cursor: pointer;
}
.note-view-close:hover, .note-view-close:focus-visible { background: var(--hover); color: var(--text); }
.note-view-bubble {
  display: grid;
  min-height: 148px;
  width: 100%;
  place-items: center;
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  background: var(--surface-secondary);
  color: var(--text);
  padding: 24px 22px 42px;
  text-align: center;
  font-size: clamp(17px, 4vw, 20px);
  font-weight: 500;
  line-height: 1.4;
  overflow-wrap: anywhere;
  box-shadow: inset 0 2px 10px color-mix(in srgb, var(--text) 7%, transparent);
}
.note-view-bubble .note-audio-control { display: flex; width: 100%; align-items: center; gap: 8px; margin-top: 8px; }
.note-view-bubble .note-audio-control progress { min-width: 0; flex: 1; accent-color: var(--accent); }
.note-view-bubble .note-audio-control small { flex: 0 0 auto; color: var(--text-secondary); font-size: 11px; }
.note-view-profile {
  display: flex;
  max-width: 100%;
  flex-direction: column;
  align-items: center;
  margin-top: -30px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: inherit;
  padding: 0 12px 4px;
}
.note-view-avatar { position: relative; z-index: 1; }
.note-view-avatar-image {
  display: grid;
  width: 80px;
  height: 80px;
  place-items: center;
  overflow: hidden;
  border: 4px solid var(--surface);
  border-radius: 50%;
  background: var(--surface-tertiary);
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgb(0 0 0 / 30%);
}
.note-view-avatar-image img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.note-view-profile-name { max-width: 100%; margin-top: 8px; overflow: hidden; color: var(--text); font-size: 17px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.note-view-username { max-width: 100%; margin-top: 2px; padding: 0; border: 0; background: transparent; color: var(--text-secondary); font: inherit; font-size: 13px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.note-view-username:hover { color: var(--accent); text-decoration: underline; }
.note-view-username:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
.note-view-created-at { display: none; }
.note-view-replies { width: 100%; min-height: 0; max-height: 220px; overflow-y: auto; margin-top: 8px; }
.note-view-replies h2 { margin: 0 0 8px; color: var(--text-secondary); font-size: 12px; font-weight: 650; }
.note-view-replies-list { display: grid; gap: 8px; }
.note-view-reply { max-width: 92%; border: 1px solid var(--border-subtle); border-radius: 14px 14px 14px 4px; background: var(--surface-secondary); padding: 9px 12px; }
.note-view-reply.is-mine { justify-self: end; border-radius: 14px 14px 4px 14px; background: color-mix(in srgb, var(--accent) 14%, var(--surface-secondary)); }
.note-view-reply strong { display: block; color: var(--text-secondary); font-size: 11px; }
.note-view-reply p { margin: 3px 0; overflow-wrap: anywhere; color: var(--text); font-size: 13px; line-height: 1.4; white-space: pre-wrap; }
.note-view-reply time { display: block; color: var(--text-tertiary); font-size: 10px; }
.note-view-replies-list > .state { margin: 4px 0; font-size: 12px; text-align: center; }
.note-view-reply-form {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-secondary);
  padding: 5px 7px 5px 16px;
  box-shadow: inset 0 1px 5px color-mix(in srgb, var(--text) 8%, transparent);
}
.note-view-reply-form[hidden] { display: none; }
.note-view-reply-form input { min-width: 0; height: 36px; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); padding: 0; font: inherit; font-size: 14px; }
.note-view-reply-form input::placeholder { color: var(--text-secondary); opacity: 1; }
.note-view-reply-form button { display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--text-secondary); padding: 0; cursor: pointer; }
.note-view-reply-form button:hover, .note-view-reply-form button:focus-visible { background: var(--hover); color: var(--text); }
.note-view-reply-form .note-view-send { background: var(--accent); color: var(--accent-contrast); }
.note-view-reply-form button:disabled { cursor: wait; opacity: .55; }
.note-view-reply-form .icon { width: 19px; height: 19px; }
.note-view-emoji-picker {
  position: absolute;
  right: 8px;
  bottom: calc(100% + 8px);
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(6, 36px);
  gap: 4px;
  border: 1px solid rgb(63 63 70 / 82%);
  border-radius: 16px;
  background: #262626;
  padding: 8px;
  box-shadow: 0 18px 45px rgb(0 0 0 / 55%);
}
.note-view-emoji-picker button { width: 36px; height: 36px; font-size: 20px; }
.note-view-emoji-picker button:hover,
.note-view-emoji-picker button:focus-visible { background: rgb(255 255 255 / 12%); }
.note-view-status { width: 100%; margin: 8px 0 0; color: #fca5a5; text-align: center; font-size: 12px; }
.note-view-status:empty { display: none; }
.message-note-reply-preview {
  display: flex;
  max-width: 220px;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
  border: 1px solid #27272a;
  border-radius: 12px;
  background: #1e1e1e;
  padding: 10px;
}
.message-note-reply-avatar { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 50%; object-fit: cover; }
.message-note-reply-text { min-width: 0; overflow: hidden; color: #d4d4d8; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 600px) {
  .note-view-dialog { width: min(392px, calc(100vw - 24px)); padding: 20px; }
  .note-view-bubble { min-height: 132px; padding: 22px 16px 38px; }
  .note-view-profile { margin-top: -28px; }
  .note-view-avatar-image { width: 76px; height: 76px; }
  .note-view-reply-form { gap: 5px; padding-left: 12px; }
}
  #messages-section .people-pane { border-right: 1px solid var(--border); }
  #search-section .content, #notifications-section .content { padding-top: 36px; }
  #search-section .content { width: min(100%, 1100px); }
}

@media (max-width: 768px) {
  .app .mobile-header { min-height: 58px; height: 58px; }
  .app .mobile-nav {
    min-height: calc(64px + env(safe-area-inset-bottom));
    height: calc(64px + env(safe-area-inset-bottom));
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 3px;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    padding: 5px 8px env(safe-area-inset-bottom);
    backdrop-filter: blur(14px);
  }
  .app .mobile-nav button { align-content: center; gap: 3px; border-radius: 12px; color: var(--text-secondary); }
  .app .mobile-nav button.active { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); color: var(--accent); }
  .app .mobile-nav button .icon { width: 20px; height: 20px; }
  .app .mobile-nav button span { font-size: 10px; font-weight: 600; }
  .app-main { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .app .page { min-height: calc(var(--app-viewport-height, 100vh) - 58px - 64px - env(safe-area-inset-bottom)); }
  #home-section > .content { padding: 12px 14px 30px; }
  #home-section .home-layout { gap: 20px; }
  #home-section .page-heading { min-height: 44px; margin-bottom: 12px; }
  #home-section .page-heading h1 { font-size: 23px; }
  #home-section .stories-section { margin: 0 -14px 16px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: transparent; padding: 0 14px 8px; }
  #home-section .stories-heading { padding: 0 2px 8px; }
  #home-section .stories-heading > span { font-size: 11px; }
  #home-section .stories { gap: 13px; padding: 2px 3px 6px; }
  #home-section .story { width: 62px; flex-basis: 62px; gap: 7px; }
  #home-section .story .avatar { width: 54px; height: 54px; }
  #home-section .story span { font-size: 11px; }
  #home-section .post { width: 100%; margin: 0 auto; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); padding: 10px; box-shadow: none; }
  #home-section .post-media-frame { border-radius: 11px; }
  #home-section .post-actions { gap: 4px; }
  #home-section .suggested-panel { margin-top: 4px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
  #home-messages-shortcut { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .home-messages-panel { bottom: calc(136px + env(safe-area-inset-bottom)); }
  #videos-section .video-layout { padding: 12px 10px 18px; }
  #videos-section .page-heading { margin-bottom: 8px; }
  #videos-section .video-feed { height: calc(100dvh - 140px - env(safe-area-inset-bottom)); }
  #search-section .content, #notifications-section .content { padding-top: 20px; }
  #messages-section .people-pane { background: var(--bg); }
  #messages-section .chat-panel.open { background: var(--bg); }
}

@media (max-width: 390px) {
  .mobile-brand { gap: 7px; font-size: 16px; }
  .mobile-brand .mark { width: 30px; height: 30px; }
  .app .mobile-nav { padding-inline: 5px; }
  .app .mobile-nav button span { font-size: 9px; }
  #home-section > .content { padding-inline: 10px; }
  #home-section .stories-section { margin-inline: -10px; padding-inline: 10px; }
  #home-section .post { padding: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .app :where(.primary, .secondary, .icon-button, .post-actions button, .mobile-nav button) { transition: none; }
}

/* Keep the Home Feed's deferred video element filling its reserved media canvas. */
#home-section .post-media-frame > video.post-media {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-height: none;
  aspect-ratio: 4 / 5;
  object-fit: cover;
}
@media (min-width: 769px) {
  #home-section .post-media-frame > video.post-media { aspect-ratio: 1 / 1; }
}
#home-section #feed-list .post-actions { padding: 12px 4px 4px; }


/* Keep audio and video drafts independent inside the Direct Messages composer. */
.voice-recording-panel {
  min-height: 48px;
  gap: 10px;
  border: 0;
  border-radius: 999px;
  background: #6366f1;
  color: #fff;
  padding: 4px 8px;
}
.voice-recording-panel .icon-button {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 16%);
  color: #fff;
}
.voice-recording-panel #voice-send-live-button { background: #fff; color: #4f46e5; }
.voice-recording-panel #voice-recording-time { min-width: 38px; color: #fff; font-variant-numeric: tabular-nums; font-size: 12px; }
.audio-waveform { display: flex; min-width: 0; align-items: center; justify-content: center; gap: 2px; }
.audio-waveform i { display: block; width: 2px; height: var(--wave-height, 12px); border-radius: 99px; background: currentColor; opacity: .82; }
.voice-preview-panel { min-height: 48px; flex-wrap: nowrap; border-radius: 999px; background: #6366f1; color: #fff; padding: 4px 8px; }
.voice-preview-panel audio { flex: 1 1 auto; width: min(44%, 260px); min-width: 72px; height: 36px; }
.voice-preview-panel .icon-button { width: 36px; height: 36px; flex: 0 0 36px; border: 0; border-radius: 50%; color: #fff; }
.voice-preview-panel #voice-send-button { background: #fff; color: #4f46e5; }
.message-audio-player { display: grid; grid-template-columns: 36px minmax(66px, 92px) minmax(52px, 1fr) auto; align-items: center; gap: 8px; border-radius: 18px; background: #6366f1; padding: 8px 11px; color: #fff; }
.message-audio-player .audio-waveform { width: 100%; height: 24px; justify-content: space-between; gap: 1px; overflow: hidden; }
.message-audio-player .audio-waveform i { width: 2px; max-height: 22px; opacity: .78; }
.message-audio-player progress { min-width: 40px; accent-color: #fff; }
.note-form-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.note-form-actions .hidden { display: none; }
@media (max-width: 600px) {
  .message-audio-player { grid-template-columns: 34px minmax(48px, 70px) minmax(36px, 1fr) auto; gap: 6px; }
  .message-audio-player .audio-waveform i { width: 2px; }
}
.message-row.own .message-audio-player { background: #6366f1; color: #fff; }
.message-row:not(.own) .message-audio-player { background: #262626; color: #fff; }
.message-row:not(.own) .message:has(.message-audio-player),
.message-row:not(.own) .message:has(.message-image-button) {
  border-color: #333;
  background: #262626;
  color: #fff;
}
.message-row .message.audio-message { padding: 0; }
.message-audio-player {
  display: flex;
  width: min(280px, 68vw);
  max-width: 100%;
  min-width: 0;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 12px 16px;
  border-radius: 22px;
  background: #5b5bf7;
  color: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 12%);
  box-sizing: border-box;
}
.message-row.own .message-audio-player { background: #5b5bf7; color: #fff; }
.message-row:not(.own) .message-audio-player { background: #262626; color: #fff; }
.audio-message-top-row { display: flex; width: 100%; min-width: 0; align-items: center; gap: 8px; }
.message-audio-player .audio-play-button {
  display: flex;
  width: 28px;
  min-width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: #4f46e5;
  font-size: 12px;
}
.message-audio-player .audio-waveform { display: flex; min-width: 0; flex: 1 1 auto; align-items: center; justify-content: space-between; gap: 4px; overflow: hidden; }
.message-audio-player .audio-waveform i { width: 3px; min-width: 2px; max-height: 24px; border-radius: 99px; background: currentColor; opacity: .76; transition: opacity 120ms ease; }
.message-audio-player .audio-waveform i.played { opacity: 1; }
.message-audio-player .audio-duration-badge { flex: 0 0 auto; padding: 2px 8px; border-radius: 999px; background: rgb(255 255 255 / 20%); color: #fff; font-size: 11px; font-weight: 500; line-height: 1.4; opacity: 1; white-space: nowrap; }
.message-audio-player .audio-transcription-button { align-self: flex-start; min-height: 0; padding: 2px 0 0; border: 0; background: transparent; color: rgb(255 255 255 / 80%); font-size: 11px; font-weight: 400; line-height: 1.4; text-align: left; }
.message-audio-player .audio-transcription-button:hover { color: #fff; text-decoration: underline; }
.message-audio-player .audio-transcription-unavailable { margin: 2px 0 0; color: rgb(255 255 255 / 84%); font-size: 11px; line-height: 1.4; }
.message-audio-player .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }
.message-audio-player button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Instagram-style post action sheet, using the app's native dialog behavior. */
.post-more-trigger { display: grid; width: 38px; height: 38px; flex: 0 0 38px; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--text-secondary); cursor: pointer; transition: background-color .2s ease, color .2s ease; }
.post-more-trigger:hover { background: var(--hover); color: var(--text); }
.post-more-trigger .icon { width: 20px; height: 20px; }
.post-options-dialog { width: min(400px, calc(100vw - 32px)); max-width: 400px; max-height: min(90vh, 720px); overflow: visible; padding: 0; border: 0; border-radius: 16px; background: transparent; color: #fff; box-shadow: none; }
.post-options-dialog::backdrop { background: rgb(0 0 0 / 65%); backdrop-filter: blur(4px); }
.post-options-menu { display: flex; max-height: min(90vh, 720px); flex-direction: column; overflow: auto; border-radius: 16px; background: #262626; color: #fff; box-shadow: 0 24px 64px rgb(0 0 0 / 42%); animation: post-options-enter 160ms ease-out both; }
.post-options-item { width: 100%; min-height: 49px; flex: 0 0 auto; border: 0; border-bottom: 1px solid rgb(82 82 91 / 60%); background: transparent; color: #fff; padding: 12px 16px; font: inherit; font-size: 14px; font-weight: 400; text-align: center; cursor: pointer; transition: background-color .2s ease, color .2s ease; }
.post-options-item:hover:not(:disabled), .post-options-item:focus-visible { background: rgb(63 63 70 / 40%); }
.post-options-item.danger { color: #ef4444; font-weight: 700; }
.post-options-item:disabled { color: #a1a1aa; cursor: not-allowed; opacity: .72; }
.post-options-item.cancel { border-bottom: 0; color: #cbd5e1; }
.post-options-item:focus-visible { outline: 2px solid #a5b4fc; outline-offset: -3px; }
.post-options-toast { position: fixed; z-index: 100; right: 50%; bottom: max(24px, env(safe-area-inset-bottom)); max-width: min(360px, calc(100vw - 32px)); transform: translate(50%, 12px); border: 1px solid rgb(255 255 255 / 12%); border-radius: 999px; background: rgb(38 38 38 / 96%); color: #fff; padding: 10px 16px; box-shadow: 0 8px 28px rgb(0 0 0 / 32%); font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
.post-options-toast.visible { transform: translate(50%, 0); opacity: 1; }
@keyframes post-options-enter { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .post-options-menu { animation: none; } .post-options-toast { transition: none; } }

/* Keep feed videos fully visible at their native aspect ratio. */
#home-section .post-media-frame.home-feed-video {
  display: flex;
  width: min(100%, 470px);
  max-width: 470px;
  max-height: 80vh;
  aspect-ratio: 4 / 5 !important;
  align-items: center;
  justify-content: center;
  margin-inline: auto;
  border-radius: 8px;
  background: #000;
}
#home-section .post-media-frame.home-feed-video.video-metadata-ready { aspect-ratio: auto !important; }
#home-section .post-media-frame.home-feed-video > video.post-media {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: 80vh;
  aspect-ratio: auto !important;
  margin-inline: auto;
  border-radius: 8px;
  background: #000;
  object-fit: contain;
}

/* Explore uses square media tiles. */
#explore-grid {
  display: grid;
  width: min(100%, 896px);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin: 0 auto;
  padding: 16px 0;
}
#explore-grid .explore-tile {
  position: relative;
  display: grid;
  min-width: 0;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border: 0;
  border-radius: 2px;
  background: var(--surface-secondary);
  cursor: pointer;
  transition: opacity .2s ease;
}
#explore-grid .explore-tile:hover { opacity: .9; }
#explore-grid .explore-tile > img,
#explore-grid .explore-tile > video { width: 100%; height: 100%; object-fit: cover; }
#explore-grid .video-tile-indicator { top: 8px; right: 8px; }

@media (max-width: 768px) {
  #home-section .post-media-frame.home-feed-video,
  #home-section .post-media-frame.home-feed-video > video.post-media { max-height: 80vh; }
  #explore-grid { gap: 2px; padding-block: 12px; }
}

@media (max-width: 768px) {
  #videos-section {
    height: calc(100dvh - 126px - env(safe-area-inset-bottom));
    min-height: 0;
    overflow: hidden;
  }
  #videos-section > .content {
    display: flex;
    height: 100%;
    flex-direction: column;
    padding: 12px 0 0;
  }
  #videos-section .page-heading { flex: 0 0 auto; margin: 0 12px 10px; }
  #videos-section #videos-status { flex: 0 0 auto; margin: 0 12px; }
  #videos-section .video-feed { height: auto; min-height: 0; flex: 1 1 auto; }
}

/* Stable Feed video frame; source loading remains governed by Data Usage mode. */
#home-section .post-media-frame.home-feed-video {
  width: min(100%, 470px);
  max-width: 470px;
  max-height: 75vh;
  aspect-ratio: 4 / 5 !important;
  margin-inline: auto;
  overflow: hidden;
  border-radius: 12px;
  background: #000;
}
#home-section .post-media-frame.home-feed-video.video-metadata-ready { aspect-ratio: 4 / 5 !important; }
#home-section .post-media-frame.home-feed-video > video.post-media {
  width: 100%;
  height: 100%;
  max-height: 75vh;
  border-radius: inherit;
  object-fit: cover;
  background: #000;
}

@media (min-width: 769px) {
  #videos-section > .content {
    display: flex;
    width: 100%;
    height: 100%;
    max-width: none;
    flex-direction: column;
    padding: 12px 24px;
  }
  #videos-section .page-heading,
  #videos-section #videos-status:empty { display: none; }
  #videos-section .video-feed {
    display: flex;
    width: 100%;
    height: 100%;
    max-height: none;
    flex: 1 1 auto;
    justify-content: center;
    padding: 0;
  }
  #videos-section .video-reel {
    display: block;
    width: min(100%, 470px);
    height: 100%;
    margin-inline: auto;
    scroll-snap-align: center;
  }
  #videos-section .video-reel .post-media-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(100%, calc((100dvh - 48px) * 9 / 16), calc(100vw - var(--sidebar-width, 76px) - 240px));
    height: auto;
    max-height: calc(100dvh - 32px);
    aspect-ratio: 9 / 16;
    margin: 0;
    overflow: visible;
    border-radius: 8px;
    transform: translate(-50%, -50%);
  }
  #videos-section .video-reel .post-media-frame > video.post-media {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    object-fit: contain;
  }
  #videos-section .video-reel .post-media-frame::before,
  #videos-section .video-reel .post-media-frame::after { border-radius: 8px; }
  #videos-section .video-reel .post-media-frame > .reel-info {
    right: 54px;
    bottom: 14px;
    left: 14px;
    gap: 6px;
    text-shadow: 0 1px 4px rgb(0 0 0 / 78%);
  }
  #videos-section .video-reel .reel-author-profile {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 10px;
  }
  #videos-section .video-reel .reel-author-avatar {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
  }
  #videos-section .video-reel .reel-identity strong { font-size: 14px; }
  #videos-section .video-reel .reel-info .post-caption {
    max-width: 100%;
    font-size: 13px;
    line-height: 1.35;
  }
  #videos-section .video-reel .reel-actions {
    top: 50%;
    gap: 18px;
  }
  #videos-section .video-reel .reel-actions button {
    min-height: 48px;
    gap: 3px;
    color: #fff;
    text-shadow: 0 1px 4px rgb(0 0 0 / 80%);
  }
  #videos-section .video-reel .reel-actions .icon {
    width: 26px;
    height: 26px;
  }
  #videos-section .video-reel .reel-sound-toggle {
    bottom: 16px;
    background: rgb(0 0 0 / 42%);
  }
  #videos-section .video-reel .reel-actions {
    position: absolute;
    top: 50%;
    right: -72px;
    display: flex;
    width: 52px;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 0;
    transform: translateY(-50%);
  }
  #videos-section .video-reel .reel-actions button {
    min-width: 48px;
    min-height: 48px;
    border-radius: 50%;
    background: transparent;
  }
  #videos-section .video-reel .reel-actions button:hover { background: rgb(255 255 255 / 10%); }
  #videos-section .video-reel .post-media-frame > .reel-actions {
    right: -68px;
  }
  #videos-section .video-reel .reel-sound-toggle {
    position: absolute;
    right: -68px;
    bottom: 14px;
    z-index: 5;
  }
  #videos-section .video-reel-navigation {
    position: fixed;
    top: 50%;
    right: max(24px, 3vw);
    display: grid;
    width: 44px;
    gap: 14px;
    transform: translateY(-50%);
  }
  #videos-section .video-reel-navigation button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #1c1c1e;
  }
  #videos-section .video-reel-navigation button:disabled { visibility: visible; opacity: .4; }
}

@media (max-width: 1180px) and (min-width: 769px) {
  #videos-section .video-reel .post-media-frame {
    width: min(100%, calc((100dvh - 80px) * 9 / 16), calc(100vw - var(--sidebar-width, 76px) - 200px));
  }
  #videos-section .video-reel .post-media-frame > .reel-actions { right: -60px; gap: 12px; }
  #videos-section .video-reel .reel-sound-toggle { right: -60px; }
  #videos-section .video-reel-navigation { right: 16px; }
}

@media (min-width: 769px) and (max-height: 620px) {
  #videos-section > .content { padding-block: 4px; }
  #videos-section .video-reel .post-media-frame { width: min(100%, calc((100dvh - 16px) * 9 / 16)); max-height: calc(100dvh - 12px); }
}

/* Instagram-style Reel frame and in-frame creator/action overlays. */
#videos-section .video-feed { justify-content: center; }
#videos-section .video-reel {
  display: flex;
  width: min(100%, 400px);
  height: 82dvh;
  flex: 0 0 82dvh;
  align-items: center;
  justify-content: center;
  margin-inline: auto;
  overflow: visible;
  scroll-snap-align: center;
}
#videos-section .video-reel .post-media-frame {
  position: relative;
  inset: auto;
  width: min(100%, 400px, calc(82dvh * 9 / 16));
  height: auto;
  max-height: 82dvh;
  aspect-ratio: 9 / 16;
  margin: 0 auto;
  overflow: hidden;
  border: 0;
  border-radius: 12px;
  background: #000;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 45%);
  transform: none;
}
#videos-section .video-reel .post-media-frame > video.post-media {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}
#videos-section .video-reel .reel-info {
  position: absolute;
  z-index: 20;
  right: 72px;
  bottom: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 0;
  background: none;
  color: #fff;
}
#videos-section .video-reel .reel-author { width: 100%; gap: 8px; }
#videos-section .video-reel .reel-author-profile { gap: 8px; pointer-events: auto; }
#videos-section .video-reel .reel-author-avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border: 1px solid rgb(255 255 255 / 20%);
  border-radius: 50%;
  object-fit: cover;
}
#videos-section .video-reel .reel-identity strong {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .025em;
  text-shadow: 0 1px 3px rgb(0 0 0 / 80%);
}
#videos-section .video-reel .reel-follow {
  min-height: 0;
  margin-left: 8px;
  border: 1px solid rgb(255 255 255 / 40%);
  border-radius: 8px;
  background: transparent;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  transition: background-color .2s ease;
}
#videos-section .video-reel .reel-follow:hover { background: rgb(255 255 255 / 20%); }
#videos-section .video-reel .reel-info .post-caption {
  display: -webkit-box;
  max-width: 280px;
  margin: 0;
  overflow: hidden;
  color: #e4e4e7;
  font-size: 12px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  text-shadow: 0 1px 3px rgb(0 0 0 / 80%);
}
#videos-section .video-reel .reel-info .post-caption.is-expanded { display: block; max-height: 30vh; overflow: auto; }
#videos-section .video-reel .reel-actions {
  position: absolute;
  z-index: 20;
  top: auto;
  right: 16px;
  bottom: 16px;
  display: flex;
  width: 44px;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 0;
  transform: none;
}
#videos-section .video-reel .reel-actions button {
  display: grid;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  place-items: center;
  gap: 3px;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 28%);
  color: #fff;
  padding: 2px;
  font-size: 11px;
  text-shadow: 0 1px 3px rgb(0 0 0 / 80%);
}
#videos-section .video-reel .reel-actions button:hover { background: rgb(255 255 255 / 20%); }
#videos-section .video-reel .reel-actions .icon { width: 24px; height: 24px; }
#videos-section .video-reel .reel-actions .reel-sound-toggle {
  position: static;
  width: 44px;
  height: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 35%);
  padding: 8px;
}
#videos-section .video-reel .post-media-frame.is-loading .reel-info,
#videos-section .video-reel .post-media-frame.is-loading .reel-actions { visibility: visible; opacity: 1; }
@media (max-width: 768px) {
  #videos-section .video-reel { width: min(100%, 400px); }
  #videos-section .video-reel .post-media-frame { width: min(100%, calc((100dvh - 32px) * 9 / 16)); max-height: calc(100dvh - 32px); }
  #videos-section .video-reel .reel-info { right: 64px; bottom: 16px; left: 12px; }
  #videos-section .video-reel .reel-actions { right: 12px; bottom: 16px; gap: 14px; }
  #videos-section .video-reel-navigation { display: none; }
}

/* Reels: one fixed portrait viewport owns the video and every interaction overlay. */
#videos-section .video-reel {
  display: flex;
  width: min(100%, 380px);
  min-height: 580px;
  height: 80vh;
  height: 80dvh;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  overflow: visible;
  border: 0;
  background: transparent;
  padding: 0;
  box-shadow: none;
  scroll-snap-align: center;
}
#videos-section .video-reel .reel-viewport {
  position: relative;
  inset: auto;
  width: 100%;
  max-width: 380px;
  height: 80vh;
  height: 80dvh;
  min-height: 580px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgb(63 63 70 / 80%);
  border-radius: 12px;
  background: #000;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 45%);
  transform: none;
}
#videos-section .video-reel .reel-viewport > .reel-video {
  display: block;
  width: 100%;
  height: 100%;
  max-height: none;
  border-radius: inherit;
  object-fit: cover;
}
#videos-section .video-reel .reel-viewport > .reel-info {
  position: absolute;
  z-index: 20;
  right: 76px;
  bottom: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  max-width: 75%;
  padding: 0;
  background: none;
  color: #fff;
  pointer-events: none;
}
#videos-section .video-reel .reel-author { width: 100%; gap: 8px; }
#videos-section .video-reel .reel-author-profile { gap: 8px; }
#videos-section .video-reel .reel-author-avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border: 1px solid rgb(255 255 255 / 20%);
  border-radius: 50%;
  object-fit: cover;
}
#videos-section .video-reel .reel-identity strong {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .025em;
  text-shadow: 0 1px 3px rgb(0 0 0 / 80%);
}
#videos-section .video-reel .reel-follow {
  min-height: 0;
  margin-left: 4px;
  border: 1px solid rgb(255 255 255 / 40%);
  border-radius: 6px;
  background: rgb(0 0 0 / 40%);
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(8px);
  pointer-events: auto;
}
#videos-section .video-reel .reel-info .post-caption {
  display: -webkit-box;
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  color: #f4f4f5;
  font-size: 12px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  text-shadow: 0 1px 3px rgb(0 0 0 / 80%);
  pointer-events: auto;
}
#videos-section .video-reel .reel-info .caption-toggle { pointer-events: auto; }
#videos-section .video-reel .reel-viewport > .reel-actions {
  position: absolute;
  z-index: 21;
  top: auto;
  right: 12px;
  bottom: 16px;
  display: flex;
  width: 48px;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 0;
  transform: none;
}
#videos-section .video-reel .reel-actions button {
  display: grid;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  place-items: center;
  gap: 3px;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 40%);
  color: #fff;
  padding: 2px;
  font-size: 11px;
  text-shadow: 0 1px 3px rgb(0 0 0 / 80%);
}
#videos-section .video-reel .reel-actions button:hover { background: rgb(255 255 255 / 18%); }
#videos-section .video-reel .reel-actions .icon { width: 23px; height: 23px; }
#videos-section .video-reel .reel-actions .reel-sound-toggle {
  position: static;
  width: 44px;
  height: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 40%);
  padding: 8px;
}
@media (max-width: 420px) {
  #videos-section .video-reel { width: 100%; min-height: 0; height: 80dvh; }
  #videos-section .video-reel .reel-viewport { min-height: 0; border-radius: 10px; }
  #videos-section .video-reel .reel-viewport > .reel-info { right: 68px; bottom: 16px; left: 12px; }
  #videos-section .video-reel .reel-viewport > .reel-actions { right: 8px; bottom: 16px; gap: 10px; }
}

/* Desktop Reels place the action rail alongside the portrait viewport. */
#videos-section .video-reel {
  position: relative;
  display: flex;
  width: max-content;
  max-width: 100%;
  min-width: 0;
  height: 80vh;
  height: 80dvh;
  min-height: 580px;
  max-height: 750px;
  flex: 0 0 auto;
  flex-direction: row;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  margin: 24px auto;
  overflow: visible;
  border: 0;
  background: transparent;
  padding: 0;
  box-shadow: none;
}
#videos-section .video-reel .reel-viewport {
  width: auto;
  height: 100%;
  min-height: 0;
  max-width: min(380px, calc((100dvh - 48px) * 9 / 16));
  aspect-ratio: 9 / 16;
  flex: 0 1 auto;
  margin: 0;
}
#videos-section .video-reel > .reel-actions {
  position: static;
  z-index: 1;
  display: flex;
  width: 44px;
  flex: 0 0 44px;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 0 0 8px;
  transform: none;
}
#videos-section .video-reel > .reel-actions button {
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  border: 1px solid #27272a;
  background: rgb(24 24 27 / 88%);
  transition: background-color .18s ease, transform .18s ease;
}
#videos-section .video-reel > .reel-actions button:hover { background: #27272a; }
#videos-section .video-reel > .reel-actions button:active { transform: scale(.9); }
#videos-section .video-reel > .reel-actions > button:not(.reel-sound-toggle) {
  display: flex;
  height: auto;
  flex-direction: column;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}
#videos-section .video-reel > .reel-actions > button:not(.reel-sound-toggle) .icon {
  box-sizing: content-box;
  width: 20px;
  height: 20px;
  border: 1px solid #27272a;
  border-radius: 50%;
  background: rgb(24 24 27 / 88%);
  padding: 9px;
}
#videos-section .video-reel > .reel-actions > button:not(.reel-sound-toggle) { gap: 4px; }
#videos-section .video-reel > .reel-actions > button:not(.reel-sound-toggle):hover .icon { background: #27272a; }
#videos-section .video-reel > .reel-actions .reel-sound-toggle {
  position: static;
  width: 40px;
  height: 40px;
  min-height: 40px;
  border: 1px solid #27272a;
  background: rgb(24 24 27 / 88%);
}
#videos-section .video-reel-navigation { position: absolute; right: -64px; bottom: 50%; width: auto; margin: 0; transform: translateY(50%); }
@media (max-width: 768px) {
  #videos-section .video-reel {
    width: max-content;
    max-width: 100%;
    height: min(80dvh, 750px);
    min-height: 0;
    gap: 8px;
    margin-block: 8px;
  }
  #videos-section .video-reel .reel-viewport {
    width: auto;
    max-width: min(calc(100vw - 64px), calc((80dvh - 16px) * 9 / 16));
    height: 100%;
    min-height: 0;
  }
  #videos-section .video-reel > .reel-actions { width: 40px; flex-basis: 40px; gap: 10px; }
  #videos-section .video-reel > .reel-actions button { width: 36px; min-width: 36px; min-height: 36px; }
  #videos-section .video-reel > .reel-actions > button:not(.reel-sound-toggle) .icon { padding: 7px; }
  #videos-section .video-reel > .reel-actions .reel-sound-toggle { width: 36px; height: 36px; min-height: 36px; }
}
@media (max-height: 620px) {
  #videos-section .video-reel { min-height: 0; height: 80dvh; }
}

/* Stable Reel sizing: the media and its action rail share one snap-aligned item. */
#videos-section .video-feed {
  align-items: center;
  scroll-snap-type: y mandatory;
  scroll-padding-block: 12px;
}
#videos-section .video-reel {
  display: flex;
  width: max-content;
  height: clamp(550px, 78vh, 720px);
  height: clamp(550px, 78dvh, 720px);
  min-height: 0;
  max-height: 720px;
  align-items: flex-end;
  gap: 12px;
  margin: 0 auto;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}
#videos-section .video-reel .reel-viewport {
  position: relative;
  width: auto;
  height: 100%;
  min-height: 0;
  max-width: min(380px, calc((100dvh - 48px) * 9 / 16), calc(100vw - var(--sidebar-width, 76px) - 100px));
  aspect-ratio: 9 / 16;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid #27272a;
  border-radius: 16px;
  background: #09090b;
  isolation: isolate;
}
#videos-section .video-reel .reel-viewport > video.reel-video {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
  background: #09090b;
}
#videos-section .video-reel .reel-empty-source {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-items: center;
  color: #a1a1aa;
  font-size: 12px;
}
#videos-section .video-reel .reel-viewport > .reel-info { z-index: 2; }
#videos-section .video-reel > .reel-actions {
  height: 100%;
  align-self: stretch;
  justify-content: flex-end;
  gap: 14px;
  padding-bottom: 8px;
}
#videos-section .video-reel-navigation { right: -58px; bottom: 50%; }
@media (max-width: 768px) {
  #videos-section .video-reel {
    width: max-content;
    height: min(78dvh, 720px);
    min-height: 0;
    max-width: 100%;
    gap: 8px;
  }
  #videos-section .video-reel .reel-viewport {
    width: auto;
    max-width: min(380px, calc((78dvh) * 9 / 16), calc(100vw - 64px));
    height: 100%;
  }
  #videos-section .video-reel > .reel-actions { width: 40px; flex-basis: 40px; gap: 10px; }
}

/* Final Reel item contract: explicit 9:16 media, one shared snap item and rail. */
#videos-section .video-feed {
  align-items: center;
  scroll-snap-type: y mandatory;
  scroll-snap-stop: always;
}
#videos-section .video-reel {
  display: flex;
  width: 100%;
  height: clamp(580px, calc(100vh - 40px), 750px);
  height: clamp(580px, calc(100dvh - 40px), 750px);
  min-height: 580px;
  max-height: 750px;
  flex: 0 0 auto;
  flex-direction: row;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  margin-block: auto;
  padding-block: 8px;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}
#videos-section .video-reel .reel-viewport {
  position: relative;
  inset: auto;
  width: auto !important;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: none;
  max-height: none;
  aspect-ratio: 9 / 16 !important;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid rgb(63 63 70 / 80%);
  border-radius: 16px;
  background: #09090b;
  isolation: isolate;
}
#videos-section .video-reel .reel-viewport::after {
  position: absolute;
  z-index: 1;
  inset: 0;
  background: linear-gradient(180deg, rgb(0 0 0 / 20%), transparent 38%, rgb(0 0 0 / 80%));
  content: "";
  pointer-events: none;
}
#videos-section .video-reel .reel-viewport > video.reel-video {
  position: absolute !important;
  z-index: 0;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none;
  max-height: none;
  object-fit: cover;
  background: #09090b;
}
#videos-section .video-reel .reel-viewport > .reel-info { z-index: 2; }
#videos-section .video-reel > .reel-actions {
  position: static;
  height: 100%;
  flex: 0 0 44px;
  align-self: stretch;
  justify-content: flex-end;
  gap: 14px;
  padding: 0 0 8px;
}
@media (max-width: 768px) {
  #videos-section .video-reel {
    width: 100%;
    height: min(78dvh, 720px);
    min-height: 0;
    padding-block: 0;
    gap: 8px;
    margin-block: auto;
  }
  #videos-section .video-reel .reel-viewport {
    height: 100%;
    max-height: 100%;
  }
  #videos-section .video-reel > .reel-actions {
    width: 40px;
    flex: 0 0 40px;
    gap: 10px;
  }
}
/* Desktop Reel item: 1:1 Instagram Standard Layout */
#videos-section .video-feed {
  display: flex !important;
  width: 100% !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-height: none !important;
  overflow-y: auto !important;
  scroll-snap-type: y mandatory !important;
  flex-direction: column !important;
  align-items: center !important;
  background: #000 !important;
  padding: 24px 0 !important;
  margin: 0 !important;
}
#videos-section .video-reel.reel-layout {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-end !important;
  justify-content: center !important;
  gap: 16px !important;
  width: 100% !important;
  height: 85vh !important;
  height: 85dvh !important;
  min-height: 600px !important;
  max-height: 780px !important;
  margin: auto auto !important;
  padding: 8px 0 !important;
  overflow: visible !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  scroll-snap-align: center !important;
  flex-shrink: 0 !important;
}
#videos-section .video-reel.reel-layout > .reel-portrait-frame {
  position: relative !important;
  inset: auto !important;
  height: 100% !important;
  width: 400px !important;
  min-width: 400px !important;
  max-width: 400px !important;
  aspect-ratio: 9 / 16 !important;
  background: #09090b !important;
  border-radius: 16px !important;
  overflow: hidden !important;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 50%) !important;
  border: 1px solid #27272a !important;
  flex-shrink: 0 !important;
  margin: 0 !important;
}
#videos-section .video-reel.reel-layout > .reel-portrait-frame > video.reel-video-element {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 100% !important;
  min-height: 100% !important;
  object-fit: contain !important;
  z-index: 0 !important;
  background: #000 !important;
}
#videos-section .video-reel.reel-layout > .reel-portrait-frame::after {
  content: "" !important;
  position: absolute !important;
  inset: 0 !important;
  background: linear-gradient(180deg, rgb(0 0 0 / 20%) 0%, transparent 40%, rgb(0 0 0 / 80%) 100%) !important;
  pointer-events: none !important;
  z-index: 10 !important;
}
#videos-section .video-reel.reel-layout > .reel-portrait-frame > .reel-info {
  position: absolute !important;
  bottom: 16px !important;
  left: 16px !important;
  right: 16px !important;
  z-index: 20 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 8px !important;
  color: #fff !important;
  pointer-events: none !important;
  max-width: calc(100% - 32px) !important;
}
#videos-section .video-reel.reel-layout .reel-author {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  pointer-events: auto !important;
}
#videos-section .video-reel.reel-layout .reel-author-profile {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  color: #fff !important;
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
  cursor: pointer !important;
}
#videos-section .video-reel.reel-layout .reel-author-avatar {
  width: 32px !important;
  height: 32px !important;
  flex: 0 0 32px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  border: 1px solid rgb(255 255 255 / 20%) !important;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 30%) !important;
}
#videos-section .video-reel.reel-layout .reel-identity strong {
  font-size: 14px !important;
  font-weight: 600 !important;
  letter-spacing: .025em !important;
  text-shadow: 0 1px 3px rgb(0 0 0 / 80%) !important;
}
#videos-section .video-reel.reel-layout .reel-follow {
  pointer-events: auto !important;
  margin-left: 8px !important;
  padding: 4px 12px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  border-radius: 8px !important;
  border: 1px solid rgb(255 255 255 / 40%) !important;
  background: rgb(0 0 0 / 40%) !important;
  backdrop-filter: blur(8px) !important;
  color: #fff !important;
  transition: all .2s ease !important;
}
#videos-section .video-reel.reel-layout .reel-follow:hover {
  background: rgb(255 255 255 / 20%) !important;
}
#videos-section .video-reel.reel-layout .post-caption {
  font-size: 12px !important;
  color: #f4f4f5 !important;
  max-width: 280px !important;
  display: -webkit-box !important;
  -webkit-box-orient: vertical !important;
  -webkit-line-clamp: 2 !important;
  overflow: hidden !important;
  line-height: 1.5 !important;
  text-shadow: 0 1px 3px rgb(0 0 0 / 80%) !important;
  pointer-events: auto !important;
}
#videos-section .video-reel.reel-layout > .reel-actions {
  display: flex !important;
  position: static !important;
  z-index: 20 !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 16px !important;
  padding-bottom: 8px !important;
  color: #fff !important;
  flex-shrink: 0 !important;
  width: 44px !important;
}
#videos-section .video-reel.reel-layout > .reel-actions button {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  gap: 4px !important;
  border: 0 !important;
  background: transparent !important;
  color: #a1a1aa !important;
  padding: 0 !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  width: auto !important;
  height: auto !important;
}
#videos-section .video-reel.reel-layout > .reel-actions button .icon,
#videos-section .video-reel.reel-layout > .reel-actions .reel-sound-toggle .icon {
  width: 20px !important;
  height: 20px !important;
}
#videos-section .video-reel.reel-layout > .reel-actions button:not(.reel-sound-toggle) > svg:first-child,
#videos-section .video-reel.reel-layout > .reel-actions .reel-sound-toggle {
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  min-height: 40px !important;
  border-radius: 50% !important;
  background: rgb(24 24 27 / 90%) !important;
  border: 1px solid #27272a !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: #fff !important;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 20%) !important;
  transition: transform .15s ease, background-color .15s ease !important;
}
#videos-section .video-reel.reel-layout > .reel-actions button:hover:not(.reel-sound-toggle) > svg:first-child,
#videos-section .video-reel.reel-layout > .reel-actions .reel-sound-toggle:hover {
  background: #27272a !important;
}
#videos-section .video-reel.reel-layout > .reel-actions button:active:not(.reel-sound-toggle) > svg:first-child,
#videos-section .video-reel.reel-layout > .reel-actions .reel-sound-toggle:active {
  transform: scale(.9) !important;
}
#videos-section .video-reel.reel-layout .video-reel-navigation {
  display: none !important;
}
@media (max-width: 768px) {
  #videos-section .video-reel.reel-layout {
    width: 100% !important;
    height: 85dvh !important;
    min-height: 520px !important;
    gap: 8px !important;
    padding: 4px 0 !important;
  }
  #videos-section .video-reel.reel-layout > .reel-portrait-frame {
    width: min(calc(100vw - 64px), 400px) !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  #videos-section .video-reel.reel-layout > .reel-actions {
    width: 40px !important;
    flex-basis: 40px !important;
    gap: 12px !important;
  }
}

/* Direct Messages dark surfaces and compact controls. */
html.dark #messages-section {
  --bg: #000;
  --surface: #111;
  --surface-secondary: #1a1a1a;
  --surface-tertiary: #202020;
  --text: #f5f5f5;
  --text-secondary: #a1a1aa;
  --border: #262626;
  --hover: #202020;
  --accent: #818cf8;
  --surface-elevated: #1a1a1a;
  --border-subtle: #202020;
  --border-strong: #3f3f46;
  --bubble-incoming-bg: #262626;
  --bubble-incoming-text: #f4f4f5;
  --bubble-outgoing-bg: #4f46e5;
  --bubble-outgoing-text: #ffffff;
  --focus-ring: 0 0 0 3px rgb(129 140 248 / 22%);
  background: var(--bg);
}
html.dark #messages-section.participant-tone-0,
html.dark #messages-section.participant-tone-1,
html.dark #messages-section.participant-tone-2,
html.dark #messages-section.participant-tone-3,
html.dark #messages-section.participant-tone-4,
html.dark #messages-section.participant-tone-5 {
  --participant-bubble: #1a1a1a;
  --participant-text: #f5f5f5;
}
html.dark #messages-section .conversation > header,
html.dark #messages-section .people-pane,
html.dark #messages-section .conversation-list-section,
html.dark #messages-section .people-list-section { background: #111; }
html.dark #messages-section .chat-panel,
html.dark #messages-section .chat-box { background: #000; }
#messages-section .message-reply-reference,
#messages-section .message-row.own .message-reply-reference {
  display: -webkit-box;
  max-width: min(100%, 320px);
  max-height: 3.25em;
  margin: 0 0 4px;
  overflow: hidden;
  border: 0;
  border-left: 2px solid #818cf8;
  border-radius: 0 7px 7px 0;
  background: rgb(63 63 70 / 45%);
  color: #e4e4e7;
  padding: 5px 9px;
  font-size: 12px;
  line-height: 1.4;
  text-align: left;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  white-space: normal;
}
#messages-section .message-reply-reference:disabled { cursor: default; opacity: .72; }
#messages-section .message-composer-bar {
  gap: 6px;
  border-color: var(--border);
  background: var(--surface-secondary);
  transition: border-color .16s ease, box-shadow .16s ease;
}
#messages-section .message-composer-bar:focus-within {
  border-color: color-mix(in srgb, var(--accent) 72%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
#messages-section .message-composer-controls > .icon-button {
  transition: color .15s ease, background-color .15s ease, transform .15s ease;
}
#messages-section .message-composer-controls > .icon-button:hover:not(:disabled) {
  background: var(--hover);
  color: var(--accent);
}
#messages-section .message-composer-controls > .icon-button:active:not(:disabled) { transform: scale(.94); }
#messages-section .message-composer-controls > .icon-button:focus-visible,
#messages-section .audio-speed-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
#messages-section .composer-quick-like { color: #f87171; }
#messages-section .composer-quick-like:hover:not(:disabled) { color: #fb7185; }
#messages-section .composer-quick-like:disabled { opacity: .4; cursor: not-allowed; }
#messages-section .message-composer-controls #message-quick-like { width: 40px; min-height: 40px; flex-basis: 40px; }
html.dark #messages-section .conversation > header .presence-dot {
  border-color: #111;
  background: #22c55e;
  box-shadow: 0 0 0 1px rgb(34 197 94 / 55%);
}
#messages-section .message-audio-player .audio-duration-badge { font-variant-numeric: tabular-nums; }
#messages-section .audio-speed-button {
  min-width: 40px;
  min-height: 32px;
  flex: 0 0 auto;
  border: 1px solid rgb(255 255 255 / 24%);
  border-radius: 999px;
  background: rgb(0 0 0 / 16%);
  color: inherit;
  padding: 3px 7px;
  font: inherit;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
#messages-section .audio-speed-button:hover { background: rgb(0 0 0 / 28%); }
@media (max-width: 520px) {
  #messages-section .audio-speed-button { min-width: 36px; min-height: 36px; padding-inline: 5px; }
  #messages-section .message-reply-reference { max-width: min(100%, 72vw); }
}

/* DM refinements: private Video Notes remain neutral until the authorized open action. */
#messages-section .message-video-note-player { width: min(100%, 340px); max-width: min(100%, 68vw); }
#messages-section .video-note-play-button {
  display: grid;
  width: 100%;
  min-width: 0;
  min-height: 82px;
  grid-template-columns: 76px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  overflow: hidden;
  border: 1px solid #303036;
  border-radius: 16px;
  background: linear-gradient(135deg, #18181b, #09090b 76%);
  color: #fafafa;
  padding: 8px;
  text-align: left;
  transition: border-color .16s ease, background-color .16s ease, transform .16s ease;
}
#messages-section .video-note-preview-art {
  position: relative;
  display: grid;
  width: 76px;
  height: 62px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 11px;
  background: radial-gradient(ellipse at 20% 0%, rgb(129 140 248 / 28%), transparent 62%), linear-gradient(145deg, #27272a, #09090b 76%);
  color: #a5b4fc;
}
#messages-section .video-note-preview-art > .icon { width: 27px; height: 27px; opacity: .78; }
#messages-section .video-note-preview-play {
  position: absolute;
  right: 5px;
  bottom: 5px;
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 24%);
  border-radius: 50%;
  background: rgb(9 9 11 / 82%);
  color: #fff;
}
#messages-section .video-note-preview-play .icon { width: 12px; height: 12px; }
#messages-section .video-note-preview-copy { display: grid; min-width: 0; gap: 4px; }
#messages-section .video-note-play-label { overflow: hidden; color: #fafafa; font-size: 13px; font-weight: 600; line-height: 1.3; text-overflow: ellipsis; }
#messages-section .video-note-preview-meta { overflow: hidden; color: #a1a1aa; font-size: 11px; font-weight: 400; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
#messages-section .video-note-play-button:hover:not(:disabled) { border-color: #52525b; background-color: #18181b; }
#messages-section .video-note-play-button:active:not(:disabled) { transform: scale(.99); }
#messages-section .video-note-play-button:focus-visible { outline: 2px solid #818cf8; outline-offset: 3px; }
#messages-section .video-note-play-button:disabled { cursor: not-allowed; opacity: .72; }
#messages-section .note-bubble {
  top: -34px;
  width: max-content;
  max-width: 104px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface-elevated);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.25;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}
#messages-section .note-bubble::after { border-top-color: var(--surface-elevated); }
#messages-section .notes-list {
  align-items: flex-start;
  gap: 12px;
  padding: 20px 6px 8px;
}
#messages-section .note-item { width: 78px; flex-basis: 78px; }
#messages-section .note-main { gap: 7px; border-radius: 14px; }
#messages-section .note-avatar-wrap .avatar {
  width: 58px;
  height: 58px;
  border: 2px solid var(--bg);
  outline: 1px solid var(--border-strong);
  outline-offset: 2px;
  transition: outline-color 160ms ease, transform 160ms ease;
}
#messages-section .note-item.unread .note-avatar-wrap .avatar {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
#messages-section .note-main:hover .note-avatar-wrap .avatar { transform: translateY(-1px); }
#messages-section .note-main:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
#messages-section .note-identity { max-width: 78px; color: var(--text-secondary); }
@media (max-width: 520px) {
  #messages-section .notes-list { gap: 8px; padding: 19px 4px 7px; }
  #messages-section .note-item { width: 68px; flex-basis: 68px; }
  #messages-section .note-avatar-wrap .avatar { width: 52px; height: 52px; }
  #messages-section .note-bubble { top: -31px; max-width: 88px; padding: 5px 8px; }
}
#messages-section .conversation-list .list-item.active,
#messages-section .conversation-list .list-item[aria-current="true"] {
  border-left: 2px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
  box-shadow: none;
}
#messages-section .conversation-list .list-item.active .item-main strong,
#messages-section .conversation-list .list-item[aria-current="true"] .item-main strong {
  color: var(--text);
  font-weight: 600;
}
#messages-section .message-composer-bar:focus-within {
  border-color: #3f3f46;
  box-shadow: none;
}
#messages-section .message-composer-controls textarea { min-width: 0; }
@media (max-width: 520px) {
  #messages-section .video-note-play-button { max-width: 100%; grid-template-columns: 64px minmax(0, 1fr); gap: 9px; }
  #messages-section .video-note-preview-art { width: 64px; height: 54px; }
  #messages-section .message-composer-bar { gap: 3px; padding-inline: 7px; }
  #messages-section .message-composer-controls { gap: 1px; }
}

/* Notes-to-DM context and a non-blocking contact panel. */
#messages-section .message-compose-context small {
  overflow: hidden;
  color: #a1a1aa;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#messages-section .conversation { position: relative; }
#messages-section .conversation.contact-info-open { --contact-info-width: min(360px, max(260px, 42%)); }
#contact-info-backdrop { display: none; }
#contact-info-drawer {
  position: absolute;
  z-index: 5;
  top: 68px;
  right: 0;
  bottom: 0;
  display: flex;
  width: var(--contact-info-width, min(360px, 42%));
  min-width: 0;
  flex-direction: column;
  overflow: auto;
  border-left: 1px solid #27272a;
  background: #111;
  color: #fafafa;
  box-shadow: -16px 0 38px rgb(0 0 0 / 22%);
  opacity: 0;
  pointer-events: none;
  transform: translateX(18px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
  visibility: hidden;
}
#contact-info-drawer[hidden] { display: none; }
#contact-info-drawer.open { opacity: 1; pointer-events: auto; transform: translateX(0); visibility: visible; }
#messages-section .conversation.contact-info-open #chat-box,
#messages-section .conversation.contact-info-open #message-status,
#messages-section .conversation.contact-info-open #composer-form { margin-right: var(--contact-info-width); }
.contact-info-drawer-header { display: flex; min-height: 58px; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #27272a; padding: 10px 14px; }
.contact-info-drawer-header h2 { margin: 0; font-size: 15px; }
.contact-info-content { display: grid; align-content: start; gap: 22px; min-height: 0; padding: 20px 16px; }
.contact-info-identity { display: grid; justify-items: center; gap: 7px; text-align: center; }
.contact-info-avatar { width: 72px; height: 72px; }
.contact-info-identity h3 { margin: 4px 0 0; font-size: 17px; }
.contact-info-username, .contact-info-bio { margin: 0; color: #a1a1aa; font-size: 13px; overflow-wrap: anywhere; }
.contact-info-bio { max-width: 100%; color: #d4d4d8; white-space: pre-wrap; }
.contact-info-profile-action { min-height: 36px; padding-inline: 14px; }
.contact-info-media { display: grid; gap: 10px; }
.contact-info-media h3 { margin: 0; color: #d4d4d8; font-size: 13px; font-weight: 600; }
.contact-info-media .state { margin: 0; font-size: 12px; }
.contact-info-media-grid { display: grid; max-height: min(40vh, 280px); grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; overflow: auto; }
.contact-info-media-item { aspect-ratio: 1; overflow: hidden; border: 1px solid #27272a; border-radius: 8px; background: #18181b; padding: 0; cursor: pointer; }
.contact-info-media-item img { display: block; width: 100%; height: 100%; object-fit: cover; }
.contact-info-media-item.is-unavailable { display: grid; place-items: center; color: #a1a1aa; padding: 6px; font-size: 10px; }
.contact-info-media-item:focus-visible { outline: 2px solid #818cf8; outline-offset: 2px; }
@media (max-width: 1024px) {
  #contact-info-backdrop:not([hidden]) { position: absolute; z-index: 4; inset: 68px 0 0; display: block; border: 0; background: rgb(0 0 0 / 45%); padding: 0; }
  #contact-info-drawer { z-index: 5; top: 68px; right: 0; bottom: 0; width: min(100%, 390px); min-width: 0; }
  #messages-section .conversation.contact-info-open #chat-box,
  #messages-section .conversation.contact-info-open #message-status,
  #messages-section .conversation.contact-info-open #composer-form { margin-right: 0; }
}
@media (prefers-reduced-motion: reduce) {
  #contact-info-drawer { transition: none; }
}

/* Compact Note reply context, text-only bubbles, and DM presence treatment. */
#messages-section #composer-form.note-reply-active {
  flex-wrap: wrap;
  align-items: stretch;
  row-gap: 0;
}
#messages-section #composer-form.note-reply-active .message-compose-context {
  flex: 0 0 100%;
  width: 100%;
  min-width: 0;
  gap: 12px;
  margin: 0;
  border: 1px solid #27272a;
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  background: #111;
  padding: 8px 12px 7px;
  color: #e4e4e7;
}
#messages-section #composer-form.note-reply-active .message-compose-context > div { display: grid; min-width: 0; gap: 2px; }
#messages-section #composer-form.note-reply-active .message-compose-context strong,
#messages-section #composer-form.note-reply-active .message-compose-context span,
#messages-section #composer-form.note-reply-active .message-compose-context small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#messages-section #composer-form.note-reply-active .message-compose-context strong { color: #fafafa; font-size: 12px; line-height: 1.35; }
#messages-section #composer-form.note-reply-active .message-compose-context span { color: #d4d4d8; font-size: 12px; line-height: 1.35; }
#messages-section #composer-form.note-reply-active .message-compose-context small { color: #a1a1aa; font-size: 10px; line-height: 1.25; }
#messages-section #composer-form.note-reply-active #message-compose-context-cancel { width: 32px; height: 32px; flex: 0 0 32px; color: #a1a1aa; }
#messages-section #composer-form.note-reply-active #message-compose-context-cancel:hover { color: #fafafa; }
#messages-section #composer-form.note-reply-active .message-composer-bar { flex: 0 0 100%; width: 100%; border-top-color: #27272a; border-top-left-radius: 0; border-top-right-radius: 0; }
#messages-section #composer-form.note-reply-active .message-composer-bar:focus-within { border-color: #3f3f46; box-shadow: none; }

#messages-section .message-row .message.message-text-only {
  width: fit-content;
  max-width: min(70vw, 520px);
  border-radius: 18px 18px 18px 5px;
  background: var(--bubble-incoming-bg);
  box-shadow: none;
  color: var(--bubble-incoming-text);
  padding: 8px 12px;
}
#messages-section .message-row.own .message.message-text-only { border-radius: 18px 18px 5px 18px; background: var(--bubble-outgoing-bg); color: var(--bubble-outgoing-text); }
#messages-section .message-row.own .message.message-text-only .message-time { color: rgb(255 255 255 / 76%); }

#messages-section .avatar .presence-dot { width: 12px; height: 12px; border: 2px solid #000; background: #22c55e; }
html.dark #messages-section .conversation > header .presence-dot { border-color: #000; background: #22c55e; box-shadow: none; }

/* Final cross-screen polish: use the shared theme tokens for repeated controls. */
.app .main-nav button,
.app .sidebar-footer > button,
.app .mobile-nav button { transition: background-color var(--motion-fast), color var(--motion-fast), border-color var(--motion-fast); }
.app .main-nav button.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
.app .story:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: var(--radius-md); }
.app .suggested-panel { border-color: var(--border-subtle); box-shadow: var(--shadow); }
.app .notification-row.unread::after { background: var(--brand-primary); }
@media (max-width: 520px) {
  .note-view-dialog { max-height: calc(100dvh - 24px); overflow-y: auto; padding: 20px; }
  .note-view-bubble { min-height: 132px; }
}
@media (max-width: 520px) {
  #messages-section .message-row .message.message-text-only { max-width: min(78vw, 520px); }
}

/* Inbox surfaces and Notes shelf refinement. */
html.dark #messages-section {
  --bg: #000;
  --surface: #090909;
  --surface-secondary: #111;
  --surface-tertiary: #1b1b1b;
  --surface-elevated: #151515;
  --border: #262626;
  --border-subtle: #262626;
  --border-strong: #3f3f46;
  --hover: #171717;
  --bubble-incoming-bg: #202020;
  background: var(--bg);
}
html.dark #messages-section .conversation > header,
html.dark #messages-section .people-pane,
html.dark #messages-section .conversation-list-section,
html.dark #messages-section .people-list-section { background: var(--surface); }
html.dark #messages-section .chat-panel,
html.dark #messages-section .chat-box { background: var(--bg); }

#messages-section .notes-shelf {
  margin: 8px -18px 10px;
  padding: 0 18px 10px;
  border-bottom: 1px solid var(--border-subtle);
}
#messages-section .notes-shelf > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px;
}
#messages-section .notes-shelf h2 {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
}
#messages-section #add-note-button {
  min-height: 30px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 650;
}
#messages-section #add-note-button:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
#messages-section .notes-list {
  gap: 14px;
  margin: 0;
  padding: 17px 4px 7px;
  scroll-behavior: smooth;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
#messages-section .notes-list::-webkit-scrollbar { display: none; }
#messages-section .note-item { width: 72px; flex: 0 0 72px; gap: 5px; padding: 2px; }
#messages-section .note-main { gap: 5px; padding: 0; }
#messages-section .note-avatar-wrap { margin-top: 10px; }
#messages-section .note-avatar-wrap .avatar {
  width: 54px;
  height: 54px;
  border: 2px solid var(--surface);
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, var(--border));
  outline-offset: 1px;
  transition: transform var(--motion-fast), outline-color var(--motion-fast);
}
#messages-section .note-item.unread .note-avatar-wrap .avatar { outline-color: var(--accent); }
#messages-section .note-bubble {
  top: -22px;
  max-width: 120px;
  border-color: var(--border);
  border-radius: 12px;
  background: var(--surface-elevated);
  box-shadow: var(--shadow);
  padding: 5px 8px;
  font-size: 10px;
}
#messages-section .note-bubble::after { border-top-color: var(--surface-elevated); }
#messages-section .note-identity { max-width: 72px; font-size: 11px; }
#messages-section .inbox-search-wrap {
  min-height: 42px;
  border: 1px solid var(--border-subtle);
  border-radius: 13px;
  background: var(--surface-secondary);
}
#messages-section .inbox-search-wrap:focus-within {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: var(--surface);
}
#messages-section .conversation-list { display: grid; gap: 3px; }
#messages-section .conversation-list .list-item {
  min-height: 72px;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 10px 12px;
  transition: background-color var(--motion-fast), border-color var(--motion-fast), transform var(--motion-fast);
}
#messages-section .conversation-list .list-item:hover {
  border-color: var(--border-subtle);
  background: var(--hover);
}
#messages-section .conversation-list .list-item.active,
#messages-section .conversation-list .list-item[aria-current="true"] {
  border-color: color-mix(in srgb, var(--accent) 20%, var(--border-subtle));
  border-left: 2px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}
#messages-section .conversation-list .list-item > .avatar { width: 48px; height: 48px; flex-basis: 48px; }
#messages-section .conversation-list .item-main { gap: 4px; }
#messages-section .conversation-list .item-preview { color: var(--text-secondary); }
#messages-section .message-row .message { padding: 9px 13px; line-height: 1.5; }

#messages-section .inbox-empty-state,
#messages-section .inbox-people-prompt { display: grid; justify-items: start; gap: 8px; padding: 20px 16px; color: var(--text-secondary); }
#messages-section .inbox-people-heading { margin: 16px 10px 6px; color: var(--text-secondary); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
#messages-section .inbox-empty-state strong { color: var(--text); }
#messages-section .inbox-empty-state p,
#messages-section .inbox-people-prompt p { max-width: 260px; margin: 0; font-size: 13px; line-height: 1.5; }
#messages-section .inbox-people-prompt { border-top: 1px solid var(--border-subtle); }
@media (max-width: 768px) {
  #messages-section .notes-shelf { margin: 6px -16px 8px; padding-inline: 16px; }
  #messages-section .notes-list { gap: 11px; padding-top: 15px; }
  #messages-section .note-item { width: 68px; flex-basis: 68px; }
  #messages-section .note-avatar-wrap .avatar { width: 52px; height: 52px; }
  #messages-section .conversation-list .list-item { min-height: 68px; padding: 9px 10px; }
}

.message-note-reply-preview {
  width: min(100%, 260px);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.message-note-reply-preview:hover { border-color: var(--border-strong); background: var(--surface-tertiary); }
.message-note-reply-preview:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#messages-section .notes-shelf { min-width: 0; max-width: 100%; overflow: hidden; }
#messages-section .notes-list {
  display: flex;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  align-items: flex-start;
  gap: 16px;
  padding: 14px 8px 12px;
  scroll-behavior: smooth;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}
#messages-section .note-item {
  width: max-content;
  max-width: 166px;
  flex: 0 0 auto;
  min-width: 72px;
  gap: 6px;
  padding: 2px;
  cursor: pointer;
}
#messages-section .note-avatar-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 0; }
#messages-section .note-profile-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}
#messages-section .note-avatar-button { width: 62px; height: 62px; padding: 2px; border: 0; border-radius: 50%; background: transparent; }
#messages-section .note-avatar-button .avatar { width: 56px; height: 56px; border: 2px solid var(--surface); outline: 2px solid color-mix(in srgb, var(--accent) 54%, var(--border)); outline-offset: 1px; object-fit: cover; }
#messages-section .note-item.unread .note-avatar-button .avatar { outline-color: var(--accent); }
#messages-section .note-identity {
  max-width: 100%;
  margin-top: 5px;
  padding: 2px 4px;
  overflow: hidden;
  border-radius: 6px;
  font: inherit;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#messages-section .note-owner-replies { max-width: 100%; border: 0; border-radius: 999px; background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent); padding: 4px 7px; font: inherit; font-size: 9px; line-height: 1.2; cursor: pointer; }
#messages-section .note-owner-replies:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#messages-section .note-bubble-action {
  order: -1;
  pointer-events: auto;
  position: relative;
  top: auto;
  left: auto;
  z-index: auto;
  display: -webkit-box;
  width: max-content;
  max-width: min(156px, calc(100vw - 48px));
  overflow: hidden;
  transform: none;
  border: 1px solid var(--border-subtle);
  border-radius: 15px;
  background: var(--surface-elevated);
  box-shadow: var(--shadow);
  color: var(--text);
  padding: 7px 10px;
  font: inherit;
  font-size: 11px;
  line-height: 1.4;
  text-align: left;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  cursor: pointer;
}
#messages-section .note-bubble-action::after { border-top-color: var(--surface-elevated); }
#messages-section .note-bubble-action:hover { border-color: var(--border-strong); }
#messages-section .note-bubble-action:active { transform: scale(.98); }
#messages-section .note-profile-button:hover { color: var(--text); }
#messages-section .note-profile-button:active { transform: scale(.98); }
#messages-section .note-profile-button:focus-visible,
#messages-section .note-bubble-action:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.message-note-reply-preview {
  position: relative;
  display: flex;
  width: 132px;
  height: 132px;
  max-width: min(132px, calc(100vw - 84px));
  flex: 0 0 132px;
  align-items: center;
  justify-content: center;
  margin: 2px 0 9px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--border-strong) 78%, transparent);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 34%, color-mix(in srgb, var(--surface-tertiary) 88%, var(--accent) 12%), var(--surface-secondary) 72%);
  box-shadow: 0 8px 22px rgb(0 0 0 / 20%);
  cursor: pointer;
  isolation: isolate;
}
.message-note-reply-preview::after { position: absolute; z-index: -1; inset: 0; border-radius: inherit; background: linear-gradient(180deg, rgb(9 11 22 / 5%) 24%, rgb(9 11 22 / 58%) 100%); content: ""; pointer-events: none; }
.message-note-reply-profile {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
}
.message-note-reply-profile:empty { display: none; }
.message-note-reply-avatar { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: inherit; background: var(--surface-tertiary); object-fit: cover; }
.message-note-reply-profile > .message-note-reply-avatar img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.message-note-reply-author {
  position: absolute;
  right: 8px;
  bottom: 8px;
  left: 8px;
  z-index: 2;
  max-width: calc(100% - 16px);
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: rgb(9 11 22 / 78%);
  color: #fff;
  padding: 4px 8px;
  font: inherit;
  font-size: 10px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(10px);
}
.message-note-reply-text {
  position: absolute;
  top: 9px;
  right: 8px;
  left: 8px;
  z-index: 1;
  display: block;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 13%);
  border-radius: 14px;
  background: rgb(9 11 22 / 82%);
  box-shadow: 0 5px 14px rgb(0 0 0 / 20%);
  color: #fff;
  padding: 7px 9px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  overflow-wrap: anywhere;
  text-overflow: ellipsis;
  cursor: pointer;
  backdrop-filter: blur(12px);
}
.message-note-reply-author:hover { background: rgb(9 11 22 / 92%); text-decoration: underline; }
.message-note-reply-preview:hover { border-color: color-mix(in srgb, var(--accent) 48%, var(--border-strong)); box-shadow: 0 10px 28px rgb(0 0 0 / 28%); }
.message-note-reply-text:hover { background: rgb(9 11 22 / 92%); }
.message-note-reply-author:focus-visible,
.message-note-reply-text:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 768px) {
  #messages-section .notes-list { gap: 12px; padding-inline: 5px; }
  #messages-section .note-item { max-width: 148px; }
  #messages-section .note-bubble-action { max-width: min(140px, calc(100vw - 40px)); }
  .message-note-reply-preview { width: 116px; height: 116px; flex-basis: 116px; }
}
@media (prefers-reduced-motion: reduce) {
  #messages-section .notes-list { scroll-behavior: auto; }
}

/* Pitch-black app shell with stable Instagram-style navigation breakpoints. */
.app {
  --bg: #000;
  --surface: #000;
  --surface-secondary: #111;
  --surface-tertiary: #1b1b1b;
  --surface-elevated: #151515;
  --text: #f5f5f5;
  --text-secondary: #a3a3a3;
  --text-tertiary: #737373;
  --border: #262626;
  --border-subtle: #262626;
  --border-strong: #3f3f46;
  --hover: #171717;
  --bubble-incoming-bg: #202020;
  --bubble-incoming-text: #f5f5f5;
  --scrollbar-track: #000;
  --scrollbar-thumb: #3f3f46;
  --scrollbar-thumb-hover: #52525b;
  --sidebar-width: 72px;
  --sidebar-collapsed: 72px;
  --sidebar-expanded: 72px;
  min-width: 0;
  height: var(--app-viewport-height, 100vh);
  min-height: 0;
  overflow: hidden;
  background: #000;
  color: #f5f5f5;
}
.app > .sidebar {
  position: fixed;
  z-index: 30;
  inset: 0 auto 0 0;
  width: 72px;
  height: var(--app-viewport-height, 100vh);
  flex: 0 0 72px;
  overflow-x: hidden;
  border-right: 1px solid #262626;
  background: #000;
}
.app > .app-main {
  width: calc(100% - 72px);
  min-width: 0;
  height: 100%;
  min-height: 0;
  margin-left: 72px;
  overflow: hidden;
  padding-bottom: 0;
  background: #000;
  color: #f5f5f5;
}
.app .page,
.app .page > .content,
.app .messages-layout { background-color: #000; }
html.dark .app #messages-section {
  --bg: #000;
  --surface: #090909;
  --surface-secondary: #111;
  --surface-tertiary: #1b1b1b;
  --surface-elevated: #151515;
  --text: #f5f5f5;
  --text-secondary: #a3a3a3;
  --text-tertiary: #737373;
  --border: #262626;
  --border-subtle: #262626;
  --border-strong: #3f3f46;
  --hover: #171717;
  --bubble-incoming-bg: #202020;
  --bubble-incoming-text: #f5f5f5;
  --scrollbar-track: #000;
  background: #000;
}

/* Keep the compact icon rail at tablet widths; show labels on large desktops. */
@media (min-width: 1280px) {
  .app {
    --sidebar-width: 300px;
    --sidebar-collapsed: 300px;
    --sidebar-expanded: 300px;
  }
  .app > .sidebar {
    width: 300px;
    flex-basis: 300px;
    padding-inline: 20px;
  }
  .app > .app-main {
    width: calc(100% - 300px);
    margin-left: 300px;
  }
  .app .brand { justify-content: flex-start; padding-inline: 10px; margin-bottom: 8px; }
  .app .brand > span,
  .app .main-nav button > span:not(.nav-badge),
  .app .sidebar-footer > button > span {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
    white-space: nowrap;
  }
  .app .main-nav { gap: 7px; margin-top: 20px; }
  .app .main-nav button,
  .app .sidebar-footer > button { min-height: 54px; justify-content: flex-start; padding-inline: 12px; }
  .app .main-nav button > .icon,
  .app .sidebar-footer > button > .icon { width: 23px; height: 23px; flex: 0 0 23px; }
  .app .main-nav button[data-section="profile-section"] { display: none; }
  .app .sidebar-footer > .current-user-identity { min-height: 68px; gap: 12px; padding-inline: 8px; }
  .app .current-user-identity .avatar { width: 44px; height: 44px; flex: 0 0 44px; }
  .app .current-user-copy { display: grid; min-width: 0; flex: 1 1 auto; gap: 3px; overflow: hidden; text-align: left; }
  .app .current-user-copy strong,
  .app .current-user-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app .current-user-copy strong { color: var(--text); font-size: 14px; font-weight: 700; }
  .app .current-user-copy small { color: var(--text-secondary); font-size: 12px; }
  .app .sidebar-footer > .current-user-identity.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
  .app .sidebar-create-button { min-height: 54px; justify-content: center; margin-top: 14px; border-radius: 999px; font-weight: 750; }
  .app .sidebar-footer { gap: 8px; padding-top: 14px; }
  .app > .sidebar:hover,
  .app > .sidebar:focus-within { width: 300px; }
  #more-dialog { left: 316px; }
}
@media (min-width: 769px) and (max-width: 1279px) {
  .app > .sidebar,
  .app > .sidebar:hover,
  .app > .sidebar:focus-within { width: 72px; }
  .app > .app-main { width: calc(100% - 72px); margin-left: 72px; }
}
@media (max-width: 768px) {
  .app { overflow-x: clip; }
  .app > .app-main { width: 100%; margin-left: 0; }
}

@media (hover: none) and (pointer: coarse) {
  .app .main-nav button,
  .app .sidebar-footer > button,
  .app .mobile-header button,
  .app .mobile-nav button,
  #home-section .post-actions button,
  #search-section .search-mode button,
  #messages-section .inbox-tabs button,
  #profile-section .profile-tabs button,
  #profile-section #profile-actions > button,
  #videos-section .ihuza-reel-actions button,
  #videos-section .ihuza-reel-follow,
  #more-dialog .more-nav button {
    min-height: 44px;
  }
  #profile-section #profile-actions > .profile-settings-button { width: 44px; min-width: 44px; flex-basis: 44px; }
}

/* Note replies keep the existing author and Note click targets in a compact card. */
.message-note-reply-preview {
  width: 112px;
  height: 112px;
  max-width: min(112px, calc(100vw - 84px));
  flex-basis: 112px;
  margin-block: 2px 5px;
  background: #111;
}
.message-note-reply-preview::after { background: linear-gradient(180deg, rgb(0 0 0 / 5%) 24%, rgb(0 0 0 / 58%) 100%); }
.message-note-reply-author,
.message-note-reply-text { background-color: rgb(0 0 0 / 84%); }
.message-note-reply-author:hover,
.message-note-reply-text:hover { background-color: rgb(0 0 0 / 94%); }
@media (max-width: 768px) {
  .message-note-reply-preview { width: 100px; height: 100px; flex-basis: 100px; }
}

/* Avatar images crop consistently and retain their fallback sizing. */
.avatar img { display: block; border-radius: inherit; object-fit: cover; }
.avatar-fallback { display: grid; width: 100%; height: 100%; place-items: center; border-radius: inherit; }

/* Keep Notes evenly spaced and keep Note replies visually separate from chat bubbles. */
#messages-section .notes-shelf {
  margin: 0 -18px 8px;
  border-bottom: 1px solid #262626;
  background: #000;
  padding: 6px 18px 8px;
}
#messages-section .notes-list {
  gap: 14px;
  padding: 12px 6px 8px;
}
#messages-section .note-item {
  width: 72px;
  max-width: 72px;
  min-width: 72px;
  flex: 0 0 72px;
}
#messages-section .note-identity {
  max-width: 68px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#messages-section .note-bubble-action {
  display: block;
  width: max-content;
  max-width: 88px;
  overflow: hidden;
  border: 1px solid #3f3f46;
  border-radius: 999px;
  background: #202020;
  color: #e4e4e7;
  padding: 5px 8px;
  font-size: 10px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgb(0 0 0 / 28%);
}
#messages-section .note-bubble-action::after { display: none; }
#messages-section .message-row .message.message-note-reply-bubble,
#messages-section .message-row.own .message.message-note-reply-bubble {
  display: flex;
  width: fit-content;
  max-width: min(220px, calc(100vw - 70px));
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: inherit;
  padding: 0;
}
#messages-section .message-note-reply-bubble .message-note-reply-preview {
  width: 112px;
  height: 112px;
  max-width: min(112px, calc(100vw - 84px));
  flex: 0 0 112px;
  margin: 2px 0 1px;
  border-color: #3f3f46;
  background: #090909;
  box-shadow: 0 8px 22px rgb(0 0 0 / 35%);
}
#messages-section .message-note-reply-content {
  max-width: 200px;
  border-radius: 16px 16px 4px 16px;
  background: #4f46e5;
  color: #fff;
  padding: 7px 12px;
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
#messages-section .message-note-reply-bubble > .message-footer {
  width: 100%;
  color: #a3a3a3;
  padding-inline: 2px;
}
#messages-section .message-note-reply-bubble .message-time { color: #a3a3a3; }
@media (max-width: 768px) {
  #messages-section .notes-shelf { margin-inline: -16px; padding-inline: 16px; }
  #messages-section .notes-list { gap: 12px; padding-inline: 5px; }
  #messages-section .message-note-reply-bubble .message-note-reply-preview { width: 100px; height: 100px; flex-basis: 100px; }
}

/* Clamp Note text to one line so it never spills over the circular avatar. */
#messages-section .message-note-reply-bubble .message-note-reply-text {
  top: 8px;
  right: 8px;
  left: 8px;
  display: block;
  max-width: calc(100% - 16px);
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 10px;
  line-height: 1.25;
  overflow: hidden;
  overflow-wrap: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#messages-section .message-note-reply-bubble .message-note-reply-text {
  top: 8px;
  right: 8px;
  left: 8px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10px;
  line-height: 1.25;
  white-space: nowrap;
}
#messages-section .message-note-reply-content {
  align-self: flex-end;
  max-width: min(200px, 100%);
  border-radius: 4px 16px 16px 16px;
  padding: 6px 14px;
}

/* Notes stay in a compact horizontal rail; the Add Note tile remains its creation control. */
#messages-section .notes-list { gap: 12px; padding: 10px 6px 8px; }
#messages-section .note-item { gap: 4px; }
#messages-section .note-avatar-button { overflow: hidden; }
#messages-section .note-avatar-button .avatar { object-fit: cover; }
#messages-section .note-bubble-action {
  max-width: 80px;
  border-radius: 16px;
  padding: 3px 8px;
}

/* Compact Note previews in DMs use the avatar and Note text without a separate author label. */
#messages-section .message-row .message.message-note-reply-bubble,
#messages-section .message-row.own .message.message-note-reply-bubble {
  max-width: min(200px, calc(100vw - 70px));
  gap: 6px;
}
#messages-section .message-note-reply-bubble .message-note-reply-preview {
  width: 96px;
  height: 96px;
  max-width: min(96px, calc(100vw - 84px));
  flex-basis: 96px;
  margin: 0;
}
#messages-section .message-note-reply-bubble .message-note-reply-text {
  top: 6px;
  right: 4px;
  left: 4px;
  max-width: calc(100% - 8px);
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 650;
  line-height: 1.25;
}
#messages-section .message-note-reply-content {
  align-self: flex-end;
  max-width: min(200px, 100%);
  border-radius: 4px 16px 16px 16px;
  padding: 6px 14px;
  text-align: right;
}

/* Keep the Notes rail below search and match its compact avatar and bubble scale. */
#messages-section .notes-shelf { margin: 0 -18px 8px; padding: 2px 18px 6px; }
#messages-section .notes-list { gap: 12px; padding: 7px 6px 5px; }
#messages-section .note-item { width: 72px; max-width: 72px; min-width: 72px; flex-basis: 72px; gap: 4px; text-align: center; }
#messages-section .note-avatar-wrap { margin-top: 7px; }
#messages-section .note-avatar-button { width: 58px; height: 58px; padding: 2px; }
#messages-section .note-avatar-button .avatar { width: 52px; height: 52px; object-fit: cover; }
#messages-section .note-identity { max-width: 60px; font-size: 10px; text-align: center; }
#messages-section .note-bubble-action { max-width: 75px; border-radius: 16px; padding: 2px 8px; font-size: 10px; }
@media (max-width: 768px) {
  #messages-section .notes-shelf { margin-inline: -16px; padding-inline: 16px; }
  #messages-section .notes-list { gap: 12px; padding: 7px 5px 5px; }
}

/* Match the rounded DM composer and keep every existing action in a predictable order. */
#messages-section .message-composer-bar {
  min-height: 52px;
  gap: 4px;
  border: 1px solid #27272a;
  border-radius: 999px;
  background: #111;
  padding: 5px 8px;
}
#messages-section .message-composer-bar:focus-within {
  border-color: #52525b;
  box-shadow: 0 0 0 2px rgb(113 113 122 / 18%);
}
#messages-section .message-composer-controls { align-items: center; gap: 3px; }
#messages-section .message-composer-controls #emoji-button { order: 0; }
#messages-section .message-composer-controls #message-input {
  order: 1;
  width: 0;
  min-width: 0;
  min-height: 40px;
  flex: 1 1 0%;
  background: transparent;
  color: #f4f4f5;
  padding-inline: 6px;
}
#messages-section .message-composer-controls #message-quick-like { order: 2; }
#messages-section .message-composer-controls #voice-record-button { order: 3; }
#messages-section .message-composer-controls #video-note-record-button { order: 4; }
#messages-section .message-composer-controls #attach-button { order: 5; }
#messages-section .message-composer-controls #send-button { order: 6; }
@media (max-width: 520px) {
  #messages-section .message-composer-bar { min-height: 48px; gap: 2px; padding-inline: 5px; }
  #messages-section .message-composer-controls { gap: 1px; }
  #messages-section .message-composer-controls > .icon-button { width: 34px; flex-basis: 34px; }
}

/* Consolidated profile layout. Keep profile presentation scoped to this page. */
#profile-section {
  min-height: 100%;
  background: #000;
  color: var(--text);
}
#profile-section > .profile-content {
  width: min(100%, 1040px);
  margin-inline: auto;
  padding: 22px clamp(12px, 3vw, 28px) 48px;
}
#profile-section .profile-view {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  overflow: visible;
  background: transparent;
}
#profile-section .profile-head {
  display: grid;
  width: min(100%, 896px);
  grid-template-columns: 176px minmax(0, 1fr);
  grid-template-areas: "avatar summary";
  align-items: center;
  gap: clamp(28px, 5vw, 64px);
  margin: 10px auto 20px;
  border: 0;
  background: transparent;
  padding: 24px clamp(12px, 2vw, 24px) 28px;
}
#profile-section .profile-avatar-column {
  display: flex;
  grid-area: avatar;
  align-items: center;
  justify-content: center;
}
#profile-section .profile-avatar-wrap {
  position: relative;
  display: grid;
  width: max-content;
  place-items: center;
}
#profile-section #profile-story-ring {
  display: grid;
  width: 164px;
  height: 164px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  padding: 0;
}
#profile-section #profile-story-ring:disabled { cursor: default; }
#profile-section #profile-story-ring.has-active-story { background: var(--gradient-story); padding: 3px; }
#profile-section #profile-story-ring .profile-avatar {
  display: grid;
  width: 156px;
  height: 156px;
  place-items: center;
  overflow: hidden;
  border: 3px solid #000;
  border-radius: 50%;
  background: var(--surface-secondary);
  object-fit: cover;
}
#profile-section #profile-note {
  position: absolute;
  top: -13px;
  left: 50%;
  z-index: 2;
  width: max-content;
  max-width: min(220px, calc(100vw - 40px));
  margin: 0;
  transform: translateX(-50%);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: var(--surface-tertiary);
  color: var(--text);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 550;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
#profile-section .profile-summary {
  display: grid;
  min-width: 0;
  grid-area: summary;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "identity actions" "stats stats" "bio bio" "mutual mutual";
  align-items: center;
  gap: 18px 20px;
  padding: 0;
  text-align: left;
}
#profile-section .profile-identity {
  display: flex;
  min-width: 0;
  grid-area: identity;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}
#profile-section .profile-identity h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(21px, 2.4vw, 26px);
  font-weight: 450;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
#profile-section #profile-handle {
  margin: 3px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
}
#profile-section .profile-brand-mark { display: none; }
#profile-section #profile-actions {
  display: flex;
  min-width: 0;
  grid-area: actions;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}
#profile-section #profile-actions > button {
  display: inline-flex;
  min-width: 96px;
  min-height: 38px;
  flex: 0 1 auto;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: var(--surface-tertiary);
  color: var(--text);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}
#profile-section #profile-actions > button.primary { background: var(--accent); color: var(--accent-contrast); }
#profile-section #profile-actions > button:hover { filter: brightness(1.12); }
#profile-section #profile-actions.is-visitor-profile > button:not(.primary) { border: 1px solid var(--border-strong); background: transparent; }
#profile-section #profile-actions.is-own-profile > #profile-archive-button { border: 1px solid var(--border-subtle); background: var(--surface-tertiary); }
#profile-section #profile-actions > .profile-settings-button {
  position: relative;
  z-index: 3;
  box-sizing: border-box;
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  flex: 0 0 42px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-tertiary);
  color: var(--text-secondary);
  padding: 10px;
  cursor: pointer;
  pointer-events: auto;
  transition: color 140ms ease, border-color 140ms ease, background-color 140ms ease, transform 140ms ease;
}
#profile-section .profile-settings-button .icon { width: 20px; height: 20px; stroke-width: 2; }
#profile-section #profile-actions > .profile-settings-button:hover { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface-tertiary)); transform: translateY(-1px); }
#profile-section #profile-actions > .profile-settings-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#profile-section #profile-stats {
  display: flex;
  grid-area: stats;
  align-items: baseline;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: clamp(20px, 4vw, 38px);
  margin: 0;
  border: 0;
  padding: 0;
  color: var(--text);
}
#profile-section #profile-stats > * {
  display: inline-flex;
  min-width: 0;
  align-items: baseline;
  gap: 5px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: 14px;
  white-space: nowrap;
}
#profile-section #profile-stats strong { font-weight: 700; }
#profile-section #profile-stats .profile-stat-button { cursor: pointer; font: inherit; }
#profile-section #profile-stats .profile-stat-button:hover { text-decoration: underline; }
#profile-section #profile-bio {
  grid-area: bio;
  max-width: 62ch;
  margin: 0;
  color: var(--text);
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
#profile-section #profile-mutuals { grid-area: mutual; margin: -10px 0 0; color: var(--text-secondary); font-size: 12px; }
#profile-section .profile-highlights {
  width: min(100%, 896px);
  margin: 4px auto 16px;
  border: 0;
  background: transparent;
  padding: 12px 16px 16px;
}
#profile-section .profile-highlights[hidden],
#profile-section .profile-highlights.hidden { display: none; }
#profile-section .profile-highlights > header { display: contents; }
#profile-section .profile-highlights-list { display: flex; width: 100%; align-items: flex-start; gap: 24px; overflow-x: auto; border-bottom: 1px solid rgb(39 39 42 / 60%); margin-bottom: 4px; padding: 8px 4px 20px; scrollbar-width: none; }
#profile-section .profile-highlights-list::-webkit-scrollbar { display: none; }
#profile-section .profile-highlight-new,
#profile-section .profile-highlight-open { display: grid; flex: 0 0 80px; justify-items: center; gap: 6px; border: 0; background: transparent; color: var(--text); padding: 0; cursor: pointer; }
#profile-section .profile-highlight-new { color: var(--text-secondary); font: inherit; font-size: 12px; }
#profile-section .profile-highlight-new > .icon,
#profile-section .profile-highlight-cover { display: grid; width: 80px; height: 80px; place-items: center; overflow: hidden; border: 1px solid var(--border-strong); border-radius: 50%; background: var(--surface-secondary); padding: 3px; transition: border-color .18s ease; }
#profile-section .profile-highlight-new > .icon { border-color: var(--border-strong); color: var(--text-secondary); padding: 23px; }
#profile-section .profile-highlight-new:hover > .icon,
#profile-section .profile-highlight-open:hover .profile-highlight-cover { border-color: #71717a; }
#profile-section .profile-highlight-cover > img { display: block; width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
#profile-section .profile-highlight-text-cover { color: var(--text-secondary); font-size: 20px; }
#profile-section .profile-highlight { display: grid; flex: 0 0 80px; justify-items: center; gap: 6px; }
#profile-section .profile-highlight-open { gap: 6px; }
#profile-section .profile-highlight-title,
#profile-section .profile-highlight-new > span { max-width: 75px; overflow: hidden; color: #d4d4d8; font-size: 12px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
#profile-section .profile-highlight-manage { font-size: 10px; }
#profile-section .profile-tabs {
  display: flex;
  width: min(100%, 896px);
  min-height: 52px;
  justify-content: center;
  margin: 0 auto;
  border-top: 1px solid var(--border-subtle);
  background: transparent;
}
#profile-section .profile-tabs button {
  display: flex;
  width: auto;
  min-width: 0;
  min-height: 52px;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  border: 0;
  border-top: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 0 12px;
  transition: color .16s ease, border-color .16s ease;
}
#profile-section .profile-tabs button[hidden] { display: none; }
#profile-section .profile-tabs button .icon { width: 18px; height: 18px; }
#profile-section .profile-tabs button.active { border-top-color: var(--accent); color: var(--accent); }
#profile-section #profile-posts.post-grid {
  display: grid;
  width: min(100%, 896px);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(2px, .55vw, 7px);
  margin: 0 auto;
  padding: 4px 0 24px;
}
#profile-section #profile-posts .profile-grid-item {
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--surface-secondary);
}
#profile-section #profile-posts .profile-grid-item > button {
  position: absolute;
  inset: 0;
  display: grid;
  width: 100%;
  height: 100%;
  min-width: 0;
  place-items: center;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}
#profile-section #profile-posts .profile-grid-item > button > img,
#profile-section #profile-posts .profile-grid-item > button > video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#profile-section #profile-posts .profile-repost-item > p {
  position: absolute;
  z-index: 2;
  top: 5px;
  right: 5px;
  left: 5px;
  margin: 0;
  overflow: hidden;
  border-radius: 5px;
  background: rgb(0 0 0 / 68%);
  color: #fff;
  padding: 4px 6px;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#profile-section #profile-posts .profile-grid-item > button.text-tile {
  background: linear-gradient(145deg, var(--surface-tertiary), var(--surface-secondary));
  color: var(--text);
  padding: 18px;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
#profile-section .profile-grid-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2vw, 22px);
  background: rgb(0 0 0 / 44%);
  color: #fff;
  opacity: 0;
  transition: opacity .18s ease;
  pointer-events: none;
}
#profile-section #profile-posts button:hover .profile-grid-overlay,
#profile-section #profile-posts button:focus-visible .profile-grid-overlay { opacity: 1; }
#profile-section .profile-grid-count { display: inline-flex; align-items: center; gap: 6px; font-size: clamp(12px, 1.4vw, 16px); font-weight: 700; }
#profile-section .profile-grid-count .icon { width: 18px; height: 18px; }
#profile-section #profile-posts .profile-grid-empty {
  display: grid;
  grid-column: 1 / -1;
  min-height: 180px;
  place-items: center;
  margin: 0;
  border-top: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  padding: 32px 12px;
  text-align: center;
}
#profile-section #profile-actions > button:focus-visible,
#profile-section .profile-tabs button:focus-visible,
#profile-section .profile-stat-button:focus-visible,
#profile-section .profile-highlight button:focus-visible,
#profile-section #profile-posts button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

@media (max-width: 900px) {
  #profile-section > .profile-content { padding-top: 14px; }
  #profile-section .profile-head { grid-template-columns: 144px minmax(0, 1fr); gap: clamp(20px, 4vw, 36px); padding-block: 20px 24px; }
  #profile-section #profile-story-ring { width: 136px; height: 136px; }
  #profile-section #profile-story-ring .profile-avatar { width: 128px; height: 128px; }
  #profile-section .profile-summary { gap: 14px 12px; }
  #profile-section #profile-actions { gap: 6px; }
  #profile-section #profile-actions > button { min-width: 84px; padding-inline: 11px; }
  #profile-section #profile-stats { gap: clamp(14px, 3vw, 24px); }
}
@media (max-width: 600px) {
  #profile-section > .profile-content { padding: 8px 0 32px; }
  #profile-section .profile-head {
    width: 100%;
    grid-template-columns: 88px minmax(0, 1fr);
    grid-template-areas: "avatar identity" "avatar actions" "stats stats" "bio bio" "mutual mutual";
    align-items: center;
    gap: 12px 14px;
    margin: 4px auto 14px;
    padding: 18px 16px 16px;
  }
  #profile-section .profile-avatar-column { align-self: start; }
  #profile-section #profile-story-ring { width: 84px; height: 84px; }
  #profile-section #profile-story-ring .profile-avatar { width: 78px; height: 78px; border-width: 2px; }
  #profile-section #profile-note { top: -12px; max-width: min(180px, calc(100vw - 28px)); padding: 6px 9px; font-size: 10px; }
  #profile-section .profile-summary { display: contents; }
  #profile-section .profile-identity { grid-area: identity; align-items: flex-start; }
  #profile-section .profile-identity h1 { font-size: clamp(17px, 4.8vw, 21px); }
  #profile-section #profile-handle { font-size: 12px; }
  #profile-section #profile-actions { grid-area: actions; justify-content: flex-start; flex-wrap: wrap; }
  #profile-section #profile-actions > button { min-width: 0; min-height: 34px; flex: 1 1 76px; padding: 6px 8px; font-size: 12px; }
  #profile-section #profile-actions > .profile-settings-button { width: 44px; min-width: 44px; min-height: 44px; flex: 0 0 44px; padding: 11px; }
  #profile-section #profile-stats { grid-area: stats; justify-content: space-between; flex-wrap: nowrap; gap: 5px; border-top: 1px solid var(--border-subtle); border-bottom: 1px solid var(--border-subtle); padding: 11px 0; }
  #profile-section #profile-stats > * { gap: 4px; font-size: 12px; }
  #profile-section #profile-stats strong { font-size: 13px; }
  #profile-section #profile-bio { font-size: 13px; }
  #profile-section #profile-mutuals { margin: -5px 0 0; }
  #profile-section .profile-highlights { margin-bottom: 12px; padding: 8px 14px 12px; }
  #profile-section .profile-highlights-list { gap: 16px; }
  #profile-section .profile-tabs,
  #profile-section .profile-tabs button { min-height: 46px; }
  #profile-section #profile-posts.post-grid { gap: 2px; padding-top: 2px; }
  #profile-section #profile-posts .profile-grid-item > button.text-tile { padding: 10px; font-size: 11px; }
  #profile-section .profile-grid-count .icon { width: 16px; height: 16px; }
}
@media (max-width: 360px) {
  #profile-section .profile-head { grid-template-columns: 76px minmax(0, 1fr); gap: 10px 12px; padding-inline: 12px; }
  #profile-section #profile-story-ring { width: 74px; height: 74px; }
  #profile-section #profile-story-ring .profile-avatar { width: 68px; height: 68px; }
  #profile-section #profile-actions > button { flex-basis: 70px; }
  #profile-section #profile-stats > * { gap: 2px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  #profile-section .profile-tabs button,
  #profile-section .profile-grid-overlay { transition: none; }
}

/* Mobile touch sizing and single-owner scrolling for full-screen overlays. */
@media (max-width: 768px) {
  .app {
    height: var(--app-viewport-height, 100dvh);
    min-height: 0;
    overflow: hidden;
  }
  .app > .app-main {
    display: flex;
    height: calc(100% - 66px - env(safe-area-inset-bottom));
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: 0;
  }
  .app-main > .mobile-header { flex: 0 0 60px; }
  .app-main > .page:not(.hidden) {
    height: auto;
    min-height: 0;
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }
  .app-main > #messages-section:not(.hidden),
  .app-main > #videos-section:not(.hidden) { height: auto; overflow: hidden; }
  .app-main > #messages-section:not(.hidden) { display: flex; flex-direction: column; }
  .app-main > #messages-section:not(.hidden) .messages-layout { height: auto; min-height: 0; flex: 1 1 auto; overflow: hidden; }
  .app-main > #messages-section:not(.hidden) .people-pane {
    height: 100%;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    padding-bottom: 18px;
  }

  .comments-dialog {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-width: none;
    height: min(76dvh, 680px);
    min-height: min(42dvh, 280px);
    max-height: min(88dvh, 760px);
    flex-direction: column;
    margin: 0;
    border-radius: 20px 20px 0 0;
    overflow: hidden;
    padding: 28px 16px max(16px, env(safe-area-inset-bottom));
  }
  .comments-dialog[open] { display: flex; }
  .comments-dialog::before {
    position: absolute;
    top: 10px;
    left: 50%;
    width: 40px;
    height: 5px;
    border-radius: 999px;
    background: var(--text-tertiary);
    content: "";
    opacity: .7;
    transform: translateX(-50%);
  }
  .comments-dialog > header { position: relative; justify-content: center; }
  .comments-dialog > header h2 { margin: 0; font-size: 18px; }
  .comments-dialog > header .icon-button { position: absolute; top: -7px; right: -8px; }
  .comments-dialog > header { flex: 0 0 auto; }
  #comments-list {
    min-height: 0;
    max-height: none;
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  #comment-status,
  #comment-form { flex: 0 0 auto; }
  #comment-form { margin-top: 10px; }
  .comment-composer { min-width: 0; align-items: center; }
  #comment-input { min-height: 44px; font-size: 16px; }
  .comment-composer > button { min-height: 44px; }

  .post-detail-dialog > header #post-detail-close,
  .post-detail-dialog .post-actions > button,
  #home-section #feed-list .post-actions > button,
  #profile-section #profile-actions > button,
  #profile-section #profile-actions > .profile-settings-button,
  .note-view-close {
    box-sizing: border-box;
    min-width: 44px;
    min-height: 44px;
    touch-action: manipulation;
  }
  #profile-section #profile-actions > button { padding: 8px 10px; }
  #profile-section #profile-actions > .profile-settings-button { width: 44px; flex-basis: 44px; padding: 10px; }
  .post-detail-dialog .post-actions > button,
  #home-section #feed-list .post-actions > button { padding: 8px; }
  .note-view-close { width: 44px; height: 44px; }

  #post-detail-content {
    touch-action: pan-y;
    overscroll-behavior-y: contain;
  }
  .post-detail-dialog .post-body { min-height: 0; overflow: hidden; }
  .post-detail-comment-list {
    min-height: 0;
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  .note-view-dialog {
    box-sizing: border-box;
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-width: none;
    height: auto;
    max-height: min(78dvh, 620px);
    min-height: 0;
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    border-radius: 28px 28px 0 0;
    padding: 38px max(20px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    box-shadow: 0 -14px 44px rgb(0 0 0 / 38%);
  }
  .note-view-dialog[open] { display: flex; flex-direction: column; align-items: stretch; gap: 0; }
  .note-view-dialog::before {
    position: absolute;
    top: 12px;
    left: 50%;
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: var(--text-tertiary);
    content: "";
    opacity: .7;
    transform: translateX(-50%);
  }
  .note-view-dialog::backdrop { background: rgb(0 0 0 / 58%); backdrop-filter: blur(3px); }
  .note-view-close {
    appearance: none;
    position: absolute;
    display: grid;
    top: 13px;
    right: 12px;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    background: var(--surface-elevated);
    color: var(--text);
    font-size: 22px;
    padding: 0;
  }
  .note-view-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .note-view-bubble {
    box-sizing: border-box;
    order: 1;
    width: 100%;
    min-width: 0;
    min-height: 116px;
    flex: 0 0 auto;
    border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--border));
    border-radius: 22px;
    background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 9%, var(--surface-secondary)), var(--surface-elevated));
    padding: 22px 20px;
    box-shadow: 0 12px 30px color-mix(in srgb, var(--text) 8%, transparent);
    color: var(--text);
    font-size: clamp(20px, 5.4vw, 25px);
    font-weight: 560;
    line-height: 1.38;
    overflow-wrap: anywhere;
    text-align: left;
  }
  .note-view-profile {
    order: 0;
    display: grid;
    width: 100%;
    max-width: 100%;
    grid-template-columns: 52px minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    align-items: center;
    justify-items: start;
    column-gap: 12px;
    margin: 0 0 16px;
    padding: 0 50px 0 0;
  }
  .note-view-avatar { grid-column: 1; grid-row: 1 / span 3; }
  .note-view-avatar-image { width: 52px; height: 52px; border-width: 2px; box-shadow: 0 4px 14px rgb(0 0 0 / 30%); }
  .note-view-profile-name { grid-column: 2; grid-row: 1; margin: 0; font-size: 16px; font-weight: 700; }
  #note-view-username {
    grid-column: 2;
    grid-row: 2;
    justify-self: start;
    margin: 1px 0 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-secondary);
    padding: 0;
    font-size: 13px;
    text-align: left;
  }
  .note-view-created-at { display: block; grid-column: 2; grid-row: 3; margin-top: 3px; color: var(--text-tertiary); font-size: 11px; }
  .note-view-replies { order: 2; max-height: min(24dvh, 180px); margin-top: 4px; }
  .note-view-replies h2 { margin-bottom: 6px; }
  .note-view-reply-form {
    box-sizing: border-box;
    position: relative;
    display: flex;
    order: 3;
    width: 100%;
    min-width: 0;
    min-height: 58px;
    flex: 0 0 auto;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    padding: 6px 7px 6px 15px;
    margin-top: 14px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--surface-secondary);
    box-shadow: inset 0 1px 5px color-mix(in srgb, var(--text) 8%, transparent);
  }
  .note-view-reply-form input {
    display: block;
    width: 0;
    min-width: 0;
    height: 44px;
    flex: 1 1 auto;
    border: 0;
    border-radius: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    padding: 0;
    font-size: 16px;
  }
  .note-view-reply-form input:focus { outline: 0; box-shadow: none; }
  .note-view-reply-form > button {
    display: grid;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    flex: 0 0 44px;
    align-items: center;
    justify-content: center;
    padding: 0;
    touch-action: manipulation;
  }
  #note-view-emoji,
  #note-view-reply-form > .note-view-send {
    appearance: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
  }
  #note-view-emoji:hover,
  #note-view-emoji:focus-visible { background: var(--hover); color: var(--text); }
  .note-view-reply-form > .note-view-send { border-radius: 50%; background: var(--accent); color: var(--accent-contrast); }
  #note-view-emoji-picker {
    position: absolute;
    right: 6px;
    bottom: calc(100% + 10px);
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(6, 40px);
    gap: 4px;
    max-width: calc(100vw - 48px);
    border: 1px solid var(--border-strong);
    border-radius: 18px;
    background: var(--surface-elevated);
    padding: 8px;
    box-shadow: 0 12px 32px rgb(0 0 0 / 42%);
  }
  #note-view-emoji-picker button {
    display: grid;
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
    place-items: center;
    border: 0;
    border-radius: 12px;
    background: transparent;
    font-size: 21px;
    padding: 0;
  }
  #note-view-emoji-picker button:hover,
  #note-view-emoji-picker button:focus-visible { background: var(--hover); }
  .note-view-status { order: 4; }
}

@media (max-width: 520px) {
  .app > .app-main { height: calc(100% - 62px - env(safe-area-inset-bottom)); }
}

/* Mobile Home Feed: one vertical page scroller and media sized by its source ratio. */
@media (max-width: 768px) {
  .app-main > #home-section:not(.hidden) {
    height: auto;
    min-height: 0;
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }
  #home-section > .content,
  #home-section .home-layout,
  #home-section .feed-layout,
  #home-section .feed,
  #home-section #feed-list {
    height: auto;
    min-height: 0;
    overflow: visible;
  }
  #home-section .home-layout,
  #home-section .feed-layout,
  #home-section .feed {
    display: flex;
    flex-direction: column;
  }
  #home-section .feed-layout { width: 100%; max-width: 100%; }
  #home-section .feed { width: 100%; }
  #home-section #feed-list > .post {
    height: auto;
    min-height: 0;
    flex: 0 0 auto;
    overflow: visible;
  }
  #home-section #feed-list .post-media-frame {
    display: flex;
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 60vh;
    max-height: 60dvh;
    min-height: 0;
    aspect-ratio: auto !important;
    align-items: center;
    justify-content: center;
    overflow: visible;
  }
  #home-section #feed-list .post-media-frame > .post-media {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 60vh;
    max-height: 60dvh;
    min-height: 0;
    aspect-ratio: auto !important;
    object-fit: contain;
  }
}

/* Balance mobile post media with the comment area. */
@media (max-width: 768px) {
  .post-detail-dialog .post-media-frame {
    height: 42dvh;
    max-height: 42dvh;
    flex: 0 0 42dvh;
  }
  .post-detail-dialog .post-media-frame > .post-media {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 42dvh;
    object-fit: contain;
  }
  .post-detail-dialog .post-body { flex: 1 1 0; }
  .post-detail-comment-list { padding: 12px 14px; }
  .post-detail-comments-empty { gap: 6px; padding: 24px 12px; }
  .post-detail-footer { padding-top: 2px; }
  .post-detail-comment-form { min-height: 52px; }
}

/* Put an opened mobile conversation above the inbox list. */
@media (max-width: 768px) {
  #messages-section .chat-panel.open {
    position: fixed;
    z-index: 100;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    background: var(--bg);
  }
  #messages-section .chat-panel.open .conversation,
  #messages-section .chat-panel.open .conversation-empty {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
  }
  #messages-section .chat-panel.open .conversation {
    grid-template-rows: 64px minmax(0, 1fr) auto auto;
  }
}

/* Final phone layout for opened post details and inbox Notes. */
@media (max-width: 768px) {
  .post-detail-dialog,
  .post-detail-dialog #post-detail-content {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
  }
  .post-detail-dialog .post {
    position: relative;
    display: flex;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 42dvh) minmax(0, 1fr);
    grid-template-areas: none;
    overflow: hidden;
  }
  .post-detail-dialog .post-media-frame {
    position: relative;
    width: 100%;
    height: 42dvh;
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    max-height: 42dvh;
    flex: 0 0 42dvh;
    border-right: 0;
  }
  .post-detail-dialog .post-media-frame > .post-media {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
  }
  .post-detail-dialog .post-body {
    position: absolute;
    z-index: 10;
    inset: 36dvh 0 0;
    width: 100%;
    min-width: 0;
    min-height: 0;
    flex: none;
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -10px 30px rgb(0 0 0 / 24%);
    padding-top: 14px;
  }
  .post-detail-comments-heading {
    display: block;
    flex: 0 0 auto;
    margin: 0;
    color: var(--text);
    padding: 3px 14px 8px;
    font-size: 17px;
    line-height: 1.2;
    text-align: center;
  }
  .post-detail-dialog .post-body::before {
    position: absolute;
    top: 7px;
    left: 50%;
    width: 40px;
    height: 5px;
    border-radius: 999px;
    background: var(--text-tertiary);
    content: "";
    opacity: .7;
    transform: translateX(-50%);
  }

}

/* Give the phone Home feed a clear hierarchy without changing desktop. */
@media (max-width: 600px) {
  #home-section > .content.home-layout {
    gap: 0;
    padding: 0 0 max(12px, env(safe-area-inset-bottom));
  }
  #home-section .feed-layout { gap: 0; padding-inline: 12px; }
  #home-section .page-heading {
    min-height: 62px;
    margin: 0 -12px 4px;
    padding: 10px 16px 8px;
  }
  #home-section .page-heading .eyebrow { margin-bottom: 3px; }
  #home-section .page-heading h1 { font-size: 22px; letter-spacing: -.025em; }
  #home-section .create-post-button { min-height: 42px; border-radius: 13px; padding-inline: 12px; white-space: nowrap; }
  #home-section .stories-section {
    margin: 0 -12px 8px;
    padding: 10px 14px 12px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface-secondary) 38%, transparent);
  }
  #home-section .stories-heading { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
  #home-section .stories-heading h2 { font-size: 14px; font-weight: 700; }
  #home-section .stories-heading > span { color: var(--text-secondary); font-size: 11px; }
  #home-section .feed-toolbar { min-height: 44px; margin: 0; padding: 0 2px; }
  #home-section .feed-toolbar h2 { font-size: 16px; font-weight: 750; letter-spacing: -.015em; }
  #home-section #feed-list > .post,
  #home-section #feed-list > .post.has-media-fit {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 -12px 14px;
    padding: 12px 12px 14px;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
  }
  #home-section #feed-list .post-head { min-height: 52px; padding: 0 2px 10px; }
  #home-section #feed-list .post-media-frame {
    width: 100%;
    max-width: 100%;
    max-height: 66dvh;
    border: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
    border-radius: 16px;
    background: #08090c;
    overflow: hidden;
  }
  #home-section #feed-list .post-media-frame > .post-media {
    width: 100%;
    max-width: 100%;
    max-height: 66dvh;
    object-fit: contain;
  }
  #home-section #feed-list .post-body { padding-top: 4px; }
  #home-section #feed-list .post-actions { min-height: 52px; gap: 6px; padding: 4px 0 2px; }
  #home-section #feed-list .post-actions > button {
    min-width: 44px;
    min-height: 44px;
    gap: 6px;
    border-radius: 12px;
    padding: 8px;
    font-size: 12px;
    font-weight: 650;
  }
  #home-section #feed-list .post-actions > button .icon { width: 21px; height: 21px; }
  #home-section #feed-list .post-likes-summary { display: block; margin: 0 4px 5px; font-size: 12px; }
  #home-section #feed-list .post-caption,
  #home-section #feed-list .post-view-all-comments,
  #home-section #feed-list .caption-toggle { margin-inline: 4px; }
  #home-section #feed-list .post-caption { line-height: 1.5; }
  #home-messages-shortcut {
    position: relative;
    right: auto;
    bottom: auto;
    z-index: 1;
    display: flex;
    min-height: 44px;
    margin: 4px 12px 12px;
    margin-left: auto;
    padding: 6px 10px;
    box-shadow: 0 5px 18px rgb(0 0 0 / 22%);
  }
  #home-messages-shortcut > .icon { width: 19px; height: 19px; }
  .home-messages-label { font-size: 12px; }
  .home-message-avatar { width: 23px; height: 23px; flex-basis: 23px; }
  .home-messages-panel {
    right: 10px;
    bottom: calc(82px + env(safe-area-inset-bottom));
    width: min(366px, calc(100vw - 20px));
    height: min(530px, calc(100dvh - 112px - env(safe-area-inset-bottom)));
  }
  #home-section #feed-list > .suggested-recommendations {
    display: block;
    width: 100%;
    min-width: 0;
    margin: 12px 0 18px;
    padding: 14px 12px 10px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 8px 24px rgb(0 0 0 / 18%);
  }
  #home-section #feed-list > .suggested-recommendations h2 {
    margin: 0;
    font-size: 16px;
    line-height: 1.3;
    letter-spacing: -.015em;
  }
  #home-section #feed-list > .suggested-recommendations .suggested-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 5px;
  }
  #home-section #feed-list > .suggested-recommendations .suggested-heading > button:not(.hidden) {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
  }
  #home-section #feed-list > .suggested-recommendations #suggested-status {
    margin: 0 0 8px;
    color: var(--text-secondary);
    font-size: 12px;
  }
  #home-section #feed-list > .suggested-recommendations .suggested-users {
    gap: 9px;
    margin-inline: -2px;
    padding: 2px 2px 7px;
  }
  #home-section #feed-list > .suggested-recommendations .suggested-user {
    flex-basis: min(78%, 230px);
    min-height: 66px;
    gap: 8px;
    padding: 10px;
    border-radius: 14px;
  }
  #home-section #feed-list > .suggested-recommendations .suggested-user .avatar { width: 40px; height: 40px; }
  #home-section #feed-list > .suggested-recommendations .suggested-user button.primary { min-height: 40px; border-radius: 11px; padding-inline: 11px; }
  #home-section #feed-list > .suggested-recommendations.is-expanded .suggested-users {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    overflow: visible;
    padding-bottom: 2px;
  }
  #home-section #feed-list > .suggested-recommendations.is-expanded .suggested-user { flex: initial; }
}

/* On phones, let Home feed videos keep their native ratio. The frame remains
   in the scrolling feed; it is not fixed or expanded over the application. */
@media (max-width: 600px) {
  #home-section #feed-list .post-media-frame.home-feed-video {
    width: 100%;
    max-width: 100%;
    max-height: none;
    overflow: hidden;
  }
  #home-section #feed-list .post-media-frame.home-feed-video > video.post-media {
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: contain;
  }
}

/* Keep the phone Home feed focused; Messages and Install stay in navigation/More. */
@media (max-width: 768px) {
  .mobile-header-actions .mobile-messages { display: none !important; }
  #home-messages-shortcut,
  #home-messages-panel,
  #home-section #install-notice,
  #home-section .home-account-switch { display: none !important; }
  #home-section #feed-list > .suggested-recommendations.is-empty { display: none !important; }
  .mobile-header-actions .mobile-install-button {
    position: relative;
    display: grid;
    width: 40px;
    min-width: 40px;
    height: 42px;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
    border-radius: 13px;
    background: color-mix(in srgb, var(--accent) 12%, var(--surface));
    color: var(--accent);
  }
  .mobile-header-actions .mobile-install-button .icon { width: 19px; height: 19px; }
  .mobile-header-actions .mobile-install-button:hover,
  .mobile-header-actions .mobile-install-button:focus-visible { background: color-mix(in srgb, var(--accent) 20%, var(--surface)); }
  #more-dialog .more-nav #install-app-button {
    min-height: 48px;
    margin-block: 8px;
    border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
    border-radius: 13px;
    background: color-mix(in srgb, var(--accent) 12%, var(--surface));
    color: var(--accent);
    padding-inline: 12px;
    font-weight: 700;
  }
  #more-dialog .more-nav #install-app-button:hover { background: color-mix(in srgb, var(--accent) 20%, var(--surface)); }
}

/* Inbox receipts and keyboard-safe conversation layout. */
#messages-section .message-receipt-status {
  display: block;
  flex: 0 0 100%;
  margin: 0 4px 1px 0;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  text-align: right;
}
#messages-section .message-row.own .message-receipt-status {
  color: color-mix(in srgb, var(--accent-contrast) 72%, transparent);
}

/* Give Create a clear media-first flow and keep its actions reachable on phones. */
#create-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: min(820px, calc(100dvh - 32px));
  overflow: hidden;
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
  background: var(--surface-elevated);
  padding: 0;
}
#create-form {
  display: grid;
  max-height: min(820px, calc(100dvh - 32px));
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
#create-form > header {
  position: sticky;
  z-index: 5;
  top: 0;
  margin: 0;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-elevated) 94%, transparent);
  padding: 18px 22px;
  backdrop-filter: blur(14px);
}
#create-form > header h2 { font-size: 22px; letter-spacing: -.03em; }
#create-form > .create-options,
#create-form > #create-editor { margin-inline: 22px; }
#create-form > .create-options { margin-top: 20px; }
.create-options button {
  min-height: 104px;
  align-content: center;
  border-color: var(--border);
  background: linear-gradient(145deg, var(--surface), color-mix(in srgb, var(--accent) 5%, var(--surface)));
  font-weight: 650;
  transition: border-color .16s ease, transform .16s ease, background .16s ease;
}
.create-options button .icon {
  width: 24px;
  height: 24px;
  color: var(--accent);
}
.create-options button:hover,
.create-options button:focus-visible {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 58%, var(--border));
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}
#create-editor { gap: 14px; margin-top: 18px; padding-bottom: 22px; }
#create-editor .file-picker {
  gap: 9px;
  border: 1px dashed color-mix(in srgb, var(--accent) 42%, var(--border));
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
  padding: 15px;
  color: var(--text);
  font-weight: 650;
}
#create-file { width: 100%; min-width: 0; color: var(--text-secondary); font: inherit; font-size: 12px; }
#create-file::file-selector-button {
  min-height: 38px;
  margin-right: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-elevated);
  color: var(--text);
  padding: 0 12px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
#create-caption {
  min-height: 112px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface);
  color: var(--text);
  padding: 13px 14px;
  line-height: 1.5;
}
#create-caption:focus-visible { border-color: var(--accent); }
#create-preview { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); max-height: 300px; border-radius: 14px; }
#create-preview img, #create-preview video { aspect-ratio: 4 / 5; max-height: 240px; object-fit: cover; }
#publish-button { min-height: 46px; border-radius: 13px; font-weight: 700; }
@media (max-width: 600px) {
  #create-dialog {
    width: min(calc(100vw - 16px), 520px);
    max-height: min(90dvh, 760px);
    border-radius: 22px;
  }
  #create-form { max-height: min(90dvh, 760px); }
  #create-form > header { padding: 14px 16px; }
  #create-form > .create-options,
  #create-form > #create-editor { margin-inline: 16px; }
  #create-form > .create-options { gap: 8px; margin-top: 14px; }
  .create-options button { min-height: 76px; grid-template-columns: 30px minmax(0, 1fr); justify-items: start; gap: 10px; padding: 12px; text-align: left; }
  .create-options button .icon { width: 20px; height: 20px; }
  #create-editor { gap: 11px; margin-top: 14px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  #create-caption { min-height: 96px; }
}
@media (prefers-reduced-motion: reduce) {
  .create-options button { transition: none; }
}
@media (max-width: 768px) {
  #messages-section .chat-panel.open { height: var(--app-viewport-height, 100dvh); }
  #messages-section .chat-panel.open .conversation,
  #messages-section .chat-panel.open .conversation-empty {
    height: 100%;
    min-height: 0;
  }
  #messages-section .chat-panel.open .conversation {
    grid-template-rows: 64px minmax(0, 1fr) auto auto;
  }
  #messages-section .chat-panel.open #composer-form {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}
@media (min-width: 769px) and (max-width: 950px) {
  #messages-section .chat-panel.open { bottom: env(safe-area-inset-bottom); height: auto; }
  #messages-section .chat-panel.open #composer-form { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}

/* Keep conversation details quiet until requested, while preserving screen-reader access. */
#messages-section .message-row.grouped-before { margin-top: -7px; }
#messages-section .message-footer:has(.message-time) { min-height: 0; }
#messages-section .message-footer .message-time {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  opacity: 0;
  margin: 0;
  transition: opacity var(--motion-fast);
}
#messages-section .message-row .message-time { color: var(--text-secondary); }
#messages-section .message-row.own .message-time { color: color-mix(in srgb, var(--bubble-outgoing-text) 78%, transparent); }
#messages-section .message-row:focus-within .message-time,
#messages-section .message-row.show-message-time .message-time {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip-path: none;
  opacity: 1;
  margin: 0 auto 0 0;
}
@media (min-width: 769px) {
  #messages-section .message-row:hover .message-time {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
    opacity: 1;
    margin: 0 auto 0 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  #messages-section .message-time { transition: none; }
}

/* Use theme surfaces in the composer so its text remains readable in both themes. */
#messages-section .message-composer-bar {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}
#messages-section .message-composer-bar:focus-within {
  border-color: color-mix(in srgb, var(--accent) 68%, var(--border));
  box-shadow: var(--focus-ring);
}
#messages-section .message-composer-controls #message-input { color: var(--text); }
#messages-section .conversation-list .item-preview {
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}
#messages-section .conversation-list .item-time { flex: 0 0 auto; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Distinctive, grouped More menu that keeps native dialog dismissal and focus. */
#more-dialog.more-dialog {
  width: min(380px, calc(100vw - 32px));
  max-height: min(720px, calc(100dvh - 32px));
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  border-radius: 24px;
  background: linear-gradient(155deg, color-mix(in srgb, var(--surface-elevated) 92%, var(--accent) 8%), var(--surface));
  padding: 12px;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
#more-dialog.more-dialog[open] { animation: more-menu-enter 180ms cubic-bezier(.2,.8,.2,1) both; }
#more-dialog.more-dialog::backdrop { background: rgb(0 0 0 / 38%); backdrop-filter: blur(3px); }
#more-dialog .more-dialog-header {
  position: sticky;
  z-index: 2;
  top: -12px;
  display: flex;
  min-height: 66px;
  align-items: center;
  margin: -12px -12px 4px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  padding: 12px 14px 10px;
  backdrop-filter: blur(18px);
}
#more-dialog .more-dialog-header > div { display: grid; gap: 1px; }
#more-dialog .more-dialog-header .eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .14em;
}
#more-dialog .more-dialog-header h2 { margin: 0; font-size: 21px; letter-spacing: -.03em; }
#more-dialog .more-dialog-header .icon-button { width: 40px; min-width: 40px; height: 40px; border-radius: 14px; }
#more-dialog .more-nav { display: grid; gap: 12px; }
#more-dialog .more-group { display: grid; min-width: 0; gap: 6px; }
#more-dialog .more-group > h3 {
  margin: 0 4px 2px;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .11em;
  text-transform: uppercase;
}
#more-dialog .more-shortcuts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
#more-dialog .more-shortcuts > button {
  display: flex;
  min-width: 0;
  min-height: 72px;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  padding: 8px 5px;
  text-align: center;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}
#more-dialog .more-shortcuts > button .icon {
  width: 19px;
  height: 19px;
  color: var(--accent);
}
#more-dialog .more-shortcuts > button span { overflow: hidden; font-size: 11px; font-weight: 650; text-overflow: ellipsis; }
#more-dialog .more-shortcuts > button:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); background: var(--hover); }
#more-dialog .more-install-card {
  display: flex;
  min-width: 0;
  min-height: 70px;
  align-items: center;
  gap: 11px;
  border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--border));
  border-radius: 18px;
  background: linear-gradient(110deg, color-mix(in srgb, var(--accent) 18%, var(--surface)), color-mix(in srgb, var(--accent) 7%, var(--surface)));
  color: var(--text);
  padding: 10px 12px;
  text-align: left;
}
#more-dialog .more-install-icon { display: grid; width: 40px; height: 40px; flex: 0 0 40px; place-items: center; border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 13px; background: color-mix(in srgb, var(--accent) 18%, var(--surface)); color: var(--accent); }
#more-dialog .more-install-icon .icon { width: 20px; height: 20px; }
#more-dialog .more-install-copy { display: grid; min-width: 0; flex: 1; gap: 3px; }
#more-dialog .more-install-copy strong { font-size: 12px; font-weight: 750; }
#more-dialog .more-install-copy small { color: var(--text-secondary); font-size: 10px; line-height: 1.35; }
#more-dialog .more-install-arrow { width: 16px; height: 16px; flex: 0 0 16px; color: var(--accent); }
#more-dialog .more-preferences { gap: 2px; }
#more-dialog .more-preferences .notification-settings { margin-top: 3px; border: 1px solid var(--border); border-radius: 16px; background: color-mix(in srgb, var(--surface) 78%, transparent); padding: 12px; }
#more-dialog .more-preferences .privacy-settings { margin-top: 3px; border: 1px solid var(--border); border-radius: 16px; background: color-mix(in srgb, var(--surface) 78%, transparent); padding: 8px 12px 10px; }
#more-dialog .more-preferences .notification-setting strong { font-size: 12px; }
#more-dialog .more-preferences .notification-setting small { font-size: 10px; }
#more-dialog .privacy-settings .presence-setting { font-size: 12px; }
#more-dialog .privacy-settings .presence-setting > span > .icon { width: 17px; height: 17px; flex: 0 0 17px; color: var(--text-secondary); }
#more-dialog .more-preferences > button:not(.mobile-secondary),
#more-dialog .more-preferences > .more-language,
#more-dialog .more-preferences > .presence-setting {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  margin: 0;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
  background: transparent;
  color: var(--text);
  padding: 4px 8px;
  font-size: 12px;
  text-align: left;
}
#more-dialog .more-preferences > button:not(.mobile-secondary) > .icon,
#more-dialog .more-preferences > .more-language > span > .icon,
#more-dialog .more-preferences > .presence-setting > span > .icon { width: 17px; height: 17px; flex: 0 0 17px; color: var(--text-secondary); }
#more-dialog .more-preferences .more-row-chevron { width: 15px; height: 15px; margin-left: auto; color: var(--text-tertiary); }
#more-dialog .more-language > span,
#more-dialog .presence-setting > span { display: flex; min-width: 0; align-items: center; gap: 10px; }
#more-dialog .more-language select { margin-left: auto; border-color: var(--border); border-radius: 10px; background: var(--surface-secondary); color: var(--text); }
#more-dialog .more-account { padding-top: 4px; border-top: 1px solid var(--border); }
#more-dialog .more-account > button { min-height: 44px; border-radius: 12px; padding: 0 8px; }
#more-dialog .more-account > button .icon { width: 17px; height: 17px; }
@keyframes more-menu-enter { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@media (min-width: 769px) {
  #more-dialog.more-dialog { width: min(380px, calc(100vw - 104px)); }
}
@media (max-width: 768px) {
  #more-dialog.more-dialog {
    position: fixed;
    inset: auto 12px max(10px, env(safe-area-inset-bottom));
    width: auto;
    max-width: 480px;
    max-height: min(78dvh, 620px);
    margin-inline: auto;
    border-radius: 24px;
    padding: 12px;
  }
  #more-dialog .more-dialog-header { top: -12px; }
}
@media (prefers-reduced-motion: reduce) {
  #more-dialog.more-dialog[open] { animation: none; }
  #more-dialog .more-shortcuts > button { transition: none; }
}

/* Present a shared Note as a compact reply context, then keep the reply bubble
   aligned with the sender so the relationship reads clearly in every layout. */
#messages-section .message-row .message.message-note-reply-bubble,
#messages-section .message-row.own .message.message-note-reply-bubble {
  width: fit-content;
  max-width: min(280px, calc(100vw - 76px));
  align-items: flex-start;
  gap: 7px;
}
#messages-section .message-note-reply-bubble .message-note-reply-preview {
  display: grid;
  width: min(240px, 100%);
  height: auto;
  min-height: 60px;
  max-width: 100%;
  flex: 0 1 auto;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  justify-content: initial;
  gap: 10px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #303039;
  border-radius: 15px;
  background: linear-gradient(135deg, #17171d, #101014);
  box-shadow: 0 5px 16px rgb(0 0 0 / 22%);
  text-align: left;
}
#messages-section .message-note-reply-preview::after { display: none; }
#messages-section .message-note-reply-profile {
  position: relative;
  inset: auto;
  width: 38px;
  height: 38px;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 50%;
  background: #24242a;
}
#messages-section .message-note-reply-avatar,
#messages-section .message-note-reply-profile > .message-note-reply-avatar img {
  position: static;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}
#messages-section .message-note-reply-bubble .message-note-reply-text {
  position: static;
  display: -webkit-box;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: #f4f4f5;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  text-align: left;
  text-overflow: ellipsis;
  white-space: normal;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
#messages-section .message-note-reply-bubble .message-note-reply-text:hover { background: transparent; }
#messages-section .message-note-reply-bubble .message-note-reply-text:focus-visible {
  border-radius: 4px;
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
#messages-section .message-note-reply-content {
  align-self: flex-start;
  max-width: min(240px, 100%);
  border-radius: 5px 16px 16px 16px;
  text-align: left;
}
#messages-section .message-row.own .message-note-reply-content {
  align-self: flex-end;
  border-radius: 16px 5px 16px 16px;
  text-align: left;
}
#messages-section .message-note-reply-bubble > .message-footer { align-self: stretch; }
@media (max-width: 768px) {
  #messages-section .message-row .message.message-note-reply-bubble,
  #messages-section .message-row.own .message.message-note-reply-bubble {
    max-width: min(270px, calc(100vw - 70px));
  }
  #messages-section .message-note-reply-bubble .message-note-reply-preview {
    width: min(228px, 100%);
    min-height: 58px;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 9px;
    padding: 8px 9px;
  }
#messages-section .message-note-reply-profile { width: 36px; height: 36px; }
}

/* Keep Story replies in a dedicated footer so they never cover the media. */
#story-viewer {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}
.story-stage { min-height: 0; }
img.story-media {
  object-fit: contain;
  background: #050507;
}
.story-actions {
  position: relative;
  inset: auto;
  min-width: 0;
  margin: 0;
  border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: 0;
  background: var(--surface-elevated);
  padding: 9px 2px max(2px, env(safe-area-inset-bottom));
}
.story-actions .story-reply-form {
  width: min(100%, 250px);
  min-width: 0;
  min-height: 44px;
  flex: 0 1 250px;
  flex-wrap: wrap;
  gap: 0;
  padding: 2px 4px 2px 10px;
  background: var(--surface);
}
.story-actions .story-reply-form input {
  min-height: 34px;
  padding: 5px 4px;
  outline: none;
  box-shadow: none;
}
.story-actions .story-reply-form .story-reply-send {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
}
.story-reply-status:empty { display: none; }
.story-reply-form:focus-within {
  border-color: color-mix(in srgb, var(--text) 66%, var(--border));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--text) 14%, transparent);
}
.story-actions .story-reply-form input:focus-visible {
  outline: none;
  box-shadow: none;
}
.story-actions .story-reply-status,
.story-actions #story-status {
  color: var(--text-secondary);
  text-align: left;
}
/* Use one neutral focus indicator for text fields; keep the accent on controls. */
.app :where(input, textarea, select):focus-visible {
  outline: 2px solid color-mix(in srgb, var(--text) 72%, transparent);
  outline-offset: 2px;
  box-shadow: none;
}
.app #messages-section .message-composer-bar:focus-within,
.app #messages-section .inbox-search-wrap:focus-within {
  border-color: color-mix(in srgb, var(--text) 48%, var(--border));
  box-shadow: none;
}
@media (max-width: 768px) {
  #story-viewer {
    min-height: 0;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    padding-bottom: 0;
  }
  .story-actions { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  .story-actions .story-reply-form { transition: none; }
}

.music-clip-dialog { box-sizing: border-box; width: min(660px, calc(100vw - 32px)); max-height: min(88dvh, 780px); overflow: auto; overscroll-behavior: contain; padding: 0 clamp(20px, 4vw, 30px) 18px; border: 1px solid color-mix(in srgb, #9b8dff 25%, var(--border)); border-radius: 26px; background: radial-gradient(ellipse at 50% -30%, rgb(118 101 255 / 15%), transparent 58%), var(--surface, #111); color: var(--text); box-shadow: 0 28px 90px rgb(0 0 0 / 55%); scrollbar-color: color-mix(in srgb, var(--text) 28%, transparent) transparent; }
.music-clip-dialog::backdrop { background: rgb(0 0 0 / 76%); backdrop-filter: blur(8px); }
.music-clip-dialog > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.music-clip-dialog > .music-clip-sticky-header { position: sticky; z-index: 5; top: 0; margin-inline: calc(clamp(20px, 4vw, 30px) * -1); padding: 17px clamp(20px, 4vw, 30px) 14px; border-bottom: 1px solid color-mix(in srgb, var(--border) 82%, transparent); background: color-mix(in srgb, var(--surface, #111) 93%, transparent); backdrop-filter: blur(18px); }
.music-clip-sticky-header .eyebrow { margin: 0 0 3px; color: #a89cff; font-size: .66rem; font-weight: 750; letter-spacing: .16em; }
.music-clip-dialog > header h2 { margin: 0; font-size: clamp(1.25rem, 3vw, 1.55rem); letter-spacing: -.025em; }
.music-clip-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 17px 0 11px; padding: 0; list-style: none; counter-reset: clip-step; }
.music-clip-steps li { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--text-secondary); font-size: .78rem; line-height: 1.25; }
.music-clip-steps li::before { display: grid; width: 23px; height: 23px; flex: 0 0 23px; place-items: center; border: 1px solid var(--border); border-radius: 50%; color: var(--text-secondary); content: counter(clip-step); counter-increment: clip-step; font-size: .7rem; }
.music-clip-steps[data-stage="select"] li:nth-child(-n+2), .music-clip-steps[data-stage="preview"] li:nth-child(-n+2), .music-clip-steps[data-stage="use"] li { color: var(--text); }
.music-clip-steps[data-stage="select"] li:nth-child(-n+2)::before, .music-clip-steps[data-stage="preview"] li:nth-child(-n+2)::before, .music-clip-steps[data-stage="use"] li::before { border-color: #7665ff; background: #7665ff; color: #fff; box-shadow: 0 0 0 4px rgb(118 101 255 / 12%); }
.music-clip-instructions { margin: 0 0 16px; color: var(--text-secondary); font-size: .91rem; line-height: 1.5; }
.music-clip-source-card { margin-bottom: 17px; padding: 14px 16px 11px; border: 1px solid color-mix(in srgb, var(--border) 78%, transparent); border-radius: 20px; background: linear-gradient(135deg, color-mix(in srgb, var(--text) 7%, transparent), color-mix(in srgb, #7665ff 7%, transparent)); }
.music-clip-source-top { display: flex; align-items: center; gap: 11px; }
.music-clip-source-top::before { display: grid; width: 42px; height: 42px; flex: 0 0 42px; place-items: center; border: 1px solid rgb(255 255 255 / 12%); border-radius: 13px; background: linear-gradient(145deg, #9b67ff, #ed5b9b); color: #fff; content: "♫"; font-family: Georgia, serif; font-size: 24px; box-shadow: 0 7px 20px rgb(118 101 255 / 25%); }
.music-clip-dialog .music-clip-file-picker { position: relative; display: inline-flex; order: 2; flex: 0 0 auto; align-items: center; justify-content: center; min-height: 38px; margin: 0 0 0 auto; padding: 0 12px; overflow: hidden; border: 1px solid color-mix(in srgb, #9b8dff 35%, var(--border)); border-radius: 999px; background: color-mix(in srgb, #7665ff 12%, transparent); color: var(--text); cursor: pointer; font-size: .83rem; font-weight: 700; transition: background .18s ease, border-color .18s ease, transform .18s ease; }
.music-clip-file-picker:hover { border-color: #9b8dff; background: color-mix(in srgb, #7665ff 20%, transparent); }
.music-clip-file-picker:active { transform: scale(.98); }
.music-clip-file-picker input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.music-clip-file-picker:focus-within { outline: 2px solid #b4aaff; outline-offset: 3px; }
.music-clip-source-meta { display: grid; order: 1; flex: 1 1 auto; justify-items: start; gap: 3px; min-width: 0; margin: 0; color: var(--text-secondary); font-size: .78rem; }
.music-clip-source-meta strong { max-width: 100%; overflow: hidden; color: var(--text); font-size: .88rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.music-clip-source-meta span { font-variant-numeric: tabular-nums; font-size: .74rem; }
.music-clip-dialog > .music-clip-source-card audio { display: block; width: 100%; height: 42px; margin: 11px 0 0; border-radius: 999px; color-scheme: dark; accent-color: #9b8dff; }
.music-clip-source-player { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 48px; margin-top: 11px; padding: 4px 12px 4px 5px; border: 1px solid rgb(255 255 255 / 8%); border-radius: 999px; background: linear-gradient(110deg, #3b3b3b, #292929); color: #fff; }
.music-clip-source-toggle { display: grid; width: 38px; height: 38px !important; min-height: 38px !important; place-items: center; border: 0 !important; border-radius: 50%; background: linear-gradient(145deg, #8b73ff, #6255df) !important; color: #fff; font-family: Arial, sans-serif; font-size: 15px; cursor: pointer; box-shadow: 0 4px 14px rgb(118 101 255 / 30%); }
.music-clip-source-toggle:hover, .music-clip-source-toggle:focus-visible { filter: brightness(1.12); outline: 2px solid rgb(255 255 255 / 80%); outline-offset: 2px; }
.music-clip-source-player > span { overflow: hidden; color: rgb(255 255 255 / 78%); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.music-clip-source-player time { color: #fff; font-variant-numeric: tabular-nums; font-size: .72rem; white-space: nowrap; }
.music-clip-dialog > .music-clip-source-card audio { display: none; }
.music-clip-editor { display: grid; gap: 17px; padding: clamp(17px, 3vw, 23px); border: 1px solid color-mix(in srgb, #9b8dff 33%, var(--border)); border-radius: 22px; background: linear-gradient(145deg, color-mix(in srgb, #7665ff 13%, var(--surface)), color-mix(in srgb, var(--surface) 95%, #18152b)); box-shadow: inset 0 1px rgb(255 255 255 / 4%), 0 12px 30px rgb(0 0 0 / 13%); }
.music-clip-editor-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.music-clip-editor-heading strong { font-size: 1rem; letter-spacing: -.01em; }
.music-clip-limit-badge { flex: 0 0 auto; padding: 6px 10px; border: 1px solid color-mix(in srgb, #a89cff 52%, var(--border)); border-radius: 999px; background: rgb(118 101 255 / 9%); color: var(--text); font-size: .74rem; font-weight: 700; }
.music-clip-timeline { --clip-start: 0%; --clip-end: 10%; position: relative; min-height: 76px; touch-action: none; overflow: visible; border: 1px solid color-mix(in srgb, #9b8dff 42%, var(--border)); border-radius: 17px; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgb(255 255 255 / 7%) calc(10% - 1px) 10%), linear-gradient(180deg, rgb(255 255 255 / 4%), rgb(0 0 0 / 12%)); cursor: crosshair; }
.music-clip-timeline::after { position: absolute; z-index: 0; inset: 14px 9px; border-radius: 8px; background: repeating-linear-gradient(90deg, rgb(221 215 255 / 55%) 0 2px, transparent 2px 7px); opacity: .42; -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 24%, #000 78%, transparent 100%); mask-image: linear-gradient(180deg, transparent 0%, #000 24%, #000 78%, transparent 100%); content: ""; pointer-events: none; }
.music-clip-timeline::before { position: absolute; inset: 33px 0 auto; height: 2px; background: rgb(255 255 255 / 17%); content: ""; }
.music-clip-selection-visual { position: absolute; z-index: 1; inset-block: 5px; left: var(--clip-start); width: max(12px, calc(var(--clip-end) - var(--clip-start))); border: 1px solid #c4bbff; border-radius: 12px; background: linear-gradient(100deg, rgb(117 100 255 / 43%), rgb(175 111 255 / 31%)); box-shadow: 0 0 24px rgb(118 101 255 / 24%), inset 0 0 18px rgb(255 255 255 / 10%); cursor: grab; }
.music-clip-selection-visual:active { cursor: grabbing; }
.music-clip-handle { position: absolute; z-index: 2; top: 50%; width: 22px; height: 46px !important; min-height: 46px !important; padding: 0; border: 2px solid #fff !important; border-radius: 9px; background: linear-gradient(180deg, #a79aff, #705cff) !important; box-shadow: 0 3px 12px rgb(0 0 0 / 48%), 0 0 0 3px rgb(118 101 255 / 16%); transform: translate(-50%, -50%); touch-action: none; cursor: ew-resize; }
.music-clip-handle::after { display: block; width: 3px; height: 17px; margin: auto; border-inline: 1px solid rgb(255 255 255 / 70%); content: ""; }
.music-clip-handle-start { left: var(--clip-start); }
.music-clip-handle-end { left: var(--clip-end); }
.music-clip-handle:focus-visible { outline: 3px solid #d0caff; outline-offset: 4px; }
.music-clip-time-readout { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 3px; }
.music-clip-time-readout > span { display: inline-flex; align-items: baseline; gap: 7px; color: var(--text-secondary); font-size: .76rem; }
.music-clip-time-readout small { color: var(--text-tertiary); font-size: .7rem; }
.music-clip-time-readout time { color: var(--text); font-variant-numeric: tabular-nums; font-size: .84rem; font-weight: 700; }
.music-clip-preview-row { display: flex; align-items: center; gap: 10px; color: var(--text-secondary); font-size: .76rem; }
.music-clip-preview-button { min-height: 38px !important; padding: 0 12px; border: 1px solid var(--border) !important; border-radius: 999px; background: var(--surface-secondary) !important; color: var(--text) !important; font: inherit; font-size: .8rem; font-weight: 650; cursor: pointer; }
.music-clip-preview-button:hover:not(:disabled), .music-clip-preview-button:focus-visible { border-color: #9b8dff !important; background: color-mix(in srgb, #7665ff 15%, var(--surface-secondary)) !important; }
.music-clip-preview-button:disabled { opacity: .5; cursor: not-allowed; }
.music-clip-dialog > .music-clip-sticky-footer { position: sticky; z-index: 5; bottom: 0; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 11px; margin: 14px calc(clamp(20px, 4vw, 30px) * -1) 0; padding: 13px clamp(20px, 4vw, 30px) max(14px, env(safe-area-inset-bottom)); border-top: 1px solid color-mix(in srgb, var(--border) 82%, transparent); background: color-mix(in srgb, var(--surface, #111) 94%, transparent); backdrop-filter: blur(18px); }
.music-clip-dialog button { min-height: 44px; }
.story-audio { position: relative; z-index: 3; width: min(100%, 420px); margin: auto; }
.story-audio-status { position: relative; z-index: 3; margin: 8px auto; color: #fff; text-align: center; }
.story-music-card { position: absolute; z-index: 4; right: 14px; bottom: 12px; left: 14px; display: grid; gap: 7px; max-width: 520px; margin-inline: auto; padding: 11px 13px 9px; border: 1px solid rgb(255 255 255 / 20%); border-radius: 16px; background: rgb(14 13 20 / 78%); color: #fff; box-shadow: 0 10px 34px rgb(0 0 0 / 32%); backdrop-filter: blur(18px); }
.story-music-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.story-music-heading strong { overflow: hidden; font-size: .86rem; text-overflow: ellipsis; white-space: nowrap; }
.story-music-heading small { flex: 0 0 auto; color: rgb(255 255 255 / 70%); font-variant-numeric: tabular-nums; font-size: .72rem; }
.story-music-audio { display: block; width: 100%; height: 40px; border-radius: 999px; color-scheme: dark; accent-color: #a89cff; }
.story-music-status { color: rgb(255 255 255 / 84%); font-size: .78rem; }
.story-caption-with-music { bottom: 138px; }
.create-music-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.create-music-preview { display: grid; gap: 8px; margin-block: 9px 14px; padding: 11px 13px; border: 1px solid color-mix(in srgb, #9b8dff 35%, var(--border)); border-radius: 15px; background: linear-gradient(130deg, color-mix(in srgb, #7665ff 12%, var(--surface)), var(--surface)); }
.create-music-preview-track { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.create-music-preview-track strong { overflow: hidden; font-size: .86rem; text-overflow: ellipsis; white-space: nowrap; }
.create-music-preview-track small { flex: 0 0 auto; color: var(--text-secondary); font-size: .74rem; }
.create-music-preview audio { width: 100%; height: 40px; border-radius: 999px; color-scheme: dark; accent-color: #9b8dff; }
@media (max-width: 720px) {
  .music-clip-dialog { position: fixed; inset: auto 0 0; width: min(100vw, 620px); max-height: min(90dvh, 760px); margin-inline: auto; padding: 0 20px 10px; border-radius: 24px 24px 0 0; }
  .music-clip-dialog > .music-clip-sticky-header { margin-inline: -20px; padding-inline: 20px; }
  .music-clip-dialog > .music-clip-sticky-footer { display: flex; justify-content: stretch; margin-inline: -20px; padding-inline: 20px; }
  .music-clip-dialog > .music-clip-sticky-footer button { width: 100%; min-width: 0; padding-inline: 8px; font-size: .88rem; }
}
@media (max-width: 480px) {
  .music-clip-dialog { width: 100vw; max-width: 100vw; max-height: min(92dvh, 760px); padding-inline: 15px; border-inline: 0; border-bottom: 0; border-radius: 22px 22px 0 0; }
  .music-clip-dialog > .music-clip-sticky-header { margin-inline: -15px; padding: 13px 15px 11px; }
  .music-clip-dialog > .music-clip-sticky-footer { margin-inline: -15px; padding-inline: 15px; }
  .music-clip-dialog > .music-clip-sticky-footer #music-clip-use { width: 100%; }
  .music-clip-steps { gap: 5px; margin: 13px 0 9px; }
  .music-clip-steps li { gap: 5px; font-size: .69rem; }
  .music-clip-steps li::before { width: 20px; height: 20px; flex-basis: 20px; }
  .music-clip-instructions { margin-bottom: 12px; font-size: .84rem; }
  .music-clip-source-card { padding: 11px; border-radius: 15px; }
  .music-clip-source-top { align-items: flex-start; }
  .music-clip-dialog .music-clip-file-picker { min-height: 38px; padding-inline: 10px; font-size: .76rem; }
  .music-clip-source-meta strong { font-size: .78rem; }
  .music-clip-source-meta span { font-size: .69rem; }
  .music-clip-editor { gap: 13px; padding: 13px; border-radius: 17px; }
  .music-clip-editor-heading strong { font-size: .91rem; }
  .music-clip-limit-badge { padding: 5px 8px; font-size: .68rem; }
  .music-clip-timeline { min-height: 64px; }
  .music-clip-timeline::before { top: 30px; }
  .music-clip-handle { width: 21px; height: 42px !important; min-height: 42px !important; }
  .music-clip-time-readout { gap: 8px; }
  .music-clip-preview-row { align-items: flex-start; flex-direction: column; gap: 7px; }
  .music-clip-preview-button { width: 100%; }
}
@media (max-width: 600px) {
  .note-compose-dialog { position: fixed; inset: auto 0 0; width: 100vw; max-width: 100vw; max-height: min(91dvh, 760px); margin: 0 auto; padding: 16px 16px max(14px, env(safe-area-inset-bottom)); border-inline: 0; border-bottom: 0; border-radius: 24px 24px 0 0; }
  .note-compose-dialog > form { gap: 12px; }
  .note-compose-field textarea#note-content { min-height: 86px; font-size: .92rem; }
  .note-compose-dialog .note-form-actions > .primary { width: 100%; }
  .music-clip-source-player { grid-template-columns: 36px minmax(0, 1fr) auto; gap: 7px; min-height: 46px; padding-right: 9px; }
  .music-clip-source-toggle { width: 36px; height: 36px !important; min-height: 36px !important; }
  .music-clip-source-player > span { font-size: .7rem; }
  .music-clip-source-player time { font-size: .66rem; }
  .story-music-card { right: 8px; bottom: 8px; left: 8px; gap: 5px; padding: 9px 10px 7px; border-radius: 13px; }
  .story-music-heading strong { font-size: .78rem; }
  .story-music-audio { height: 38px; }
  .story-caption-with-music { bottom: 126px; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .music-clip-dialog { max-height: 96dvh; }
  .music-clip-steps { margin-block: 10px 7px; }
  .music-clip-instructions { margin-bottom: 9px; }
  .music-clip-editor { gap: 9px; padding: 11px; }
  .music-clip-timeline { min-height: 50px; }
  .music-clip-timeline::before { top: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .music-clip-file-picker { transition: none; }
}

/* Story soundtrack follows the compact title row used by story viewers. */
#story-viewer { grid-template-rows: minmax(0, 1fr) auto; gap: 0; padding: 0; }
.story-stage { position: relative; width: 100%; height: 100%; border: 0; border-radius: 0; background: #08080b; }
.story-progress { position: absolute; z-index: 7; top: max(12px, env(safe-area-inset-top)); right: 14px; left: 14px; }
.story-author { position: absolute; z-index: 7; top: max(23px, calc(env(safe-area-inset-top) + 11px)); right: 0; left: 0; min-height: 46px; padding: 5px 56px 5px 14px; color: #fff; text-shadow: 0 1px 6px rgb(0 0 0 / 72%); }
.story-author .avatar { flex: 0 0 36px; }
.story-identity { text-align: left; }
.story-identity strong { overflow: hidden; color: #fff; text-overflow: ellipsis; white-space: nowrap; }
.story-identity small { color: rgb(255 255 255 / 75%); }
.story-sound-toggle { width: 34px; height: 34px; min-height: 34px; flex: 0 0 34px; margin-left: auto; border: 0; border-radius: 50%; background: rgb(0 0 0 / 24%); color: #fff; }
.story-sound-toggle:hover, .story-sound-toggle:focus-visible { background: rgb(0 0 0 / 52%); outline: 2px solid #fff; outline-offset: 2px; }
.story-sound-toggle .icon { width: 20px; height: 20px; }
.story-actions { z-index: 8; min-height: 62px; align-items: center; justify-content: flex-start; gap: 10px; padding: 8px 12px max(10px, env(safe-area-inset-bottom)); border: 0; border-radius: 0; background: #111113; }
.story-actions .story-reply-form { flex: 1 1 150px; width: auto; max-width: none; }
.story-actions .story-like-button, .story-actions .story-share-button { flex: 0 0 42px; }
.story-caption-with-music { bottom: 18px; }
.story-music-track { display: flex; width: fit-content; max-width: min(100%, 280px); align-items: center; gap: 6px; margin-top: 2px; padding: 0; overflow: hidden; border: 0; background: transparent; color: #fff; text-align: left; cursor: pointer; }
.story-music-toggle { display: grid; width: 17px; height: 17px; flex: 0 0 17px; place-items: center; color: #fff; font: 700 13px/1 system-ui, sans-serif; }
.story-music-title { overflow: hidden; color: rgb(255 255 255 / 96%); font: 600 11px/1.3 system-ui, sans-serif; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 1px 5px rgb(0 0 0 / 72%); }
.story-music-track:focus-visible { outline: 2px solid #fff; outline-offset: 3px; border-radius: 4px; }
.story-music-track.unavailable { cursor: default; opacity: .82; }
.story-song-actions { position: absolute; z-index: 16; top: max(82px, calc(env(safe-area-inset-top) + 68px)); left: 14px; display: grid; width: min(330px, calc(100% - 28px)); gap: 12px; padding: 15px; border: 1px solid rgb(255 255 255 / 22%); border-radius: 17px; background: rgb(17 17 22 / 92%); color: #fff; box-shadow: 0 16px 44px rgb(0 0 0 / 42%); text-shadow: none; backdrop-filter: blur(20px); }
.story-song-actions.hidden { display: none; }
.story-song-details { display: flex; min-width: 0; align-items: center; gap: 11px; padding: 3px 24px 3px 1px; }
.story-song-icon { display: grid; width: 38px; height: 38px; flex: 0 0 38px; place-items: center; border: 1px solid rgb(255 255 255 / 14%); border-radius: 12px; background: linear-gradient(145deg, #927aff, #5645c8); }
.story-song-icon .icon { width: 18px; height: 18px; }
.story-song-copy { display: grid; min-width: 0; gap: 4px; }
.story-song-copy strong { overflow: hidden; font-size: .92rem; text-overflow: ellipsis; white-space: nowrap; }
.story-song-copy small { color: rgb(255 255 255 / 70%); font-size: .75rem; }
.story-song-close { position: absolute; top: 7px; right: 8px; display: grid; width: 34px; height: 34px; place-items: center; border: 0; border-radius: 50%; background: transparent; color: #fff; font-size: 24px; cursor: pointer; }
.story-song-close:hover, .story-song-close:focus-visible { background: rgb(255 255 255 / 12%); outline: 2px solid #fff; outline-offset: 1px; }
.story-use-song { min-height: 44px; }
.story-song-actions :focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.story-music-status { display: block; max-width: min(100%, 280px); overflow: hidden; color: rgb(255 255 255 / 78%); font: 500 10px/1.3 system-ui, sans-serif; text-overflow: ellipsis; }
.story-music-audio { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.story-stage > video.story-media { object-fit: contain; background: #050507; }
.music-clip-processing { display: grid; gap: 8px; padding: 10px 12px; border: 1px solid color-mix(in srgb, #9b8dff 30%, var(--border)); border-radius: 13px; background: color-mix(in srgb, #7665ff 9%, var(--surface)); }
.music-clip-processing > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--text-secondary); font-size: .78rem; }
.music-clip-processing > div strong { color: var(--text); font-variant-numeric: tabular-nums; font-size: .75rem; }
.music-clip-processing progress { width: 100%; height: 6px; overflow: hidden; border: 0; border-radius: 99px; background: color-mix(in srgb, var(--text) 13%, transparent); accent-color: #7665ff; }
.music-clip-processing progress::-webkit-progress-bar { border-radius: 99px; background: color-mix(in srgb, var(--text) 13%, transparent); }
.music-clip-processing progress::-webkit-progress-value { border-radius: 99px; background: linear-gradient(90deg, #7665ff, #dc65b8); transition: width .18s linear; }
.music-clip-processing progress::-moz-progress-bar { border-radius: 99px; background: linear-gradient(90deg, #7665ff, #dc65b8); }
@media (min-width: 769px) {
  #story-dialog { width: min(440px, calc(100vw - 48px)); height: min(880px, calc(100dvh - 32px)); max-height: none; }
  #story-viewer { height: 100%; min-height: 0; grid-template-rows: minmax(0, 1fr) auto; gap: 0; padding: 0; }
  .story-stage { height: 100%; min-height: 0; border-radius: 15px 15px 0 0; background: #050507; }
  .story-stage > .story-media { width: 100%; height: 100%; max-height: 100%; object-fit: contain; background: #050507; }
  .story-music-track { max-width: 320px; }
  .story-song-actions { top: max(82px, calc(env(safe-area-inset-top) + 68px)); left: 9px; width: min(340px, calc(100% - 18px)); }
}
@media (max-width: 768px) {
  #story-viewer { grid-template-rows: minmax(0, 1fr) auto; gap: 0; padding: 0; }
  .story-stage { border-radius: 0; }
  .story-author { padding-left: 14px; }
  .story-actions { min-height: 58px; padding-right: 10px; padding-left: 10px; }
}

/* Final Story viewer overrides: portrait sizing and Instagram-style identity. */
@media (min-width: 769px) {
  #story-dialog {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
}
#story-dialog::backdrop { background: rgb(10 10 15 / 94%); }
#story-dialog > .icon-button {
  position: absolute;
  z-index: 30;
  top: max(18px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  color: #fff;
  background: rgb(255 255 255 / 8%);
}
#story-dialog > .icon-button:hover { background: rgb(255 255 255 / 16%); }
#story-viewer {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(480px, 53dvh, calc(100vw - 48px));
  height: auto;
  max-height: calc(100dvh - 32px);
  aspect-ratio: 9 / 16;
  display: block;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  transform: translate(-50%, -50%);
  border: 1px solid color-mix(in srgb, var(--border) 70%, #fff 12%);
  border-radius: 18px;
  background: var(--surface-elevated);
  box-shadow: 0 24px 90px rgb(0 0 0 / 48%), 0 0 0 1px rgb(255 255 255 / 5%);
}
#story-viewer > .story-progress { position: absolute; z-index: 12; top: max(12px, env(safe-area-inset-top)); right: 14px; left: 14px; }
#story-viewer .story-progress span.current::before { background: var(--gradient-story); }
.story-author {
  position: absolute;
  z-index: 11;
  top: max(24px, calc(env(safe-area-inset-top) + 20px));
  right: 12px;
  left: 12px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 34px 34px 34px;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 5px;
  row-gap: 1px;
  min-width: 0;
  min-height: 46px;
  padding: 4px 4px 4px 3px;
  color: #fff;
  text-shadow: 0 1px 6px rgb(0 0 0 / 60%);
}
.story-profile-link {
  display: flex;
  grid-column: 1 / 3;
  grid-row: 1;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.story-profile-link > .avatar { width: 36px; height: 36px; flex: 0 0 36px; }
.story-author .avatar { border: 1px solid rgb(255 255 255 / 45%); }
.story-profile-link:focus-visible { border-radius: 8px; outline: 2px solid #fff; outline-offset: 3px; }
.story-identity { display: grid; gap: 1px; min-width: 0; text-align: left; }
.story-identity-heading { display: flex; min-width: 0; align-items: baseline; gap: 7px; }
.story-identity strong { min-width: 0; flex: 0 1 auto; overflow: hidden; color: #fff; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.story-identity small { flex: 0 0 auto; overflow: hidden; color: rgb(255 255 255 / 74%); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.story-music-track {
  position: absolute;
  top: 42px;
  right: 112px;
  left: 48px;
  width: auto;
  max-width: none;
  margin: 0;
  justify-content: flex-start;
}
.story-music-toggle .icon { width: 13px; height: 13px; color: var(--accent); }
.story-music-status { position: absolute; top: 61px; right: 112px; left: 48px; max-width: none; margin: 0; }
.story-control-button {
  display: grid;
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 22%);
  color: #fff;
  cursor: pointer;
}
.story-control-button:hover, .story-control-button:focus-visible { background: rgb(0 0 0 / 55%); outline: 2px solid #fff; outline-offset: 2px; }
.story-control-button .icon { width: 18px; height: 18px; }
.story-sound-toggle {
  grid-column: 3;
  grid-row: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease, background-color .16s ease;
}
.story-pause-toggle { grid-column: 4; grid-row: 1; }
.story-more-wrap { position: relative; grid-column: 5; grid-row: 1; }
.story-more-toggle { background: transparent; }
.story-more-menu {
  position: absolute;
  z-index: 20;
  top: 42px;
  right: 0;
  display: grid;
  min-width: 176px;
  gap: 3px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-elevated);
  color: var(--text);
  box-shadow: 0 12px 32px rgb(0 0 0 / 32%);
  text-shadow: none;
}
.story-more-menu button { min-height: 40px; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.story-more-menu button:hover, .story-more-menu button:focus-visible { background: var(--hover); outline: 0; }
#story-dialog:hover .story-sound-toggle,
#story-dialog:focus-within .story-sound-toggle,
.story-sound-toggle:focus-visible { opacity: 1; pointer-events: auto; }
.story-stage {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border: 0;
  border-radius: inherit;
  background: #101019;
}
.story-stage > .story-media { display: block; width: 100%; height: 100%; max-height: none; margin: 0; object-fit: contain; background: #08080c; }
.story-stage > img.story-media { object-fit: cover; }
.story-stage > .story-audio { position: absolute; z-index: 4; right: 18px; bottom: 102px; left: 18px; width: calc(100% - 36px); }
.story-actions {
  position: absolute;
  z-index: 8;
  right: 0;
  bottom: 0;
  left: 0;
  min-height: 74px;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 12px 16px max(14px, env(safe-area-inset-bottom));
  border: 0;
  border-radius: 0;
  background: linear-gradient(180deg, transparent, rgb(5 5 10 / 70%));
}
.story-actions .story-reply-form { flex: 1 1 150px; width: auto; max-width: none; background: rgb(20 20 28 / 32%); backdrop-filter: blur(10px); }
.story-caption { z-index: 5; bottom: 90px; }
.story-caption-with-music { bottom: 90px; }
.story-step { z-index: 9; border-color: transparent; background: rgb(20 20 28 / 24%); color: #fff; opacity: 0; transition: opacity .16s ease, background-color .16s ease; }
#story-dialog:hover .story-step, #story-dialog:focus-within .story-step { opacity: 1; }
.story-step:hover, .story-step:focus-visible { background: rgb(20 20 28 / 72%); }
.story-neighbor-layout { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.story-neighbor-rail { position: absolute; top: 50%; display: flex; width: 250px; align-items: center; gap: 12px; transform: translateY(-50%); pointer-events: auto; }
.story-neighbor-rail-previous { left: calc(50% - min(240px, 26.5dvh, calc(50vw - 24px)) - 268px); justify-content: flex-end; }
.story-neighbor-rail-next { left: calc(50% + min(240px, 26.5dvh, calc(50vw - 24px)) + 18px); justify-content: flex-start; }
.story-neighbor-card {
  position: relative;
  width: 112px;
  height: min(250px, 34dvh);
  flex: 0 1 112px;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 11%);
  border-radius: 13px;
  background: var(--surface-elevated);
  box-shadow: 0 12px 35px rgb(0 0 0 / 27%);
  color: #fff;
  cursor: pointer;
  opacity: .82;
  transition: opacity .18s ease, transform .18s ease, border-color .18s ease;
}
.story-neighbor-card:hover, .story-neighbor-card:focus-visible { z-index: 2; border-color: color-mix(in srgb, var(--accent) 66%, #fff); opacity: 1; outline: 2px solid color-mix(in srgb, var(--accent) 70%, #fff); outline-offset: 2px; transform: scale(1.035); }
.story-neighbor-art { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 80%, #111), color-mix(in srgb, #22b8aa 65%, #111)); }
.story-neighbor-art > img { width: 100%; height: 100%; object-fit: cover; }
.story-neighbor-art-brand > span:first-child { color: rgb(255 255 255 / 86%); font-size: 44px; font-weight: 800; }
.story-neighbor-shade { position: absolute; inset: 35% 0 0; background: linear-gradient(transparent, rgb(0 0 0 / 73%)); }
.story-neighbor-identity { position: absolute; right: 8px; bottom: 10px; left: 8px; display: grid; justify-items: center; gap: 5px; text-align: center; text-shadow: 0 1px 4px #000; }
.story-neighbor-identity .avatar { width: 42px; height: 42px; border: 2px solid #fff; box-shadow: 0 2px 12px rgb(0 0 0 / 30%); }
.story-neighbor-identity strong { max-width: 100%; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.story-neighbor-identity small { color: rgb(255 255 255 / 75%); font-size: 10px; }
@media (max-width: 1099px) {
  .story-neighbor-layout { display: none; }
}
@media (hover: none), (max-width: 768px) {
  .story-sound-toggle { opacity: 1; pointer-events: auto; }
}
@media (max-width: 768px) {
  #story-dialog { width: 100vw; height: var(--story-viewport-height, 100dvh); max-height: var(--story-viewport-height, 100dvh); }
  #story-viewer { inset: 0; width: 100vw; height: var(--story-viewport-height, 100dvh); max-height: var(--story-viewport-height, 100dvh); aspect-ratio: auto; transform: none; border: 0; border-radius: 0; }
  .story-author { right: 50px; left: 12px; grid-template-columns: 36px minmax(0, 1fr) 34px 34px 34px; column-gap: 4px; }
  .story-actions { min-height: 68px; padding-inline: 12px; }
  .story-neighbor-layout { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  .story-sound-toggle { transition: none; }
}

/* Compact Video Note recording and review cards inside the DM composer. */
#messages-section .message-composer-bar.video-note-active {
  min-height: 0;
  justify-content: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  box-shadow: none;
}
#messages-section .video-note-capture-panel {
  display: grid;
  width: min(100%, 520px);
  min-width: 0;
  flex: 1 1 100%;
  grid-template-columns: minmax(112px, 176px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 12px;
  margin-inline: auto;
  padding: 10px;
  border: 1px solid var(--border, #303038);
  border-radius: 18px;
  background: var(--surface-elevated, var(--surface, #111114));
  box-shadow: 0 10px 28px rgb(0 0 0 / 28%);
}
#messages-section .video-note-capture-panel.hidden { display: none; }
#messages-section .video-note-capture-panel > video {
  display: block;
  width: 100%;
  min-width: 0;
  max-height: 112px;
  grid-column: 1;
  grid-row: 1 / span 2;
  aspect-ratio: 16 / 10;
  border-radius: 12px;
  background: #050505;
  object-fit: cover;
}
#messages-section .video-note-preview-panel > video { object-fit: contain; }
#messages-section #video-note-live-preview { transform: scaleX(-1); }
#messages-section .video-note-capture-details,
#messages-section .video-note-preview-details {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text, #f4f4f5);
  font-size: 12px;
  font-weight: 600;
}
#messages-section .video-note-state { display: inline-flex; min-width: 0; align-items: center; gap: 8px; }
#messages-section .video-note-state > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#messages-section .video-note-state > i {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 4px rgb(239 68 68 / 14%);
  animation: video-note-recording-pulse 1.4s ease-in-out infinite;
}
#messages-section #video-note-recording-time,
#messages-section #video-note-preview-time {
  flex: 0 0 auto;
  color: var(--text-secondary, #e4e4e7);
  font-variant-numeric: tabular-nums;
}
#messages-section .video-note-capture-actions,
#messages-section .video-note-preview-actions {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}
#messages-section .video-note-preview-actions { flex-wrap: nowrap; }
#messages-section .video-note-action {
  display: inline-flex;
  width: auto;
  min-width: 40px;
  min-height: 40px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid var(--border, #3f3f46);
  border-radius: 12px;
  background: var(--surface-secondary, #1b1b20);
  color: var(--text, #f4f4f5);
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
}
#messages-section .video-note-action .icon { width: 17px; height: 17px; flex: 0 0 17px; }
#messages-section .video-note-action > span { flex: 0 0 auto; white-space: nowrap; }
#messages-section .video-note-action:hover:not(:disabled) { border-color: #71717a; background: #27272a; }
#messages-section .video-note-action:focus-visible { outline: 2px solid #8b7cff; outline-offset: 2px; }
#messages-section .video-note-action.video-note-send-action {
  width: max-content;
  min-width: max-content;
  flex: 0 0 auto;
  border-color: transparent;
  background: var(--accent, #645bff);
  color: #fff;
  font-weight: 700;
}
#messages-section .video-note-action.video-note-send-action:hover:not(:disabled) { filter: brightness(1.12); }
@keyframes video-note-recording-pulse {
  50% { box-shadow: 0 0 0 7px rgb(239 68 68 / 7%); opacity: .72; }
}
@media (max-width: 520px) {
  #messages-section .video-note-capture-panel {
    width: 100%;
    grid-template-columns: minmax(86px, 34vw) minmax(0, 1fr);
    gap: 8px 10px;
    padding: 9px;
    border-radius: 16px;
  }
  #messages-section .video-note-capture-panel > video { max-height: 100px; border-radius: 10px; }
  #messages-section .video-note-action { min-height: 42px; padding-inline: 8px; font-size: 11px; }
  #messages-section .video-note-preview-panel {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
  }
  #messages-section .video-note-preview-panel > video {
    max-height: 132px;
    grid-column: 1;
    grid-row: 1;
    aspect-ratio: 16 / 9;
  }
  #messages-section .video-note-preview-details { grid-column: 1; grid-row: 2; }
  #messages-section .video-note-preview-actions {
    display: grid;
    grid-column: 1;
    grid-row: 3;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    width: 100%;
  }
  #messages-section .video-note-preview-actions .video-note-send-action {
    width: 100%;
    min-width: 0;
    grid-column: 1 / -1;
  }
}
@media (prefers-reduced-motion: reduce) {
  #messages-section .video-note-state > i { animation: none; }
}

/* Media-first Story composer. Existing upload and publish handlers stay in place. */
#create-dialog.create-editor-open {
  width: min(1040px, calc(100vw - 40px));
  max-height: min(860px, calc(100dvh - 36px));
  border-radius: 22px;
}
#create-form {
  display: grid;
  max-height: min(860px, calc(100dvh - 36px));
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
}
#create-form > header { flex: 0 0 auto; }
#create-form > .create-options { min-height: 0; }
#create-form > #create-editor {
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
}
.create-editor-body {
  display: grid;
  min-height: 0;
  grid-template-columns: minmax(170px, .85fr) minmax(260px, 1.2fr) minmax(220px, .95fr);
  align-items: stretch;
  gap: 20px;
  overflow-y: auto;
  padding: 20px 24px;
}
#create-editor:not(.story-composer-active) .create-editor-body {
  grid-template-columns: minmax(280px, 1.15fr) minmax(280px, 1.15fr);
  max-width: 860px;
  margin: 0 auto;
}
.create-story-assets { display: grid; min-width: 0; align-content: start; gap: 14px; }
.create-dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  padding: 22px 14px;
  border: 2px dashed color-mix(in srgb, var(--accent) 50%, var(--border));
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 75%, var(--accent) 5%);
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease, transform .2s ease;
  text-align: center;
}
.create-dropzone:hover,
.create-dropzone.drag-over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--surface) 65%, var(--accent) 12%);
  transform: translateY(-1px);
}
.create-dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}
.create-dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.create-upload-icon {
  width: 32px;
  height: 32px;
  color: var(--accent);
}
.create-dropzone-content strong {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--text);
}
.create-dropzone-content span {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.create-selected-media { display: grid; gap: 10px; }
.create-selected-item {
  position: relative;
  display: grid;
  min-width: 0;
  grid-template-columns: 50px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 4px 12px rgb(0 0 0 / 18%);
}
.create-selected-thumb {
  display: block;
  width: 50px;
  height: 60px;
  border-radius: 8px;
  background: var(--surface-secondary);
  object-fit: cover;
}
.create-selected-item > span {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.create-selected-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface-elevated) 80%, #ff3b30 20%);
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  transition: all .2s ease;
}
.create-selected-remove:hover {
  background: #ff3b30;
  color: #fff;
  transform: scale(1.1);
}
.create-story-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 340px;
  max-height: min(68dvh, 620px);
  min-height: 380px;
  aspect-ratio: 9 / 16;
  margin: 0 auto;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--border) 80%, #fff 15%);
  border-radius: 20px;
  background: radial-gradient(ellipse at 50% 20%, color-mix(in srgb, var(--accent) 18%, #24242a), #111114 70%);
  box-shadow: 0 16px 45px rgb(0 0 0 / 40%);
}
.create-story-empty { display: grid; justify-items: center; gap: 12px; padding: 20px; color: var(--text-secondary); font-size: 13px; text-align: center; }
.create-story-empty .icon { width: 34px; height: 34px; color: var(--accent); }
.create-story-stage.has-media .create-story-empty { display: none; }
.create-story-stage #create-preview { width: 100%; height: 100%; max-height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.create-story-stage #create-preview .create-media-item { display: flex; width: 100%; height: 100%; min-height: 0; align-items: center; justify-content: center; position: relative; }
.create-story-stage #create-preview img,
.create-story-stage #create-preview video { width: 100%; height: 100%; max-height: 100%; aspect-ratio: auto; border-radius: 0; object-fit: contain; z-index: 1; }
.create-story-stage .create-media-controls { top: 10px; right: 10px; bottom: auto; left: auto; z-index: 6; }
.create-story-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
}
.create-story-overlay-text {
  max-width: 90%;
  max-height: 80%;
  overflow: hidden;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  line-height: 1.4;
  word-break: break-word;
  white-space: pre-wrap;
  color: #fff;
  text-shadow: 0 2px 8px rgb(0 0 0 / 80%), 0 0 2px rgb(0 0 0 / 90%);
  padding: 8px 14px;
  border-radius: 10px;
  background: rgb(0 0 0 / 38%);
  backdrop-filter: blur(5px);
  transition: all .15s ease;
}
.create-story-overlay-text:empty {
  display: none;
}
.create-story-tools { display: flex; min-width: 0; flex-direction: column; align-items: stretch; gap: 14px; padding: 16px; border: 1px solid var(--border); border-radius: 18px; background: color-mix(in srgb, var(--surface) 90%, var(--accent) 4%); }
.create-story-tools-header { display: flex; min-height: 30px; align-items: center; justify-content: space-between; color: var(--text); font-size: 14px; font-weight: 700; }
.create-story-tools-header .icon-button { display: none; }
.create-story-tool-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.create-story-tool-tabs button { display: inline-flex; min-height: 38px; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); color: var(--text); padding: 0 13px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; transition: all .15s ease; }
.create-story-tool-tabs button[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 20%, var(--surface)); color: var(--accent); }
.create-story-tool-tabs .icon { width: 17px; height: 17px; color: currentColor; }
.create-story-tool-panel { display: grid; min-width: 0; gap: 10px; }
.create-story-tools .create-music-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.create-caption-label { display: grid; min-width: 0; gap: 7px; color: var(--text-secondary); font-size: 12px; font-weight: 650; }
.create-caption-label #create-caption { width: 100%; min-height: 120px; resize: vertical; border-radius: 12px; }
.story-text-styling {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}
.story-text-styling > span {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}
.story-color-options {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.story-color-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease;
  padding: 0;
}
.story-color-btn:hover {
  transform: scale(1.15);
}
.story-color-btn.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent);
  transform: scale(1.1);
}
.create-story-tools .create-music-preview { margin: 0; }
#create-editor:not(.story-composer-active) .create-story-stage {
  display: none !important;
}
#create-editor:not(.story-composer-active) .create-story-tools .create-story-tool-tabs,
#create-editor:not(.story-composer-active) .create-story-tools .story-text-styling,
#create-editor:not(.story-composer-active) .create-story-tools #create-story-music-panel,
#create-editor:not(.story-composer-active) .create-story-empty {
  display: none !important;
}
.create-publish-bar { position: sticky; z-index: 6; bottom: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(160px, .35fr); align-items: center; gap: 14px; margin: 0; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface-elevated) 94%, transparent); padding: 12px 22px max(12px, env(safe-area-inset-bottom)); backdrop-filter: blur(16px); }
.create-publish-bar .form-status { min-width: 0; margin: 0; }
.create-publish-bar #publish-button { width: 100%; min-height: 46px; font-weight: 700; border-radius: 12px; }
.post-music-player { display: grid; gap: 8px; margin: 0 16px 12px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 12px; background: color-mix(in srgb, var(--surface) 90%, var(--accent) 4%); }
.post-music-player strong { overflow: hidden; color: var(--text); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.post-music-player audio { display: block; width: 100%; min-width: 0; height: 40px; }
#create-kind-back { margin-left: auto; }
#create-form > header #create-kind-back.hidden { display: none; }

@media (max-width: 720px) {
  #create-dialog.create-editor-open[open] { position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; margin: 0; overflow: hidden; border: 0; border-radius: 0; padding: 0; }
  #create-dialog.create-editor-open #create-form { width: 100%; height: 100%; max-height: 100%; grid-template-rows: auto minmax(0, 1fr); }
  #create-form > header { min-height: 60px; padding: 10px 14px; }
  #create-form > .create-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 12px 0; }
  #create-form > .create-options button { min-height: 74px; grid-template-columns: 1fr; justify-items: center; gap: 6px; padding: 9px 5px; text-align: center; font-size: 12px; }
  #create-form > #create-editor { max-height: none; }
  .create-editor-body { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; padding: 12px 12px 130px; }
  .create-story-stage { order: 1; width: min(68vw, 340px); min-height: 0; max-height: min(56dvh, 540px); flex: 0 0 auto; align-self: center; border-radius: 14px; }
  .create-story-assets { order: 2; display: block; flex: 0 0 auto; }
  .create-story-assets .file-picker { display: flex; min-height: 44px; align-items: center; padding: 9px 12px; }
  .create-story-assets .file-picker input { min-width: 0; }
  .create-selected-media { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; scrollbar-width: thin; }
  .create-selected-item { width: 190px; flex: 0 0 190px; }
  .create-story-tools { display: none; }
  #create-editor.story-composer-active .create-story-tools { position: fixed; z-index: 20; right: 12px; bottom: calc(78px + env(safe-area-inset-bottom)); left: 12px; display: flex; width: auto; max-height: min(44dvh, 390px); gap: 10px; overflow: auto; border-radius: 18px; padding: 11px 13px; box-shadow: 0 18px 50px rgb(0 0 0 / 38%); }
  #create-editor.story-composer-active:not([data-active-tool]) .create-story-tools { right: auto; left: 50%; width: max-content; max-width: calc(100vw - 24px); transform: translateX(-50%); overflow: visible; border-radius: 999px; padding: 7px; }
  #create-editor.story-composer-active:not([data-active-tool]) .create-story-tools-header,
  #create-editor.story-composer-active:not([data-active-tool]) .create-story-tool-panel { display: none; }
  #create-editor.story-composer-active .create-story-tools-header { flex: 0 0 auto; }
  #create-editor.story-composer-active[data-active-tool="music"] #create-story-text-panel,
  #create-editor.story-composer-active[data-active-tool="text"] #create-story-music-panel { display: none; }
  #create-editor.story-composer-active[data-active-tool="text"] .create-caption-label #create-caption { min-height: 100px; }
  #create-editor.story-composer-active .create-story-tools-header .icon-button { display: inline-flex; width: 34px; min-height: 34px; }
  #create-editor.story-composer-active .create-story-tool-tabs { flex: 0 0 auto; }
  #create-editor.story-composer-active[data-active-tool] .create-story-tool-panel { min-height: 0; }
  .create-publish-bar { min-height: 72px; grid-template-columns: minmax(0, 1fr) minmax(116px, .42fr); gap: 8px; padding: 9px 12px max(10px, env(safe-area-inset-bottom)); }
  .create-publish-bar .form-status { max-height: 40px; overflow: auto; font-size: 11px; }
  .create-publish-bar #publish-button { min-height: 46px; }
  #create-editor:not(.story-composer-active) .create-story-tools { display: flex; }
  #create-editor:not(.story-composer-active) .create-story-tools-header,
  #create-editor:not(.story-composer-active) .create-story-tool-tabs,
  #create-editor:not(.story-composer-active) #create-story-music-panel { display: none; }
  #create-editor:not(.story-composer-active) .create-story-stage { width: 100%; height: auto; aspect-ratio: 16 / 10; }
  #create-editor:not(.story-composer-active) .create-publish-bar { position: sticky; }
}

@media (prefers-reduced-motion: reduce) {
  .create-story-tool-tabs button { transition: none; }
}

/* Keep the selected Story image fully visible while its blurred copy fills the 9:16 frame. */
.create-story-stage {
  width: auto;
  height: min(100%, 66dvh, 640px);
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  align-self: center;
  justify-self: center;
  isolation: isolate;
}
.create-story-stage::before {
  position: absolute;
  z-index: 0;
  inset: -20px;
  background: var(--story-preview-bg) center / cover no-repeat;
  filter: blur(22px) brightness(.62);
  opacity: .88;
  transform: scale(1.08);
  content: "";
  pointer-events: none;
}
.create-story-stage #create-preview { position: relative; z-index: 1; max-height: 100%; overflow: hidden; }
.create-story-stage #create-preview .create-media-item { position: relative; }
.create-story-stage #create-preview img,
.create-story-stage #create-preview video { object-fit: contain; }

@media (max-width: 720px) {
  .create-story-stage { width: min(68vw, 340px); height: auto; max-height: min(56dvh, 540px); }
  .create-story-stage #create-preview { overflow: hidden; }
}

/* The title and selected-section controls are the useful focus of this picker. */
.music-clip-dialog > #music-clip-steps,
.music-clip-dialog > .music-clip-instructions,
.music-clip-dialog #music-clip-source-duration,
.music-clip-dialog .music-clip-source-player { display: none; }
.music-clip-dialog > .music-clip-source-card { margin: 18px 0 14px; padding: 13px 15px; }
.music-clip-dialog .music-clip-source-top { min-height: 44px; align-items: center; }
.music-clip-dialog .music-clip-source-meta strong { font-size: .96rem; }
.music-clip-dialog .music-clip-editor { gap: 15px; }
.music-clip-dialog > .music-clip-sticky-footer { margin-top: 12px; }

/* Keep Story audio controls easy to reach on mouse, touch, and keyboard. */
.story-sound-toggle { opacity: 1; pointer-events: auto; }

/* Global Background Upload Banner */
.upload-banner {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 420px);
  background: #1a1a1a;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  padding: 12px 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.upload-banner.hidden {
  display: none !important;
}
.upload-banner-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.upload-banner-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.88rem;
}
.upload-banner-title {
  font-weight: 600;
}
.upload-banner-progress-text {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.7);
}
.upload-banner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.upload-banner-actions .button-sm {
  padding: 4px 10px;
  font-size: 0.8rem;
}
.upload-banner-progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  overflow: hidden;
}
.upload-banner-progress-fill {
  height: 100%;
  background: #0095f6;
  border-radius: 2px;
  transition: width 0.25s ease;
}
.upload-banner.is-error .upload-banner-progress-fill {
  background: #ed4956;
}

/* Notification controls and feed cards share the app's quiet, dark surface. */
#notifications-section .notifications-heading { align-items: end; gap: 16px; }
#notifications-section .notifications-mark-read { min-height: 38px; white-space: nowrap; color: var(--accent); font-weight: 650; }
#notifications-section .notifications-mark-read:disabled { cursor: default; opacity: .48; }
#notifications-section .notification-toolbar { display: flex; gap: 8px; margin: 20px 0 12px; border-bottom: 1px solid var(--border); }
#notifications-section .notification-filter { position: relative; min-height: 44px; border: 0; background: transparent; color: var(--text-secondary); padding: 0 14px; font: inherit; font-weight: 650; cursor: pointer; }
#notifications-section .notification-filter::after { position: absolute; right: 12px; bottom: -1px; left: 12px; height: 3px; border-radius: 3px 3px 0 0; background: transparent; content: ""; }
#notifications-section .notification-filter.active { color: var(--text); }
#notifications-section .notification-filter.active::after { background: var(--accent); }
#notifications-section .notification-filter:focus-visible,
#notifications-section .notifications-mark-read:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#notifications-section .activity-list .notification-row { min-height: 72px; border-color: color-mix(in srgb, var(--border) 88%, var(--accent)); background: color-mix(in srgb, var(--surface) 95%, var(--accent)); transition: border-color .16s ease, background-color .16s ease; }
#notifications-section .activity-list .notification-row:hover { border-color: color-mix(in srgb, var(--accent) 38%, var(--border)); background: color-mix(in srgb, var(--hover) 72%, var(--surface)); }
#notifications-section .activity-list .notification-row.unread { border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
#notifications-section .notification-day-heading { margin: 22px 4px 4px; font-size: 13px; letter-spacing: .01em; }
#notifications-section #notifications-status:not(:empty) { margin: 18px 0; }

#home-section #feed-list > .post {
  margin-bottom: 14px;
  border: 1px solid color-mix(in srgb, var(--border) 86%, transparent);
  background: color-mix(in srgb, var(--surface) 38%, transparent);
  padding: 14px 14px 12px;
  transition: border-color .16s ease, background-color .16s ease;
}
#home-section #feed-list > .post:hover { border-color: color-mix(in srgb, var(--accent) 24%, var(--border)); background: color-mix(in srgb, var(--surface) 58%, transparent); }
#home-section #feed-list .post-head { padding-bottom: 12px; }
#home-section #feed-list .post-body { padding-top: 10px; }
#home-section #feed-list .post-head .meta { display: flex; min-width: 0; flex: 1; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; }
#home-section #feed-list .post-head .post-meta-separator { display: none; }
#home-section #feed-list .post-head .post-handle,
#home-section #feed-list .post-head time { white-space: nowrap; }
#home-section #feed-list .post-caption { margin: 9px 4px 0; font-size: 14px; line-height: 1.5; }
#home-section #feed-list .text-only-post .post-caption { margin-top: 4px; padding: 10px 4px 5px; font-size: clamp(17px, 2vw, 20px); line-height: 1.55; letter-spacing: -.01em; }
#home-section #feed-list .post-likes-summary { display: flex; min-height: 24px; align-items: center; gap: 8px; margin: 0; color: var(--text); font-size: 12px; line-height: 1.35; }
#home-section #feed-list .post-likes-avatars { display: inline-flex; flex: 0 0 auto; align-items: center; padding-left: 2px; }
#home-section #feed-list .post-likes-avatar { width: 19px; height: 19px; flex: 0 0 19px; margin-left: -4px; border: 2px solid var(--bg); font-size: 9px; }
#home-section #feed-list .post-likes-copy { min-width: 0; overflow-wrap: anywhere; }
#home-section #feed-list .post-likes-copy::first-letter { font-weight: 650; }
#post-detail-content .post-likes-summary { display: flex; min-height: 28px; align-items: center; gap: 8px; margin: 4px 14px 10px; color: var(--text); font-size: 13px; }
#post-detail-content .post-likes-avatars { display: inline-flex; align-items: center; padding-left: 2px; }
#post-detail-content .post-likes-avatar { width: 21px; height: 21px; flex: 0 0 21px; margin-left: -4px; border: 2px solid var(--surface); font-size: 9px; }
#post-detail-content .post-likes-copy { font-weight: 550; }

.create-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.create-options button { min-height: 132px; align-content: center; gap: 9px; }
.create-options button > span { font-size: 15px; }
.create-options button > small { max-width: 25ch; color: var(--text-secondary); font-size: 12px; font-weight: 450; line-height: 1.45; }
.create-options button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

@media (max-width: 600px) {
  #notifications-section .notifications-heading { align-items: center; }
  #notifications-section .notifications-mark-read { max-width: 132px; white-space: normal; text-align: right; line-height: 1.25; }
  #notifications-section .notification-toolbar { margin-top: 14px; }
  #home-section #feed-list > .post { padding: 12px 10px 10px; border-radius: 14px; }
  .create-options { grid-template-columns: 1fr; }
  .create-options button { min-height: 96px; }
}

/* Desktop sidebar polish: X-like proportions while retaining IhuzaChat branding. */
@media (min-width: 1280px) {
  .app {
    --sidebar-width: 312px;
    --sidebar-collapsed: 312px;
    --sidebar-expanded: 312px;
  }
  .app > .sidebar,
  .app > .sidebar:hover,
  .app > .sidebar:focus-within {
    width: 312px;
    padding: 18px 20px 20px;
    border-right-color: color-mix(in srgb, var(--border) 88%, transparent);
    box-shadow: none;
  }
  .app > .app-main { width: calc(100% - 312px); margin-left: 312px; }
  .app .brand { min-height: 48px; height: auto; gap: 11px; margin: 2px 0 18px; padding-inline: 10px; font-size: 19px; letter-spacing: -.035em; }
  .app .brand .mark { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 11px; font-size: 17px; }
  .app .main-nav { gap: 5px; margin: 0; }
  .app .main-nav button,
  .app .sidebar-footer > button { min-height: 52px; gap: 16px; border-radius: 14px; padding-inline: 14px; font-size: 17px; font-weight: 560; }
  .app .main-nav button > .icon { width: 23px; height: 23px; flex-basis: 23px; stroke-width: 1.9; }
  .app .main-nav button:hover,
  .app .sidebar-footer > button:hover { background: color-mix(in srgb, var(--hover) 82%, var(--accent) 5%); }
  .app .main-nav button:hover { transform: none; }
  .app .main-nav button:focus-visible,
  .app .sidebar-footer > button:focus-visible,
  .app .sidebar-create-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .app .main-nav button.active {
    background: color-mix(in srgb, var(--accent) 10%, var(--surface));
    box-shadow: inset 3px 0 0 var(--accent);
    color: var(--accent);
    font-weight: 720;
  }
  .app .main-nav button.active .icon { stroke-width: 2.25; }
  .app .sidebar-create-button { min-height: 56px; margin: 12px 0 16px; border-radius: 999px; font-size: 16px; font-weight: 750; letter-spacing: -.01em; box-shadow: 0 7px 20px color-mix(in srgb, var(--accent) 22%, transparent); }
  .app .sidebar-footer { gap: 5px; margin-top: auto; padding-top: 14px; }
  .app .sidebar-footer > .current-user-identity { min-height: 68px; gap: 12px; border-radius: 16px; padding-inline: 8px; }
  .app .current-user-identity .avatar { width: 44px; height: 44px; flex: 0 0 44px; }
  .app .current-user-copy { gap: 3px; }
  .app .current-user-copy strong { font-size: 14px; font-weight: 720; }
  .app .current-user-copy small { font-size: 12px; }
  .app .sidebar-footer > #more-button { min-height: 48px; }
  #more-dialog { left: 328px; }
}

/* Give the icon rail readable labels on compact desktop and tablet widths. */
@media (min-width: 769px) and (max-width: 1023px) {
  .app { --sidebar-expanded: 264px; }
  .app > .sidebar {
    z-index: 60;
    transition: width .18s ease, box-shadow .18s ease;
  }
  .app > .sidebar:hover,
  .app > .sidebar:focus-within {
    width: var(--sidebar-expanded);
    box-shadow: 10px 0 32px rgb(0 0 0 / 22%);
  }
  .app > .sidebar:hover .brand,
  .app > .sidebar:focus-within .brand { justify-content: flex-start; padding-inline: 10px; }
  .app > .sidebar:hover .brand > span,
  .app > .sidebar:focus-within .brand > span,
  .app > .sidebar:hover .main-nav button > span:not(.nav-badge),
  .app > .sidebar:focus-within .main-nav button > span:not(.nav-badge),
  .app > .sidebar:hover .sidebar-footer > button > span,
  .app > .sidebar:focus-within .sidebar-footer > button > span {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
    white-space: nowrap;
  }
  .app > .sidebar:hover .main-nav button,
  .app > .sidebar:focus-within .main-nav button,
  .app > .sidebar:hover .sidebar-footer > button,
  .app > .sidebar:focus-within .sidebar-footer > button {
    justify-content: flex-start;
    padding-inline: 10px;
  }
  .app > .sidebar .main-nav button:focus-visible,
  .app > .sidebar .sidebar-footer > button:focus-visible,
  .app > .sidebar .sidebar-create-button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
  #more-dialog { left: 88px; }
}

/* Mobile navigation prioritizes the five most-used destinations. */
@media (max-width: 768px) {
  .app .mobile-nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
    padding-inline: 8px;
  }
  .app .mobile-nav button { min-width: 0; min-height: 48px; padding-inline: 2px; }
  .app .mobile-nav button:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; border-radius: 10px; }
  .app .mobile-nav button > span:not(.nav-badge) { font-size: 9px; }
  .app .mobile-nav .mobile-nav-create .icon {
    box-sizing: border-box;
    width: 34px;
    height: 34px;
    padding: 8px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-contrast, #fff);
    stroke-width: 2.5;
  }
  .app .mobile-current-user-avatar { position: relative; width: 26px; height: 26px; flex: 0 0 26px; }
  .app .mobile-current-user-avatar .presence-dot,
  .app .post-likes-avatar .presence-dot { display: none; }
  #home-section #feed-list > .post,
  #home-section #feed-list > .post.has-media-fit {
    box-sizing: border-box;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 0 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    padding: 10px;
  }
  #home-section > .content { padding-top: 8px; }
  #home-section .page-heading { display: none; }
  #home-section .stories-section {
    margin: 0 -14px 8px;
    padding: 0 14px 8px;
    border-bottom: 1px solid var(--border);
  }
  #home-section .stories-heading { margin: 0; padding: 0; }
  #home-section .feed-toolbar { min-height: 0; margin: 0; border: 0; }
  #home-section .feed-toolbar h2 { display: none; }
  #home-section .feed { margin-top: 0; }
  #home-section #feed-list .post-media-frame { aspect-ratio: 4 / 5 !important; background: var(--surface-secondary); }
  #home-section #feed-list .post-media-frame > .post-media { width: 100%; height: 100%; max-height: none; object-fit: cover; }
  #home-section #feed-list .post-age-full { display: none; }
  #home-section #feed-list .post-age-compact { display: inline; }
  #home-section #feed-list .post-meta-separator { display: inline; }
  .app .mobile-nav .mobile-nav-create .icon { width: 28px; height: 28px; padding: 6px; }
}

@media (max-width: 390px) {
  #home-section .stories-section { margin-inline: -10px; padding-inline: 10px; }
}

.post-age { color: var(--text-secondary); font-size: 11px; font-weight: 500; white-space: nowrap; }
.post-age-compact { display: none; }

/* Audius Story Music is added inside the existing lazy-loaded clip composer. */
.audius-music-browser { display: grid; gap: 11px; margin: 0 0 16px; }
.audius-music-search { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.audius-music-search input { min-width: 0; min-height: 44px; padding: 0 13px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface-secondary); color: var(--text); font: inherit; }
.audius-music-search button, .audius-track-result button { min-height: 42px; padding-inline: 14px; }
.audius-search-status { min-height: 1em; margin: 0; color: var(--text-secondary); font-size: .82rem; }
.audius-search-status[data-state="error"] { color: var(--danger, #ff7786); }
.audius-search-results { display: grid; gap: 8px; max-height: 260px; overflow: auto; overscroll-behavior: contain; }
.audius-track-result { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-secondary); }
.audius-track-result > img, .audius-create-music-preview > img { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; background: var(--surface); }
.audius-track-details, .create-music-preview-details { display: grid; min-width: 0; gap: 3px; }
.audius-track-details strong, .create-music-preview-details strong { overflow: hidden; color: var(--text); font-size: .88rem; text-overflow: ellipsis; white-space: nowrap; }
.audius-track-details small, .create-music-preview-details small { color: var(--text-secondary); font-size: .75rem; }
.audius-rights-confirmation { display: flex; align-items: flex-start; gap: 9px; color: var(--text-secondary); font-size: .79rem; line-height: 1.4; }
.audius-rights-confirmation input { width: 18px; height: 18px; flex: 0 0 18px; accent-color: var(--accent); }
.audius-create-music-preview { display: flex; align-items: center; gap: 10px; min-width: 0; }
.create-music-preview-details { flex: 1; }
.create-music-preview audio { width: 100%; }
@media (max-width: 520px) {
  .audius-track-result { grid-template-columns: 42px minmax(0, 1fr); }
  .audius-track-result > img { width: 42px; height: 42px; }
  .audius-track-result button { grid-column: 1 / -1; width: 100%; }
}
