/* ========== Alibaba Font Faces ========== */
@font-face {
  font-family: 'Alibaba';
  src: url('assets/fonts/Alibaba-Black.ttf') format('truetype');
  font-weight: 900;
  font-display: swap;
}
@font-face {
  font-family: 'Alibaba';
  src: url('assets/fonts/Alibaba-Bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Alibaba';
  src: url('assets/fonts/Alibaba-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Alibaba';
  src: url('assets/fonts/Alibaba-Light.ttf') format('truetype');
  font-weight: 300;
  font-display: swap;
}

/* ========== CSS Variables — AMOLED Dark (default) ========== */
:root {
  --bg: #000000;
  --bg2: rgba(18, 18, 18, 0.92);
  --bg3: rgba(30, 30, 30, 0.92);
  --solid-bg: #000000;
  --solid-bg2: #0f0f0f;
  --gradient-shadow: rgba(0, 0, 0, 0.70);
  --text: #f5f5f7;
  --text2: #a1a1a6;
  --text3: #48484a;
  --sep: rgba(255, 255, 255, 0.07);
  --sep-top: rgba(255, 255, 255, 0.10);
  --accent: #ff8c42;
  --accent-dim: rgba(255, 140, 66, 0.14);
  --accent-fg: #000000;
  --font: 'Alibaba', -apple-system, sans-serif;
  --glass-bg: rgba(35, 35, 35, 0.60);
  --glass-blur: blur(12px) saturate(3);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --theme-color: #000000;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f5f7;
    --bg2: rgba(255, 255, 255, 0.85);
    --bg3: rgba(232, 232, 237, 0.90);
    --solid-bg: #f5f5f7;
    --solid-bg2: #ffffff;
    --gradient-shadow: rgba(245, 245, 247, 0.70);
    --text: #1d1d1f;
    --text2: #6e6e73;
    --text3: #aeaeb2;
    --sep: rgba(0, 0, 0, 0.07);
    --sep-top: rgba(255, 255, 255, 0.70);
    --accent: #f07020;
    --accent-dim: rgba(240, 112, 32, 0.10);
    --accent-fg: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.78);
    --glass-blur: blur(12px) saturate(3);
    --theme-color: #f5f5f7;
  }
}

/* ========== Reset & Base ========== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

input,
textarea {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
  touch-action: manipulation;
}

img {
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

a {
  -webkit-touch-callout: none;
  pointer-events: auto;
}

button,
a,
[onclick] {
  touch-action: manipulation;
}

html,
body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--solid-bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  touch-action: none;
}

/* ========== App Shell ========== */
#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  background: var(--solid-bg);
}

/* ========== Screen ========== */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: transparent;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  width: 100%;
  will-change: transform, opacity;
}

.screen.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

/* ========== Page Header ========== */
.page-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  padding: max(20px, calc(var(--safe-top) + 14px)) 16px 14px;
  display: flex;
  direction: rtl;
  align-items: center;
  justify-content: flex-start;
  background: transparent;
}

.page-header::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: -10px;
  background: linear-gradient(to bottom, var(--gradient-shadow) 0%, transparent 100%);
  pointer-events: none;
  z-index: -1;
}

.page-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.3px;
  text-align: right;
  color: var(--text);
  direction: rtl;
  width: 100%;
}

/* ========== Support Button ========== */
.support-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--sep-top);
  border-bottom: 1px solid var(--sep-top);
  border-left: none;
  border-right: none;
  color: var(--text2);
  cursor: pointer;
  padding: 7px 14px;
  border-radius: 50px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.support-btn:active {
  transform: scale(.95);
  color: var(--text);
}

/* ========== Support Modal ========== */
.support-modal-body {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.support-tabs {
  display: flex;
  direction: rtl;
  gap: 6px;
  width: 100%;
}

.support-tab {
  flex: 1;
  padding: 8px 6px;
  border-radius: 50px;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font);
  border: none;
  cursor: pointer;
  background: var(--bg3);
  color: var(--text3);
  transition: background .18s, color .18s;
  white-space: nowrap;
  text-align: center;
}

