/*
  Instashop UI - Persian RTL Instagram-style interface.
  Built on Bootstrap RTL with custom visual language and local-only interactions.
*/
:root {
  --app-max-width: 480px;
  --bs-body-font-size: 1rem;
  --ig-bg: #fafafa;
  --ig-surface: #ffffff;
  --ig-surface-soft: #f5f5f5;
  --ig-pastel-pink: rgba(255, 192, 203, 0.35);
  --ig-border: #dbdbdb;
  --ig-text: #262626;
  --ig-muted: #737373;
  --ig-primary: #0095f6;
  --ig-danger: #ed4956;
  --ig-success: #2fbf71;
  --ig-gradient: linear-gradient(45deg, #feda75, #fa7e1e, #d62976, #962fbf, #4f5bd5);
  --ig-shadow: 0 16px 45px rgba(0, 0, 0, 0.08);
  --ig-radius: 18px;
}

[data-theme="dark"] {
  --ig-bg: #000000;
  --ig-surface: #121212;
  --ig-surface-soft: #1f1f1f;
  --ig-pastel-pink: rgba(255, 105, 180, 0.18);
  --ig-border: #2a2a2a;
  --ig-text: #f5f5f5;
  --ig-muted: #a8a8a8;
  --ig-shadow: 0 18px 55px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

.min-w-0 {
  min-width: 0;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--ig-bg);
  color: var(--ig-text);
  font-family: "Vazirmatn", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  scrollbar-color: #ececec transparent;
  scrollbar-width: thin;
}

body.desktop-phone {
  background: linear-gradient(180deg, #f7f7f7, #ffffff);
}

body.desktop-phone .main-content > *:first-child {
  border-radius: 24px;
}

body.desktop-phone .app-shell {
  border-inline: 1px solid var(--ig-border);
  background: var(--ig-bg);
}

body.desktop-phone .top-nav {
  border-bottom: 1px solid var(--ig-border);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #ececec;
  border: 2px solid #fafafa;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #dedede;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover,
a:focus,
a:active,
a:visited {
  text-decoration: none;
}

img:not(.avatar):not(.story-avatar),
video {
  max-width: 100%;
  display: block;
}

img.avatar,
img.story-avatar {
  display: block;
  max-width: none;
}

.app-shell {
  min-height: 100vh;
  width: 100%;
  max-width: var(--app-max-width);
  margin-inline: auto;
  padding-inline-start: 0;
}

.top-nav {
  position: sticky;
  inset-block-start: 0;
  z-index: 1025;
  width: 100%;
  padding: 10px 12px;
  background: var(--ig-surface);
  border-bottom: 1px solid var(--ig-border);
}

.top-nav-brandbar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 0 6px;
}

.top-nav:has(.top-nav-inner) .top-nav-brandbar {
  margin-bottom: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ig-border);
}

.top-nav-brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--ig-text);
  text-decoration: none;
}

.top-nav-brand:hover {
  color: var(--ig-text);
  opacity: 0.85;
}

.top-nav-brand-latin {
  font-weight: 600;
  font-size: 0.92em;
  color: var(--ig-muted);
  margin-inline-start: 0.25em;
}

.top-nav-inner {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
}

.top-nav-city {
  justify-self: start;
}

.top-nav-wallet {
  justify-self: center;
}

.top-nav-cart {
  justify-self: end;
}

.top-nav-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 6px 10px;
  color: var(--ig-text);
  background: transparent;
  border: 0;
  border-radius: 999px;
}

a.top-nav-pill {
  text-decoration: none;
}

.top-nav-wallet {
  cursor: pointer;
  border: 1px solid var(--ig-border);
}

.top-nav-cart {
  cursor: pointer;
}

.top-nav-city {
  border: 1px solid transparent;
}

.top-nav-wallet:hover,
.top-nav-cart:hover,
.top-nav-city:hover {
  background: var(--ig-surface-soft);
}

.top-nav-pill span {
  color: var(--ig-muted);
  font-size: 0.78rem;
}

.top-nav-pill strong {
  white-space: nowrap;
  font-size: 0.84rem;
}

.brand-mark {
  width: 108px;
  height: 108px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  border-radius: 24px;
  background: var(--ig-gradient);
}

.main-content {
  width: 100%;
  padding: 18px 12px 86px;
}

.app-shell .row > [class*="col-"] {
  flex: 0 0 100%;
  max-width: 100%;
  width: 100%;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  justify-content: center;
}

.right-rail {
  display: none;
}

.ig-card {
  background: var(--ig-surface);
  border: 1px solid var(--ig-border);
  border-radius: var(--ig-radius);
  box-shadow: var(--ig-shadow);
}

.stories-strip {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 18px;
  scrollbar-width: none;
}

.stories-strip::-webkit-scrollbar {
  display: none;
}

.story-item {
  min-width: 78px;
  text-align: center;
}

.story-open {
  color: var(--ig-text);
}

.story-ring,
.avatar-ring {
  padding: 3px;
  border-radius: 999px;
  background: var(--ig-gradient);
}

.story-avatar,
.avatar {
  box-sizing: border-box;
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  min-width: 64px;
  min-height: 64px;
  max-width: none;
  max-height: 64px;
  aspect-ratio: 1;
  object-fit: cover;
  border: 3px solid var(--ig-surface);
  border-radius: 999px;
}

#storyModal .modal-dialog,
#profileStoryModal .modal-dialog {
  width: min(420px, calc(100vw - 32px));
  max-width: min(420px, calc(100vw - 32px));
  margin: 1rem auto;
}

#storyModal .modal-content,
#profileStoryModal .modal-content {
  width: 100%;
}

.story-viewer {
  position: relative;
  width: 100%;
  height: min(90vh, 820px);
  max-height: 90vh;
  overflow: hidden;
  border-radius: 1rem;
  background: #0a0a0a;
}

.story-viewer > img,
.story-viewer > .story-media,
.story-viewer > .story-placeholder,
.story-viewer > .image-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center;
  border-radius: inherit;
}

.story-viewer > .story-placeholder,
.story-viewer > .story-placeholder.placeholder-media,
.story-viewer > .image-fallback {
  min-height: 0;
  display: block;
}

.story-viewer > .story-placeholder.placeholder-media {
  padding: 1.5rem;
  display: grid;
  place-items: center;
}

@media (max-width: 576px) {
  #storyModal .modal-dialog,
  #profileStoryModal .modal-dialog {
    width: 100%;
    max-width: 100%;
    margin: 0;
  }

  .story-viewer {
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
}

.story-zone {
  position: absolute;
  inset-block: 0;
  z-index: 2;
  width: 50%;
  background: transparent;
  border: 0;
}

.story-zone-prev {
  inset-inline-start: 0;
}

