/* =====================================================================
   پارسا تی‌وی
   پوسته‌ی «رک» — همون پالت پروژه‌ی store: زمینه‌ی خیلی تیره،
   یک رنگ تأکیدی، و نارنجی/قرمز فقط برای وضعیت (نه تزئین).
   ===================================================================== */

:root {
  color-scheme: dark;

  /* سطح‌ها */
  --rack:    #06090a;   /* پس‌زمینه‌ی صفحه — تیره‌ترین */
  --bay:     #0a1012;   /* بندها، کارت‌ها، پنل‌ها */
  --bay-2:   #0f1719;   /* اینپوت‌ها و سطح بالاتر */
  --hair:    #1a2427;   /* خطِ مویی جداکننده */
  --hair-2:  #273437;   /* حاشیه‌ی قوی‌تر / hover */

  /* متن */
  --ink:     #e9f0ed;   /* متن اصلی */
  --ink-2:   #b7c6c2;   /* متن لینک و ثانویه */
  --dim:     #839692;   /* متن توضیحات و ثابت */

  /* تنها رنگ تأکیدی سایت */
  --link:        #34e0b0;
  --link-hover:  #4deec2;
  --link-on:     #04120d;   /* متن روی دکمه‌ی سبز */
  --link-soft:   rgba(52, 224, 176, 0.07);
  --link-line:   rgba(52, 224, 176, 0.34);

  /* وضعیت‌ها */
  --hold:      #e8a33d;   /* نارنجی — هشدار / در حال آماده‌سازی */
  --hold-soft: rgba(232, 163, 61, 0.08);
  --hold-line: rgba(232, 163, 61, 0.34);
  --cut:       #ff6b5e;   /* قرمز مرجانی — خطا / سیگنال زنده */
  --cut-soft:  rgba(255, 107, 94, 0.07);
  --cut-line:  rgba(255, 107, 94, 0.34);

  /* دستگاه */
  --well:  #000000;   /* چاه ویدیو */
  --bezel: var(--bay-2); /* قاب پلیر */

  /* نوار رنگ‌های کارت تست — فقط برای نشانِ کانالِ بدون لوگو */
  --t0: #ffd84d;
  --t1: #7fd6ee;
  --t2: #77d9a4;
  --t3: #f3a3d8;
  --t4: #f79a86;
  --t5: #a3b4f5;

  --sans: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;

  --r: 14px;
  --topbar-h: 64px;
}
* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--rack);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

body { overflow-x: hidden; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
  border-radius: 4px;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--hair-2); border-radius: 9px; }
::-webkit-scrollbar-thumb:hover { background: #3a4a4e; }

/* ================================================================
   هدر
   ================================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--topbar-h);
  padding: 0 20px;
  background: var(--bay);
  border-bottom: 1px solid var(--hair);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  flex-shrink: 0;
}

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  background: var(--link-soft);
  border: 1px solid var(--link-line);
  border-radius: 8px;
  color: var(--link);
}
.brand-mark svg { width: 18px; height: 18px; display: block; }

.brand-name {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  white-space: nowrap;
  color: var(--ink);
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 460px;
  min-width: 0;
}
.search-icon {
  position: absolute;
  right: 12px;
  width: 17px;
  height: 17px;
  color: var(--dim);
  pointer-events: none;
}
#search {
  width: 100%;
  height: 40px;
  padding: 0 38px 0 36px;
  background: var(--bay-2);
  border: 1px solid var(--hair);
  border-radius: 11px;
  font-size: 16px;      /* زیر ۱۶px باعث زومِ خودکار iOS می‌شه */
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
#search::placeholder { color: var(--dim); }
#search::-webkit-search-cancel-button { display: none; }
#search:focus {
  background: var(--bay-2);
  border-color: var(--link);
  box-shadow: 0 0 0 3px rgba(52, 224, 176, 0.15);
}
.search-clear {
  position: absolute;
  left: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: var(--dim);
}
.search-clear:hover { background: var(--hair-2); color: var(--ink); }
.search-clear svg { width: 15px; height: 15px; }