.support-tab.active {
  background: var(--accent);
  color: var(--accent-fg);
}

.support-tab:active {
  transform: scale(.95);
}

.support-pane {
  display: none;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.support-pane.active {
  display: flex;
}

.support-desc {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.8;
  background: var(--bg2);
  border-radius: 14px;
  padding: 14px 16px;
  text-align: right;
  direction: rtl;
  font-weight: 500;
}

.support-wallet-addr {
  font-size: 12px;
  color: var(--text2);
  background: var(--bg3);
  border-radius: 12px;
  padding: 12px 14px;
  direction: ltr;
  text-align: left;
  font-weight: 700;
  word-break: break-all;
  cursor: pointer;
  transition: background .15s;
  border: 1px solid var(--sep);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.support-wallet-addr:active {
  background: var(--bg2);
}

.support-wallet-copy-hint {
  font-size: 11px;
  color: var(--text3);
  flex-shrink: 0;
  font-family: var(--font);
}

.support-action-btn {
  width: 100%;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: 50px;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity .15s;
  text-decoration: none;
}

.support-action-btn:active {
  opacity: .8;
}

/* ========== Main Pane ========== */
.ent-pane {
  flex: 1;
  position: relative;
  overflow: hidden;
  width: 100%;
  z-index: 1;
}

/* ========== Suggestions / Notifications placeholder screens ========== */
.coming-soon-screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text3);
  padding: 40px;
  padding-top: calc(var(--safe-top) + 72px);
  text-align: center;
}

.coming-soon-screen.active {
  display: flex;
}

.coming-soon-screen .coming-soon-emoji {
  font-size: 52px;
  opacity: .45;
}

.coming-soon-screen .coming-soon-text {
  font-size: 18px;
  font-weight: 700;
  direction: rtl;
}

/* ========== History / Saved scroll ========== */
.history-section-wrapper {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: 100%;
}

.history-scroll {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: calc(var(--safe-top) + 72px) 16px calc(110px + var(--safe-bottom));
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  width: 100%;
  box-sizing: border-box;
  align-content: start;
  -webkit-overflow-scrolling: touch;
}

/* ========== Cards ========== */
.history-card {
  width: 100%;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  position: relative;
}

.history-card-image-container {
  position: relative;
  width: 100%;
  aspect-ratio: 2/3;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg3);
}

.history-card-image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.history-card-gradient {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 65%;
  background: linear-gradient(to top, rgba(0, 0, 0, .6) 0%, rgba(0, 0, 0, 0) 100%);
  z-index: 1;
  pointer-events: none;
}

.history-card-badges {
  position: absolute;
  bottom: 6px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 2;
  direction: ltr;
}

.history-badge-imdb {
  color: #f5c518;
  font-size: 12px;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .8);
}

.history-badge-year {
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .8);
}

.history-card-texts {
  margin-top: 7px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  width: 100%;
}

.history-card-texts-fa {
  font-size: 12px;
  font-weight: 700;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  direction: ltr;
  text-align: left;
  color: var(--text);
}

/* ========== Movie Results Grid ========== */
.movie-results-list {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: calc(var(--safe-top) + 72px) 16px calc(110px + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  width: 100%;
  align-content: start;
  -webkit-overflow-scrolling: touch;
}

/* ========== Placeholder ========== */
#placeholder,
#saved-empty-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text3);
  padding: 40px;
  padding-top: calc(var(--safe-top) + 72px);
  text-align: center;
  width: 100%;
}

/* ========== Loading Skeleton ========== */
@keyframes shimmer {
  0% { background-position: 200% center; }
  100% { background-position: -200% center; }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg3) 25%, var(--bg2) 50%, var(--bg3) 75%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 10px;
}

.loading-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 8px 16px calc(110px + var(--safe-bottom));
  align-content: start;
  width: 100%;
}

.loading-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.loading-card-img {
  width: 100%;
  aspect-ratio: 2/3;
  border-radius: 10px;
}