.story-zone-next {
  inset-inline-end: 0;
}

.story-viewer .position-absolute {
  z-index: 3;
}

.story-progress {
  display: flex;
  gap: 4px;
  height: 4px;
}

.story-progress-segment {
  flex: 1;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 999px;
}

.story-progress-fill {
  width: 0;
  height: 100%;
  display: block;
  background: #fff;
  border-radius: inherit;
}

.story-progress-segment.is-complete .story-progress-fill {
  width: 100%;
}

@keyframes storyProgress {
  from {
    width: 0;
  }

  to {
    width: 100%;
  }
}

.avatar.avatar-sm {
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  max-height: 38px;
}

.avatar.avatar-lg {
  width: 96px;
  height: 96px;
  min-width: 96px;
  min-height: 96px;
  max-height: 96px;
}

.post-card {
  overflow: hidden;
}

.post-media-hit {
  cursor: pointer;
}

.post-media {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--ig-surface-soft);
}

.single-post-root {
  width: 100%;
}

img.single-post-media-video,
video.single-post-media-video,
.video-cover-preview.single-post-media-video {
  display: block;
  width: 100%;
  max-width: var(--app-max-width);
  margin-inline: auto;
  aspect-ratio: 9 / 16;
  max-height: min(85vh, 920px);
  object-fit: cover;
  background: var(--ig-surface-soft);
}

.video-cover-preview {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--ig-surface-soft);
}

.video-cover-preview__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.post-media.video-cover-preview {
  aspect-ratio: 1 / 1;
}

.video-cover-preview__play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.video-cover-preview__play-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: grid;
  place-items: center;
  padding-inline-start: 4px;
  font-size: 1.2rem;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}

.video-cover-preview--empty {
  min-height: 120px;
  background: linear-gradient(145deg, #3a3a42, #1e1e22);
}

.explore-tile .video-cover-preview {
  width: 100%;
  height: 100%;
}

.explore-tile .video-cover-preview__img {
  transition: transform 0.25s ease;
}

.explore-tile:hover .video-cover-preview__img {
  transform: scale(1.05);
}

.cart-row .video-cover-preview__play-btn {
  width: 26px;
  height: 26px;
  font-size: 0.62rem;
  padding-inline-start: 2px;
}

.single-post-page .placeholder-media.single-post-media-video {
  max-width: var(--app-max-width);
  margin-inline: auto;
  aspect-ratio: 9 / 16;
  max-height: min(85vh, 920px);
}

.post-actions button,
.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  color: var(--ig-text);
  background: transparent;
  border: 0;
  border-radius: 999px;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.post-actions button:hover,
.icon-btn:hover {
  background: var(--ig-surface-soft);
}

.post-shop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-block: 10px;
  padding: 10px 12px;
  background: var(--ig-pastel-pink);
  border-radius: 14px;
}

.post-shop-row-under-media {
  margin: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--ig-border);
}

.icon-btn.active,
.like-btn.active {
  color: var(--ig-danger);
}

.save-btn.active {
  color: var(--ig-primary);
}

.comment-input {
  color: var(--ig-text);
  background: var(--ig-surface-soft);
  border: 1px solid var(--ig-border);
  border-radius: 999px;
  outline: none;
  padding: 8px 12px;
  min-height: 34px;
}

.comment-form {
  align-items: center;
}

.muted {
  color: var(--ig-muted);
}

.dropdown-menu {
  text-align: right;
}

.dropdown-menu .dropdown-item,
.dropdown-menu .dropdown-header,
.dropdown-menu .dropdown-item-text {
  text-align: right;
}

.gradient-text {
  background: var(--ig-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.suggestion-card,
.profile-summary,
.settings-panel,
.auth-card {
  padding: 20px;
}

.settings-page .settings-panel.ig-card {
  box-shadow: none;
  border-radius: 14px;
  border: 0;
}

.settings-page--account .settings-panel {
  padding-inline: 0;
}

.settings-page--account .settings-panel-pad {
  padding-inline: 1rem;
}

.settings-page--shop .settings-panel {
  padding-inline: 0;
}

.settings-page--shop .settings-panel-pad {
  padding-inline: 1rem;
}

/* هدر یکسان: دکمهٔ بک + عنوان (پدینگ بالا/پایین/بغل و تایپوگرافی عنوان) */
.theme-page-topbar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
  box-sizing: border-box;
  padding: 12px 1rem 11px;
}

.theme-page-topbar__title {
  margin: 0;
  min-width: 0;
  flex: 1 1 auto;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.02em;
  color: var(--ig-text);
}

/* جلوگیری از دوبل شدن فاصلهٔ بالا: پدینگ پیش‌فرض پنل وقتی اولین فرزند تاپ‌بار است */
.settings-page .settings-panel.ig-card:has(> .theme-page-topbar:first-child) {
  padding-top: 0;
}

/* صفحهٔ پست تکی (/post): هم‌تراز با خانه — بدون پدینگ اضافهٔ کنار کارت */
main.single-post-page-shell > section.main-content {
  padding-top: 0;
}

main.single-post-page-shell .settings-panel.ig-card {
  padding-top: 0;
  overflow-x: visible;
}

main.single-post-page-shell .single-post-root {
  padding-inline: 0;
  overflow-x: visible;
}

.post-card.single-post-page {
  overflow: visible;
}

/* فاصلهٔ نوار وضعیت / ناچ + پدینگ بغل مثل main-content خانه */
main.single-post-page-shell .settings-panel > .theme-page-topbar:first-child {
  padding-top: max(6px, env(safe-area-inset-top, 0px));
  padding-inline: 12px;
}

@media (max-width: 576px) {
  body.user-app main.single-post-page-shell > section.main-content {
    padding-top: 0;
  }

  body.user-app main.single-post-page-shell .settings-panel > .theme-page-topbar:first-child {
    padding-inline-start: calc(5px + env(safe-area-inset-left, 0px));
    padding-inline-end: calc(5px + env(safe-area-inset-right, 0px));
  }

  body.user-app main.create-page-shell .create-page-panel > .theme-page-topbar:first-child {
    padding-inline-start: calc(5px + env(safe-area-inset-left, 0px));
    padding-inline-end: calc(5px + env(safe-area-inset-right, 0px));
  }
}

[data-theme="dark"] .settings-page .btn-outline-dark {
  color: var(--ig-text);
  border-color: var(--ig-border);
}

[data-theme="dark"] .settings-page .btn-outline-dark:hover,
[data-theme="dark"] .settings-page .btn-outline-dark:focus {
  color: var(--ig-text);
  background: var(--ig-surface-soft);
  border-color: var(--ig-border);
}

.settings-block {
  padding: 1.25rem 1.35rem;
  border-radius: var(--ig-radius);
  border: 1px solid var(--ig-border);
  background: var(--ig-surface);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.settings-page .settings-block {
  padding: 0.95rem 1rem;
  border-radius: 14px;
  box-shadow: none;
  border: 0;
}

.settings-block--personal {
  border-inline-start: 4px solid var(--ig-primary);
}

.settings-block--shop {
  border-inline-start: 4px solid var(--ig-success);
}

.settings-page .settings-block--personal,
.settings-page .settings-block--shop {
  border-inline-start-width: 0;
}

.settings-block-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.settings-page .settings-block-header {
  gap: 0;
}

.settings-block-icon {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  background: var(--ig-surface-soft);
  color: var(--ig-primary);
}

.settings-block--shop .settings-block-icon {
  color: var(--ig-success);
  background: var(--ig-surface-soft);
}

.create-product-shell {
  width: 100%;
}

.create-product-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  padding: 24px;
}

.create-product-hero > i {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  color: var(--ig-text);
  background: var(--ig-surface-soft);
  border-radius: 18px;
  font-size: 1.35rem;
}

.create-product-eyebrow {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--ig-muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.create-product-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  padding: 0;
}

.create-kind-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.create-kind-tile {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 12px 10px 10px;
  text-align: right;
  color: var(--ig-text);
  background: var(--ig-surface);
  border: 1px solid var(--ig-border);
  border-radius: 16px;
}

.create-kind-tile i {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--ig-surface-soft);
}