/* دکمه‌ی «انجام» — فقط در حالت جستجوی موبایل دیده می‌شه */
.search-done {
  display: none;
  flex-shrink: 0;
  align-items: center;
  height: 40px;
  padding: 0 14px;
  background: var(--link);
  border: 0;
  border-radius: 11px;
  color: var(--link-on);
  font-size: 14px;
  font-weight: 600;
}

.topbar-end {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
  margin-right: auto;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--hair);
}
.dot[data-state="ready"]  { background: var(--link); }
.dot[data-state="warming"]{ background: var(--link); }
.dot[data-state="error"]  { background: var(--cut); }
.count {
  font-size: 13px;
  color: var(--dim);
  padding: 5px 10px;
  background: var(--bay-2);
  border: 1px solid var(--hair);
  border-radius: 9px;
  white-space: nowrap;
}

/* ================================================================
   چیدمان کلی
   ================================================================ */
.stage {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  max-width: 1560px;
  margin: 0 auto;
  padding: 22px 20px 64px;
}

/* ================================================================
   دکمه‌ی پخش
   ================================================================ */
.deck {
  min-width: 0;
  position: sticky;                          /* موقع اسکرول فهرست، پلیر بمونه */
  top: calc(var(--topbar-h) + 22px);
}

.monitor {
  background: var(--bezel);
  border: 1px solid #000;
  border-radius: var(--r);
  padding: 10px;
  box-shadow:
    0 24px 50px -34px rgba(0, 0, 0, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.monitor-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 4px 9px;
  font-size: 12px;
  color: var(--dim);
}

.live-badge {
  position: absolute;
  top: 12px;
  inset-inline-start: 12px;
  z-index: 3;
  display: none;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--cut-line);
  border-radius: 999px;
  color: var(--cut);
  font-size: 11px;
  line-height: 1;
  letter-spacing: 1.4px;
  direction: ltr;
  pointer-events: none;
  transition: opacity .25s;
}
.live-badge.on { display: flex; }

/* موقع پخش و بی‌حرکتی، نشان LIVE هم با کنترل‌ها محو می‌شه */
.screen.controls-idle .live-badge { opacity: 0; }

/* چراغِ زنده چشمک می‌زنه — پرش سخت، مثل چراغِ ضبطِ تجهیزات پخش */
.live-badge i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
  animation: blink 1.15s step-end infinite;
}
@keyframes blink {
  0%, 55%   { opacity: 1; }
  56%, 100% { opacity: 0.12; }
}

.now {
  flex: 1;
  min-width: 0;
  color: var(--ink);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ch-no {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--link);
  padding: 2px 8px;
  border: 1px solid var(--link-line);
  border-radius: 6px;
  direction: ltr;   /* برچسب ماشینی: CH 042 */
}