.loading-card-txt {
  height: 12px;
  border-radius: 6px;
  width: 80%;
  align-self: flex-end;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--bg3);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto;
}

/* ========== Bottom Gradient Overlay ========== */
.bottom-gradient-overlay {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  height: calc(90px + var(--safe-bottom));
  background: linear-gradient(to top, var(--gradient-shadow) 0%, transparent 100%);
  pointer-events: none;
  z-index: 84;
}

#search-screen.visible ~ .bottom-gradient-overlay {
  display: none;
}

/* ========== Bottom Nav Area ========== */
.bottom-nav-area {
  position: fixed;
  bottom: calc(14px + var(--safe-bottom));
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  direction: ltr;
  gap: 10px;
  z-index: 100;
  padding: 0 16px;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}

.bottom-nav-area.hidden {
  opacity: 0;
  transform: translateY(80px);
  pointer-events: none !important;
}

.bottom-navbar {
  display: flex;
  align-items: center;
  border-radius: 50px;
  padding: 5px 8px;
  gap: 2px;
  pointer-events: all;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--sep-top);
  border-bottom: 1px solid var(--sep-top);
  border-left: none;
  border-right: none;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 16px;
  border-radius: 50px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  transition: background .18s, color .18s, transform .15s;
  white-space: nowrap;
  min-width: 64px;
  height: 50px;
}

.nav-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-btn.active {
  color: var(--accent);
  background: var(--accent-dim);
}

.nav-btn:active:not(:disabled) {
  transform: scale(.92);
}

.search-bubble-btn {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .15s;
  pointer-events: all;
  flex-shrink: 0;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--sep-top);
  border-bottom: 1px solid var(--sep-top);
  border-left: none;
  border-right: none;
}

.search-bubble-btn svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: var(--text);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-bubble-btn:active {
  transform: scale(.9);
}

/* ========== Movie Detail Overlay ========== */
#movie-detail-overlay {
  position: absolute;
  inset: 0;
  background: var(--solid-bg);
  z-index: 60;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  width: 100%;
  height: 100%;
  overflow: hidden;
  will-change: transform, opacity;
}

#movie-detail-overlay.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.movie-detail-header-wrapper {
  padding-top: var(--safe-top);
  background: transparent;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.movie-detail-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  direction: rtl;
  height: 48px;
  padding: 0 16px;
  box-sizing: border-box;
}

.header-spacer {
  width: 44px;
  flex-shrink: 0;
}

.movie-detail-title-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 0;
  padding: 0 10px;
}

.movie-detail-title-fa {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-align: center;
  color: var(--text);
}

.movie-detail-title-en {
  font-size: 11px;
  color: var(--text3);
  direction: ltr;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-align: center;
  margin-top: 2px;
}

.btn-back {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  border-radius: 50%;
  transition: background .15s;
}

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

.btn-back:active {
  background: rgba(128, 128, 128, 0.15);
}

.movie-detail-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-bottom: calc(80px + var(--safe-bottom));
  display: block;
  width: 100%;
}

.mb-16 {
  margin-bottom: 16px;
}

.movie-detail-top {
  display: flex;
  direction: rtl;
  gap: 16px;
  align-items: flex-start;
}

.movie-detail-cover {
  width: 110px;
  height: 160px;
  border-radius: 14px;
  object-fit: cover;
  background: var(--bg3);
  flex-shrink: 0;
}

.movie-detail-titles {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  min-width: 0;
  min-height: 160px;
  justify-content: flex-start;
}

.movie-detail-fa-title {
  font-size: 18px;
  font-weight: 700;
  direction: rtl;
  text-align: right;
  width: 100%;
  line-height: 1.3;
}

.movie-detail-en-title {
  font-size: 13px;
  color: var(--text3);
  direction: ltr;
  text-align: right;
  width: 100%;
  line-height: 1.3;
  word-wrap: break-word;
}

.detail-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
  width: 100%;
  flex-wrap: wrap;
}