.create-kind-tile span {
  color: var(--ig-muted);
  font-size: 0.75rem;
  line-height: 1.35;
}

.create-kind-tile.is-active {
  border-color: var(--ig-text);
}

.media-upload-preview {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: var(--ig-muted);
  text-align: center;
  background: var(--ig-surface-soft);
  border: 1px dashed var(--ig-border);
  border-radius: 20px;
  overflow: hidden;
}

.media-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.media-upload-placeholder {
  width: 100%;
  margin-top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  text-align: center;
}

.media-upload-placeholder i {
  margin: 0 !important;
}

.media-upload-clickable {
  width: 100%;
  cursor: pointer;
}

.media-upload-clickable:hover {
  background: color-mix(in srgb, var(--ig-surface-soft) 80%, #fff);
}

.media-upload-preview .media-upload-hint {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--ig-muted);
}

.media-upload-preview img,
.media-upload-preview video {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  margin-top: 0;
}

.media-upload-preview--compact {
  min-height: 140px;
  padding: 16px;
}

.media-upload-progress {
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--ig-surface-soft);
  border: 1px solid var(--ig-border);
}

.media-upload-progress__head {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--ig-text);
}

.media-upload-progress__track {
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ig-border) 70%, transparent);
  overflow: hidden;
}

.media-upload-progress__bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0095f6, #5851db);
  transition: width 0.15s ease-out;
}

.media-upload-progress.is-indeterminate .media-upload-progress__bar {
  width: 35%;
  animation: media-upload-indeterminate 1.2s ease-in-out infinite;
}

@keyframes media-upload-indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

.explore-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

a.explore-tile {
  display: block;
  color: inherit;
  text-decoration: none;
}

.explore-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 8px;
  cursor: pointer;
  background: var(--ig-surface-soft);
}

.explore-tile.large {
  grid-row: span 2;
  aspect-ratio: auto;
}

.explore-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}

.explore-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.explore-tile:hover img {
  transform: scale(1.05);
}

/* جستجو: تب‌ها تمام‌عرض */
.main-content.search-page {
  padding-inline: 0;
  padding-top: 10px;
}

.main-content.create-page {
  padding-top: 0;
}

.settings-page--shop .settings-panel.search-page-panel {
  padding: 0;
}

.settings-page--shop .settings-panel.create-page-panel {
  padding: 0;
}

/* صفحهٔ افزودن محتوا (/create): پدینگ بغل مثل خانه */
main.create-page-shell > section.main-content.create-page {
  padding-top: 0;
}

main.create-page-shell .create-page-panel > .theme-page-topbar:first-child {
  padding-top: max(6px, env(safe-area-inset-top, 0px));
  padding-inline: 12px;
}

main.create-page-shell .create-product-shell {
  padding-top: 5px;
  padding-inline: 12px;
  padding-bottom: 1rem;
  overflow-x: visible;
}

main.create-page-shell .create-page-panel {
  overflow-x: visible;
}

/* سه کارت نوع محتوا در یک ردیف، بدون اسکرول و بریدگی کنار */
main.create-page-shell .create-kind-grid {
  margin-inline: 0;
  padding-inline: 0;
  overflow: visible;
}

.search-page-header {
  width: 100%;
}

.search-kind-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  border-block-end: 1px solid var(--ig-border);
  background: var(--ig-surface);
}

.search-kind-tab {
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 12px 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ig-muted);
  background: transparent;
  cursor: pointer;
  transition:
    color 0.15s ease,
    box-shadow 0.15s ease;
}

.search-kind-tab:hover {
  color: var(--ig-text);
}

.search-kind-tab.active {
  color: var(--ig-text);
  box-shadow: inset 0 -2px 0 0 var(--ig-primary);
}

.search-product-sort {
  max-width: 220px;
  width: 100%;
}

.explore-grid.explore-grid--search {
  width: 100%;
  gap: 2px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.explore-grid.explore-grid--search .explore-tile {
  border-radius: 0;
}

.theme-search-tile-skeleton {
  background: linear-gradient(90deg, var(--ig-surface-soft) 25%, var(--ig-border) 50%, var(--ig-surface-soft) 75%);
  background-size: 200% 100%;
  animation: theme-skeleton-shimmer 1.1s ease-in-out infinite;
  pointer-events: none;
}

.search-empty-state {
  grid-column: 1 / -1;
}

.search-sentinel {
  height: 1px;
}

/* فهرست دنبال‌کنندگان / دنبال‌شونده: ردیف‌های تمام‌عرض شبیه اینستاگرام */
.follows-rows {
  width: 100%;
  margin: 0;
  padding: 0;
  background: var(--ig-surface);
}

.follows-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 16px;
  margin: 0;
  border: 0;
  border-radius: 0;
  border-block-end: 1px solid var(--ig-border);
  text-decoration: none;
  color: var(--ig-text);
  background: var(--ig-surface);
  width: 100%;
  box-sizing: border-box;
}

.follows-row:last-of-type {
  border-block-end: 0;
}

.follows-row:hover,
.follows-row:focus-visible {
  background: color-mix(in srgb, var(--ig-text) 5%, var(--ig-surface));
}

.follows-row__avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.follows-row__meta {
  flex: 1 1 auto;
  min-width: 0;
  text-align: start;
}

