/* =====================================================================
 * Social Portal (Postiz) — same theme as the Inbox Portal:
 * near-black surfaces, 1px borders, indigo accent pills, Inter.
 * Layout modelled on Buffer: channels sidebar + Queue / Calendar / Drafts / Sent.
 * ===================================================================== */

/* ============ Tokens ============ */
:root {
  --bg: #111111;
  --rail: #1b1b1b;
  --pane: #1b1b1b;
  --pane-2: #242424;
  --pane-3: #2c2c2c;
  --border: rgba(255,255,255,.08);
  --border-strong: rgba(255,255,255,.14);
  --text: #f3f3f3;
  --muted: #a3a3a3;
  --muted-2: #7a7a7a;
  --accent: #5258e4;
  --accent-hover: #4046ca;
  --accent-soft: rgba(82,88,228,.18);
  --accent-2: #8b90ff;
  --success: #2ec27e;
  --danger: #e5484d;
  --warn: #e9a23b;
  --info: #4aa3ff;
  --note: #35301a;
  --note-text: #f1e2a0;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --shadow: 0 12px 40px rgba(0,0,0,.45);
  --rail-w: 76px;
  --folders-w: 250px;
  --font: "Inter", -apple-system, "Segoe UI", "Noto Sans Arabic", Tahoma, sans-serif;
  --series-1: #6c72ff; --series-2: #f08a4b; --series-3: #2ec27e;
}
:root[data-theme="light"] {
  --bg: #f5f5f5;
  --rail: #ffffff;
  --pane: #ffffff;
  --pane-2: #f7f7f7;
  --pane-3: #efefef;
  --border: rgba(0,0,0,.08);
  --border-strong: rgba(0,0,0,.14);
  --text: #222222;
  --muted: #6e6e6e;
  --muted-2: #9a9a9a;
  --accent-soft: rgba(82,88,228,.12);
  --accent-2: #4046ca;
  --note: #fff6cc;
  --note-text: #5a4a00;
  --shadow: 0 12px 40px rgba(0,0,0,.14);
  --series-1: #5258e4; --series-2: #e8732a; --series-3: #1baf7a;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font); font-size: 13.5px; line-height: 1.45;
  overflow: hidden; -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); font-size: 12.5px; }
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -.01em; }
button { font-family: inherit; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: var(--text); }
a { color: var(--accent-2); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--pane-2); padding: 1px 5px; border-radius: 4px; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.spacer { flex: 1; }
svg { flex-shrink: 0; }

/* ============ Buttons / inputs ============ */
.btn {
  background: var(--pane-2); border: 1px solid var(--border); border-radius: var(--radius-pill);
  padding: 7px 14px; cursor: pointer; font-size: 13px; font-weight: 500; white-space: nowrap; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; line-height: 1.2; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--pane-3); border-color: var(--border-strong); }