.detail-action-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg3);
  color: var(--text);
  border: none;
  padding: 8px 14px;
  height: 34px;
  border-radius: 50px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}

.detail-action-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--text);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: all .2s;
}

.detail-action-btn:active {
  transform: scale(.95);
  opacity: .8;
}

.detail-action-btn.saved {
  color: var(--accent);
}

.detail-action-btn.saved svg {
  fill: var(--accent);
  stroke: var(--accent);
}

.imdb-gold-box {
  flex-shrink: 0;
  background: #f5c518;
  color: #000;
  font-weight: 900;
  font-size: 14px;
  padding: 0 12px;
  height: 34px;
  border-radius: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  direction: ltr;
}

.movie-info-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  direction: rtl;
}

.info-tag {
  background: var(--bg3);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  white-space: nowrap;
}

.movie-summary-box {
  font-size: 13px;
  color: var(--text);
  line-height: 1.8;
  background: var(--bg2);
  padding: 14px;
  border-radius: 16px;
  text-align: justify;
  direction: rtl;
  font-weight: 500;
}

/* ========== Season selector ========== */
.season-selector-box {
  background: var(--bg2);
  border-radius: 18px;
  padding: 14px;
  direction: rtl;
}

.season-selector-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  text-align: right;
}

.custom-select-wrapper {
  position: relative;
  user-select: none;
  width: 100%;
  direction: rtl;
}

.custom-select-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg3);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.custom-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--solid-bg2);
  border: 1px solid var(--sep);
  border-radius: 10px;
  margin-top: 8px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-10px);
  transition: all 0.3s cubic-bezier(.4, 0, .2, 1);
  z-index: 50;
  max-height: 250px;
  overflow-y: auto;
}

.custom-select-wrapper.open .custom-options {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
  transform: translateY(0);
}

.custom-option {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: background .2s;
  border-bottom: 1px solid var(--sep);
  text-align: right;
}

.custom-option:last-child {
  border-bottom: none;
}

.custom-option:hover {
  background: var(--bg3);
}

.custom-option.selected {
  background: var(--text);
  color: var(--solid-bg);
}

.arrow-icon {
  transition: transform 0.3s;
  font-size: 12px;
}

.custom-select-wrapper.open .arrow-icon {
  transform: rotate(180deg);
}

.movie-section-box {
  background: var(--bg2);
  border-radius: 18px;
  direction: rtl;
  overflow: hidden;
  position: relative;
  z-index: 10;
}

.movie-ep-row {
  display: flex;
  align-items: center;
  direction: rtl;
  padding: 14px 16px;
  gap: 10px;
  border-bottom: 1px solid var(--sep);
  flex-wrap: nowrap;
}

.movie-ep-row:last-child {
  border-bottom: none;
}

.movie-ep-label {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  direction: rtl;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.movie-ep-badge {
  background: var(--bg3);
  padding: 4px 8px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
  color: var(--text);
  direction: ltr;
}

.movie-ep-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.ep-btn {
  padding: 8px 16px;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  transition: opacity .15s;
  white-space: nowrap;
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.ep-btn:active {
  opacity: .72;
}

.ep-btn-copy {
  background: var(--accent);
  color: var(--accent-fg);
}

/* ========== Search Screen ========== */
#search-screen {
  position: fixed;
  inset: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--solid-bg);
  z-index: 80;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
  will-change: opacity;
}

#search-screen.visible {
  opacity: 1;
  pointer-events: all;
}

.search-screen-top {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-top: calc(var(--safe-top) + 16px);
  padding-bottom: calc(80px + var(--safe-bottom));
}

.search-screen-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  direction: rtl;
  padding: 0 16px 18px;
}

.search-screen-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  direction: rtl;
}

.search-clear-all-btn {
  background: var(--bg3);
  border: none;
  color: var(--text3);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}

.search-clear-all-btn svg {
  width: 18px;
  height: 18px;
}

.search-clear-all-btn:active {
  background: rgba(128, 128, 128, 0.2);
}

