:root {
  --bg: #0f1117;
  --card: #171a23;
  --border: #262b38;
  --text: #e8eaf0;
  --muted: #8a90a2;
  --primary: #6366f1;
  --primary-dark: #4f52d6;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 14px;
}

/* فونت پیش‌فرض پروژه (وزیر) به‌صورت محلی و بدون نیاز به اینترنت بارگذاری می‌شود.
   اگر مدیر از داشبورد فونت دلخواهی آپلود کند، یک تگ <style> با همین نام خانواده‌ی فونت
   ('Vazir') بعد از این فایل تزریق می‌شود که منبع را بازنویسی و کل سایت را یکجا عوض می‌کند. */
@font-face {
  font-family: 'Vazir';
  src: url('../fonts/Vazir-Light.woff2') format('woff2');
  font-weight: 100 700;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Vazir', Tahoma, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
}
a { color: var(--primary); text-decoration: none; }

.wrap { max-width: 1000px; margin: 0 auto; padding: 20px; }
.wrap.narrow { max-width: 480px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 20px;
}
.topbar h1 { font-size: 1.3rem; margin: 0; }
.topbar nav { display: flex; gap: 8px; flex-wrap: wrap; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.card.center { text-align: center; }
.card h2 { font-size: 1rem; margin: 0 0 8px; }

label { display: block; margin: 8px 0 4px; font-size: .88rem; color: var(--muted); }
input[type=text], input[type=number], input[type=password], select, textarea {
  width: 100%; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: #0d0f16; color: var(--text);
  font-family: inherit; font-size: .95rem;
}
textarea { resize: vertical; }

.btn {
  display: inline-block; padding: 10px 18px; border-radius: 10px;
  border: none; background: var(--primary); color: #fff; cursor: pointer;
  font-size: .95rem; text-align: center;
}
.btn:hover { background: var(--primary-dark); }
.btn.small { padding: 6px 12px; font-size: .8rem; }
.btn.large { padding: 14px 28px; font-size: 1.1rem; }
.btn.success { background: var(--success); }
.btn.danger { background: var(--danger); }
.btn.round { border-radius: 50%; width: 46px; height: 46px; padding: 0; font-size: 1.1rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 8px 0; }

.badge { padding: 4px 12px; border-radius: 20px; font-size: .85rem; }
.badge.online { background: rgba(34,197,94,.15); color: var(--success); }
.badge.offline { background: rgba(239,68,68,.15); color: var(--danger); }

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .82rem; }
.hint.center { text-align: center; }
.small { font-size: .82rem; }

.card.wide { grid-column: 1 / -1; }
.radio-label { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--text); margin-left: 16px; cursor: pointer; }
.radio-label input { width: auto; }

.tracks-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.track-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #0d0f16; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
.track-info { display: flex; flex-direction: column; gap: 2px; }
.track-info .badge { align-self: flex-start; margin-bottom: 4px; font-size: .7rem; padding: 2px 8px; }

.track-controls-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.track-controls-row .btn.round.small { width: 38px; height: 38px; font-size: .95rem; border-radius: 50%; padding: 0; }
.track-note { color: var(--muted); font-size: .8rem; }
.track-row.playing { border-color: var(--success); box-shadow: 0 0 0 2px rgba(34,197,94,.15); }

.volume-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.volume-row label { min-width: 130px; margin: 0; color: var(--text); font-size: .85rem; }
.volume-row input[type=range] { flex: 1; }

.alert { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }
.alert.success { background: rgba(34,197,94,.15); color: var(--success); }
.alert.error { background: rgba(239,68,68,.15); color: var(--danger); }

/* ---- Auth pages ---- */
.auth-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px;
  background:
    radial-gradient(circle at 15% 15%, rgba(99,102,241,.20), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(99,102,241,.14), transparent 50%),
    var(--bg);
}
.auth-box {
  background: linear-gradient(180deg, #1b1e29, var(--card));
  border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px);
  padding: 36px 32px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 50px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.02) inset;
}
.auth-logo-wrap {
  display: flex; align-items: center; justify-content: center;
  width: 88px; height: 88px; margin: 0 auto 18px; border-radius: 50%;
  background: #0d0f16; border: 1px solid var(--border); overflow: hidden;
  box-shadow: 0 0 0 6px rgba(99,102,241,.08);
}
.auth-logo { width: 100%; height: 100%; object-fit: cover; }
.auth-logo-fallback { font-size: 2.2rem; }
.auth-box h1 { text-align: center; font-size: 1.25rem; margin: 0 0 4px; }
.auth-subtitle { text-align: center; color: var(--muted); font-size: .85rem; margin: 0 0 18px; }
.auth-form label { font-size: .85rem; }
.auth-input-wrap { position: relative; }
.auth-input-wrap .auth-input-icon {
  position: absolute; top: 50%; right: 12px; transform: translateY(-50%);
  font-size: .95rem; opacity: .65; pointer-events: none;
}
.auth-input-wrap input { padding-right: 38px; }
.auth-submit { margin-top: 20px; font-weight: 600; letter-spacing: .3px; }