/* نوار رنگ — سیگنال */
.rail {
  display: flex;
  gap: 2px;
  height: 4px;
  margin-bottom: 8px;
  border-radius: 3px;
  overflow: hidden;
  opacity: 0.35;
  transition: opacity .3s;
}
.rail.locked { opacity: 1; }
.rail i { flex: 1; }
.rail i:nth-child(1) { background: #c9c9c9; }
.rail i:nth-child(2) { background: #c9c900; }
.rail i:nth-child(3) { background: #00c9c9; }
.rail i:nth-child(4) { background: #00c900; }
.rail i:nth-child(5) { background: #c900c9; }
.rail i:nth-child(6) { background: #c90000; }
.rail i:nth-child(7) { background: #1a1ac9; }

/* چاه ویدیو */
.screen {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 9px;
  overflow: hidden;
  isolation: isolate;
}

#video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #000;
  object-fit: contain;   /* نسبتِ تصویر حفظ بشه، کش نیاد */
}

/* کارت تست — وضعیت بدون سیگنال */
.testcard {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--well);
  transition: opacity .25s;
}
.testcard.off { opacity: 0; pointer-events: none; }

.testcard-bars {
  flex: 1;
  background: linear-gradient(90deg,
    #b8b8b8 0 14.2857%,
    #b8b800 14.2857% 28.5714%,
    #00b8b8 28.5714% 42.8571%,
    #00b800 42.8571% 57.1428%,
    #b800b8 57.1428% 71.4285%,
    #b80000 71.4285% 85.7142%,
    #1a1ab8 85.7142% 100%);
  opacity: 0.82;
}

.testcard-pluge {
  display: flex;
  height: 22%;
  min-height: 34px;
}
.testcard-pluge i:nth-child(1) { flex: 3; background: #0a0a0a; }
.testcard-pluge i:nth-child(2) { flex: 1; background: #1c1c1c; }
.testcard-pluge i:nth-child(3) { flex: 3; background: #050505; }

.testcard-label {
  position: absolute;
  left: 50%;
  bottom: 16%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 9px 18px;
  background: rgba(0, 0, 0, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 12.5px;
  text-align: center;
  white-space: nowrap;
}
.testcard-label .mono {
  font-size: 10.5px;
  letter-spacing: 1.6px;
  color: var(--link);
  direction: ltr;
}

/* نشانگر لود */
.buffering {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 15px;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: var(--ink);
  font-size: 12.5px;
  z-index: 5;
}
.buffering i {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-top-color: var(--link);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* نشان موقت */
.toast {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 13px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  color: var(--link);
  font-size: 11.5px;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
  z-index: 6;
}
.toast.show { opacity: 1; }

/* ================================================================
   کنترل‌های پخش
   ================================================================ */
.pcontrols {
  position: absolute;
  inset: auto 0 0 0;
  padding: 26px 10px 9px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.86) 0%, rgba(0, 0, 0, 0.4) 55%, transparent 100%);
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
  z-index: 4;
}
/* کنترل‌ها همیشه دیده می‌شن، مگر وقتی پلیر در حالت «بی‌حرکت»ه —
   اون حالت رو جاوااسکریپت موقع پخش، بعد از چند ثانیه بی‌حرکتی می‌ذاره */
.screen:not(.controls-idle) .pcontrols,
.pcontrols:focus-within {
  opacity: 1;
  pointer-events: auto;
}
/* موقع پخش و بی‌حرکتی، نشانگر موس هم محو می‌شه */
.screen.controls-idle { cursor: none; }

.prow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.grp { display: flex; align-items: center; gap: 5px; }

.pbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 34px;
  height: 34px;
  padding: 0 7px;
  background: rgba(255, 255, 255, 0.13);
  border: 0;
  border-radius: 8px;
  color: #fff;
  transition: background .14s, transform .1s;
}
.pbtn:hover { background: rgba(255, 255, 255, 0.24); }
.pbtn:active { transform: scale(0.94); }
.pbtn svg { width: 18px; height: 18px; }
.pbtn--wide { padding: 0 11px; }
.pbtn .qlabel { font-size: 11px; font-weight: 500; }

.hidden, .i-pause, .i-voff, .i-comp { display: none; }
#btnPlay.on .i-play    { display: none; }
#btnPlay.on .i-pause   { display: block; }
#btnMute.on .i-von     { display: none; }
#btnMute.on .i-voff    { display: block; }
#btnFullscreen.on .i-exp  { display: none; }
#btnFullscreen.on .i-comp { display: block; }

.vol { display: flex; align-items: center; gap: 6px; }
.vol-range {
  direction: ltr;          /* صدا در همه‌ی زبان‌ها از چپ به راست */
  width: 68px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  outline: none;
  accent-color: var(--link);
}
.vol-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
}

/* منوی کیفیت */
.qwrap { position: relative; }
.qpanel {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 148px;
  padding: 5px;
  background: var(--bay-2);
  border: 1px solid var(--hair-2);
  border-radius: 10px;
  box-shadow: 0 -14px 34px -14px rgba(0, 0, 0, 0.8);
  display: none;
  z-index: 9;
}
.qpanel.open { display: block; }

.qitem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--dim);
  font-size: 13px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.qitem:hover { background: var(--link-soft); color: var(--ink); }
.qitem.on { color: var(--link); background: var(--link-soft); box-shadow: inset 0 0 0 1px var(--link-line); }
.qsep { height: 1px; margin: 4px 2px; background: rgba(255, 255, 255, 0.14); }
.qbadge {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
  background: rgba(255, 255, 255, 0.07);
  padding: 2px 5px;
  border-radius: 4px;
}
.qitem.on .qbadge { color: var(--link); background: var(--link-soft); }

/* نشانگر ABR */
.qsignal { display: flex; align-items: flex-end; gap: 2px; height: 13px; }
.qsignal i {
  display: block;
  width: 3px;
  border-radius: 2px;
  background: var(--dim);
  transition: background .2s;
}
.qsignal i:nth-child(1) { height: 4px; }
.qsignal i:nth-child(2) { height: 8px; }
.qsignal i:nth-child(3) { height: 12px; }
.qitem.on .qsignal i { background: var(--link); }

/* ================================================================
   زیرِ دکمه
   ================================================================ */
.deck-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
  padding: 13px 16px;
  background: var(--bay);
  border: 1px solid var(--hair);
  border-radius: var(--r);
}

.now-block { min-width: 0; }
.now-block .lbl {
  display: block;
  font-size: 11.5px;
  color: var(--dim);
  margin-bottom: 2px;
}
.now-block .ttl {
  display: block;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.now-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.grp-label {
  font-size: 12px;
  color: var(--ink-2);
  padding: 4px 10px;
  background: var(--hair);
  border: 1px solid var(--hair-2);
  border-radius: 999px;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.grp-label:empty { display: none; }
.fmt {
  font-size: 11px;
  color: var(--dim);
  padding: 4px 8px;
  border: 1px dashed var(--hair);
  border-radius: 6px;
  direction: ltr;
}
.fmt:empty { display: none; }

/* ================================================================
   فهرست شبکه‌ها
   ================================================================ */
.sheet {
  min-width: 0;
  max-width: 100%;
  background: var(--bay);
  border: 1px solid var(--hair);
  border-radius: var(--r);
  padding: 16px;
}

/* سربرگِ چسبانِ فهرست — عنوان و دسته‌‌ها موقع اسکرول بالا می‌مونن */
.sheet-top {
  position: sticky;
  top: calc(var(--topbar-h) - 1px);
  z-index: 8;
  margin: -16px -16px 0;
  padding: 14px 16px 8px;
  background: var(--bay);
  border-bottom: 1px solid var(--hair);
  border-radius: var(--r) var(--r) 0 0;
}

.sheet-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--hair-2);
}
.sheet-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.2px;
}
.sheet-count { font-size: 12.5px; color: var(--dim); }

/* ---- چیپ‌های دسته‌بندی ---- */
.chips {
  display: flex;
  gap: 7px;
  margin: 13px 0 0;
  padding-bottom: 4px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  padding: 7px 13px;
  background: var(--bay-2);
  border: 1px solid var(--hair);
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.3;
  white-space: nowrap;
  transition: background .14s, border-color .14s, color .14s;
}
.chip:hover { background: var(--hair); border-color: var(--hair-2); color: var(--ink); }
.chip[aria-pressed="true"] {
  background: var(--link);
  border-color: var(--link);
  color: var(--link-on);
  font-weight: 600;
}
.chip .n {
  font-family: var(--mono);
  font-size: 10.5px;
  opacity: 0.8;
  margin-right: 6px;
}
.chip[aria-pressed="true"] .n { color: var(--link-on); opacity: 0.7; }

/* ---- گرید ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(134px, 1fr));
  gap: 10px;
  margin-top: 15px;
}

.ch {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 13px 8px 11px;
  background: var(--bay-2);
  border: 1px solid var(--hair-2);
  border-radius: 12px;
  text-align: center;
  overflow: hidden;
  scroll-margin-top: calc(var(--topbar-h) + 12px);   /* پشت هدر چسبان نره */
  transition: background .14s, border-color .14s, box-shadow .14s;
}
.ch:hover {
  background: var(--hair);
  border-color: var(--hair-2);
  box-shadow: 0 8px 20px -14px rgba(0, 0, 0, 0.9);
}
.ch:active { background: var(--hair-2); }

.ch[aria-pressed="true"] {
  background: var(--link-soft);
  border-color: var(--link);
  box-shadow: 0 0 0 1px var(--link-line);
}
.ch[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--link);
}

.ch-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  background: var(--rack);
  border: 1px solid var(--hair);
  border-radius: 11px;
  overflow: hidden;
  flex-shrink: 0;
}
.ch-logo img {
  width: 100%;
  height: 100%;
  padding: 4px;
  object-fit: contain;
}
/* نشان بدون لوگو — حرفِ اول روی پِشِ رنگِ کارت تست */
.ch-mono {
  --tint: var(--t1);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--tint);
  background: var(--rack);
  background: color-mix(in srgb, var(--tint) 16%, var(--rack));
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.ch-name {
  width: 100%;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.ch-grp {
  width: 100%;
  font-size: 10.5px;
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ch-fmt {
  direction: ltr;
  position: absolute;
  top: 7px;
  inset-inline-end: 7px;
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 0.4px;
  color: var(--dim);
  background: var(--bay);
  border: 1px solid var(--hair-2);
  border-radius: 4px;
  padding: 1px 4px;
}

/* ---- حالت‌ها ---- */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 54px 18px;
  text-align: center;
}
.state-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--ink); }
.state-hint  { margin: 0; font-size: 13.5px; color: var(--dim); max-width: 34ch; }