.follows-row__handle {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.2;
}

.follows-row__name {
  font-size: 0.8125rem;
  color: var(--ig-muted);
  line-height: 1.25;
  margin-top: 2px;
}

.follows-row__verified {
  font-size: 0.85rem;
}

.follows-rows-empty {
  width: 100%;
  margin: 0;
  padding: 2.5rem 1rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--ig-muted);
  background: var(--ig-surface);
}

.follows-subject strong {
  unicode-bidi: plaintext;
}

.tile-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.28);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.explore-tile:hover .tile-overlay {
  opacity: 1;
}

.chat-layout {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 72vh;
  overflow: hidden;
}

.messages-dm-page .chat-layout {
  min-height: 0;
  height: 100%;
  /* allow emoji picker & popovers; clipping is per-panel below */
  overflow: visible;
}

.messages-dm-page.dm-chat-page .chat-layout {
  grid-template-columns: 1fr !important;
}

.messages-dm-page .dm-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.messages-dm-page .chat-thread {
  overflow: visible;
}

.messages-dm-page .emoji-wrap {
  flex-shrink: 0;
}

.messages-dm-page .emoji-picker {
  z-index: 30;
}

/* Used by DM layout flex children (theme markup); not in default Bootstrap. */
.min-h-0 {
  min-height: 0;
}

@media (min-width: 768px) {
  .messages-dm-page .chat-layout {
    grid-template-columns: minmax(260px, 340px) 1fr;
  }

  .messages-dm-page.dm-chat-page .chat-layout {
    grid-template-columns: 1fr !important;
  }

  .messages-dm-page .dm-sidebar {
    border-start-start-radius: var(--ig-radius);
    border-end-start-radius: var(--ig-radius);
  }

  .messages-dm-page .chat-thread {
    border-start-end-radius: var(--ig-radius);
    border-end-end-radius: var(--ig-radius);
  }

  .messages-dm-page .conversation-list {
    flex: 1;
    max-height: none;
    border-inline-end: 1px solid var(--ig-border);
    border-bottom: 0;
  }
}

@media (max-width: 767.98px) {
  .messages-dm-page .conversation-list {
    max-height: none;
  }

  /* One full-height panel (list or thread) on narrow screens */
  .messages-dm-page .chat-layout {
    grid-template-rows: minmax(0, 1fr);
    min-height: 100%;
  }

  .messages-dm-page .dm-sidebar,
  .messages-dm-page .dm-thread {
    min-height: 0;
  }

  .messages-dm-page .chat-thread {
    min-height: 0;
  }

  .messages-dm-page .message-list {
    padding: 12px;
    -webkit-overflow-scrolling: touch;
  }

  .messages-dm-page .bubble {
    max-width: min(88%, 340px);
  }

  .messages-dm-page .dm-thread-head {
    padding-inline: 12px;
    padding-top: max(10px, env(safe-area-inset-top, 0px));
    background: color-mix(in srgb, var(--ig-surface) 76%, transparent);
    backdrop-filter: saturate(150%) blur(16px);
    -webkit-backdrop-filter: saturate(150%) blur(16px);
  }

  .messages-dm-page .dm-thread-head #chatHeader .avatar.avatar-sm {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    max-height: 44px;
  }

  .messages-dm-page .dm-inbox-head {
    padding-top: max(16px, calc(12px + env(safe-area-inset-top, 0px)));
  }

  .messages-dm-page .dm-composer {
    padding-inline: 12px;
    padding-block: 10px;
    gap: 8px;
  }

  .messages-dm-page .dm-message-input {
    min-width: 0;
    flex: 1 1 auto;
  }

  .messages-dm-page .emoji-picker {
    width: min(240px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
  }

  /* Split inbox+thread only; dedicated chat route uses .dm-chat-page (always show thread). */
  .messages-dm-page:not(.dm-chat-page):not(.has-active-conversation) .dm-thread {
    display: none !important;
  }

  .messages-dm-page.has-active-conversation .dm-sidebar {
    display: none !important;
  }

  .messages-dm-page:not(.has-active-conversation) .dm-sidebar {
    border-radius: inherit;
  }

  .messages-dm-page.has-active-conversation .chat-thread,
  .messages-dm-page.dm-chat-page .chat-thread {
    border-radius: inherit;
  }
}

.conversation-list {
  max-height: 260px;
  overflow-y: auto;
  border-inline-end: 0;
  border-bottom: 1px solid var(--ig-border);
}

.conversation-item {
  display: flex;
  gap: 12px;
  padding: 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--ig-border);
}

.conversation-item.active,
.conversation-item:hover {
  background: var(--ig-surface-soft);
}

.chat-thread {
  display: flex;
  min-height: 540px;
  flex-direction: column;
}

.chat-page-content {
  height: calc(100vh - 55px - 68px);
  padding-block: 8px;
}

/* DM page: match real chrome (main padding + bottom nav), dynamic viewport for mobile keyboards */
.messages-dm-page.chat-page-content {
  --dm-page-pad-block: 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: calc(100dvh - 18px - 86px - var(--dm-page-pad-block));
  max-height: calc(100dvh - 18px - 86px - var(--dm-page-pad-block));
  padding-block: 8px;
}

.messages-dm-page .ig-card.chat-layout {
  flex: 1 1 auto;
  min-height: 0;
}

/* Direct messages: headers, composer, list (all breakpoints) */
.messages-dm-page .dm-inbox-head {
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--ig-border);
  background: linear-gradient(
    180deg,
    var(--ig-surface) 0%,
    color-mix(in srgb, var(--ig-surface-soft) 65%, var(--ig-surface)) 100%
  );
}

.messages-dm-page .dm-inbox-head h1 {
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 1.1rem;
}

.messages-dm-page .dm-thread-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--ig-border);
  background: var(--ig-surface);
}

.messages-dm-page .dm-thread-head #chatHeader a {
  border-radius: 14px;
  padding: 6px 12px 6px 8px;
  margin: -4px 0;
  transition: background 0.15s ease;
}

.messages-dm-page .dm-thread-head #chatHeader a:hover {
  background: var(--ig-surface-soft);
}

.messages-dm-page .dm-composer {
  padding: 12px 14px;
  border-top: 1px solid var(--ig-border);
  background: linear-gradient(180deg, var(--ig-surface) 0%, color-mix(in srgb, var(--ig-surface-soft) 35%, var(--ig-surface)) 100%);
  align-items: center;
  gap: 10px;
}

.messages-dm-page .dm-message-input {
  border-radius: 22px;
  padding: 10px 16px;
  border: 1px solid var(--ig-border);
  background: var(--ig-surface-soft);
}