/* ---- Mic / broadcast page ---- */
.mic-circle {
  width: 100px; height: 100px; border-radius: 50%; margin: 20px auto;
  display: flex; align-items: center; justify-content: center; font-size: 2.4rem;
  background: #1d2130; border: 2px solid var(--border); transition: all .2s;
}
.mic-circle.active { border-color: var(--danger); box-shadow: 0 0 0 8px rgba(239,68,68,.12); }
.level-meter { width: 100%; height: 8px; background: #1d2130; border-radius: 6px; overflow: hidden; margin: 14px 0; }
.level-bar { height: 100%; width: 0%; background: var(--success); transition: width .1s; }

.preview-img { display: block; width: 100%; height: auto; max-width: 100%; border-radius: 10px; margin-bottom: 10px; object-fit: cover; }

/* ---- Listener / player page ---- */
.player-wrap.player-standalone { max-width: 480px; margin: 0 auto; padding: 20px; position: relative; }
.player-wrap.player-embed { padding: 8px; position: relative; }
body.embed-mode { background: transparent; }

.player-card {
  position: relative;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}

/* لایه شفاف روی کل کارت برای شروع پخش با اولین لمس/کلیک کاربر */
.tap-overlay {
  position: absolute; inset: 0; z-index: 5;
  background: rgba(10,12,18,.55);
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 16px; cursor: pointer;
  font-size: .95rem; backdrop-filter: blur(2px);
}

/* باکس تصویر ریسپانسیو با نسبت ثابت؛ روی هر سایز صفحه (موبایل/دسکتاپ/iframe) درست نمایش داده می‌شود */
.player-image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0d0f16;
  overflow: hidden;
}
.player-image-wrap img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: center;
  display: block;
}
.player-body { padding: 14px 16px; }
.player-titlebar { display: flex; align-items: center; gap: 8px; font-weight: bold; }

.live-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.live-dot.online { background: var(--success); box-shadow: 0 0 0 4px rgba(34,197,94,.2); animation: pulse 1.4s infinite; }
.live-dot.offline { background: var(--danger); }
@keyframes pulse { 0%{opacity:1} 50%{opacity:.4} 100%{opacity:1} }

.controls { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.controls input[type=range] { flex: 1; min-width: 80px; }

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .wrap { padding: 14px; }
  .btn.large { width: 100%; }
}

/* ================= OBS-style Operator Panel ================= */
.obs-theme { background: #16181d; }
.obs-wrap { max-width: 1100px; margin: 0 auto; padding: 14px; }

.obs-topbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  background: #1c1f26; border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 16px; margin-bottom: 14px; position: sticky; top: 0; z-index: 20;
}
.obs-topbar-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.live-indicator {
  width: 12px; height: 12px; border-radius: 50%; background: var(--muted); display: inline-block;
}
.live-indicator.on { background: var(--danger); box-shadow: 0 0 0 5px rgba(239,68,68,.18); animation: pulse 1.2s infinite; }
.live-text { font-weight: bold; font-size: .95rem; }
.obs-timer { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9rem; }

.chip {
  background: #262b38; border: 1px solid var(--border); border-radius: 20px;
  padding: 4px 12px; font-size: .78rem; color: var(--text);
}
.chip.online { background: rgba(34,197,94,.18); color: var(--success); border-color: rgba(34,197,94,.4); }

.obs-grid {
  display: grid; grid-template-columns: 320px 1fr; gap: 14px;
  align-items: start; /* مهم: ستون‌ها ارتفاع همدیگر را کش نمی‌دهند، هرکدام به‌اندازه محتوای خودشان */
}
.obs-col-narrow, .obs-col-wide {
  display: flex; flex-direction: column; gap: 14px; min-width: 0;
}

.obs-panel {
  background: #1c1f26; border: 1px solid var(--border); border-radius: 14px; padding: 16px;
}
.obs-panel h2 { font-size: 1rem; margin-top: 0; margin-bottom: 12px; }

