:root {
  --bg: #050507;
  --surface: #0f1014;
  --surface-2: #171820;
  --surface-3: #20222c;
  --text: #f4f5f7;
  --muted: #9a9ca8;
  --line: #2b2d38;
  --brand: #ef3b68;
  --brand-2: #ff8a3d;
  --accent: #7c5cff;
  --ok: #2bd576;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: clamp(96px, 13vh, 132px);
  background:
    radial-gradient(circle at top left, rgba(239, 59, 104, 0.16), transparent 30rem),
    radial-gradient(circle at top right, rgba(124, 92, 255, 0.13), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 0 max(18px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(5, 5, 7, 0.82);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  width: clamp(170px, 22vw, 300px);
  min-height: 58px;
  text-decoration: none;
}

.brand img {
  width: 100%;
  max-height: 62px;
  object-fit: contain;
  object-position: left center;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.42));
}

.nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-only {
  display: none !important;
}

body.is-authenticated .auth-only {
  display: inline-grid !important;
}

.top-action {
  width: 44px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  background:
    radial-gradient(circle at 30% 18%, rgba(255, 63, 164, 0.18), transparent 1.7rem),
    radial-gradient(circle at 78% 82%, rgba(21, 200, 255, 0.14), transparent 1.8rem),
    rgba(12, 13, 19, 0.92);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 0 18px rgba(138, 61, 255, 0.22);
}

.top-action .rgb-icon {
  width: 24px;
  height: 24px;
  fill: none;
  overflow: visible;
  filter: drop-shadow(0 0 10px rgba(255, 63, 164, 0.28));
}

.rgb-stroke,
.story-dash {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.15;
}

.story-dash {
  stroke-width: 2.8;
  stroke-dasharray: 5 4.2;
}

.rgb-fill {
  stroke: none;
}

.photo-action { color: #36f279; }
.reel-action { color: #15c8ff; }
.story-action { color: #ff4ecb; }
.carousel-action { color: #b45cff; }

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 26px auto 64px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 620px);
  justify-content: center;
  gap: 0;
}

.sidebar {
  position: static;
  display: grid;
  align-content: start;
  gap: 16px;
  max-height: none;
  margin-bottom: 18px;
}

.stream {
  min-width: 0;
}

.panel,
.post-card,
.stories-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 16, 20, 0.92);
  box-shadow: var(--shadow);
}

.welcome {
  padding: 20px;
  overflow: hidden;
}

.is-hidden {
  display: none !important;
}

.welcome h1 {
  margin: 0 0 8px;
  font-size: 2rem;
  line-height: 1;
}

.welcome-logo {
  display: block;
  width: min(100%, 520px);
  margin: -12px auto 12px;
  object-fit: contain;
  filter: drop-shadow(0 18px 34px rgba(0, 0, 0, 0.52));
}

.welcome p {
  margin: 0 0 18px;
  color: var(--muted);
}

.interest-panel {
  display: grid;
  gap: 12px;
}

.section-title {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.chip {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 11px;
  background: var(--surface-2);
  color: var(--text);
}

.chip.active {
  border-color: transparent;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
}

.welcome-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
}

.primary-button,
.secondary-button,
.text-button,
.icon-button,
.action-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-weight: 850;
}

.secondary-button {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 750;
}

.text-button {
  background: transparent;
  color: var(--text);
  font-weight: 850;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  place-items: center;
  padding: 0;
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.08rem;
}

.primary-button:hover,
.secondary-button:hover,
.text-button:hover,
.icon-button:hover,
.action-button:hover {
  transform: translateY(-1px);
}

.stories-row {
  display: flex;
  gap: 14px;
  min-height: 112px;
  margin-bottom: 18px;
  overflow-x: auto;
  padding: 16px;
}

.story-bubble {
  display: grid;
  gap: 7px;
  justify-items: center;
  min-width: 72px;
  border: 0;
  background: transparent;
  color: var(--text);
}

.avatar-ring {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  padding: 3px;
  background: conic-gradient(var(--brand), var(--brand-2), var(--accent), var(--brand));
}

.avatar,
.avatar-fallback {
  width: 100%;
  height: 100%;
  border: 3px solid var(--surface);
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--text);
  font-weight: 900;
}

.story-name {
  max-width: 76px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
}

.empty-story-note {
  display: flex;
  align-items: center;
  min-width: 190px;
  color: var(--muted);
  font-size: 0.9rem;
}