.messages-dm-page .dm-message-input:focus {
  background: var(--ig-surface);
  border-color: color-mix(in srgb, var(--ig-primary) 55%, var(--ig-border));
}

.messages-dm-page .dm-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 0;
  display: inline-grid;
  place-items: center;
  line-height: 1;
  font-size: 0.95rem;
  box-shadow: 0 3px 14px color-mix(in srgb, var(--ig-primary) 42%, transparent);
}

.messages-dm-page .dm-back-btn,
.messages-dm-page .dm-emoji-btn,
.settings-page .dm-back-btn {
  background: var(--ig-surface-soft);
  border: 1px solid var(--ig-border);
}

.messages-dm-page .dm-back-btn:hover,
.messages-dm-page .dm-emoji-btn:hover,
.settings-page .dm-back-btn:hover {
  background: color-mix(in srgb, var(--ig-surface-soft) 70%, var(--ig-border));
}

.messages-dm-page .message-list {
  background:
    radial-gradient(ellipse 90% 55% at 50% -35%, rgba(0, 149, 246, 0.08), transparent 58%),
    linear-gradient(180deg, var(--ig-surface-soft) 0%, var(--ig-bg) 100%);
}

[data-theme="dark"] .messages-dm-page .message-list {
  background:
    radial-gradient(ellipse 85% 50% at 50% -25%, rgba(79, 91, 213, 0.18), transparent 55%),
    linear-gradient(180deg, #121212 0%, #0a0a0a 100%);
}

.messages-dm-page .conversation-item {
  padding: 14px 16px;
  gap: 14px;
  align-items: center;
  transition: background 0.12s ease;
}

.messages-dm-page .conversation-list {
  border-bottom: 0;
  padding: 10px 12px 14px;
}

.messages-dm-page .conversation-card {
  margin: 10px 0;
  overflow: hidden;
}

.messages-dm-page .conversation-card .conversation-item {
  border-bottom: 0;
  width: 100%;
  border-radius: inherit;
}

.messages-dm-page .conversation-card .conversation-item:hover {
  background: var(--ig-surface-soft);
}

.messages-dm-page .conversation-item:last-child {
  border-bottom: 0;
}

.messages-dm-page .conversation-item.active {
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--ig-primary) 16%, var(--ig-surface)) 0%,
    var(--ig-surface-soft) 36px
  );
  border-inline-start: 3px solid var(--ig-primary);
}

.messages-dm-page .conversation-item.active .avatar {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ig-primary) 35%, transparent);
}

.chat-full-height {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.message-list {
  flex: 1;
  min-height: 0;
  padding: 18px;
  overflow-y: auto;
}

.chat-form {
  position: relative;
}

.emoji-wrap {
  position: relative;
}

.emoji-picker {
  position: absolute;
  inset-inline-start: 0;
  inset-block-end: calc(100% + 10px);
  z-index: 20;
  width: 220px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  padding: 10px;
  background: var(--ig-surface);
  border: 1px solid var(--ig-border);
  border-radius: 16px;
  box-shadow: var(--ig-shadow);
}

.emoji-picker button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
}

.emoji-picker button:hover {
  background: var(--ig-surface-soft);
}

.bubble {
  width: fit-content;
  max-width: 75%;
  margin-bottom: 10px;
  padding: 10px 14px;
  border-radius: 18px;
  background: var(--ig-surface-soft);
}

.bubble.me {
  margin-inline-start: auto;
  color: #fff;
  background: var(--ig-primary);
}

.messages-dm-page .bubble:not(.me) {
  background: var(--ig-surface);
  border: 1px solid color-mix(in srgb, var(--ig-border) 75%, transparent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
}

.messages-dm-page .bubble.me {
  background: linear-gradient(145deg, #0095f6 0%, #1877f2 52%, #5b7cfa 100%);
  border: 0;
  box-shadow: 0 3px 14px rgba(0, 149, 246, 0.32);
}

[data-theme="dark"] .messages-dm-page .bubble:not(.me) {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.messages-dm-page .bubble .small.opacity-75 {
  font-size: 0.68rem;
  letter-spacing: 0.02em;
}

.profile-header {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  align-items: center;
  text-align: center;
}

.profile-header .avatar-ring {
  width: fit-content;
  margin-inline: auto;
}

.profile-story-trigger {
  width: fit-content;
  cursor: pointer;
  background: var(--ig-gradient);
}

.profile-bio {
  min-width: 0;
}

.profile-quick-actions {
  width: 100%;
}

.profile-quick-actions-inner {
  padding: 0;
}

.profile-quick-actions .profile-identity-actions {
  justify-content: stretch;
  gap: 8px;
  flex-wrap: nowrap;
  overflow: visible;
}

.profile-quick-actions .profile-identity-actions > .btn {
  flex: 1 1 0;
  min-width: 0;
  padding-inline: 0.4rem;
}

.profile-quick-actions .profile-identity-actions .profile-icon-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-quick-actions .btn.btn-outline-secondary {
  background: var(--ig-surface);
}

.profile-quick-actions .btn.btn-outline-secondary:hover,
.profile-quick-actions .btn.btn-outline-secondary:focus {
  background: var(--ig-surface-soft);
}

.profile-identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.profile-identity:has(.profile-visitor-actions--below-handle) {
  gap: 4px;
}

.profile-identity-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.profile-identity-me-links {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.profile-identity-me-links > .btn {
  flex: 0 0 auto;
}

.profile-identity-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
}

.profile-identity-actions > .btn {
  flex: 0 0 auto;
}

.profile-identity-actions.profile-identity-actions--icon-row {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.profile-quick-actions .profile-identity-actions.profile-identity-actions--icon-row {
  overflow: visible;
}

.profile-icon-text {
  font-size: 0.82rem;
  line-height: 1;
  white-space: nowrap;
  color: var(--ig-muted);
}

/* مودال اشتراک‌گذاری پروفایل — حداکثر عرض ۳۵۰px */
.profile-share-modal__dialog {
  max-width: min(350px, calc(100% - 1rem));
  width: 100%;
  margin-inline: auto;
}

.profile-share-modal__panel {
  border-radius: 14px;
  overflow: hidden;
}

.profile-share-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem 0.35rem;
  flex-direction: row;
}

.profile-share-modal__title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ig-text);
  text-align: start;
  width: auto;
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
}

.profile-share-modal__close {
  position: static;
  flex-shrink: 0;
  margin: 0;
  opacity: 0.55;
}

.profile-share-modal__body {
  padding: 0 0 0.85rem;
  text-align: center;
}

.profile-share-modal__qr-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 100%;
  margin-inline: auto;
  margin-bottom: 0.65rem;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
}

.profile-share-modal__qr {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  background: transparent;
  padding: 0;
  margin: 0;
}