.obs-control-panel { display: flex; flex-direction: column; align-items: stretch; gap: 8px; text-align: center; }
.btn-stream {
  padding: 16px; border-radius: 12px; border: none; font-size: 1.05rem; font-weight: bold; cursor: pointer; color: #fff;
}
.btn-stream.start { background: linear-gradient(180deg, #ef4444, #b91c1c); }
.btn-stream.start:hover { filter: brightness(1.1); }
.btn-stream.stop { background: #2a2e38; border: 1px solid var(--danger); color: var(--danger); }
.full-width { width: 100%; }

.btn-onair {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px; border-radius: 10px; border: 2px solid #7f1d1d; background: #1a0e0e;
  color: #f87171; font-weight: 800; font-size: .92rem; letter-spacing: 2px; cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn-onair .onair-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #7f1d1d; flex-shrink: 0;
  transition: background .15s, box-shadow .15s;
}
.btn-onair:hover { border-color: #ef4444; color: #fca5a5; }
.btn-onair.active {
  background: linear-gradient(180deg, #ef4444, #b91c1c); border-color: #ef4444; color: #fff;
  box-shadow: 0 0 18px rgba(239,68,68,.55); animation: pulse 1.4s infinite;
}
.btn-onair.active .onair-dot { background: #fff; box-shadow: 0 0 6px #fff; }
.onair-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  background: rgba(239,68,68,.15); border: 1px solid var(--danger); border-radius: 10px;
  padding: 8px 12px; font-size: .82rem; color: #fecaca;
}
#broadcastTracksList.locked { opacity: .45; pointer-events: none; }

.channel-strip { background: #12141a; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.channel-strip:last-child { margin-bottom: 0; }
.channel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.channel-icon { font-size: 1.05rem; }
.channel-name { font-size: .88rem; flex: 1; }
.mute-btn {
  background: #262b38; border: 1px solid var(--border); border-radius: 8px; color: var(--text);
  width: 34px; height: 30px; cursor: pointer; font-size: .95rem;
}
.mute-btn.muted { background: rgba(239,68,68,.18); border-color: var(--danger); color: var(--danger); }

.vu-meter { width: 100%; height: 10px; background: #0a0c10; border-radius: 6px; overflow: hidden; margin-bottom: 8px; }
.vu-bar { height: 100%; width: 0%; border-radius: 6px; background: linear-gradient(90deg, #22c55e 0%, #22c55e 65%, #eab308 85%, #ef4444 100%); transition: width .08s linear; }

.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-row input[type=range] { flex: 1; }
.vol-val { min-width: 42px; text-align: left; font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.source-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.source-info { display: flex; flex-direction: column; gap: 4px; }
.source-note { color: var(--muted); font-size: .78rem; }

@media (max-width: 860px) {
  .obs-grid { grid-template-columns: 1fr; }
  /* در موبایل هر دو ستون به‌صورت شفاف تجزیه می‌شوند تا بتوان با order ترتیب دلخواه
     (کنترل، میکسر، کتابخانه صوتی، پیام آنی، منابع) را مستقل از گروه‌بندی دسکتاپ چید */
  .obs-col-narrow, .obs-col-wide { display: contents; }
  .obs-control-panel   { order: 1; }
  .obs-mixer-panel     { order: 2; }
  .obs-tracks-panel    { order: 3; }
  .obs-livenote-panel  { order: 4; }
  .obs-sources-panel   { order: 5; }
  .obs-grid { display: flex; flex-direction: column; gap: 14px; }
  .obs-topbar { position: static; }

  /* اطمینان از اینکه همه باکس‌های ابزار دقیقاً هم‌عرض هستند، صرف‌نظر از عرض محتوای داخلی‌شان
     (مثلاً اسلایدرهای میکسر که می‌توانستند باعث شوند آن باکس نسبت به کتابخانه صوتی کوچک‌تر دیده شود) */
  .obs-panel { width: 100%; max-width: 100%; box-sizing: border-box; }
  .slider-row input[type=range] { min-width: 0; }

  /* در موبایل برای جمع‌وجورتر شدن صفحه، همه توضیحات/نکات اضافه (آکاردئون‌های ℹ️) مخفی می‌شوند */
  .obs-panel .info-accordion { display: none; }
}

.raw-mic-toggle {
  display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--text);
  background: #12141a; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  text-align: right; cursor: pointer; margin-top: 4px;
}
.raw-mic-toggle input { width: auto; flex-shrink: 0; }

.gain-row { margin-top: 6px; }
.gain-label { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.gain-hint { margin-top: 4px; font-size: .74rem; }

/* ================= بخش‌بندی پنل مدیریت ================= */
.section-title {
  margin: 20px 0 8px; padding-bottom: 6px;
  font-size: 1rem; color: var(--text);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 6px;
}
.section-title:first-of-type { margin-top: 4px; }

/* ================= Modern Listener Stream Page ================= */
body.stream-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 15%, rgba(99,102,241,.25), transparent 45%),
    radial-gradient(circle at 85% 25%, rgba(236,72,153,.18), transparent 40%),
    radial-gradient(circle at 50% 100%, rgba(34,211,238,.12), transparent 45%),
    #0b0d13;
}
body.stream-page.embed-mode { background: transparent; }

.stream-page .player-wrap.player-standalone {
  max-width: 460px; margin: 0 auto; padding: 28px 18px; min-height: 100vh;
  display: flex; flex-direction: column; justify-content: center; gap: 16px;
}
/* حالت iframe: محتوا بر اساس اندازه واقعی خودِ iframe (نه اندازه صفحه اصلی) خودکار تنظیم می‌شود
   تا نیازی به تنظیم دستی ارتفاع/عرض برای هر مورد نباشد */
.stream-page .player-wrap.player-embed {
  padding: 10px; max-width: 640px; margin: 0 auto;
  container-type: size; container-name: playerEmbed;
  width: 100%; height: 100%; min-height: 100vh;
  box-sizing: border-box; display: flex; flex-direction: column; justify-content: center;
}
html, body.embed-mode { height: 100%; margin: 0; }

/* iframe خیلی کوتاه (مثلاً ارتفاع کمتر از ۱۵۰px): فقط نوار کنترل جمع‌وجور، بدون تصویر/ویژوالایزر */
@container playerEmbed (max-height: 150px) {
  .stream-hero, .visualizer, .live-note-stack, .now-playing-box { display: none !important; }
  .stream-body { padding: 10px 14px; }
  .stream-title { font-size: .95rem; }
  .stream-caption { display: none; }
  .stream-title-row { gap: 10px; }
  .play-btn-modern { width: 42px; height: 42px; font-size: 1rem; }
  .stream-status { display: none; }
}

/* iframe کوتاه (۱۵۰ تا ۲۶۰px): بدون تصویر، ولی عنوان/کنترل‌ها کامل */
@container playerEmbed (min-height: 151px) and (max-height: 260px) {
  .stream-hero, .visualizer { display: none !important; }
  .stream-body { padding: 12px 16px; }
}

/* iframe خیلی باریک (کمتر از ۳۰۰px عرض) */
@container playerEmbed (max-width: 300px) {
  .stream-title { font-size: 1rem; }
  .stream-caption { display: none; }
  .live-chip .live-chip-text { display: none; }
  .stream-body { padding: 12px; }
}

/* مرورگرهایی که Container Query را پشتیبانی نمی‌کنند: حالت امن (کارت کامل، بدون شکستگی) */
@supports not (container-type: size) {
  .stream-page .player-wrap.player-embed { min-height: auto; height: auto; }
}

/* ---- کارت اصلی (Glassmorphism) ---- */
.stream-card {
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 20px 60px -20px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.02) inset;
  backdrop-filter: blur(16px);
}

/* ---- هیرو (تصویر یا نمای جایگزین) ---- */
.stream-hero { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #0a0c12; overflow: hidden; }
.stream-hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; opacity: 1; transition: opacity 1.1s ease-in-out; }
.stream-hero-gradient {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(10,12,18,.85) 100%);
  pointer-events: none;
}
.stream-hero-placeholder {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 45%, rgba(99,102,241,.35), rgba(10,12,18,0) 60%);
}
.hero-icon { font-size: 2.6rem; z-index: 2; filter: drop-shadow(0 4px 14px rgba(99,102,241,.6)); }
.hero-pulse-ring {
  position: absolute; width: 70px; height: 70px; border-radius: 50%;
  border: 2px solid rgba(99,102,241,.55);
  animation: heroPulse 2.6s ease-out infinite;
}
.hero-pulse-ring.r2 { animation-delay: .7s; }
.hero-pulse-ring.r3 { animation-delay: 1.4s; }
@keyframes heroPulse {
  0%   { transform: scale(1);   opacity: .9; }
  100% { transform: scale(3.2); opacity: 0; }
}

.live-chip {
  position: absolute; top: 14px; right: 14px; z-index: 3;
  display: flex; align-items: center; gap: 6px;
  background: rgba(10,12,18,.55); backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 20px; padding: 5px 12px 5px 10px;
  font-size: .72rem; font-weight: bold; letter-spacing: .04em; color: #fff;
}
.live-chip .live-dot { width: 8px; height: 8px; }
.live-chip .live-dot.offline { background: var(--muted); animation: none; box-shadow: none; }

/* ---- بدنه کارت ---- */
.stream-body { padding: 18px 22px 24px; }
.stream-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stream-title {
  margin: 0; font-size: 1.25rem; font-weight: 800; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: linear-gradient(90deg, #fff, #cfd2ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stream-caption { margin: 4px 0 14px; color: var(--muted); font-size: .88rem; line-height: 1.7; }

/* ---- ویژوالایزر: مستقیم روی پایین تصویر لایو (نه بیرون از کادر تصویر) ---- */
.visualizer {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; pointer-events: none;
  display: flex; align-items: flex-end; justify-content: center; gap: 3px;
  height: 40px; padding: 0 16px 10px; opacity: .95;
}
.vbar {
  width: 4px; min-height: 3px; border-radius: 3px;
  background: linear-gradient(180deg, #a5b4fc, var(--primary));
  transition: height .06s ease-out;
  box-shadow: 0 0 6px rgba(129,140,248,.5);
}

/* ---- دکمه پخش (کنار عنوان) ---- */
.play-btn-modern {
  flex-shrink: 0; width: 46px; height: 46px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(145deg, #818cf8, var(--primary));
  color: #fff; font-size: 1.05rem;
  box-shadow: 0 10px 25px -8px rgba(99,102,241,.7);
  transition: transform .15s ease;
}
.play-btn-modern:hover { transform: scale(1.06); }
.play-btn-modern:active { transform: scale(.96); }

.stream-status { margin: 10px 0 0; font-size: .78rem; color: var(--muted); text-align: center; min-height: 1.1em; }
.stream-status:empty { margin: 0; min-height: 0; }

/* ---- باکس «هم‌اکنون پخش می‌شود» ---- */
.now-playing-box {
  margin: 14px 0 0; padding: 12px 14px; border-radius: 12px;
  background: linear-gradient(135deg, rgba(99,102,241,.18), rgba(99,102,241,.07));
  border: 1px solid rgba(99,102,241,.38);
  box-shadow: 0 4px 14px -8px rgba(99,102,241,.5);
  transition: background .2s ease, border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
.now-playing-box:hover {
  background: linear-gradient(135deg, rgba(99,102,241,.26), rgba(99,102,241,.1));
  border-color: rgba(129,140,248,.65);
  box-shadow: 0 8px 22px -10px rgba(99,102,241,.7);
  transform: translateY(-1px);
}
.np-current {
  display: flex; align-items: center; gap: 7px; font-size: .86rem; font-weight: 700; color: var(--text);
  overflow: hidden;
}
.np-current-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np-live-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(239,68,68,.25), 0 0 6px rgba(239,68,68,.85);
  animation: pulse 1.3s infinite;
  transform: translateX(-3px);
}
.np-upcoming {
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed rgba(255,255,255,.12);
  display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--muted);
}
.np-upcoming-label { flex-shrink: 0; }
.np-icon { display: inline-block; transform: translateX(-3px); }
.np-upcoming-slider { position: relative; flex: 1; height: 1.4em; overflow: hidden; min-width: 0; }
.np-upcoming-slider span {
  position: absolute; inset: 0; opacity: 0; transition: opacity .6s ease;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.np-upcoming-slider span.active { opacity: 1; }

.np-divider { margin: 8px 0; border: none; border-top: 1px dashed rgba(255,255,255,.16); height: 0; }

/* ---- لایه لمس برای فعال‌سازی پخش ---- */
.tap-overlay-modern {
  position: absolute; inset: 0; z-index: 10;
  background: rgba(8,9,14,.68); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.tap-overlay-box {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: rgba(23,26,35,.9); border: 1px solid rgba(255,255,255,.16);
  border-radius: 18px; padding: 26px 32px; margin: 16px;
  box-shadow: 0 20px 50px -10px rgba(0,0,0,.75);
}
.tap-play-icon {
  width: 74px; height: 74px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, #ef4444, #b91c1c);
  box-shadow: 0 0 0 8px rgba(239,68,68,.16), 0 12px 30px -6px rgba(239,68,68,.75);
  animation: tapPulse 1.4s ease-in-out infinite;
}
.tap-play-icon svg { margin-right: -3px; } /* برای اینکه مثلث پخش دقیقاً مرکز به‌نظر برسد */
.tap-overlay-text { color: #fff; font-size: .92rem; font-weight: 700; text-align: center; }
@keyframes tapPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.1); } }

/* ---- پشته پیام‌های آنی (چند پیام هم‌زمان) ---- */
.live-note-stack { display: flex; flex-direction: column; gap: 10px; }
.live-note-item {
  display: flex; align-items: flex-start; gap: 10px;
  background: linear-gradient(135deg, rgba(99,102,241,.16), rgba(236,72,153,.10));
  border: 1px solid rgba(99,102,241,.3);
  border-radius: 16px; padding: 14px 16px;
  animation: liveNoteIn .35s ease;
}
.live-note-item.leaving { animation: liveNoteOut .2s ease forwards; }
@keyframes liveNoteIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes liveNoteOut { to { opacity: 0; transform: translateY(-6px); } }
.live-note-icon { font-size: 1.1rem; line-height: 1.5; }
.live-note-content { flex: 1; font-size: .86rem; line-height: 1.8; color: var(--text); word-break: break-word; }
.live-note-content a { color: #a5b4fc; text-decoration: underline; }
.live-note-close {
  flex-shrink: 0; background: none; border: none; color: var(--muted); font-size: 1.1rem;
  cursor: pointer; line-height: 1; padding: 2px 4px;
}
.live-note-close:hover { color: var(--text); }

.stream-footer-hint { opacity: .6; }

@media (max-width: 480px) {
  .stream-body { padding: 16px 16px 20px; }
}

/* ---- لوگو/آیکون روی تصویر لایو ---- */
.live-logo {
  position: absolute; bottom: 14px; z-index: 4;
  border-radius: 10px; object-fit: contain;
  background: rgba(10,12,18,.4); backdrop-filter: blur(6px);
  padding: 5px; box-shadow: 0 8px 20px -8px rgba(0,0,0,.6);
  border: 1px solid rgba(255,255,255,.1);
}
.live-logo-left { left: 14px; }
.live-logo-right { right: 14px; }
.live-logo-center { left: 50%; transform: translateX(-50%); }

/* باکس پیام آنی وقتی داخل بدنه کارت جای می‌گیرد کمی متفاوت‌تر است */
.stream-body .live-note-stack:not(:empty) { margin-top: 8px; }

/* ---- آکاردئون توضیحات (برای جمع‌وجورتر شدن پنل‌ها) ---- */
.info-accordion {
  margin-top: 6px; border: 1px solid var(--border); border-radius: 10px;
  background: #12141a; overflow: hidden;
}
.info-accordion summary {
  cursor: pointer; padding: 6px 12px; font-size: .78rem; color: var(--muted);
  display: flex; align-items: center; gap: 6px; list-style: none; user-select: none;
}
.info-accordion summary::-webkit-details-marker { display: none; }
.info-accordion summary::before { content: '▸'; font-size: .7rem; transition: transform .15s; }
.info-accordion[open] summary::before { transform: rotate(90deg); }
.info-accordion .info-accordion-body { padding: 0 12px 8px; font-size: .78rem; color: var(--muted); line-height: 1.65; }
.info-accordion .info-accordion-body p { margin: 5px 0; }

/* ================= پروفایل/پلی‌لیست کتابخانه صوتی (صفحه پخش‌کننده) ================= */
.profile-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.profile-tab-btn {
  background: #12141a; border: 1px solid var(--border); color: var(--muted);
  border-radius: 20px; padding: 6px 14px; font-size: .8rem; cursor: pointer;
  transition: opacity .15s, box-shadow .15s;
}
.profile-tab-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.profile-tab-btn[draggable="true"] { cursor: grab; }
.profile-tab-btn.dragging { opacity: .4; }
.profile-tab-btn.drag-over-start { box-shadow: inset 3px 0 0 0 var(--primary); }
.profile-tab-btn.drag-over-end { box-shadow: inset -3px 0 0 0 var(--primary); }

.now-playing-bar {
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(135deg, rgba(99,102,241,.18), rgba(34,197,94,.08));
  border: 1px solid rgba(99,102,241,.35); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px;
}
.now-playing-icon { font-size: 1.2rem; }
.now-playing-info { flex: 1; min-width: 0; }
.now-playing-title { font-size: .85rem; font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 5px; }
.now-playing-progress { width: 100%; height: 6px; background: #0a0c10; border-radius: 4px; overflow: hidden; }
.now-playing-progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--primary), #a5b4fc); transition: width .2s linear; }
.now-playing-time { font-size: .72rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.track-reorder-col { display: flex; flex-direction: column; gap: 2px; }
.track-reorder-col button {
  background: #1a1d26; border: 1px solid var(--border); color: var(--muted);
  border-radius: 5px; width: 22px; height: 18px; font-size: .65rem; cursor: pointer; line-height: 1;
}
.track-reorder-col button:hover { color: var(--text); }

.track-progress-mini { width: 100%; height: 4px; background: #0a0c10; border-radius: 3px; overflow: hidden; margin-top: 4px; }
.track-progress-mini-fill { height: 100%; width: 0%; background: var(--success); transition: width .2s linear; }
.track-row.now-playing {
  border-color: var(--success);
  background: rgba(34,197,94,.14);
  box-shadow: 0 0 0 1px rgba(34,197,94,.4);
}
.track-row.now-playing:hover { background: rgba(34,197,94,.2); }

/* ---- ردیف تراک در صفحه پخش زنده: تک‌خط، جمع‌وجور، عنوان سمت راست، کنترل‌ها همه در یک ردیف افقی ---- */
.broadcast-track-row.track-row { padding: 5px 10px; gap: 8px; align-items: center; }
.broadcast-track-row:hover { background: #1a1d26; }
.broadcast-track-row.now-playing:hover { background: rgba(34,197,94,.2); }
.broadcast-track-row .track-info { flex: 1; min-width: 0; }
.broadcast-track-row .track-info-line strong {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; max-width: 100%;
}
.track-reorder-pair { display: flex; flex-direction: row; gap: 3px; flex-shrink: 0; }
.track-reorder-pair .ctrlArrow {
  background: #1a1d26; border: 1px solid var(--border); color: var(--muted);
  border-radius: 5px; width: 22px; height: 22px; font-size: .62rem; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.track-reorder-pair .ctrlArrow:hover { color: var(--text); }
.track-reorder-pair .ctrlArrow:disabled { opacity: .3; cursor: default; }
.loopToggleBtn {
  background: #1a1d26; border: 1px solid var(--border); color: var(--muted);
  border-radius: 7px; width: 26px; height: 26px; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s, color .15s;
}
.loopToggleBtn:hover { color: var(--text); }
.loopToggleBtn.active { background: rgba(245,158,11,.16); border-color: #f59e0b; color: #fbbf24; }
.dupTrackBtn {
  width: 26px; height: 26px; border-radius: 7px; font-size: .85rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.trackPlayBtn {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  border: none; color: #fff; font-size: .9rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  box-shadow: 0 3px 10px -3px rgba(99,102,241,.65);
  transition: transform .12s, filter .12s;
}
.trackPlayBtn:hover { filter: brightness(1.1); }
.trackPlayBtn:active { transform: scale(.94); }
.track-row.now-playing .trackPlayBtn {
  background: linear-gradient(135deg, var(--success), #4ade80);
  box-shadow: 0 3px 10px -3px rgba(34,197,94,.65);
}

/* ---- جمع‌وجورسازی پنل کنترل پخش زنده ---- */
.obs-control-panel .hint { margin: 0; line-height: 1.6; }
.obs-control-panel { gap: 6px; }

/* ---- دکمه‌های اضطراری/تیتراژ ---- */
.emergency-buttons-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.emergency-btn {
  border: none; border-radius: 8px; padding: 8px 12px; color: #fff; font-size: .78rem; font-weight: bold;
  cursor: pointer; box-shadow: 0 3px 10px -4px rgba(0,0,0,.6); transition: transform .1s;
}
.emergency-btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.emergency-btn:active { transform: translateY(0); }
.emergency-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  background: rgba(239,68,68,.15); border: 1px solid var(--danger); border-radius: 10px;
  padding: 8px 12px; font-size: .82rem; color: #fecaca;
}

/* ---- فشرده‌سازی ردیف تراک‌ها در لیست/پلی‌لیست ---- */
.track-row { padding: 7px 10px; gap: 8px; }
.track-info { gap: 1px; }
.track-info-line { display: flex; align-items: center; gap: 6px; }
.track-info-line strong { font-size: .85rem; line-height: 1.3; }
.track-info-line .badge { margin: 0; font-size: .65rem; padding: 1px 7px; }
.track-note { font-size: .72rem; line-height: 1.3; }
.track-progress-mini { cursor: pointer; margin-top: 4px; }
.track-progress-mini:hover .track-progress-mini-fill { filter: brightness(1.3); }

/* ---- نوار پیشرفت موزیک/تیتراژ در حال پخش، داخل میکسر صدا ---- */
.mixer-music-progress-wrap { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border); }
.mixer-music-progress-title { font-size: .74rem; color: var(--text); margin-bottom: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mixer-music-progress-bar { width: 100%; height: 7px; background: #0a0c10; border-radius: 5px; overflow: hidden; cursor: pointer; }
.mixer-music-progress-bar:hover .mixer-music-progress-fill { filter: brightness(1.3); }
.mixer-music-progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--success), #4ade80); transition: width .2s linear; }
.mixer-music-progress-time { margin-top: 4px; font-size: .68rem; color: var(--muted); text-align: left; font-variant-numeric: tabular-nums; }

.now-playing-progress { cursor: pointer; }

/* ---- باکس پیشنهاد نصب PWA ---- */
.pwa-install-banner {
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(135deg, rgba(99,102,241,.18), rgba(34,211,238,.10));
  border: 1px solid rgba(99,102,241,.35); border-radius: 14px; padding: 12px 14px;
  animation: liveNoteIn .3s ease;
}
.pwa-install-icon { font-size: 1.4rem; flex-shrink: 0; }
.pwa-install-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pwa-install-text strong { font-size: .85rem; color: var(--text); }
.pwa-install-text span { font-size: .74rem; color: var(--muted); line-height: 1.6; }
.pwa-install-close {
  flex-shrink: 0; background: none; border: none; color: var(--muted); font-size: 1.1rem;
  cursor: pointer; line-height: 1; padding: 2px 4px;
}
.pwa-install-close:hover { color: var(--text); }

/* ---- پلی‌لیست‌ها (پنل مدیریت) ---- */
.playlist-row { align-items: center; }
.playlist-row .track-info { flex: 1; }
.playlist-row .btn-row { margin: 0; justify-content: flex-start; }

/* ---- مودال ویرایش تراک‌های پلی‌لیست ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(6,7,12,.72);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 1000;
}
.modal-box {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  width: 100%; max-width: 640px; max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,.5);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-header h2 { font-size: 1.05rem; margin: 0; }
.modal-close {
  background: none; border: none; color: var(--muted); font-size: 1.2rem; cursor: pointer;
  line-height: 1; padding: 4px 6px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 16px 20px 20px; overflow-y: auto; }
.modal-subtitle { font-size: .92rem; margin: 18px 0 6px; }
.modal-subtitle:first-child { margin-top: 0; }

.playlist-track-check-row { cursor: pointer; }
.playlist-track-check-row input[type=checkbox] { width: auto; flex-shrink: 0; }
.playlist-track-check-row .track-info { flex: 1; }

/* ---- انتخابگر تب‌محور دسته‌بندی‌ها در مودال ویرایش پلی‌لیست ---- */
.category-picker-list {
  max-height: 280px; overflow-y: auto; border: 1px solid var(--border);
  border-radius: 10px; padding: 6px; background: #0d0f16;
}
.lib-pick-row { background: #12141a; }
.lib-pick-row .plPickBtn { flex-shrink: 0; min-width: 96px; }
.lib-pick-row .plPickBtn-added { opacity: .9; }

.selected-track-row .track-reorder-col { flex-direction: row; gap: 4px; }
.selected-track-row .track-reorder-col button {
  width: 30px; height: 30px; border-radius: 8px;
  background: #1a1d26; border: 1px solid var(--border); color: var(--muted); cursor: pointer;
}
.selected-track-row .track-reorder-col button:hover { color: var(--text); }
.selected-track-row .track-reorder-col button:disabled { opacity: .35; cursor: default; }

/* ---- واکنش‌گرایی بیشتر در صفحه‌نمایش‌های کوچک (موبایل) ---- */
@media (max-width: 600px) {
  .wrap { padding: 12px; }
  .card { padding: 12px; }
  .grid { gap: 10px; }
  .topbar h1 { font-size: 1.1rem; }
  .section-title { font-size: .92rem; margin: 16px 0 6px; }
}

/* ---- گالری اسلایدهای تصویر لایو ---- */
.images-gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px;
}
.images-gallery-item {
  position: relative; border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  background: #0d0f16; aspect-ratio: 16/10;
}
.images-gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.images-gallery-item .ig-order-badge {
  position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.65); color: #fff;
  font-size: .68rem; padding: 1px 6px; border-radius: 6px;
}
.images-gallery-item .ig-controls {
  position: absolute; inset: auto 0 0 0; display: flex; gap: 3px; padding: 4px;
  background: linear-gradient(to top, rgba(0,0,0,.75), transparent);
}
.images-gallery-item .ig-controls button {
  flex: 1; background: rgba(20,22,30,.85); border: 1px solid var(--border); color: #fff;
  border-radius: 6px; font-size: .68rem; padding: 3px 0; cursor: pointer;
}
.images-gallery-item .ig-controls button:hover { background: rgba(40,42,54,.95); }
.images-gallery-item .ig-controls .ig-del { color: #fca5a5; }

/* ---- بخش پروفایل‌ها/پلی‌لیست‌ها: فرم افزودن جمع‌شونده + گروه‌بندی دسته‌بندی/پلی‌لیست ---- */
.add-new-toggle {
  border: 1px dashed var(--border); border-radius: 10px; background: #12141a; overflow: hidden;
}
.add-new-toggle summary {
  cursor: pointer; padding: 8px 12px; font-size: .85rem; font-weight: bold; color: var(--text);
  display: flex; align-items: center; gap: 6px; list-style: none; user-select: none;
}
.add-new-toggle summary::-webkit-details-marker { display: none; }
.add-new-toggle summary::before { content: '▸'; font-size: .7rem; color: var(--muted); transition: transform .15s; }
.add-new-toggle[open] summary::before { transform: rotate(90deg); }
.add-new-toggle form { padding: 0 12px 12px; }

.profile-group-title {
  font-size: .8rem; font-weight: bold; color: var(--muted);
  margin: 0 0 6px; display: flex; align-items: center; gap: 5px;
}
.profile-chip-list { display: flex; flex-direction: column; gap: 5px; }
.profile-chip {
  display: flex; align-items: center; gap: 8px; background: #12141a;
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: .85rem;
}
.profile-chip-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-chip-actions { display: flex; gap: 4px; flex-shrink: 0; }
.chipBtn {
  background: #1a1d26; border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px; width: 26px; height: 24px; font-size: .78rem; cursor: pointer;
}
.chipBtn:hover { color: var(--text); }
.chipBtn.danger:hover { color: #fca5a5; border-color: #7f1d1d; }
.playlist-entry-list { display: flex; flex-direction: column; gap: 6px; }

/* ---- درگ‌اند‌دراپ برای جابه‌جایی سریع ترک‌ها (پلی‌لیست‌ها و لیست پخش زنده) ---- */
.drag-handle {
  cursor: grab; color: var(--muted); font-size: 1rem; flex-shrink: 0;
  padding: 0 2px; user-select: none; touch-action: none;
}
.drag-handle:active { cursor: grabbing; }
.track-row[draggable="true"] { transition: opacity .15s, box-shadow .15s; }
.track-row.dragging { opacity: .4; }
.track-row.drag-over-top { box-shadow: inset 0 2px 0 0 var(--primary); }
.track-row.drag-over-bottom { box-shadow: inset 0 -2px 0 0 var(--primary); }

/* ---- پیام‌های آنی ارسال‌شده: یک خط با سه‌نقطه در صورت طولانی بودن ---- */
.live-note-row .track-info { min-width: 0; flex: 1; }
.live-note-text-line {
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}

/* ---- پاپ‌آپ تبلیغات بنری (اسپانسرها) در صفحه شنونده ---- */
.ad-popup {
  position: absolute; top: 50%; left: 50%; z-index: 60;
  width: calc(100% - 32px); max-width: 300px;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; box-shadow: 0 20px 50px -12px rgba(0,0,0,.75);
  opacity: 0; pointer-events: none;
  transform: translate(-50%, -50%) scale(.94);
  transition: opacity .35s ease, transform .35s ease;
}
.ad-popup.visible { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.ad-popup a { display: block; }
.ad-popup img { width: 100%; height: auto; max-height: 200px; object-fit: cover; display: block; }
.ad-popup-close {
  position: absolute; top: 6px; left: 6px; z-index: 2;
  width: 26px; height: 26px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(0,0,0,.6); color: #fff; font-size: .8rem; line-height: 1;
}
.ad-popup-close:hover { background: rgba(0,0,0,.8); }
.ad-popup-label {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  background: rgba(0,0,0,.6); color: #fbbf24; font-size: .6rem; font-weight: 700;
  padding: 2px 7px; border-radius: 6px; letter-spacing: .3px;
}

/* ---- هشدار اتصال دوباره وقتی سشن قبلاً روی سرور فعال بوده ولی این صفحه هنوز وصل نشده ---- */
.reconnect-hint { color: #fbbf24 !important; font-weight: 700; }