.profile-panel,
.panel {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.feed {
  display: grid;
  gap: 20px;
}

.post-card {
  overflow: hidden;
}

.post-head,
.post-actions,
.post-body {
  padding: 14px 16px;
}

.post-head {
  display: flex;
  align-items: center;
  gap: 11px;
}

.post-author-button {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
}

.post-head .avatar-ring {
  width: 46px;
  height: 46px;
}

.post-author {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.post-author strong {
  line-height: 1.1;
}

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

.media-frame {
  position: relative;
  background: #000;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  cursor: pointer;
}

.views-badge {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 850;
  backdrop-filter: blur(8px);
}

.media-frame img,
.media-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.carousel-controls {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.carousel-controls button {
  pointer-events: auto;
  margin: 10px;
  border: 0;
  background: rgba(0, 0, 0, 0.55);
}

.post-body h2 {
  margin: 0 0 8px;
  font-size: 1.08rem;
}

.post-body p {
  margin: 0;
  color: #d7d8df;
}

.post-external-link {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 36px;
  margin-top: 12px;
  border: 1px solid rgba(54, 242, 121, 0.25);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(54, 242, 121, 0.08);
  color: #86f7ae;
  font-size: 0.88rem;
  font-weight: 800;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.tag {
  border-radius: 999px;
  background: rgba(239, 59, 104, 0.13);
  padding: 4px 9px;
  color: #ff9db2;
  font-size: 0.78rem;
  font-weight: 750;
}

.post-actions {
  display: block;
  border-top: 1px solid var(--line);
}

.social-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.social-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 0;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  background:
    linear-gradient(var(--surface-2), var(--surface-2)) padding-box,
    linear-gradient(135deg, #15c8ff, #8a3dff, #ff3fa4, #ff9c18) border-box;
  color: var(--text);
  font-weight: 850;
}

.social-icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  filter: drop-shadow(0 0 8px rgba(255, 63, 164, 0.24));
}

.social-icon-button span {
  min-width: 0;
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.like-button.liked {
  border-color: rgba(255, 48, 84, 0.55);
  background: rgba(255, 48, 84, 0.12);
  color: #ff3054;
  animation: likePulse 0.8s ease-in-out infinite alternate;
}

.like-button.liked svg,
.favorite-button.favorited svg {
  fill: currentColor;
}

.favorite-button.favorited {
  border-color: rgba(255, 226, 58, 0.7);
  background: rgba(255, 226, 58, 0.12);
  color: #ffe23a;
}

@keyframes likePulse {
  from {
    box-shadow: 0 0 0 rgba(255, 48, 84, 0);
    transform: translateY(0);
  }
  to {
    box-shadow: 0 0 18px rgba(255, 48, 84, 0.32);
    transform: translateY(-1px);
  }
}

.action-button {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 750;
}

.action-button.active {
  border-color: rgba(239, 59, 104, 0.45);
  background: rgba(239, 59, 104, 0.16);
  color: #ff7d9a;
}

.comment-box {
  display: flex;
  gap: 8px;
  width: 100%;
}

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

.modal {
  width: min(560px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.modal-body {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: var(--surface);
}

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

.modal-head h2 {
  margin: 0;
  font-size: 1.25rem;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #090a0d;
  color: var(--text);
}

textarea {
  resize: vertical;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segment {
  min-height: 38px;
  border: 0;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 850;
}

.segment.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-row input {
  width: auto;
}

.edit-profile-preview {
  display: flex;
  justify-content: center;
  margin: 4px 0;
}

.edit-profile-preview img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--line);
}

.form-error {
  margin: 0;
  color: #ff8ca3;
  font-weight: 750;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

.preview-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface-2);
  position: relative;
}

.remove-preview {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,.7);
  color: #fff;
  border: none;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.preview-count {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 0;
}

.preview-card img,
.preview-card video {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  background: #000;
}

.camera-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 42px;
  border: 1px solid color-mix(in srgb, #ff4ecb 55%, var(--line));
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 78, 203, 0.13), rgba(54, 242, 121, 0.11)),
    var(--surface-2);
  color: var(--text);
  font-weight: 850;
}

.camera-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: #ff4ecb;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  filter: drop-shadow(0 0 9px rgba(255, 78, 203, 0.45));
}

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

.notification {
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  color: #d7d8df;
  font-size: 0.9rem;
}

.story-modal {
  width: min(430px, calc(100% - 28px));
}

.story-viewer {
  min-height: 520px;
  display: grid;
  place-items: center;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}

.story-viewer img,
.story-viewer video {
  width: 100%;
  height: 100%;
  max-height: 70vh;
  object-fit: contain;
}

.story-media-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.comments-modal {
  width: min(620px, calc(100% - 20px));
}

.comments-modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.comments-sheet {
  max-height: min(78vh, 720px);
}

.comments-list {
  display: grid;
  gap: 12px;
  max-height: 48vh;
  overflow: auto;
  padding-right: 2px;
}

.comment-item {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  align-items: start;
}

.comment-item .avatar-ring {
  width: 42px;
  height: 42px;
}

.comment-content {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.comment-content p {
  margin: 0;
  color: #d7d8df;
}

.comment-like-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: max-content;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-weight: 800;
}

.comment-like-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.comment-like-button.active {
  color: #ff3054;
}

.comment-like-button.active svg {
  fill: currentColor;
}

.comment-drawer-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding-top: 4px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 34px;
  text-align: center;
  color: var(--muted);
  background: rgba(15, 16, 20, 0.72);
}

