/* ---------- tokens ---------- */
:root {
  --bg: #0b0b0d;
  --bg-soft: #121215;
  --surface: #17171b;
  --surface-2: #202026;
  --line: #2a2a31;
  --text: #f4f4f6;
  --muted: #9a9aa4;
  --muted-2: #6e6e78;
  --accent: #ff2d55;
  --accent-soft: rgba(255, 45, 85, .14);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Vazirmatn, "Segoe UI", Tahoma, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
svg.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.app {
  min-height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-t);
}

/* ---------- topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 12px 14px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--line); }

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-weight: 700;
  letter-spacing: .2px;
}
.logo {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  box-shadow: 0 4px 14px rgba(255, 45, 85, .35);
}
.brand-name { font-size: 16px; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  transition: border-color .2s, background .2s;
}
.search:focus-within {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
  background: var(--surface-2);
}
.search-icon { color: var(--muted); flex: none; }
.search input {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  outline: none;
  font-size: 15.5px;
}
.search input::placeholder { color: var(--muted-2); }
.search input::-webkit-search-cancel-button { display: none; }
.clear {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  flex: none;
}
.clear svg { width: 14px; height: 14px; }

/* ---------- chips ---------- */
.chips {
  display: flex;
  gap: 8px;
  padding: 2px 14px 12px;
  overflow-x: auto;
  min-width: 0;
  max-width: 100%;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
  transition: transform .12s, background .2s, border-color .2s;
}
.chip:active { transform: scale(.95); }
.chip:hover { border-color: var(--muted-2); }

/* ---------- scroll area ---------- */
.scroll {
  flex: 1;
  padding: 2px 14px calc(28px + var(--safe-b));
}

/* ---------- hero ---------- */
.hero {
  padding: 26px 6px 8px;
  text-align: center;
}
.hero-art {
  width: 74px;
  height: 74px;
  margin: 0 auto 16px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(120% 120% at 30% 20%, rgba(255, 45, 85, .9), rgba(255, 45, 85, .35) 55%, transparent 70%),
    var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.hero-art .play {
  font-size: 26px;
  color: #fff;
  transform: translateX(1px);
}
.hero h1 { margin: 0 0 6px; font-size: 20px; }
.hero p { margin: 0 auto; max-width: 300px; color: var(--muted); font-size: 13.5px; }

/* ---------- result list ---------- */
.list { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; }

.card {
  position: relative;
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform .14s ease, border-color .2s, background .2s;
  animation: rise .32s ease both;
}
.card:active { transform: scale(.985); background: var(--surface-2); }
.card.sent { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }

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

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background:
    linear-gradient(135deg, #26262d, #16161a);
  align-self: start;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity .3s;
}
.thumb img.ready { opacity: 1; }
.thumb .fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted-2);
  font-size: 18px;
}
.dur {
  position: absolute;
  bottom: 5px;
  left: 5px;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .78);
  color: #fff;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  direction: ltr;
}
.live {
  position: absolute;
  top: 5px;
  right: 5px;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

.meta { min-width: 0; display: flex; flex-direction: column; }
.meta h3 {
  margin: 0 0 4px;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sub {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 6px;
}
.dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 11px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: #ff6b86;
  font-size: 12.5px;
  font-weight: 600;
  transition: background .2s, transform .1s;
}
.dl-btn:active { transform: scale(.94); }
.dl-btn svg { width: 14px; height: 14px; }
.sent-badge {
  margin-inline-start: auto;
  color: #4ade80;
  font-size: 11.5px;
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

/* ---------- skeleton ---------- */
.sk {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
}
.sk-thumb { aspect-ratio: 16 / 9; border-radius: var(--radius-sm); }
.sk-lines { display: flex; flex-direction: column; gap: 8px; padding-top: 2px; }
.sk-line { height: 11px; border-radius: 6px; }
.sk-line.w70 { width: 70%; }
.sk-line.w45 { width: 45%; }
.sk-thumb, .sk-line {
  background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 45%, var(--surface) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- states ---------- */
.state {
  padding: 44px 16px;
  text-align: center;
}
.state-icon { font-size: 34px; margin-bottom: 10px; }
.state h2 { margin: 0 0 6px; font-size: 17px; }
.state p { margin: 0 0 16px; color: var(--muted); font-size: 13.5px; }

.btn {
  height: 42px;
  padding: 0 20px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  transition: transform .12s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { width: 100%; background: var(--surface-2); border: 1px solid var(--line); }

.sentinel { height: 1px; }
.loader {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 20px 0;
}
.loader span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted-2);
  animation: bounce 1s infinite ease-in-out;
}
.loader span:nth-child(2) { animation-delay: .15s; }
.loader span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* ---------- bottom sheet ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, .58);
  backdrop-filter: blur(2px);
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } }

.sheet {
  position: fixed;
  z-index: 41;
  inset-inline: 0;
  bottom: 0;
  padding: 8px 16px calc(18px + var(--safe-b));
  border-radius: 24px 24px 0 0;
  background: var(--bg-soft);
  border-top: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: slide-up .26s cubic-bezier(.2, .9, .25, 1);
}
@keyframes slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.grabber {
  width: 38px;
  height: 4px;
  margin: 2px auto 12px;
  border-radius: 999px;
  background: var(--line);
}
.sheet-title { margin: 0 0 2px; font-size: 16px; }
.sheet-sub {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quality-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.q {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: start;
  transition: transform .1s, border-color .2s, background .2s;
}
.q:active { transform: scale(.985); background: var(--surface-2); }
.q-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: #ff6b86;
  flex: none;
}
.q-body { display: flex; flex-direction: column; }
.q-title { font-weight: 600; font-size: 14px; }
.q-desc { color: var(--muted); font-size: 11.5px; }
.q:disabled { opacity: .45; }
.q .arrow { margin-inline-start: auto; color: var(--muted-2); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: calc(26px + var(--safe-b));
  transform: translate(-50%, 20px);
  max-width: min(88vw, 380px);
  padding: 11px 18px;
  border-radius: 13px;
  background: #24242b;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  text-align: center;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: rgba(74, 222, 128, .35); }
.toast.err { border-color: rgba(255, 45, 85, .45); }

/* ---------- wide screens ---------- */
@media (min-width: 520px) {
  .app { max-width: 560px; margin: 0 auto; }
  .sheet { max-width: 560px; margin: 0 auto; border-radius: 24px 24px 0 0; }
  .bulk-bar { max-width: 560px; margin: 0 auto; }
  .card { grid-template-columns: 168px 1fr; }
  .sk { grid-template-columns: 168px 1fr; }
}

/* ---------- header extras ---------- */
.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.brand-row .brand { margin-bottom: 0; }

.text-btn {
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  transition: background .2s, color .2s, border-color .2s;
}
.text-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- channel view ---------- */
.channel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 2px 4px;
}
.icon-btn {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
}
.icon-btn:active { transform: scale(.95); }
.channel-info { min-width: 0; }
.channel-title {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.channel-sub { color: var(--muted); font-size: 12px; }

/* ---------- multi-select ---------- */
.check {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, .7);
  background: rgba(0, 0, 0, .42);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  transition: background .15s, border-color .15s, transform .15s;
}
.check svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: #fff;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}
.card.selected { border-color: color-mix(in srgb, var(--accent) 65%, var(--line)); }
.card:not(.selecting) .check { display: none; }
.card.selected .check { background: var(--accent); border-color: var(--accent); transform: scale(1.02); }
.card.selected .check svg { opacity: 1; }
.card.selecting .card-foot { display: none; }
.card.selecting .thumb { outline: 1px solid transparent; }

.channel-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.channel-btn svg { width: 14px; height: 14px; }
.channel-btn:active { transform: scale(.94); }

/* ---------- bulk action bar ---------- */
.bulk-bar {
  position: fixed;
  z-index: 35;
  inset-inline: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px calc(10px + var(--safe-b));
  background: color-mix(in srgb, var(--bg-soft) 90%, transparent);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--line);
  animation: slide-up .22s cubic-bezier(.2, .9, .25, 1);
}
.bulk-info { font-size: 12px; color: var(--muted); white-space: nowrap; }
.bulk-info strong { color: var(--text); font-size: 15px; }
.bulk-actions {
  margin-inline-start: auto;
  display: flex;
  gap: 7px;
}
.btn.mini {
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 12.5px;
}
body.has-bulk .scroll { padding-bottom: calc(120px + var(--safe-b)); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