.profile-share-modal__label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--ig-muted);
  margin-bottom: 0.3rem;
  letter-spacing: 0.01em;
  padding-inline: 0.75rem;
}

.profile-share-modal__input-group {
  width: calc(100% - 1.5rem);
  max-width: 100%;
  margin-inline: 0.75rem;
  flex-wrap: nowrap;
}

.profile-share-modal__input {
  font-size: 0.6875rem;
  padding: 0.28rem 0.45rem;
  background: var(--ig-surface-soft);
  border-color: var(--ig-border);
  color: var(--ig-muted);
  min-width: 0;
}

.profile-share-modal__input:focus {
  background: var(--ig-surface);
  border-color: color-mix(in srgb, var(--ig-primary) 45%, var(--ig-border));
  color: var(--ig-text);
  box-shadow: none;
}

.profile-share-modal__copy {
  flex-shrink: 0;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.28rem 0.55rem;
  border-radius: 8px;
  border: none;
  background: var(--ig-primary);
  color: #fff;
  white-space: nowrap;
}

.profile-share-modal__copy:hover,
.profile-share-modal__copy:focus {
  background: color-mix(in srgb, var(--ig-primary) 88%, #000);
  color: #fff;
}

.profile-stats {
  justify-content: center;
}

.profile-stats.profile-stats--in-flow {
  margin-block-start: 8px;
  margin-block-end: 12px;
}

a.profile-stat-link:hover {
  opacity: 0.88;
}

.profile-settings-row {
  width: 100%;
  margin-block-start: 12px;
}

.profile-visitor-actions {
  width: 100%;
  justify-content: center;
  margin-block-start: 12px;
}

/* پیام / اشتراک زیر آیدی؛ دنبال‌کردن اندازهٔ میانه */
.profile-visitor-actions.profile-visitor-actions--below-handle {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: min(100%, 400px);
  margin-inline: auto;
  margin-block-start: 0;
  margin-block-end: 5px;
}

.profile-visitor-actions.profile-visitor-actions--below-handle > a.btn-sm,
.profile-visitor-actions.profile-visitor-actions--below-handle > button.btn-sm {
  flex: 0 0 auto;
}

.profile-visitor-actions.profile-visitor-actions--below-handle .profile-follow-btn-wide {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 10.75rem;
}

.profile-visitor-actions.profile-visitor-actions--below-handle.profile-visitor-actions--solo {
  flex-wrap: wrap;
  max-width: 100%;
}

.profile-visitor-actions.profile-visitor-actions--below-handle.profile-visitor-actions--solo > .btn {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 11.25rem;
}

@media (max-width: 360px) {
  .profile-visitor-actions.profile-visitor-actions--below-handle {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  .profile-visitor-actions.profile-visitor-actions--below-handle .profile-follow-btn-wide {
    flex: 1 1 100%;
    min-width: 0;
  }
}

/* دکمه دنبال‌کردن: گرادیان دو آبی (روشن → تیره)؛ حالت دنبال‌شده با ترکیب متفاوت */
.btn-follow-duotone {
  --follow-duo-a: #4db8ff;
  --follow-duo-b: #0366d6;
  border: 0;
  color: #fff !important;
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.25;
  letter-spacing: 0.02em;
  padding-block: 0.45rem;
  padding-inline: 1.1rem;
  background: linear-gradient(125deg, var(--follow-duo-a) 0%, var(--follow-duo-b) 100%);
  box-shadow: 0 3px 11px rgba(3, 102, 214, 0.29);
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

.btn-follow-duotone.btn-sm {
  font-size: 0.9375rem;
  padding-block: 0.38rem;
  padding-inline: 0.95rem;
  box-shadow: 0 2px 10px rgba(3, 102, 214, 0.27);
}

.btn-follow-duotone:hover {
  filter: brightness(1.06);
  box-shadow: 0 3px 10px rgba(3, 102, 214, 0.32);
}

.btn-follow-duotone:active {
  transform: scale(0.98);
}

.btn-follow-duotone.is-following {
  --follow-duo-a: #7cc9ff;
  --follow-duo-b: #004494;
  box-shadow: 0 2px 8px rgba(0, 68, 148, 0.24);
}

.btn-follow-duotone.is-following:hover {
  box-shadow: 0 3px 10px rgba(0, 68, 148, 0.3);
}

[data-theme="dark"] .btn-follow-duotone {
  --follow-duo-a: #5ac8ff;
  --follow-duo-b: #0070e0;
  box-shadow: 0 3px 14px rgba(0, 140, 255, 0.22);
}

[data-theme="dark"] .btn-follow-duotone.is-following {
  --follow-duo-a: #8ad4ff;
  --follow-duo-b: #003778;
  box-shadow: 0 3px 14px rgba(0, 55, 120, 0.35);
}

.profile-bio-text {
  margin-block-start: 0;
  margin-block-end: 0;
  padding: 14px 16px;
  text-align: right;
  border: 1px solid var(--ig-border);
  border-radius: 16px;
  background: var(--ig-surface);
}

.profile-bio-text p {
  color: var(--ig-muted);
}

.profile-tabs {
  display: flex;
  flex-wrap: nowrap;
  width: 100%;
  gap: 0;
}

.profile-tabs .nav-item {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
}

.profile-tabs .nav-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  color: var(--ig-muted);
  border: 0;
  white-space: nowrap;
  width: 100%;
  padding-inline: 6px;
  padding-block: 10px;
  font-size: 0.86rem;
}

.profile-tabs .nav-link.active {
  color: var(--ig-text);
  background: transparent;
  border-bottom: 2px solid var(--ig-text);
  border-radius: 0;
}

.profile-empty {
  grid-column: 1 / -1;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 80% 20%, rgba(214, 41, 118, 0.22), transparent 32%),
    radial-gradient(circle at 20% 80%, rgba(79, 91, 213, 0.24), transparent 30%),
    var(--ig-bg);
}

/* SPA outlet: main دیگر فرزند مستقیم body نیست؛ استایل از طریق #theme-page-root اعمال می‌شود. */
#theme-page-root {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.theme-panel[hidden] {
  display: none !important;
}

.theme-panel {
  width: 100%;
  min-height: inherit;
}

.theme-panel--enter {
  animation: theme-panel-in 0.12s ease-out;
}

@keyframes theme-panel-in {
  from {
    opacity: 0.92;
  }
  to {
    opacity: 1;
  }
}

.theme-skeleton-line {
  height: 14px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--ig-surface-soft) 25%, var(--ig-border) 50%, var(--ig-surface-soft) 75%);
  background-size: 200% 100%;
  animation: theme-skeleton-shimmer 1.1s ease-in-out infinite;
}