.setup-error {
  display: grid;
  gap: 10px;
  text-align: left;
}

.setup-error strong {
  color: var(--text);
}

.filter-normal { filter: none; }
.filter-amaro { filter: contrast(1.08) brightness(1.08) saturate(1.25); }
.filter-mayfair { filter: contrast(1.08) saturate(1.12) sepia(0.16); }
.filter-valencia { filter: contrast(0.95) brightness(1.08) sepia(0.22); }
.filter-xpro2 { filter: contrast(1.28) saturate(1.25) sepia(0.18); }
.filter-aden { filter: contrast(0.9) brightness(1.14) saturate(0.85) hue-rotate(-12deg); }
.filter-brooklyn { filter: contrast(0.9) brightness(1.1) saturate(1.08) sepia(0.12); }
.filter-lofi { filter: contrast(1.32) saturate(1.22); }

.app-screen {
  display: none;
}

.app-screen.active {
  display: block;
}

.bottom-tabs {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0;
  width: min(720px, 100%);
  transform: translateX(-50%);
  padding: 8px max(6px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-right));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  background:
    radial-gradient(circle at 12% 20%, rgba(239, 59, 104, 0.16), transparent 8rem),
    radial-gradient(circle at 88% 70%, rgba(37, 136, 255, 0.14), transparent 9rem),
    rgba(5, 5, 7, 0.88);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
}

.tab-button {
  position: relative;
  display: grid;
  grid-template-rows: 30px auto;
  gap: 4px;
  min-width: 0;
  min-height: 58px;
  place-items: center;
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0;
  background: transparent;
  color: #fff;
  text-transform: uppercase;
}

.tab-button:last-child {
  border-right: 0;
}

.tab-button svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
  filter: drop-shadow(0 0 10px color-mix(in srgb, currentColor 38%, transparent));
  transition: transform 0.15s ease;
}