.bars-load {
  display: flex;
  gap: 4px;
  height: 26px;
  margin-bottom: 6px;
}
.bars-load i {
  width: 9px;
  border-radius: 3px;
  background: var(--hair);
  animation: bars 1.05s ease-in-out infinite;
}
.bars-load i:nth-child(1) { animation-delay: 0s;    background: var(--hair-2); }
.bars-load i:nth-child(2) { animation-delay: .09s;  background: var(--t0); }
.bars-load i:nth-child(3) { animation-delay: .18s;  background: var(--t1); }
.bars-load i:nth-child(4) { animation-delay: .27s;  background: var(--t2); }
.bars-load i:nth-child(5) { animation-delay: .36s;  background: var(--t3); }
.bars-load i:nth-child(6) { animation-delay: .45s;  background: var(--t4); }
.bars-load i:nth-child(7) { animation-delay: .54s;  background: var(--t5); }
@keyframes bars {
  0%, 100% { transform: scaleY(0.45); opacity: .55; }
  50%      { transform: scaleY(1);    opacity: 1;   }
}

.ghost {
  margin-top: 8px;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--hair);
  border-radius: 9px;
  color: var(--ink-2);
  font-size: 13.5px;
  transition: background .14s, border-color .14s;
}
.ghost:hover { background: var(--hair); border-color: var(--hair-2); color: var(--ink); }