.theme-skeleton-card {
  min-height: 280px;
  border-radius: var(--ig-radius);
  background: linear-gradient(90deg, var(--ig-surface-soft) 25%, var(--ig-border) 50%, var(--ig-surface-soft) 75%);
  background-size: 200% 100%;
  animation: theme-skeleton-shimmer 1.1s ease-in-out infinite;
}

@keyframes theme-skeleton-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

body.user-app #theme-page-root > main,
body.user-app > main {
  position: relative;
  z-index: 1;
}

/* تا قبل از لود JS و اعمال desktop-phone، ناحیهٔ زیر قاب اپ سفید باشد. */
body.user-app #theme-page-root > main.app-shell,
body.user-app > main.app-shell {
  background-color: #ffffff;
}

/* User-facing app page chrome (admin uses app.css but not this class). */
body.user-app {
  background: var(--ig-bg);
}

body.user-app.desktop-phone {
  background: var(--ig-bg);
}

body.user-app.auth-page {
  background:
    radial-gradient(circle at 80% 20%, rgba(214, 41, 118, 0.22), transparent 32%),
    radial-gradient(circle at 20% 80%, rgba(79, 91, 213, 0.24), transparent 30%),
    var(--ig-bg);
}

/* Mobile: user app fills the viewport edge-to-edge (no 480px phone column). */
@media (max-width: 576px) {
  body.user-app .app-shell {
    max-width: none;
    width: 100%;
    margin-inline: 0;
  }

  body.user-app.desktop-phone .app-shell {
    border-inline: 0;
    border-radius: 0;
  }

  body.user-app.desktop-phone .main-content > *:first-child {
    border-radius: 0;
  }

  body.user-app .main-content {
    padding: 18px calc(5px + env(safe-area-inset-right, 0px)) 86px calc(5px + env(safe-area-inset-left, 0px));
  }

  body.user-app .main-content.search-page {
    padding-inline: 0;
    padding-top: 10px;
    padding-bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  }

  body.user-app .main-content.create-page {
    padding-top: 0;
    padding-bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  }

  body.user-app .bottom-nav {
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
    transform: none;
    padding: 8px calc(5px + env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px))
      calc(5px + env(safe-area-inset-left, 0px));
  }

  body.user-app .top-nav {
    padding: 10px calc(5px + env(safe-area-inset-right, 0px)) 10px calc(5px + env(safe-area-inset-left, 0px));
  }

  body.user-app img.single-post-media-video,
  body.user-app video.single-post-media-video,
  body.user-app .video-cover-preview.single-post-media-video,
  body.user-app .single-post-page .placeholder-media.single-post-media-video {
    max-width: 100%;
  }
}

/* DM / inbox: full-width panel + tight clearance above bottom nav (nav ≈ 61px + safe-area). */
@media (max-width: 767.98px) {
  body.user-app .main-content.messages-dm-page {
    padding-inline-start: env(safe-area-inset-left, 0px);
    padding-inline-end: env(safe-area-inset-right, 0px);
    --messages-bottom-clearance: calc(62px + env(safe-area-inset-bottom, 0px));
    padding-bottom: var(--messages-bottom-clearance);
    padding-top: 12px;
  }

  body.user-app .main-content.messages-dm-page.chat-page-content {
    --dm-page-pad-block: 0px;
    height: calc(100dvh - 12px - env(safe-area-inset-top, 0px) - var(--messages-bottom-clearance));
    max-height: calc(100dvh - 12px - env(safe-area-inset-top, 0px) - var(--messages-bottom-clearance));
    padding-block: 0;
  }

  body.user-app .messages-dm-page > .ig-card {
    border-radius: 0;
    border-inline: 0;
    box-shadow: none;
  }

  body.user-app .messages-dm-page .ig-card.chat-layout {
    border-block: 1px solid color-mix(in srgb, var(--ig-border) 78%, transparent);
  }

  [data-theme="dark"] body.user-app .messages-dm-page .ig-card.chat-layout {
    border-block-color: color-mix(in srgb, var(--ig-border) 55%, transparent);
  }
}

.auth-card {
  width: min(var(--app-max-width), 100%);
  max-width: var(--app-max-width);
}

.form-control,
.form-select {
  font-size: 1rem;
  color: var(--ig-text);
  background-color: var(--ig-surface);
  border-color: var(--ig-border);
}

.form-control-lg,
.form-select-lg {
  font-size: 1rem;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
}

.form-control:focus,
.form-select:focus {
  color: var(--ig-text);
  background-color: var(--ig-surface);
  border-color: var(--ig-primary);
  box-shadow: 0 0 0 0.2rem rgba(0, 149, 246, 0.15);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  right: auto;
  inset-block-end: 0;
  z-index: 1040;
  display: flex;
  width: min(100%, var(--app-max-width));
  max-width: var(--app-max-width);
  transform: translateX(-50%);
  justify-content: space-around;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: var(--ig-surface);
  border-top: 1px solid var(--ig-border);
}

.bottom-nav a {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 999px;
}

.bottom-nav a.active {
  background: var(--ig-surface-soft);
}

/* لودینگ مینیمال هنگام جابه‌جایی بین تب‌های ناوبر */
.theme-nav-loader {
  position: fixed;
  inset: 0;
  inset-inline-start: 50%;
  z-index: 1055;
  width: min(100%, var(--app-max-width));
  max-width: var(--app-max-width);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%);
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.theme-nav-loader__bar {
  position: absolute;
  inset-block-start: 0;
  inset-inline: 0;
  display: block;
  height: 2px;
  overflow: hidden;
}

.theme-nav-loader__bar::after {
  content: "";
  display: block;
  width: 38%;
  height: 100%;
  border-radius: 0 999px 999px 0;
  background: linear-gradient(90deg, transparent, var(--ig-primary) 35%, var(--ig-primary) 65%, transparent);
  box-shadow: 0 0 10px rgba(0, 149, 246, 0.25);
  transform: translateX(-130%);
}

.theme-nav-loader__spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2.5px solid rgba(0, 149, 246, 0.16);
  border-top-color: var(--ig-primary);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.92);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

body.theme-nav-loading .theme-nav-loader {
  opacity: 1;
  visibility: visible;
}

body.theme-nav-loading .theme-nav-loader__bar::after {
  animation: theme-nav-loader-slide 0.85s ease-in-out infinite;
}

body.theme-nav-loading .theme-nav-loader__spinner {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  animation: theme-nav-spinner 0.62s linear infinite;
}

@keyframes theme-nav-loader-slide {
  0% {
    transform: translateX(-130%);
  }
  100% {
    transform: translateX(330%);
  }
}

@keyframes theme-nav-spinner {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

body.theme-nav-loading #theme-page-root::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: var(--ig-bg);
  opacity: 0.36;
  animation: theme-nav-veil-in 0.16s ease-out;
}