.tab-button span {
  max-width: 100%;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.58rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-button.active {
  background: transparent;
}

.tab-button.active svg {
  transform: translateY(-2px) scale(1.08);
}

.tab-profile { color: #8a3dff; }
.tab-search { color: #ff3d3d; }
.tab-home { color: #fff23a; }
.tab-reels { color: #36f279; }
.tab-share { color: #ff5b9d; }
.tab-notifications { color: #ff3fa4; }

.mini-avatar {
  display: grid;
  width: clamp(28px, 8vw, 34px);
  height: clamp(28px, 8vw, 34px);
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: var(--surface-3);
  color: #fff;
  font-weight: 900;
}

.mini-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reels-screen,
.messages-screen,
.search-screen,
.profile-screen {
  width: min(430px, 100%);
  min-height: calc(100vh - 80px);
  margin: 0 auto;
  padding: 18px 12px 92px;
}

.reel-card {
  position: relative;
  min-height: calc(100vh - 110px);
  margin-bottom: 18px;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
}

.reel-media {
  width: 100%;
  height: calc(100vh - 110px);
  object-fit: cover;
  display: block;
}

.reel-overlay {
  position: absolute;
  inset: auto 0 0;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 14px 26px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.82));
}

.reel-overlay p {
  margin: 6px 0 0;
  color: #fff;
}

.reel-views {
  display: inline-block;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.82rem;
  font-weight: 800;
}

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

.round-action,
.icon-plain {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-weight: 900;
}

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

.screen-head h2 {
  margin: 0;
}

.message-list {
  display: grid;
  gap: 12px;
}

.message-card,
.message-share {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.message-card {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.message-card p {
  margin: 0;
  color: var(--muted);
}

.message-share {
  display: grid;
  grid-template-columns: 62px 1fr;
  align-items: center;
  gap: 12px;
  min-height: 78px;
  padding: 8px;
  text-align: left;
}

.message-thumb {
  width: 62px;
  height: 62px;
  border-radius: 8px;
  object-fit: cover;
}

.message-share small {
  display: block;
  color: var(--muted);
}

.search-bar {
  position: sticky;
  top: 72px;
  z-index: 5;
  margin-bottom: 14px;
  padding: 6px 0;
  background: var(--bg);
}

.search-profiles {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.profile-result {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.profile-result .avatar-ring {
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
}

.profile-result span:last-child {
  display: grid;
  min-width: 0;
}

.profile-result small {
  color: var(--muted);
}

.search-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}

.search-tile {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 0;
  background: #111;
  color: #fff;
  padding: 0;
}

.search-media,
.profile-grid-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.search-tile span {
  position: absolute;
  inset: auto 0 0;
  padding: 18px 6px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  font-size: 0.78rem;
}

.profile-top {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 10px;
  min-height: 58px;
}

.profile-top strong {
  text-align: center;
  font-size: 1.3rem;
}

.profile-hero {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 20px;
  align-items: center;
  margin-top: 16px;
}

.profile-avatar-wrap {
  position: relative;
}

.profile-avatar-wrap .avatar,
.profile-avatar-wrap .avatar-fallback {
  width: 104px;
  height: 104px;
  border: 4px solid var(--surface-3);
}

.profile-avatar-wrap button {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 30px;
  height: 30px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: #fff;
  color: #050507;
  font-weight: 900;
}

.profile-name-block {
  display: grid;
  gap: 10px;
}

.profile-name-block > strong {
  font-size: 1.25rem;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.profile-stats span {
  display: grid;
  gap: 2px;
  font-size: 0.88rem;
}

.profile-stats b {
  font-size: 1.2rem;
}

.profile-bio {
  margin: 18px 0 12px;
  color: #f1f1f4;
  font-size: 1rem;
}

.profile-bio-link,
.profile-summary-link {
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 100%;
  min-height: 34px;
  border: 1px solid rgba(21, 200, 255, 0.28);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(21, 200, 255, 0.08);
  color: #7fe7ff;
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-bio-link {
  margin: -2px 0 12px;
}

.profile-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.profile-actions .is-following {
  border-color: var(--line);
  background: var(--surface-2);
}

.profile-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 22px;
  border-bottom: 1px solid var(--line);
}

.profile-tabs--wide {
  grid-template-columns: repeat(4, 1fr);
}

.profile-tabs button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: rgba(255, 255, 255, 0.28);
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease;
}

.profile-tabs svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: filter 0.18s ease, transform 0.15s ease;
}

.profile-tabs button.active svg {
  transform: translateY(-1px) scale(1.1);
  filter: drop-shadow(0 0 8px color-mix(in srgb, currentColor 60%, transparent));
}

.profile-tabs button.active {
  border-bottom-color: currentColor;
}

.profile-tab-posts        { color: rgba(255,255,255,0.28); }
.profile-tab-posts.active { color: #ff3232; }

.profile-tab-reels        { color: rgba(255,255,255,0.28); }
.profile-tab-reels.active { color: #ffd600; }

.profile-tab-carousel        { color: rgba(255,255,255,0.28); }
.profile-tab-carousel.active { color: #36f279; }

.profile-tab-favorites        { color: rgba(255,255,255,0.28); }
.profile-tab-favorites.active { color: #8a3dff; }

/* ── Ícones do topo do perfil ───────────────────────────────────────────── */
.icon-plain svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: filter 0.15s ease;
}

.icon-plain:hover svg {
  filter: drop-shadow(0 0 6px rgba(255,255,255,0.4));
}

/* ── Grid do perfil ─────────────────────────────────────────────────────── */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}

.profile-grid-item {
  position: relative;
  aspect-ratio: 1;
  background: #111;
  border: 0;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
}

.profile-grid-item:hover .profile-grid-media {
  opacity: 0.75;
  transform: scale(1.03);
}

.profile-grid-item .profile-grid-media {
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Badge de tipo de post (carrossel / vídeo) */
.post-type-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 5px;
  padding: 3px 4px;
  display: flex;
  align-items: center;
  pointer-events: none;
}

.post-type-badge svg {
  width: 14px;
  height: 14px;
  fill: #fff;
  stroke: none;
}

/* ── Modal de detalhe do post ───────────────────────────────────────────── */
.post-detail-modal {
  max-width: min(520px, 100vw);
  max-height: 100dvh;
  width: 100%;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.post-detail-inner {
  display: flex;
  flex-direction: column;
  max-height: 100dvh;
  overflow-y: auto;
}

.detail-options-wrap {
  position: relative;
  flex-shrink: 0;
}

.detail-options-toggle {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
}

.detail-options-toggle svg {
  width: 20px;
  height: 20px;
}

.detail-options-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  z-index: 20;
  min-width: 150px;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}

.detail-option-item {
  display: block;
  width: 100%;
  padding: 12px 16px;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
}

.detail-option-item:hover {
  background: var(--surface-3);
}

.detail-option-danger {
  color: #ff4444;
}

.detail-back-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface-3);
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s ease, background 0.15s ease;
}

.detail-back-btn:hover {
  transform: translateX(-2px);
  background: var(--surface-2);
}

.detail-back-btn svg {
  width: 20px;
  height: 20px;
}

.post-detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 16px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 10;
  border-bottom: 1px solid var(--line);
}

.post-detail-media-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: #000;
  overflow: hidden;
  flex-shrink: 0;
}

.post-detail-media-item {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.detail-carousel-prev,
.detail-carousel-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border: 0;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.detail-carousel-prev { left: 10px; }
.detail-carousel-next { right: 10px; }

.detail-media-dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  z-index: 5;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  transition: background 0.2s;
}

.dot.active { background: #fff; }

.post-detail-body {
  padding: 14px 16px 32px;
}

.post-detail-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 4px 0 6px;
}

.post-detail-desc {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0;
}

.post-detail-actions {
  display: flex;
  gap: 4px;
  margin: 14px 0 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.post-detail-comments {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0 12px;
}

.post-detail-loading {
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--muted);
  padding: 2rem;
}

.profile-login {
  display: grid;
  min-height: 70vh;
  place-content: center;
  gap: 14px;
  text-align: center;
}

.brand-large {
  font-size: 2rem;
  font-weight: 950;
}

.media-placeholder {
  display: grid;
  place-items: center;
  min-height: 120px;
  padding: 10px;
  background: var(--surface-2);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: minmax(0, 620px);
  }

  .sidebar {
    position: static;
    max-height: none;
    order: 2;
  }
}

@media (min-width: 981px) {
  .sidebar-profile,
  .sidebar-notifications {
    display: none !important;
  }
}

@media (max-width: 620px) {
  body {
    background: #050507;
    padding-bottom: calc(104px + env(safe-area-inset-bottom));
  }

  .topbar {
    min-height: 64px;
    padding: 0 12px;
  }

  .brand {
    width: min(38vw, 150px);
    min-height: 48px;
  }

  .brand img {
    max-height: 48px;
  }

  .shell {
    width: 100%;
    margin-top: 0;
  }

  .layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .stream {
    width: 100%;
  }

  .stories-row {
    min-height: 106px;
    margin: 0;
    border-width: 0 0 1px;
    border-radius: 0;
    box-shadow: none;
    background: #08090d;
  }

  .post-card {
    border-width: 0 0 1px;
    border-radius: 0;
    box-shadow: none;
    background: #050507;
  }

  .feed {
    gap: 0;
  }

  .media-frame {
    aspect-ratio: 4 / 5;
  }

  .sidebar {
    padding: 12px;
  }

  body[data-view="home"] .sidebar {
    display: grid;
  }

  body[data-view="home"].interests-ready .sidebar {
    display: none;
  }

  body[data-view="home"] .sidebar-profile,
  body[data-view="home"] .sidebar-notifications {
    display: none !important;
  }

  .bottom-tabs {
    width: 100%;
    padding: 7px 4px calc(7px + env(safe-area-inset-bottom));
    border-left: 0;
    border-right: 0;
    border-radius: 16px 16px 0 0;
  }

  .tab-button {
    grid-template-rows: 27px auto;
    min-height: 54px;
    padding: 0 2px;
  }

  .tab-button svg {
    width: 25px;
    height: 25px;
  }

  .tab-button span {
    font-size: 0.46rem;
    letter-spacing: 0.01em;
  }

  .nav {
    gap: 5px;
  }

  .icon-button {
    width: 36px;
    min-height: 36px;
    padding: 0;
  }

  .top-action .rgb-icon {
    width: 21px;
    height: 21px;
  }

  #authToggle {
    min-height: 36px;
    padding: 0 8px;
    font-size: 0.92rem;
  }

  .post-actions,
  .comment-box {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .social-actions {
    gap: 6px;
  }

  .social-icon-button {
    gap: 4px;
    min-height: 40px;
    padding: 0 5px;
  }

  .social-icon-button svg {
    width: 20px;
    height: 20px;
  }

  .social-icon-button span {
    font-size: 0.76rem;
  }

  .comments-modal {
    width: 100%;
    max-width: none;
    margin: auto 0 0;
    border-radius: 18px 18px 0 0;
  }

  .comments-sheet {
    max-height: 82vh;
  }

  .comment-box,
  .primary-button,
  .secondary-button,
  .text-button,
  .action-button {
    width: 100%;
  }
}

/* ---- API Keys dialog ---- */
.api-keys-intro {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 16px;
}
#apiKeysList {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
  min-height: 32px;
}
.api-key-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}
.api-key-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.api-key-value {
  font-size: 11px;
  word-break: break-all;
  color: var(--muted);
  background: var(--surface-3);
  padding: 4px 7px;
  border-radius: 5px;
  user-select: all;
}
.api-key-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.api-key-btns .secondary-button {
  flex: 1;
  min-width: 120px;
  font-size: 13px;
  padding: 7px 12px;
}
.api-revoke-btn {
  flex: 1;
  min-width: 80px;
  background: none;
  border: 1px solid #c0392b55;
  color: #e74c3c;
  border-radius: 8px;
  font-size: 13px;
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 600;
  transition: background .15s;
}
.api-revoke-btn:hover { background: rgba(231,76,60,.1); }
.api-key-new-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.api-key-new-form input {
  flex: 1;
  min-width: 160px;
}
.api-key-new-form .primary-button {
  flex-shrink: 0;
}
.api-snippet-details {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
.api-snippet-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
.api-snippet-preview {
  display: block;
  margin: 10px 0 8px;
  background: var(--surface-3);
  padding: 12px;
  border-radius: 8px;
  font-size: 12px;
  word-break: break-all;
  color: var(--muted);
  line-height: 1.6;
}

/* ---- Camera modal ---- */
.camera-modal {
  padding: 0;
  margin: 0;
  max-width: 100%;
  width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  border: none;
  background: #000;
  border-radius: 0;
}
.camera-modal::backdrop { background: #000; }

.camera-wrap {
  position: relative;
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

#cameraStream {
  flex: 1;
  width: 100%;
  object-fit: cover;
  min-height: 0;
  transition: filter 0.2s;
}

.camera-top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: linear-gradient(to bottom, rgba(0,0,0,.6), transparent);
}

.camera-icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(0,0,0,.5);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.camera-icon-btn svg { width: 22px; height: 22px; }

.camera-bottom {
  background: rgba(0,0,0,.8);
  padding-bottom: max(env(safe-area-inset-bottom, 0px), 12px);
}

.camera-filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 14px 6px;
  scrollbar-width: none;
}
.camera-filters::-webkit-scrollbar { display: none; }

.camera-filter-btn {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: none;
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 4px;
  cursor: pointer;
}
.camera-filter-btn.active { border-color: #fff; }

.camera-filter-swatch {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  display: block;
  background: linear-gradient(135deg, #f9a825 0%, #e91e63 50%, #1565c0 100%);
}

.camera-filter-label {
  font-size: 10px;
  color: #fff;
  white-space: nowrap;
  text-transform: capitalize;
}

.camera-capture {
  display: block;
  margin: 14px auto;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: #fff;
  border: 5px solid rgba(255,255,255,.35);
  box-shadow: 0 0 0 3px rgba(255,255,255,.2);
  cursor: pointer;
  transition: transform 0.1s;
}
.camera-capture:active { transform: scale(0.91); }
.camera-capture.recording {
  background: #e53935;
  box-shadow: 0 0 0 3px rgba(229,57,53,.4);
}

/* Mode toggle */
.camera-mode-toggle {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 8px 0 4px;
}
.camera-mode-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,.55);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  padding: 4px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.camera-mode-btn.active {
  color: #fff;
  background: rgba(255,255,255,.18);
}

/* Recording indicator */
.camera-recording-info {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.camera-rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e53935;
  animation: rec-blink 1s step-start infinite;
}
@keyframes rec-blink { 50% { opacity: 0; } }