.more {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 11px;
  background: var(--bay-2);
  border: 1px dashed var(--hair);
  border-radius: 10px;
  color: var(--ink-2);
  font-size: 13.5px;
}
.more:hover { background: var(--hair); border-color: var(--hair-2); color: var(--ink); }

.sentinel { height: 1px; }

/* ================================================================
   ریسپانسیو — از کوچک به بزرگ
   ================================================================ */

/* ---- زیرِ ۱۰۲۴ (تبلت و لپ‌تاپِ باریک): همه‌چیز تک‌ستونه ---- */
@media (max-width: 1023px) {
  .stage {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    padding: 18px 16px 56px;
  }
  .deck { position: static; }
  .sheet { padding: 14px; }
  .sheet-top { margin: -14px -14px 0; padding: 12px 14px 8px; }
}

/* پلیرِ تک‌ستونه تا عرضِ تمام وا نشه */
@media (min-width: 761px) and (max-width: 1023px) {
  .deck { width: 100%; max-width: 760px; margin-inline: auto; }
}

/* ================================================================
   موبایل — پوسته‌ی اپ:
   صفحه خودش اسکرول نمی‌شه، فقط فهرست شبکه‌ها اسکرول می‌شه.
   اینجوری پلیر همیشه معلومه و اسکرول زیرِ پلیر گیر نمی‌کنه.
   ================================================================ */