a.btn, a.btn:hover { text-decoration: none; color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--pane-2); color: var(--text); }
.btn.small { padding: 5px 11px; font-size: 12px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.btn-split { display: inline-flex; }
.btn-split .btn:first-child { border-start-end-radius: 0; border-end-end-radius: 0; }
.btn-split .btn:last-child { border-start-start-radius: 0; border-end-start-radius: 0; padding: 7px 9px; margin-inline-start: -1px; }
.icon-btn {
  background: transparent; border: 0; border-radius: var(--radius-sm); width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--muted);
}
.icon-btn:hover { background: var(--pane-2); color: var(--text); }
.icon-btn.active { background: var(--accent-soft); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.sel { background: var(--pane-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 9px; font-size: 12.5px; cursor: pointer; }
.sel:focus { outline: 0; box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); }
.inp { background: var(--pane-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 11px; font-size: 13px; width: 100%; color: var(--text); }
.inp:focus, .inp:focus-visible { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.inp::placeholder { color: var(--muted-2); }
textarea.inp { resize: vertical; min-height: 70px; line-height: 1.5; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.toggle input { accent-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label, .lbl-sm { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.chip { font-size: 10.5px; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--pane-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; vertical-align: middle; }
.chip.ok { background: rgba(46,194,126,.15); color: var(--success); border-color: transparent; }
.chip.warn { background: rgba(233,162,59,.16); color: var(--warn); border-color: transparent; }
.chip.danger { background: rgba(229,72,77,.16); color: var(--danger); border-color: transparent; }
.chip.info { background: rgba(74,163,255,.16); color: var(--info); border-color: transparent; }
.chip.accent { background: var(--accent-soft); color: var(--accent-2); border-color: transparent; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.kbd { font-family: ui-monospace, monospace; font-size: 10.5px; border: 1px solid var(--border-strong); border-radius: 5px; padding: 0 5px; color: var(--muted); }

/* ============ Login ============ */
.login { height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; background: radial-gradient(900px 500px at 50% -10%, rgba(82,88,228,.18), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--pane); border: 1px solid var(--border); border-radius: 16px; padding: 30px 28px; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { font-size: 22px; margin: 8px 0 0; }
.login-card p { margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); }
.login-card input { background: var(--pane-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; color: var(--text); }
.login-card input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card .btn { margin-top: 6px; padding: 10px 14px; }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; }

/* ============ App layout ============ */
.app { height: 100%; display: grid; grid-template-columns: var(--rail-w) 1fr; background: var(--bg); }
.module { min-height: 0; min-width: 0; height: 100%; overflow: hidden; }
.mod-split { display: grid; grid-template-columns: var(--folders-w) minmax(0, 1fr); }
.pane-head { height: 52px; display: flex; align-items: center; gap: 8px; padding: 0 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.pane-head h2 { font-size: 15px; margin: 0; flex: 1; font-weight: 600; }

/* Rail (identical to inbox portal) */
.rail { background: var(--rail); border-inline-end: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; padding: 12px 0 10px; gap: 2px; overflow: hidden; }
.rail-brand { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; margin-bottom: 10px; flex-shrink: 0; }
.rail-btn { width: 68px; min-height: 54px; border-radius: 10px; border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; text-decoration: none; padding: 4px 0; position: relative; flex-shrink: 0; }
.rail-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; display: block; }
.rail-btn > svg { padding: 4px 10px; width: 42px; height: 30px; border-radius: 10px; box-sizing: border-box; transition: background .12s; }
.rail-lbl { font-size: 11px; line-height: 1.1; letter-spacing: .01em; font-weight: 500; }
.rail-btn:hover { color: var(--text); }
.rail-btn:hover > svg { background: var(--pane-2); }
.rail-btn.active { color: var(--text); }
.rail-btn.active > svg { background: var(--accent-soft); color: #fff; }
:root[data-theme="light"] .rail-btn.active > svg { color: var(--accent); }
.rail-btn.create > svg { background: var(--accent); color: #fff; }
.rail-btn.create:hover > svg { background: var(--accent-hover); }
.rail-badge { position: absolute; top: 2px; inset-inline-end: 14px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.rail-spacer { flex: 1; }
.rail-avatar { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--pane-2); margin-top: 6px; cursor: pointer; overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex-shrink: 0; position: relative; }
.rail-avatar img { width: 100%; height: 100%; object-fit: cover; }
.rail-avatar:hover { border-color: var(--accent); }

/* Folders / channels sidebar */
.folders { background: var(--pane); border-inline-end: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.folders-scroll { overflow-y: auto; padding: 8px 8px 20px; flex: 1; }
.fsec { margin-top: 10px; }
.fsec-title { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; padding: 8px 8px 4px; font-weight: 600; }
.fitem { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; color: var(--text); position: relative; }
.fitem:hover { background: var(--pane-2); }
.fitem.active { background: var(--accent-soft); font-weight: 500; }
.fitem .lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fitem .cnt { font-size: 11.5px; color: var(--muted); background: var(--pane-2); border-radius: 10px; padding: 0 7px; min-width: 22px; text-align: center; }
.fitem.active .cnt { color: var(--text); background: rgba(255,255,255,.08); }
.fitem svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.75; }
.fitem.disabled { opacity: .5; }
.fitem .warn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.folders-foot { padding: 10px 12px; border-top: 1px solid var(--border); }

/* Channel avatar + provider badge */
.ch { position: relative; width: 28px; height: 28px; flex-shrink: 0; }
.ch img, .ch .ava-fallback { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: var(--pane-3); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; }
.ch .pb { position: absolute; bottom: -3px; inset-inline-end: -4px; width: 15px; height: 15px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 2px solid var(--pane); }
.ch .pb svg { width: 9px; height: 9px; fill: #fff; stroke: none; }
.ch.md { width: 36px; height: 36px; } .ch.md img, .ch.md .ava-fallback { width: 36px; height: 36px; } .ch.md .pb { width: 17px; height: 17px; } .ch.md .pb svg { width: 10px; height: 10px; }
.ch.lg { width: 48px; height: 48px; } .ch.lg img, .ch.lg .ava-fallback { width: 48px; height: 48px; font-size: 16px; } .ch.lg .pb { width: 20px; height: 20px; } .ch.lg .pb svg { width: 12px; height: 12px; }
.ch.sm { width: 22px; height: 22px; } .ch.sm img, .ch.sm .ava-fallback { width: 22px; height: 22px; font-size: 9px; } .ch.sm .pb { width: 12px; height: 12px; bottom: -2px; inset-inline-end: -3px; } .ch.sm .pb svg { width: 7px; height: 7px; }
.pv-facebook { background: #1877F2; }
.pv-instagram, .pv-instagram-standalone { background: linear-gradient(45deg,#f09433,#dc2743,#bc1888); }
.pv-threads { background: #000; }
.pv-x { background: #000; }
.pv-linkedin, .pv-linkedin-page { background: #0A66C2; }
.pv-youtube { background: #FF0000; }
.pv-tiktok, .pv-tiktok-business { background: #000; }
.pv-pinterest { background: #E60023; }
.pv-telegram { background: #229ED9; }
.pv-other { background: #64748b; }
:root[data-theme="light"] .pv-threads, :root[data-theme="light"] .pv-x, :root[data-theme="light"] .pv-tiktok, :root[data-theme="light"] .pv-tiktok-business { background: #222; }

/* ============ Page modules ============ */
.mod-page { display: flex; flex-direction: column; min-height: 0; min-width: 0; height: 100%; }
.page-head { min-height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 22px; border-bottom: 1px solid var(--border); background: var(--pane); flex-shrink: 0; flex-wrap: wrap; }
.page-head h2 { font-size: 16px; margin: 0; font-weight: 600; flex: 1; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
.page-head-right { display: flex; align-items: center; gap: 8px; }
.page-sub { font-size: 12.5px; color: var(--muted); margin: 2px 0 0; }
.page-scroll { overflow-y: auto; flex: 1; padding: 20px 22px 40px; }
.ptabs { display: flex; gap: 18px; border-bottom: 1px solid var(--border); padding: 0 22px; background: var(--pane); flex-shrink: 0; }
.ptab { background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 12px 2px 11px; cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: -1px; display: inline-flex; gap: 6px; align-items: center; }
.ptab b { font-weight: 500; font-size: 11px; background: var(--pane-2); border-radius: 10px; padding: 0 6px; color: var(--muted); }
.ptab:hover { color: var(--text); }
.ptab.active { color: var(--text); border-bottom-color: var(--accent); }
.panel { background: var(--pane); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.panel-title { font-size: 14px; margin: 0; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.panel-title .spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty svg { width: 44px; height: 44px; stroke: var(--border-strong); fill: none; stroke-width: 1.4; }
.empty .btn { margin-top: 6px; }

/* Stat cards */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.stat { background: var(--pane); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.stat .t { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.stat .n { font-size: 26px; font-weight: 600; line-height: 1.1; letter-spacing: -.02em; }
.stat .s { font-size: 11.5px; color: var(--muted); display: flex; gap: 8px; }
.stat .s .up { color: var(--success); } .stat .s .down { color: var(--danger); }
.stat.click { cursor: pointer; } .stat.click:hover { border-color: var(--border-strong); background: var(--pane-2); }

/* ============ Queue (Buffer-style day groups) ============ */
.queue { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.qday { display: flex; flex-direction: column; gap: 8px; }
.qday-title { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: var(--text); padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.qday-title .d { color: var(--muted); font-weight: 500; }
.qday-title.today .pill { background: var(--accent-soft); color: var(--accent-2); border-radius: var(--radius-pill); padding: 1px 8px; font-size: 11px; }
.qday-title .spacer { flex: 1; }
.qslot { display: flex; align-items: center; gap: 12px; padding: 6px 4px; color: var(--muted); font-size: 12.5px; cursor: pointer; border-radius: var(--radius-sm); }
.qslot:hover { background: var(--pane-2); color: var(--text); }
.qslot .t { width: 64px; font-variant-numeric: tabular-nums; }
.qslot .line { flex: 1; border-top: 1px dashed var(--border-strong); }
.pcard { background: var(--pane); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: grid; grid-template-columns: auto 1fr; gap: 12px; cursor: pointer; transition: border-color .12s; position: relative; }
.pcard:hover { border-color: var(--border-strong); }
.pcard.error { border-color: rgba(229,72,77,.5); }
.pcard .pc-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pcard .pc-time { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pcard .pc-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .pc-body { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.pcard .pc-text { font-size: 13.5px; white-space: pre-wrap; word-wrap: break-word; max-height: 108px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.pcard .pc-text.short { -webkit-mask-image: none; mask-image: none; }
.pcard .pc-media { display: flex; gap: 6px; flex-wrap: wrap; }
.pcard .pc-media img, .pcard .pc-media video { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--pane-2); }
.pcard .pc-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.pcard .pc-foot .spacer { flex: 1; }
.pcard .pc-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; position: absolute; top: 8px; inset-inline-end: 8px; background: var(--pane); border-radius: 8px; }
.pcard:hover .pc-actions { opacity: 1; }
.pcard .pc-actions .icon-btn { width: 28px; height: 28px; } .pcard .pc-actions .icon-btn svg { width: 15px; height: 15px; }
.pcard .pc-err { font-size: 12px; color: var(--danger); background: rgba(229,72,77,.1); border-radius: 8px; padding: 6px 9px; }
.state-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.st-QUEUE { background: var(--info); } .st-PUBLISHED { background: var(--success); } .st-ERROR { background: var(--danger); } .st-DRAFT { background: var(--muted-2); }

/* Post list (Drafts / Sent) */
.plist { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.load-more { text-align: center; padding: 10px; }

/* ============ Calendar ============ */
.cal-tools { display: flex; align-items: center; gap: 8px; }
.cal-tools .title { font-weight: 600; font-size: 14px; min-width: 160px; text-align: center; }
.seg { display: inline-flex; background: var(--pane-2); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 12px; border-radius: var(--radius-pill); font-size: 12.5px; cursor: pointer; color: var(--muted); }
.seg button.active { background: var(--pane); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.cal-wrap { flex: 1; overflow: auto; padding: 16px 22px 30px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--pane); }
.cal .dow { padding: 8px 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); border-inline-end: 1px solid var(--border); background: var(--pane-2); }
.cal .dow:nth-child(7n) { border-inline-end: 0; }
.cal .cell { min-height: 120px; border-bottom: 1px solid var(--border); border-inline-end: 1px solid var(--border); padding: 6px; display: flex; flex-direction: column; gap: 4px; position: relative; }
.cal .cell:nth-child(7n) { border-inline-end: 0; }
.cal .cell.other { background: rgba(0,0,0,.12); }
:root[data-theme="light"] .cal .cell.other { background: rgba(0,0,0,.03); }
.cal .cell.past { opacity: .75; }
.cal .cell .dn { font-size: 12px; color: var(--muted); font-weight: 500; display: flex; justify-content: space-between; align-items: center; }
.cal .cell.today .dn b { background: var(--accent); color: #fff; border-radius: 50%; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; }
.cal .cell .add { opacity: 0; width: 22px; height: 22px; border-radius: 6px; border: 0; background: var(--pane-2); color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.cal .cell:hover .add { opacity: 1; }
.cal .cell .add svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2; }
.cal .cell.drop { outline: 2px dashed var(--accent); outline-offset: -3px; }
.cev { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 7px; background: var(--pane-2); border: 1px solid var(--border); font-size: 11.5px; cursor: pointer; min-width: 0; border-inline-start: 3px solid var(--info); }
.cev:hover { border-color: var(--border-strong); }
.cev.PUBLISHED { border-inline-start-color: var(--success); }
.cev.ERROR { border-inline-start-color: var(--danger); }
.cev.DRAFT { border-inline-start-color: var(--muted-2); }
.cev .t { color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.cev .x { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cev .ch { width: 18px; height: 18px; } .cev .ch img, .cev .ch .ava-fallback { width: 18px; height: 18px; font-size: 8px; } .cev .ch .pb { width: 10px; height: 10px; bottom: -2px; inset-inline-end: -2px; border-width: 1px; } .cev .ch .pb svg { width: 6px; height: 6px; }
.cev.dragging { opacity: .4; }
.cal.week { grid-template-columns: 60px repeat(7, minmax(120px, 1fr)); }
.cal.week .dow:first-child { border-inline-end: 1px solid var(--border); }
.cal.week .hour { font-size: 10.5px; color: var(--muted); padding: 4px 6px; border-bottom: 1px solid var(--border); border-inline-end: 1px solid var(--border); text-align: end; min-height: 48px; font-variant-numeric: tabular-nums; }
.cal.week .cell { min-height: 48px; }
.cal.week .cell:nth-child(7n) { border-inline-end: 1px solid var(--border); }
.cal.week .cell:nth-child(8n) { border-inline-end: 0; }

/* ============ Composer modal ============ */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 120; padding: 16px; backdrop-filter: blur(2px); }
.modal { background: var(--pane); border: 1px solid var(--border-strong); border-radius: 16px; width: 100%; max-width: 720px; max-height: 94vh; display: flex; flex-direction: column; box-shadow: var(--shadow); overflow: hidden; }
.modal.wide { max-width: 1040px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 15px; flex: 1; }
.modal-body { overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-foot .spacer { flex: 1; }
.comp-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 0; flex: 1; min-height: 0; }
.comp-left { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; padding: 16px 18px; gap: 14px; border-inline-end: 1px solid var(--border); }
.comp-right { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; padding: 16px; gap: 12px; background: var(--pane-2); }
.ch-picker { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ch-pick { border: 0; background: transparent; padding: 0; cursor: pointer; border-radius: 50%; opacity: .4; transition: opacity .12s, transform .12s; position: relative; }
.ch-pick .ch.md img, .ch-pick .ch.md .ava-fallback { border: 2px solid transparent; }
.ch-pick.on { opacity: 1; }
.ch-pick.on .ch.md img, .ch-pick.on .ch.md .ava-fallback { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.ch-pick:hover { opacity: 1; transform: translateY(-1px); }
.ch-pick.off { opacity: .25; cursor: not-allowed; }
.ctabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.ctab { background: transparent; border: 1px solid transparent; border-radius: var(--radius-pill); padding: 4px 10px; font-size: 12.5px; cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.ctab.active { background: var(--pane-2); color: var(--text); border-color: var(--border); }
.ctab.custom::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.editor { display: flex; flex-direction: column; gap: 8px; }
.editor textarea { min-height: 150px; font-size: 14px; }
.editor-tools { display: flex; align-items: center; gap: 4px; }
.editor-tools .count { margin-inline-start: auto; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.editor-tools .count.over { color: var(--danger); font-weight: 600; }
.media-row { display: flex; gap: 8px; flex-wrap: wrap; }
.media-row .m { position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--pane-2); }
.media-row .m img, .media-row .m video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-row .m button { position: absolute; top: 3px; inset-inline-end: 3px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; cursor: pointer; font-size: 12px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.media-row .m.uploading::after { content: "…"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.5); color: #fff; font-weight: 700; }
.media-row .add-m { width: 84px; height: 84px; border-radius: 10px; border: 1px dashed var(--border-strong); background: transparent; color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; }
.media-row .add-m:hover { color: var(--text); border-color: var(--accent); }
.media-row .add-m svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.75; }
.thread-item { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; background: var(--pane); }
.thread-item .th-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.thread-item .th-head .spacer { flex: 1; }
.preview { background: var(--pane); border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.preview .pv-head { display: flex; align-items: center; gap: 8px; }
.preview .pv-head .n { font-weight: 600; font-size: 13px; }
.preview .pv-head .s { font-size: 11.5px; color: var(--muted); }
.preview .pv-text { font-size: 13.5px; white-space: pre-wrap; word-wrap: break-word; }
.preview .pv-media { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.preview .pv-media img, .preview .pv-media video { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.preview .pv-media.one { grid-template-columns: 1fr; }
.opt-group { display: flex; flex-direction: column; gap: 8px; }
.opt-group h4 { margin: 0; font-size: 12.5px; display: flex; align-items: center; gap: 8px; }
.sched-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sched-row input[type="datetime-local"] { padding: 6px 9px; }
.tags-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 3px 9px; border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--pane-2); cursor: pointer; user-select: none; }
.tag .dot { width: 8px; height: 8px; border-radius: 50%; }
.tag.on { background: var(--accent-soft); border-color: var(--accent); }
.tag.add { border-style: dashed; background: transparent; color: var(--muted); }
.warnbox { font-size: 12.5px; background: rgba(233,162,59,.12); color: var(--warn); border-radius: 8px; padding: 8px 10px; }
.errbox { font-size: 12.5px; background: rgba(229,72,77,.12); color: var(--danger); border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; }

/* Media library grid */
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.mgrid .m { aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 2px solid transparent; cursor: pointer; background: var(--pane-2); position: relative; }
.mgrid .m img, .mgrid .m video { width: 100%; height: 100%; object-fit: cover; display: block; }
.mgrid .m.on { border-color: var(--accent); }
.mgrid .m .name { position: absolute; bottom: 0; inset-inline: 0; font-size: 10px; padding: 3px 6px; background: rgba(0,0,0,.6); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============ Analyze ============ */
.an-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.chart { width: 100%; height: 180px; }
.chart svg { width: 100%; height: 100%; display: block; }
.chart .bar { fill: var(--series-1); opacity: .85; }
.chart .bar:hover { opacity: 1; }
.chart .ax { stroke: var(--border-strong); }
.chart text { fill: var(--muted); font-size: 10px; }
.legend { display: flex; gap: 12px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 4px; vertical-align: middle; }

/* ============ Channels ============ */
.ch-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.ch-card { background: var(--pane); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.ch-card .top { display: flex; align-items: center; gap: 12px; }
.ch-card .top .n { font-weight: 600; font-size: 14px; }
.ch-card .top .s { font-size: 11.5px; color: var(--muted); text-transform: capitalize; }
.ch-card .top .spacer { flex: 1; }
.ch-card .times { display: flex; gap: 6px; flex-wrap: wrap; }
.ch-card .times .chip { cursor: pointer; }
.ch-card .times .chip:hover { border-color: var(--danger); color: var(--danger); }
.ch-card .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ch-card.disabled { opacity: .6; }
.prov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.prov { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--pane); cursor: pointer; font-size: 13px; }
.prov:hover { border-color: var(--accent); background: var(--pane-2); }
.prov .pb { position: static; width: 26px; height: 26px; border: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.prov .pb svg { width: 14px; height: 14px; fill: #fff; }
.prov.nokey { opacity: .5; }
.prov.nokey:hover { border-color: var(--warn); }

/* ============ Settings ============ */
.settings-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 0; height: 100%; }
.settings-nav { border-inline-end: 1px solid var(--border); background: var(--pane); padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.settings-nav .fitem { font-size: 13px; }
.settings-body { overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 16px; max-width: 760px; }
.kv-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.kv-table td { padding: 7px 0; border-bottom: 1px solid var(--border); }
.kv-table td:first-child { color: var(--muted); width: 180px; }
.team-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.team-row .ava-fallback { width: 30px; height: 30px; border-radius: 50%; background: var(--pane-3); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; }

/* ============ Popover / toasts / search ============ */
.popover { position: fixed; z-index: 150; background: var(--pane); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow); min-width: 210px; max-width: 320px; max-height: 380px; overflow-y: auto; padding: 5px; }
.popover .p-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; }
.popover .p-item:hover { background: var(--pane-2); }
.popover .p-item.static { cursor: default; } .popover .p-item.static:hover { background: transparent; }
.popover .p-item svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.popover .p-sep { height: 1px; background: var(--border); margin: 5px 0; }
.popover .p-item.danger { color: var(--danger); }
.popover .p-head { padding: 8px 10px 4px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.p-user { display: flex; flex-direction: column; min-width: 0; }
.p-user .n { font-weight: 600; } .p-user .e { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.notif { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.notif .t { font-size: 12.5px; white-space: normal; line-height: 1.35; }
.notif .s { font-size: 11px; color: var(--muted); }
.toasts { position: fixed; bottom: 18px; inset-inline-start: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 300; }
[dir="rtl"] .toasts { transform: translateX(50%); }
.toast { background: var(--pane); border: 1px solid var(--border-strong); border-radius: var(--radius-pill); padding: 9px 16px; font-size: 12.5px; box-shadow: var(--shadow); animation: tin .15s ease; }
.toast.err { border-color: var(--danger); } .toast.ok { border-color: var(--success); }
@keyframes tin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.search-modal .modal { max-width: 560px; }
.search-modal input { font-size: 15px; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: transparent; }
.search-modal input:focus { box-shadow: none; }
.search-res { max-height: 420px; overflow-y: auto; padding: 6px; }
.search-res .p-item .mid { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.search-res .p-item .n { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-res .p-item .s { font-size: 11px; color: var(--muted); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 400; cursor: zoom-out; }
.lightbox img, .lightbox video { max-width: 92vw; max-height: 92vh; border-radius: 8px; }
.confirm .modal { max-width: 400px; }

/* ============ Responsive ============ */
@media (max-width: 980px) {
  .comp-grid { grid-template-columns: 1fr; } .comp-right { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  :root { --rail-w: 60px; --folders-w: 0px; }
  .rail-lbl { display: none; }
  .rail-btn { width: 48px; min-height: 44px; }
  .mod-split { grid-template-columns: 1fr; }
  .mod-split .folders { display: none; }
  .page-head { padding: 0 14px; } .page-scroll { padding: 14px; }
  .settings-grid { grid-template-columns: 1fr; } .settings-nav { flex-direction: row; overflow-x: auto; border-inline-end: 0; border-bottom: 1px solid var(--border); }
}