.search-section-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text3);
  padding: 0 16px 10px;
  text-align: right;
  direction: rtl;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.search-recent-scroll {
  display: flex;
  flex-direction: row;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 16px 18px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.search-recent-scroll::-webkit-scrollbar {
  display: none;
}

.search-recent-card {
  flex-shrink: 0;
  width: 90px;
  cursor: pointer;
}

.search-recent-card-img {
  position: relative;
  width: 90px;
  height: 123px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg3);
}

.search-recent-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.search-recent-card-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  text-align: left;
  direction: ltr;
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.search-queries-list {
  padding: 0 16px 16px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
  direction: rtl;
}

.search-query-item {
  display: inline-flex;
  align-items: center;
  direction: rtl;
  gap: 0;
  padding: 9px 16px;
  border-radius: 50px;
  cursor: pointer;
  transition: background .15s;
  background: var(--bg2);
  flex-shrink: 0;
}

.search-query-item:active {
  background: var(--bg3);
}

.search-query-icon,
.search-query-icon svg {
  display: none;
}

.search-query-text {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  direction: rtl;
}

/* ========== Search results body ========== */
.search-screen-body {
  display: none;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(90px + var(--safe-bottom));
  flex: 1;
  position: relative;
  min-height: 0;
}

.search-screen-body.active {
  display: block;
}

/* ========== Search body bottom gradient (mirror of filter-tabs::before) ========== */
.search-screen-body::after {
  content: '';
  position: sticky;
  bottom: -90px;
  left: 0;
  right: 0;
  display: block;
  height: 80px;
  background: linear-gradient(to top, var(--gradient-shadow) 0%, transparent 100%);
  pointer-events: none;
  z-index: 4;
}

/* ========== Filter tabs — sticky داخل search-screen-body ========== */
.search-tabs-bar {
  position: sticky;
  top: 0;
  z-index: 5;
}

.search-tabs-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: -28px;
  background: linear-gradient(to bottom, var(--gradient-shadow) 0%, transparent 100%);
  pointer-events: none;
  z-index: -1;
}

.search-filter-tabs {
  display: flex;
  direction: rtl;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 8px;
  background: transparent;
  position: relative;
  z-index: 1;
}

.filter-tab {
  padding: 7px 16px;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 700;
  backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--sep-top);
  border-bottom: 1px solid var(--sep-top);
  font-family: var(--font);
  border-left: none;
  border-right: none;
  cursor: pointer;
  background: var(--glass-bg);
  color: var(--text3);
  transition: background .18s, color .18s;
  white-space: nowrap;
}

.filter-tab.active {
  background: var(--accent);
  color: var(--accent-fg);
}

.filter-tab:active {
  transform: scale(.95);
}

.search-results-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 8px 16px 16px;
  align-content: start;
}

/* ========== Floating Search Bar ========== */
.search-floating-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: min(480px, 100%);
  width: 100%;
  margin: 0 auto;
  z-index: 85;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 10px 16px calc(10px + var(--safe-bottom));
  direction: rtl;
  pointer-events: none;
  box-sizing: border-box;
}

#search-screen.visible .search-floating-bar {
  pointer-events: all;
}

.search-input-bubble {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  border-radius: 50px;
  padding: 0 18px;
  height: 50px;
  margin-left: 8px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--sep-top);
  border-bottom: 1px solid var(--sep-top);
  border-left: none;
  border-right: none;
  overflow: hidden;
}

.search-submit-bubble.show {
  margin-left: 8px;
}

#search-screen-input {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-family: var(--font);
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  direction: rtl;
  text-align: right;
  height: 100%;
}

#search-screen-input::placeholder {
  color: var(--text3);
}

.search-close-bubble {
  width: 50px;
  height: 50px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity .15s;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--sep-top);
  border-bottom: 1px solid var(--sep-top);
  border-left: none;
  border-right: none;
}

.search-close-bubble svg {
  width: 20px;
  height: 20px;
  stroke: var(--text);
}

.search-close-bubble:active {
  opacity: .7;
}