@media (max-width: 760px) {
  :root {
    --topbar-h: calc(58px + env(safe-area-inset-top, 0px));
    --gutter: 12px;
  }

  html, body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  /* ---- هدر ---- */
  .topbar {
    gap: 10px;
    height: var(--topbar-h);
    padding: env(safe-area-inset-top, 0px) var(--gutter) 0;
  }
  .brand-mark { width: 32px; height: 32px; }
  .brand-name { display: none; }
  .search { max-width: none; }
  #search { height: 40px; border-radius: 12px; }
  .count { padding: 5px 8px; font-size: 12.5px; }
  .count .cw { display: none; }     /* «شبکه» جا نمی‌گیره؛ عدد کافیه */

  /* ---- چیدمان ---- */
  .stage {
    display: flex;
    flex-direction: column;
    /* ★ بدونِ این، align-itemsِ نسخه‌ی گرید بالا می‌مونه و
       آیتم‌ها به‌جای تمام‌عرض، اندازه‌ی محتواشون جمع می‌شن. */
    align-items: stretch;
    gap: 0;
    max-width: none;
    padding: 0;
    height: calc(100vh - var(--topbar-h));
    height: calc(100dvh - var(--topbar-h));
    /* اگه کیبورد باز باشه، ارتفاع واقعیِ قابل‌مشاهده رو جاوااسکریپت
       با --vv-h می‌ده تا فهرست زیر کیبورد نره */
    height: calc(var(--vv-h, 100dvh) - var(--topbar-h));
    overflow: hidden;
  }

  /* ---- پلیر: تمام‌عرض، لبه‌به‌لبه ---- */
  .deck {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
  }
  .monitor {
    border: 0;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
  }
  .monitor-head { padding: 8px var(--gutter) 6px; font-size: 12px; }
  .rail { margin: 0 0 6px; height: 3px; }
  .screen { border-radius: 0; }

  /* روی لمس هم کنترل‌ها بعد از چند ثانیه بی‌حرکتی محو می‌شن
     (قانون سراسریِ :not(.controls-idle) حاکمه) */
  .pcontrols {
    padding: 32px 6px 8px;
  }
  .prow { gap: 6px; }
  .grp { gap: 6px; }
  .pbtn {
    min-width: 38px;
    height: 38px;
    padding: 0 8px;
    border-radius: 10px;
  }
  .pbtn svg { width: 19px; height: 19px; }

  /* صدا: هدفِ لمسی بزرگ، ظاهر همون نوارِ باریک */
  .vol { gap: 4px; }
  .vol-range {
    width: 58px;
    height: 26px;
    background: transparent;
  }
  .vol-range::-webkit-slider-runnable-track {
    height: 4px;
    margin-top: 11px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
  }
  .vol-range::-webkit-slider-thumb {
    width: 14px;
    height: 14px;
    margin-top: -5px;
  }
  .vol-range::-moz-range-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
  }
  .vol-range::-moz-range-thumb { width: 14px; height: 14px; border: 0; }

  .qpanel { min-width: 156px; max-width: calc(100vw - 24px); }
  .qitem { padding: 10px 11px; font-size: 13.5px; }

  /* کارتِ تست: وسطِ تصویر تا با کنترل‌ها خط نگیره */
  .testcard-label {
    top: 50%;
    bottom: auto;
    transform: translate(-50%, -50%);
    font-size: 12.5px;
    padding: 10px 16px;
    gap: 4px;
  }

  /* ---- زیرِ پلیر ---- */
  .deck-foot {
    margin: 0;
    padding: 8px var(--gutter);
    gap: 10px;
    background: var(--bay-2);
    border: 0;
    border-top: 1px solid var(--hair);
    border-radius: 0;
  }
  .now-block .lbl { font-size: 11px; margin-bottom: 1px; }
  .now-block .ttl { font-size: 14.5px; }
  .grp-label { font-size: 11.5px; padding: 3px 9px; max-width: 46vw; }
  .fmt { font-size: 10.5px; padding: 3px 7px; }

  /* ---- تنها بخشِ اسکرول‌شونده ---- */
  .sheet {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    border: 0;
    border-top: 1px solid var(--hair);
    border-radius: 0;
    margin: 0;
    padding: 0 var(--gutter) calc(34px + env(safe-area-inset-bottom, 0px));
  }

  /* حالت جستجو: پلیر جمع می‌شه تا فهرست نتایج کلِ فضای بالای
     کیبورد رو بگیره و کاربر ببینه تایپش چه نتیجه‌ای داده */
  body.searching .deck { display: none; }
  body.searching .search-done { display: inline-flex; }

  .sheet-top {
    position: sticky;
    top: 0;
    z-index: 6;
    margin: 0 calc(var(--gutter) * -1);
    padding: 10px var(--gutter) 9px;
    background: var(--bay);
    border-bottom: 1px solid var(--hair);
    border-radius: 0;
  }
  .sheet-head { padding-bottom: 10px; }
  .sheet-title { font-size: 15.5px; }
  .sheet-count { font-size: 12px; }

  /* چیپ‌ها تا خودِ لبه اسکرول می‌شن */
  .chips {
    margin: 0 calc(var(--gutter) * -1);
    padding: 0 var(--gutter) 4px;
  }
  .chip { padding: 8px 14px; font-size: 13px; }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 8px;
    margin-top: 14px;
  }
  .ch {
    padding: 12px 7px 10px;
    gap: 7px;
    border-radius: 12px;
    scroll-margin-top: 8px;
  }
  .ch-logo { width: 46px; height: 46px; border-radius: 11px; }
  .ch-name { font-size: 12px; line-height: 1.35; }
  .ch-grp { display: none; }
  .ch-fmt { font-size: 9px; }

  .state { padding: 40px 14px; }
  .more { padding: 13px; font-size: 14px; }
}

