/* ═══════════ صناديق الكنز ═══════════ */
.treasure-bar {
    margin: 8px 8px 0;
    padding: 8px 10px 10px;
    border-radius: 14px;
    direction: rtl;
    background:
        radial-gradient(120% 140% at 100% 0%, rgba(255, 196, 77, .22), transparent 55%),
        linear-gradient(135deg, rgba(254, 44, 85, .10), rgba(37, 244, 238, .08)),
        var(--bg-card);
    border: 1px solid rgba(251, 191, 36, .35);
    box-shadow: 0 4px 18px rgba(251, 191, 36, .12);
}
.treasure-bar[hidden] { display: none !important; }
.tb-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.tb-title { font-family: 'DroidKufi-Bold', sans-serif; font-weight: 700; font-size: 14px; }
.tb-summary { font-size: 12px; color: var(--text-dim, #64748b); flex: 1 1 auto; }
.tb-summary b { color: var(--gold, #d97706); }
.tb-history-btn {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid var(--border-color); background: var(--hover-bg, rgba(0,0,0,.04));
    color: var(--text-primary); border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer;
}
.tb-history-btn:hover { border-color: var(--gold, #d97706); }
.tb-badge {
    min-width: 20px; padding: 0 6px; border-radius: 999px; font-size: 11px; font-weight: 700;
    background: var(--gold, #d97706); color: #fff; text-align: center;
}
.tb-list {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 4px 2px 2px;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
}
.tb-chip {
    --tb-progress: 1;
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 8px;
    border-radius: 16px;
    border: 1px solid rgba(251, 191, 36, .45);
    background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(251, 191, 36, .10)), var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    scroll-snap-align: start;
    transition: transform .15s, box-shadow .15s, opacity .3s, filter .3s;
}
.tb-chip:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(251, 191, 36, .28); }
.tb-chip.is-new { animation: tb-pop .9s ease-out; }
.tb-chip.is-expired { opacity: .55; filter: grayscale(.8); border-color: var(--border-color); }
.tb-ring {
    position: relative;
    width: 52px; height: 52px; border-radius: 50%;
    display: grid; place-items: center;
    background: conic-gradient(#fbbf24 calc(var(--tb-progress) * 360deg), rgba(148, 163, 184, .25) 0);
}
.tb-ring::before {
    content: ""; position: absolute; inset: 3px; border-radius: 50%;
    background: radial-gradient(circle at 50% 35%, #fff7e0, #ffe2a8);
}
.tb-chest { position: relative; width: 40px; height: auto; animation: tb-bob 2.4s ease-in-out infinite; }
.tb-chip.is-expired .tb-chest { animation: none; }
.tb-sender {
    position: absolute; bottom: 2px; inset-inline-end: calc(100% - 64px);
    width: 22px; height: 22px; border-radius: 50%; object-fit: cover;
    border: 2px solid var(--bg-card); box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.tb-info { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.tb-coins { font-size: 15px; font-weight: 800; color: var(--gold, #d97706); white-space: nowrap; }
.tb-time { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-dim, #64748b); }

@keyframes tb-bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-3px) rotate(2deg); } }
@keyframes tb-pop { 0% { transform: scale(.4); opacity: 0; } 60% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }

/* نافذة التفاصيل */
.tb-modal {
    position: fixed; inset: 0; z-index: 2000;
    display: grid; place-items: center;
    padding: 16px;
    background: rgba(2, 6, 23, .55);
    backdrop-filter: blur(3px);
    opacity: 0; transition: opacity .18s;
}
.tb-modal[hidden] { display: none; }
.tb-modal.is-open { opacity: 1; }
.tb-modal:not(.is-open) { pointer-events: none; }
.tb-dialog {
    width: min(420px, 100%);
    max-height: min(640px, calc(100dvh - 32px));
    display: flex; flex-direction: column;
    background: var(--bg-card); color: var(--text-primary);
    border: 1px solid rgba(251, 191, 36, .4);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
    direction: rtl;
    overflow: hidden;
    transform: translateY(12px) scale(.98); transition: transform .18s;
}
.tb-modal.is-open .tb-dialog { transform: none; }
.tb-dialog-head {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; border-bottom: 1px solid var(--border-color);
}
.tb-dialog-head h3 { flex: 1; margin: 0; font-size: 16px; font-weight: 700; text-align: center; }
.tb-icon-btn {
    width: 34px; height: 34px; border-radius: 50%;
    border: 1px solid var(--border-color); background: var(--hover-bg, transparent);
    color: var(--text-primary); font-size: 20px; line-height: 1; cursor: pointer;
}
.tb-icon-btn[hidden] { visibility: hidden; display: block; }
.tb-dialog-body { padding: 14px; overflow-y: auto; }
.tb-detail-hero {
    text-align: center; padding: 10px 10px 14px; border-radius: 16px;
    background: radial-gradient(circle at 50% 20%, rgba(251, 191, 36, .35), rgba(254, 44, 85, .08) 70%);
}
.tb-detail-hero.is-expired { filter: grayscale(.7); }
.tb-detail-chest { width: 120px; height: auto; animation: tb-bob 2.4s ease-in-out infinite; }
.tb-detail-coins { font-size: 30px; font-weight: 900; color: var(--gold, #d97706); }
.tb-detail-state { font-size: 13px; color: var(--text-dim, #64748b); }
.tb-detail-state b { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.tb-detail-bar { height: 6px; margin: 8px auto 0; max-width: 220px; border-radius: 99px; background: rgba(148,163,184,.3); overflow: hidden; }
.tb-detail-bar span { display: block; height: 100%; background: linear-gradient(90deg, #fbbf24, #fe2c55); transition: width 1s linear; }
.tb-detail-sender { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
.tb-detail-sender img { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; border: 2px solid #fbbf24; }
.tb-detail-sender small, .tb-detail-stats small { display: block; font-size: 11px; color: var(--text-dim, #64748b); }
.tb-detail-sender strong { font-size: 15px; }
.tb-detail-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tb-detail-stats > div { padding: 8px; border-radius: 12px; background: var(--hover-bg, rgba(0,0,0,.04)); text-align: center; }
.tb-detail-stats b { font-size: 14px; }
.tb-detail-title { margin: 14px 0 6px; font-size: 14px; font-weight: 700; }
.tb-recipients { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.tb-recipients li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; background: var(--hover-bg, rgba(0,0,0,.04)); }
.tb-recipients img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.tb-recipients span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-recipients b { color: var(--gold, #d97706); }
.tb-note { margin: 0; padding: 10px; border-radius: 10px; font-size: 12px; color: var(--text-dim, #64748b); background: var(--hover-bg, rgba(0,0,0,.04)); text-align: center; }
.tb-history { display: flex; flex-direction: column; gap: 6px; }
.tb-history-row {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 6px 10px; border-radius: 12px; cursor: pointer; text-align: start;
    border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-primary);
}
.tb-history-row:hover { border-color: #fbbf24; }
.tb-history-row.is-expired { opacity: .6; }
.tb-history-chest { width: 34px; }
.tb-history-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-history-time { font-size: 12px; color: var(--text-dim, #64748b); font-variant-numeric: tabular-nums; }
.tb-history-row b { color: var(--gold, #d97706); white-space: nowrap; }

@media (max-width: 768px) {
    .treasure-bar { margin: 6px 6px 0; padding: 6px 8px 8px; border-radius: 12px; }
    .tb-summary { order: 3; flex-basis: 100%; }
    .tb-history-btn { margin-inline-start: auto; }
    .tb-ring { width: 44px; height: 44px; }
    .tb-chest { width: 34px; }
    .tb-chip { padding: 5px 10px 5px 6px; gap: 6px; }
    .tb-coins { font-size: 13px; }
    .tb-modal { place-items: end center; padding: 0; }
    .tb-dialog { width: 100%; border-radius: 20px 20px 0 0; max-height: 85dvh; }
    .tb-detail-chest { width: 96px; }
}

/* ═══════════ سحب وإفلات البطاقات وتغيير أحجامها ═══════════ */
.section-card.cl-card { position: relative; }
.cl-grip {
    position: absolute; top: 6px; inset-inline-start: 6px; z-index: 3;
    width: 28px; height: 28px; border-radius: 8px;
    display: grid; place-items: center;
    font-size: 16px; line-height: 1; letter-spacing: -2px;
    color: currentColor; background: rgba(255,255,255,.18);
    border: 0; cursor: grab; opacity: .55; touch-action: none;
    transition: opacity .15s, background .15s;
}
.cl-card:hover .cl-grip, .cl-grip:focus-visible { opacity: 1; }
.cl-grip:active { cursor: grabbing; }
.cl-ghost {
    position: fixed; z-index: 3000; pointer-events: none;
    border-radius: 12px; overflow: hidden; opacity: .85;
    box-shadow: 0 18px 40px rgba(0,0,0,.35); transform: rotate(-1.5deg);
}
.cl-card.cl-dragging { opacity: .35; }
.cl-card.cl-drop-target { outline: 3px dashed var(--accent, #0891b2); outline-offset: -3px; }
.cl-card.cl-swapped { animation: cl-flash .6s ease-out; }
@keyframes cl-flash { from { box-shadow: 0 0 0 4px var(--accent, #0891b2); } to { box-shadow: var(--shadow-sm, none); } }

/* مقبض العرض (الحافة المجاورة للبطاقة التالية) ومقبض الارتفاع (الحافة السفلية) */
.cl-resize-x, .cl-resize-y { position: absolute; z-index: 4; touch-action: none; }
.cl-resize-x { top: 0; bottom: 0; width: 10px; inset-inline-end: -1px; cursor: ew-resize; }
.cl-resize-y { left: 0; right: 0; height: 10px; bottom: -1px; cursor: ns-resize; }
.cl-resize-x::after, .cl-resize-y::after {
    content: ""; position: absolute; border-radius: 4px;
    background: var(--accent, #0891b2); opacity: 0; transition: opacity .15s;
}
.cl-resize-x::after { top: 50%; inset-inline-end: 3px; width: 4px; height: 44px; transform: translateY(-50%); }
.cl-resize-y::after { left: 50%; bottom: 3px; height: 4px; width: 44px; transform: translateX(-50%); }
.cl-card:hover .cl-resize-x::after, .cl-card:hover .cl-resize-y::after { opacity: .35; }
.cl-resize-x:hover::after, .cl-resize-y:hover::after, .cl-resizing .cl-resize-x::after, .cl-resizing-y .cl-resize-y::after { opacity: 1; }
.cl-resize-x[hidden] { display: none; }
body.cl-busy, body.cl-busy * { user-select: none !important; }
body.cl-busy-x, body.cl-busy-x * { cursor: ew-resize !important; }
body.cl-busy-y, body.cl-busy-y * { cursor: ns-resize !important; }

.cl-reset-btn[hidden] { display: none; }

/* على الجوال: مقابض أكبر للمس، والعرض يتبع الشاشة */
@media (pointer: coarse) {
    .cl-grip { opacity: .85; width: 34px; height: 34px; }
    .cl-resize-y { height: 18px; }
    .cl-resize-y::after { opacity: .45; width: 56px; }
}
/* الجوال توزيعه ثابت بارتفاعات محددة: لا سحب ولا تغيير أحجام */
body.mobile-responsive-layout .cl-resize-x,
body.mobile-responsive-layout .cl-resize-y,
body.mobile-responsive-layout .cl-grip { display: none; }

/* Reserve the stream's place while video and audio data are loading. */
#videoCenterSlot { max-width: 100%; }
#liveStreamWrapper.stream-fill #videoCenterSlot {
    height: var(--stream-height, auto);
    align-self: center !important;
}
#streamResizeHandle {
    position: absolute; left: -8px; top: 0; bottom: 0; width: 16px;
    z-index: 12; cursor: ew-resize; touch-action: none;
}
#streamResizeHandle::after {
    content: ''; position: absolute; left: 5px; top: 50%;
    width: 5px; height: 54px; border-radius: 5px; transform: translateY(-50%);
    background: var(--accent, #0891b2); opacity: .65;
}
#streamResizeHandle:hover::after, #streamResizeHandle:focus-visible::after,
.stream-resizing #streamResizeHandle::after { opacity: 1; }
#streamResizeHandle:focus-visible { outline: 2px solid var(--accent, #0891b2); }
#streamCropToggle {
    position: absolute; bottom: 8px; left: 8px; z-index: 13;
    border: 1px solid #64748b; border-radius: 6px; padding: 4px 8px;
    background: rgba(15,23,42,.85); color: #fff; font: inherit; font-size: 12px;
    cursor: pointer; opacity: .7;
}
#streamCropToggle:hover, #streamCropToggle:focus-visible { opacity: 1; }
#streamCropToggle[aria-pressed="true"] { border-color: #22d3ee; }
#streamCropStatus:not(:empty) {
    position: absolute; bottom: 44px; left: 8px; right: 8px; z-index: 13;
    padding: 6px; border-radius: 6px; background: #0f172a; color: #fff;
    font-size: 12px; text-align: center;
}
#streamResizeHandle[hidden], #streamCropToggle[hidden] { display: none; }
/* Clip the encoded black bands, without stretching or covering the visible picture. */
#videoCenterSlot.stream-cropped { overflow: clip; }
#liveStreamWrapper.stream-fill #videoCenterSlot.stream-cropped #liveVideoContainer {
    top: var(--stream-source-top); bottom: auto;
    height: var(--stream-source-height); object-fit: fill;
}
/* Keep the resize grip reachable outside the clipped video. */
#videoCenterSlot.stream-cropped #streamResizeHandle { left: 0; }
/* Outside the desktop row, crop the stream without resizing adjacent cards. */
#liveStreamWrapper:not(.stream-fill) #videoCenterSlot.stream-cropped {
    position: relative;
    height: var(--stream-height) !important;
    align-self: center !important;
}
#liveStreamWrapper:not(.stream-fill) #videoCenterSlot.stream-cropped #liveVideoContainer {
    position: absolute;
    left: 0;
    top: var(--stream-source-top);
    width: 100% !important;
    height: var(--stream-source-height) !important;
    max-height: none !important;
    object-fit: fill;
}
#videoCenterSlot:fullscreen #streamResizeHandle,
#videoCenterSlot:-webkit-full-screen #streamResizeHandle,
#videoCenterSlot.lfx-fs #streamResizeHandle,
#videoCenterSlot:fullscreen #streamCropToggle,
#videoCenterSlot:-webkit-full-screen #streamCropToggle,
#videoCenterSlot.lfx-fs #streamCropToggle { display: none; }
.stream-is-loading #liveVideoContainer { display: none !important; }
/* While media loads, the host's avatar holds 90% of the stream area's height. */
.stream-loading-panel {
    position: relative;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: calc(var(--stream-height, 430px) * .9);
    max-height: 90%;
    aspect-ratio: 1;
    max-width: 100%;
    color: #e5edf5;
    text-align: center;
    font-size: 13px;
    line-height: 1.7;
}
.stream-loading-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    background: #101820;
}
.stream-loading-status {
    position: absolute;
    inset: auto 10px 10px;
    padding: 6px 10px 8px;
    border-radius: 8px;
    background: rgba(8, 14, 20, .72);
}
.stream-loading-panel p { margin: 0 0 6px; }
.stream-loading-status [hidden] { display: none !important; }
.stream-loading-status .stream-audio-play { margin-top: 8px; }
.stream-audio-play {
    padding: 6px 10px;
    border: 1px solid #22d3ee;
    border-radius: 6px;
    background: #173440;
    color: #e5edf5;
    font: inherit;
    cursor: pointer;
}
.stream-loading-track {
    position: relative;
    width: 100%;
    height: 4px;
    border-radius: 4px;
    overflow: hidden;
    background: #2a3b49;
}
.stream-loading-track::after {
    content: "";
    position: absolute;
    left: 0;
    width: 40%;
    height: 100%;
    border-radius: inherit;
    background: #22d3ee;
    animation: stream-loading-slide 1.5s ease-in-out infinite;
}
@keyframes stream-loading-slide {
    from { transform: translateX(-100%); }
    to { transform: translateX(350%); }
}
@media (prefers-reduced-motion: reduce) {
    .stream-loading-track::after { animation: none; left: 30%; }
}
body.layout-cards.mobile-responsive-layout .stream-loading-panel {
    width: 100%;
    height: auto;
    font-size: 11px;
    line-height: 1.5;
}
.live-version { align-self: center; padding: 0 6px; color: #8a9bb0; font-size: 11px; white-space: nowrap; }

/* ═══════════ ضيوف البث في الهيدر (cohosts.js) ═══════════ */
/* ارتفاع ثابت بحجم الأزرار، والفائض يُمرَّر أفقيًا حتى لا يزيد ارتفاع الهيدر */
.cohost-strip {
    /* أساس صفري: يأخذ ما تبقى من الصف الأخير ولا يدفع العناصر إلى سطر جديد */
    flex: 1 1 0;
    min-width: 0;
    max-width: 100%;
    height: 24px;
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}
.cohost-strip[hidden] { display: none; }
.cohost-strip::-webkit-scrollbar { display: none; }
.cohost-chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 24px;
    max-width: 220px;
    padding: 0 4px 0 8px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--bg-card, rgba(127,127,127,0.08));
    font-size: 10.5px;
    line-height: 1.05;
}
.cohost-avatar {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    border-radius: 50%;
    object-fit: cover;
}
.cohost-name {
    display: flex;
    flex-direction: column;
    min-width: 0;
    color: var(--text-primary);
    text-decoration: none;
}
.cohost-nick, .cohost-uid {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.cohost-nick { font-weight: 700; }
.cohost-uid { font-size: 9px; color: var(--text-dim); text-align: start; }
.cohost-add, .cohost-done {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 11px;
}
.cohost-add {
    border: 0;
    padding: 0;
    background: var(--crimson, #e11d48);
    color: #fff;
    cursor: pointer;
}
.cohost-add:disabled { opacity: 0.6; cursor: wait; }
.cohost-done { background: #22c55e; color: #fff; }