@keyframes theme-nav-veil-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 0.36;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.theme-nav-loading .theme-nav-loader__bar::after,
  body.theme-nav-loading .theme-nav-loader__spinner {
    animation: none;
  }

  body.theme-nav-loading .theme-nav-loader__spinner {
    border-top-color: var(--ig-primary);
    opacity: 0.85;
  }
}

body.theme-nav-loading .bottom-nav a {
  pointer-events: auto;
}

.toast-container {
  z-index: 2000;
}

/* Keep toast close button pinned to a corner (avoid shifting with message length). */
.instashop-toast {
  position: relative;
  border: 2px solid var(--ig-pastel-pink) !important;
}

.instashop-toast__row {
  position: relative;
}

.instashop-toast__body {
  padding-inline-end: 2.5rem;
}

.instashop-toast__close {
  position: absolute;
  inset-block-start: 0.75rem;
  inset-inline-end: 0.75rem;
  margin: 0 !important;
}

.modal {
  direction: rtl;
}

.modal-content {
  color: var(--ig-text);
  background: var(--ig-surface);
  text-align: right;
}

.modal-header {
  direction: rtl;
  flex-direction: row;
  justify-content: space-between;
  text-align: right;
}

.modal-title {
  margin: 0;
  text-align: right;
  order: 1;
}

.modal-header .btn-close {
  order: 2;
  margin: 0 !important;
}

/* Bootstrap btn-close is dark by default; invert on dark surfaces. */
[data-theme="dark"] .modal .btn-close:not(.btn-close-white),
[data-theme="dark"] .toast .btn-close:not(.btn-close-white) {
  filter: invert(1) grayscale(100%) brightness(1.8);
}

.modal-body,
.modal-footer {
  text-align: right;
}

.modal-footer {
  justify-content: flex-start;
}

.wallet-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.wallet-option {
  padding: 12px;
  color: var(--ig-text);
  background: var(--ig-surface);
  border: 1px solid var(--ig-border);
  border-radius: 14px;
  font-weight: 800;
}

.wallet-option:hover {
  background: var(--ig-surface-soft);
}

.cart-row {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding-block: 10px;
  border-bottom: 1px solid var(--ig-border);
}

.cart-row .cart-thumb {
  inline-size: 50px !important;
  block-size: 50px !important;
  width: 50px !important;
  height: 50px !important;
  min-width: 50px !important;
  max-width: 50px !important;
  min-height: 50px !important;
  max-height: 50px !important;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  overflow: hidden;
  border-radius: 12px;
}

.cart-row .cart-thumb.placeholder-media {
  padding: 4px;
  font-size: 0.65rem;
}

.cart-row .cart-thumb.placeholder-media span {
  max-width: 100%;
  overflow: hidden;
  font-size: 0.62rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cart-copy {
  min-width: 0;
}

.cart-copy strong,
.cart-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cart-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-block-start: 4px;
}

.cart-qty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.cart-qty button {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  color: var(--ig-text);
  background: var(--ig-surface);
  border: 1px solid var(--ig-border);
  border-radius: 999px;
}

.checkout-receipt-preview {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid var(--ig-border);
  background: var(--ig-surface-soft);
}

.media-fallback {
  min-height: 220px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #fff;
  text-align: center;
  font-family: "Vazirmatn", system-ui, sans-serif;
  font-weight: 800;
  background: var(--ig-gradient);
}

.placeholder-media {
  min-height: 180px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  padding: 24px;
  color: #fff;
  text-align: center;
  font-family: "Vazirmatn", system-ui, sans-serif;
  font-weight: 900;
  background: var(--ig-gradient);
}

.placeholder-media::before,
.placeholder-media::after {
  content: "";
  position: absolute;
  width: 28%;
  aspect-ratio: 1;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.placeholder-media::before {
  inset-block-start: 8%;
  inset-inline-start: 8%;
}

.placeholder-media::after {
  inset-block-end: 8%;
  inset-inline-end: 8%;
}

.placeholder-media span {
  position: relative;
  z-index: 1;
  font-size: clamp(1.15rem, 4vw, 2.4rem);
}

.notification-thumb {
  width: 46px;
  height: 46px;
  min-width: 46px;
  min-height: 46px;
  object-fit: cover;
  font-size: 0.58rem;
}

.notification-thumb.placeholder-media {
  padding: 4px;
}

.notification-item {
  min-width: 0;
}

.notification-avatar,
.notification-avatar.avatar-fallback {
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  max-width: 44px !important;
  min-height: 44px !important;
  max-height: 44px !important;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 999px !important;
}

.notification-copy {
  min-width: 0;
  max-width: 100%;
}

.notification-title,
.notification-text {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.placeholder-food {
  background: linear-gradient(45deg, #ff9f1c, #e71d36, #2ec4b6);
}

.placeholder-travel {
  background: linear-gradient(45deg, #00b4d8, #0077b6, #90e0ef);
}

.placeholder-art {
  background: linear-gradient(45deg, #8338ec, #ff006e, #ffbe0b);
}

.placeholder-fitness {
  background: linear-gradient(45deg, #06d6a0, #118ab2, #073b4c);
}

.placeholder-design {
  background: linear-gradient(45deg, #3a86ff, #8338ec, #ff006e);
}

.post-media.placeholder-media,
.explore-tile .placeholder-media {
  aspect-ratio: 1 / 1;
  width: 100%;
  height: 100%;
}

.story-placeholder:not(.story-viewer .story-placeholder) {
  min-height: 520px;
}

.image-fallback {
  width: 100%;
  height: 100%;
  min-height: 180px;
  display: grid;
  place-items: center;
  padding: 16px;
  color: #fff;
  text-align: center;
  font-family: "Vazirmatn", system-ui, sans-serif;
  font-weight: 800;
  background: var(--ig-gradient);
}

.avatar-fallback {
  min-height: 0;
  padding: 0;
  font-size: 0.95rem;
  line-height: 1;
}

.story-avatar.avatar-fallback,
.avatar.avatar-fallback {
  display: grid;
}

.follows-row__avatar.avatar-fallback {
  display: grid;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  max-width: 44px;
  max-height: 44px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.post-media.image-fallback {
  aspect-ratio: 1 / 1;
  font-size: 1.1rem;
}

/* Admin console (built on same shell) */
.admin-top-pills .btn.active {
  background: var(--ig-surface-soft);
  border-color: var(--ig-border);
}

.admin-bottom-nav {
  border-top: 1px solid var(--ig-border);
}

.admin-kpi-card {
  box-shadow: none;
}

.admin-kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--ig-surface-soft);
  color: var(--ig-text);
  flex-shrink: 0;
}