/* ---- گوشیِ کوچک (زیرِ ۴۸۰): جای پلیر مهم‌تره،
        فقط نشانگرها (گروه/فرمت) زیرِ پلیر می‌مونن ---- */
@media (max-width: 479px) {
  .now-block { display: none; }
  .deck-foot { justify-content: flex-start; padding-block: 6px; }
  .deck-foot:not(:has(.grp-label:not(:empty)), :has(.fmt:not(:empty))) {
    display: none;
  }
}

/* ---- گوشیِ خیلی کوچک (زیرِ ۳۶۰) ---- */
@media (max-width: 359px) {
  .count { display: none; }          /* جا برای جستجو */
  .grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 7px; }
  .pbtn { min-width: 36px; height: 36px; }
  .vol-range { display: none; }      /* دکمه‌ی بی‌صدا کافیه */
  .testcard-label { font-size: 11.5px; padding: 8px 12px; }
}

/* ---- گوشی افقی: ارتفاع کمه، جا رو بین پلیر و فهرست تقسیم کن ---- */
@media (orientation: landscape) and (max-height: 560px) {
  :root { --topbar-h: calc(50px + env(safe-area-inset-top, 0px)); }

  .topbar {
    height: var(--topbar-h);
    padding: env(safe-area-inset-top, 0px) 14px 0;
  }
  .deck-foot { display: none; }
  .rail { display: none; }
  .monitor-head { padding: 6px var(--gutter) 5px; }
  .screen {
    aspect-ratio: auto;
    height: min(54dvh, calc(100dvh - var(--topbar-h) - 150px));
    min-height: 130px;
  }
}

/* لمس: بدون افکت‌های ایستا */
@media (hover: none) {
  .ch:hover { background: var(--bay-2); box-shadow: none; border-color: var(--hair-2); }
  .chip:hover { background: var(--bay-2); border-color: var(--hair); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