.search-submit-bubble {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  background: var(--accent);
  border-top: 1px solid var(--sep-top);
  border-bottom: 1px solid var(--sep-top);
  border-left: none;
  border-right: none;
  opacity: 0;
  transform: scale(0.5) translateX(-10px);
  width: 0;
  overflow: hidden;
  padding: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease, width .2s ease;
}

.search-submit-bubble.show {
  opacity: 1;
  transform: scale(1) translateX(0);
  width: 50px;
  pointer-events: all;
}

.search-submit-bubble svg {
  width: 20px;
  height: 20px;
  stroke: var(--accent-fg);
  flex-shrink: 0;
}

.search-submit-bubble:active {
  transform: scale(.9);
}

/* ========== Toast ========== */
#toast {
  position: fixed;
  bottom: calc(90px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(14px);
  background: rgba(129, 129, 129, 0.5);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  color: var(--text);
  border-top: 1px solid var(--sep-top);
  border-bottom: 1px solid var(--sep-top);
  border-left: none;
  border-right: none;
  padding: 10px 20px;
  direction: rtl;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  white-space: nowrap;
  z-index: 200;
  font-family: var(--font);
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ========== Error State ========== */
.error-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px 24px;
  text-align: center;
  color: var(--text3);
  flex: 1;
  min-height: 50vh;
}

.error-box .error-icon {
  font-size: 44px;
  opacity: .5;
}

.error-box .error-msg {
  font-size: 14px;
  font-weight: 600;
  direction: rtl;
  line-height: 1.6;
  color: var(--text2);
}

.retry-btn {
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: 50px;
  padding: 10px 28px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity .15s;
}

.retry-btn:active {
  opacity: .8;
}

/* ========== Sort Panel ========== */
.sort-panel {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--sep-top);
  border-bottom: 1px solid var(--sep-top);
  border-left: 1px solid var(--sep);
  border-right: 1px solid var(--sep);
  border-radius: 16px;
  padding: 6px;
  z-index: 200;
  min-width: 160px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  opacity: 0;
  transform: scale(0.92) translateY(-6px);
  transform-origin: top left;
  transition: opacity .18s ease, transform .18s ease;
}

.sort-panel.visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.sort-panel-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  color: var(--text2);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: right;
  direction: rtl;
  border-radius: 10px;
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.sort-panel-item:active,
.sort-panel-item:hover {
  background: var(--bg3);
  color: var(--text);
}

.sort-panel-item.active {
  color: var(--text);
  background: rgba(128,128,128,0.15);
}

/* ========== Sort Button ========== */
.sort-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 50px;
  backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--sep-top);
  border-bottom: 1px solid var(--sep-top);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  background: var(--glass-bg);
  color: var(--text3);
  border-right: none;
  border-left: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background .18s, color .18s;
  margin-right: auto;
}

.sort-btn svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sort-btn.active {
  background: var(--text);
  color: var(--solid-bg);
}

.sort-btn:active {
  transform: scale(.95);
}

/* ========== PWA Install Banner ========== */
#ios-install-banner {
  display: none;
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left: 16px;
  right: 16px;
  max-width: calc(480px - 32px);
  margin: 0 auto;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--sep-top);
  border-bottom: 1px solid var(--sep-top);
  border-left: none;
  border-right: none;
  border-radius: 18px;
  padding: 14px 16px;
  direction: rtl;
  text-align: right;
  z-index: 150;
  animation: slideUp .4s cubic-bezier(.4, 0, .2, 1);
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ========== Detail loading ========== */
.detail-loading-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  flex: 1;
  min-height: 60vh;
  padding: 24px;
}

.detail-loading-wrap .loading-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text3);
  direction: rtl;
}

/* ========== Card stagger animation ========== */
@keyframes cardFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.card-animate {
  opacity: 0;
  animation: cardFadeIn 0.28s ease forwards;
}

/* ========== Floating Queries (بالای search bar، فقط در focus) ========== */
.search-floating-queries {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: min(480px, 100%);
  margin: 0 auto;
  z-index: 84;
  padding: 0 16px 8px;
  display: flex;
  flex-direction: row;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  direction: rtl;
  scrollbar-width: none;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
  box-sizing: border-box;
}

.search-floating-queries::-webkit-scrollbar { display: none; }

.search-floating-queries.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.floating-query-chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 50px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: none;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  color: var(--text2);
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s;
}

.floating-query-chip:active {
  color: var(--text);
  transform: scale(.95);
}

/* ========== AI Button ========== */
.ai-coming-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 32px);
  margin: 4px 16px 16px;
  padding: 14px 20px;
  border-radius: 18px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  background: linear-gradient(135deg, rgba(99,102,241,0.12) 0%, rgba(168,85,247,0.12) 50%, rgba(236,72,153,0.12) 100%);
  border-top: 1px solid rgba(168,85,247,0.3);
  border-bottom: 1px solid rgba(99,102,241,0.2);
  border-left: none;
  border-right: none;
  position: relative;
  overflow: hidden;
  transition: opacity .2s, transform .15s;
}

.ai-coming-btn:active { transform: scale(.98); opacity: .85; }
.keyboard-gap {
  height: 0;
  flex-shrink: 0;
  transition: height .15s ease;
  width: 100%;
  display: block;
}

/* ========== PWA Install Modal ========== */
.pwa-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: pwaBackdropIn .25s ease;
}

@keyframes pwaBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pwaBackdropOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.pwa-modal-backdrop.closing {
  animation: pwaBackdropOut .3s ease forwards;
}

.pwa-modal-box {
  background: var(--solid-bg2);
  border-radius: 28px 28px 0 0;
  padding: 20px 24px calc(24px + var(--safe-bottom));
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  direction: rtl;
  text-align: center;
  border-top: 1px solid var(--sep-top);
  animation: pwaSheetUp .35s cubic-bezier(.32, 0, .15, 1);
}

@keyframes pwaSheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes pwaSheetDown {
  from { transform: translateY(0); }
  to { transform: translateY(100%); }
}

.pwa-modal-box::before {
  content: '';
  display: block;
  width: 40px;
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  margin-bottom: 6px;
}

.pwa-modal-icon {
  width: 76px;
  height: 76px;
  border-radius: 18px;
  overflow: hidden;
}

.pwa-modal-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pwa-modal-title {
  font-size: 22px;
  font-weight: 900;
  color: var(--text);
}

.pwa-modal-desc {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.7;
  font-weight: 500;
}

.pwa-install-guide {
  font-size: 13px;
  color: var(--text3);
  line-height: 1.8;
  background: rgb(127 127 127 / 10%);
  border-radius: 16px;
  padding: 14px 16px;
  width: 100%;
  text-align: right;
  direction: rtl;
  font-weight: 500;
}

.pwa-install-guide strong {
  color: var(--text);
}

.pwa-btn-install {
  width: 100%;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: 50px;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity .15s;
  margin-top: 4px;
}

.pwa-btn-install:active {
  opacity: .8;
}

.pwa-btn-close {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 50px;
  transition: color .15s;
}

.pwa-btn-close:active {
  color: var(--text);
}

/* ========== Notifications Screen ========== */
.notifications-screen-wrapper {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
  width: 100%;
}

.notifications-screen-wrapper.active {
  display: flex;
}

.notifications-scroll {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: calc(var(--safe-top) + 72px) 16px calc(110px + var(--safe-bottom));
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  position: absolute;
  inset: 0;
  width: 100%;
  -webkit-overflow-scrolling: touch;
}

.notif-card {
  background: var(--bg2);
  border-radius: 25px;
  padding: 18px 16px;
  direction: rtl;
  text-align: right;
}

.notif-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 4px;
}

.notif-card-time {
  font-size: 11px;
  color: var(--text3);
  font-weight: 600;
  margin-bottom: 10px;
}

.notif-card-body {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.8;
  font-weight: 500;
}
