:root {
  color-scheme: dark;
  --bg: #090c12; --surface: #121724; --surface-2: #0e1320; --field: #0c111b; --ink: #e9edf6; --muted: #93a0b5; --line: #212a3b; --line-strong: #2f3a50; --hover: #1a2132;
  --accent: #5b7cfa; --accent-strong: #7391ff; --accent-ink: #fff; --accent-soft: rgba(91, 124, 250, .16);
  --ok: #3ddc97; --ok-soft: rgba(61, 220, 151, .13); --info: #7aa2ff; --info-soft: rgba(122, 162, 255, .14); --busy: #f3c14b; --busy-soft: rgba(243, 193, 75, .13);
  --warn: #ff9f4a; --warn-soft: rgba(255, 159, 74, .13); --bad: #ff6b6b; --bad-soft: rgba(255, 107, 107, .13); --neutral: #a5b0c2; --neutral-soft: rgba(165, 176, 194, .12);
  --radius: 14px; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .22);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15.5px/1.65 "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif; }
h1 { font-size: 1.45rem; margin: 0; line-height: 1.3; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
h3 { font-size: .95rem; margin: 18px 0 8px; }
p { margin: 0 0 10px; }
a { color: var(--accent-strong); }
.muted { color: var(--muted); font-size: .88rem; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.error { color: var(--bad); min-height: 1.4em; margin-top: 10px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.icon { width: 20px; height: 20px; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- shell ---- */
#app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
#app.centered { display: flex; align-items: center; justify-content: center; padding: 16px; }
.side { background: var(--surface); border-inline-end: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; padding: 0 6px; }
.brand-logo { width: 34px; height: 34px; border-radius: 10px; flex: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #5b7cfa, #b06cff); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--hover); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.side-foot { margin-top: auto; padding: 0 6px; }
.content { padding: 28px clamp(16px, 3vw, 36px) 48px; max-width: 1180px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; }



/* ---- surfaces ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.auth { width: min(430px, 100%); display: grid; gap: 14px; padding: 26px; }
.auth .field { margin-top: 0; }
.auth-switch { text-align: center; margin: 4px 0 0; }
.auth .check { align-items: flex-start; font-size: .88rem; color: var(--muted); }
.auth .check input { margin-top: 3px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.grid-2 > .card { margin-bottom: 16px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.label-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.label-row h2 { margin: 0; }
.banner { border-radius: 12px; padding: 11px 14px; margin-bottom: 14px; border: 1px solid transparent; font-weight: 500; }
.empty { text-align: center; padding: 22px 10px; color: var(--muted); }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; }
.meter { height: 8px; border-radius: 99px; background: var(--neutral-soft); overflow: hidden; margin: 2px 0 8px; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* ---- tones ---- */
.tone-ok { color: var(--ok); background: var(--ok-soft); border-color: color-mix(in srgb, currentColor 32%, transparent); }
.tone-info { color: var(--info); background: var(--info-soft); border-color: color-mix(in srgb, currentColor 32%, transparent); }
.tone-busy { color: var(--busy); background: var(--busy-soft); border-color: color-mix(in srgb, currentColor 32%, transparent); }
.tone-warn { color: var(--warn); background: var(--warn-soft); border-color: color-mix(in srgb, currentColor 32%, transparent); }
.tone-bad { color: var(--bad); background: var(--bad-soft); border-color: color-mix(in srgb, currentColor 32%, transparent); }
.tone-neutral { color: var(--neutral); background: var(--neutral-soft); border-color: color-mix(in srgb, currentColor 32%, transparent); }
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; border: 1px solid; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; border: 0; }
.dot.tone-ok { background: var(--ok); } .dot.tone-info { background: var(--info); } .dot.tone-busy { background: var(--busy); }
.dot.tone-warn { background: var(--warn); } .dot.tone-bad { background: var(--bad); } .dot.tone-neutral { background: #7d899c; }
.p-youtube { background: #e53935; } .p-facebook { background: #1877f2; } .p-instagram { background: #d62f8a; } .p-tiktok { background: #25f4ee; } .p-mock { background: #7d899c; }

/* ---- controls ---- */
label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 5px; }
.field { margin-top: 14px; }
input, textarea, select { width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; font: inherit; background: var(--field); color: inherit; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); outline-offset: 0; }
textarea { resize: vertical; min-height: 120px; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
button, a.button { font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
button:hover, a.button:hover { background: var(--hover); }
button.primary, a.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover, a.button.primary:hover { background: var(--accent-strong); }
button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
button.small, a.button.small { padding: 5px 12px; font-size: .84rem; }
button.block { width: 100%; }
button.link { border: 0; background: none; color: var(--accent); padding: 4px 2px; font-weight: 600; }
button:disabled { opacity: .55; cursor: default; }
.icon-button { padding: 7px; border-radius: 10px; }
.chip { padding: 6px 13px; border-radius: 99px; font-size: .86rem; font-weight: 500; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.submit-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 18px; }

/* ---- lists ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--muted); box-shadow: var(--shadow); display: grid; }
.stat b { font-size: 1.7rem; color: var(--ink); line-height: 1.2; }
.stat:hover { border-color: var(--accent); }
.list-row { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 8px; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: none; text-align: start; font-weight: 400; }
.list-row:first-of-type { border-top: 0; }
.list-row:hover { background: var(--hover); border-radius: 10px; }
.list-main { display: grid; gap: 1px; min-width: 0; }
.list-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.note:first-of-type { border-top: 0; }
.note .dot { margin-top: 8px; }

/* ---- identity ---- */
.identity { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.identity-text { display: grid; min-width: 0; line-height: 1.35; }
.identity-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar-wrap { position: relative; flex: none; display: inline-flex; }
.avatar-wrap .dot { position: absolute; bottom: -1px; inset-inline-start: -1px; width: 13px; height: 13px; border: 2px solid var(--surface); }
.avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: var(--neutral-soft); }
.avatar.placeholder { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); }
.account, .result { border-top: 1px solid var(--line); padding: 12px 0; }
.result-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.result-error { color: var(--bad); font-size: .9rem; margin: 8px 0 0; }

/* ---- composer ---- */
.compose { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.drop { display: grid; justify-items: center; gap: 6px; padding: 26px 14px; border: 2px dashed var(--line-strong); border-radius: 12px; cursor: pointer; text-align: center; font-weight: 600; color: var(--ink); margin: 0; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop .icon { width: 28px; height: 28px; color: var(--accent); }
.preview { display: grid; justify-items: center; gap: 6px; margin-top: 12px; }
.preview:empty { display: none; }
.preview img, .preview video { max-width: 100%; max-height: 320px; border-radius: 12px; background: #000; }
.progress { height: 22px; border-radius: 99px; background: var(--neutral-soft); overflow: hidden; margin: 12px 0; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); color: #fff; font-size: .78rem; text-align: center; line-height: 22px; transition: width .2s; }
.counter { font-weight: 400; }
.picks { display: grid; gap: 4px; max-height: 340px; overflow: auto; margin-top: 10px; }
.pick { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; margin: 0; font-weight: 400; cursor: pointer; }
.pick:hover { background: var(--hover); }
.notes { margin: 14px 0 0; padding: 10px 14px 10px 30px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: .9rem; }
[dir="rtl"] .notes { padding: 10px 30px 10px 14px; }

/* ---- calendar ---- */
.cal { padding: 14px; }
.cal-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-title { margin: 0; min-width: 150px; text-align: center; font-size: 1.15rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--line); gap: 1px; }
.cal-head { background: var(--surface-2); padding: 8px 4px; text-align: center; font-size: .82rem; font-weight: 700; color: var(--muted); }
.cell { background: var(--surface); min-height: 138px; padding: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cell:hover { background: var(--hover); }
.cell.out { background: var(--surface-2); }
.cell.out .cell-day { color: #55607a; }
.cell.past .event { opacity: .8; }
.cell.selected { box-shadow: inset 0 0 0 2px var(--accent); }
.cell-top { display: flex; justify-content: space-between; align-items: center; }
.cell-day { font-weight: 700; font-size: .9rem; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.cell.today .cell-day { background: var(--accent); color: #fff; }
.cell-count, .cell-dots { display: none; }
.cell-events { display: grid; gap: 3px; min-width: 0; }
.event { display: flex; flex-wrap: wrap; align-items: center; gap: 1px 5px; width: 100%; padding: 4px 7px; border-radius: 7px; border: 0; border-inline-start: 3px solid currentColor; font-size: .76rem; font-weight: 500; text-align: start; justify-content: flex-start; min-width: 0; }
.event:hover { filter: brightness(1.2); }
.event-time { font-weight: 700; white-space: nowrap; }
.event-dots { display: inline-flex; gap: 2px; }
.event-dots .dot { width: 7px; height: 7px; }
.event-text { flex-basis: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-weight: 500; }
.more { font-size: .74rem; color: var(--muted); padding-inline-start: 6px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: .82rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---- post sheet ---- */
dialog.sheet { border-radius: 16px; padding: 22px; width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(0, 0, 0, .6); color: var(--ink); background: var(--surface); border: 1px solid var(--line); }
dialog.sheet::backdrop { background: rgba(0, 0, 0, .65); }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sheet-head h2 { margin: 8px 0 2px; font-size: 1.15rem; }
.body-text { white-space: pre-wrap; }
.tech { margin-top: 14px; }
.platform-form { border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 12px 14px; margin-top: 12px; display: grid; gap: 8px; }
.platform-form p { margin: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }
.check input { width: auto; }
.lang-switch { font-size: .86rem; color: var(--muted); padding: 2px 0; }
.lang-switch:hover { color: var(--ink); background: none; }
.centered .lang-switch { margin-top: -6px; }
.tag-sets { margin-top: 8px; gap: 6px; }
.tag-set { display: inline-flex; align-items: center; gap: 2px; padding: 3px 4px 3px 10px; }
.tag-set .link { padding: 0 4px; }
.remove-set { color: var(--muted) !important; }
.tab-gap { width: 12px; }
.account-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.account-stat { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--surface-2); display: grid; gap: 10px; }
.account-stat.best { border-color: color-mix(in srgb, var(--ok) 55%, transparent); }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; text-align: center; }
.stat-grid b { display: block; font-size: 1.05rem; }
.stat-grid span { font-size: .72rem; color: var(--muted); }
.table-wrap { overflow-x: auto; margin: 0 -6px; }
table.metrics { width: 100%; border-collapse: collapse; font-size: .86rem; min-width: 860px; }
table.metrics th, table.metrics td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
table.metrics th:first-child, table.metrics td:first-child { text-align: start; white-space: normal; min-width: 220px; }
table.metrics tbody tr { cursor: pointer; }
table.metrics tbody tr:hover { background: var(--hover); }
.sort { color: var(--muted) !important; font-weight: 600; font-size: .8rem; padding: 0; }
.sort.active { color: var(--accent-strong) !important; }
.cell-post { display: flex; gap: 8px; align-items: flex-start; }
.cell-post .dot { margin-top: 7px; }
.metric-line { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: .86rem; color: var(--muted); align-items: center; }
.metric-line b { color: var(--ink); }
.retention-wrap { display: flex; align-items: center; gap: 8px; flex-basis: 100%; }
svg.retention { width: 160px; height: 40px; }
.retention-area { fill: var(--accent-soft); }
.retention-line { fill: none; stroke: var(--accent-strong); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
details.card > summary { cursor: pointer; font-weight: 600; }
.tech summary { cursor: pointer; color: var(--muted); font-size: .88rem; }
.tech pre { background: var(--field); border-radius: 8px; padding: 8px 10px; font-size: .74rem; white-space: pre-wrap; word-break: break-word; text-align: left; margin: 8px 0 0; }

/* ---- toasts ---- */
#toasts { position: fixed; inset-inline: 0; bottom: 20px; display: grid; justify-items: center; gap: 8px; z-index: 50; pointer-events: none; padding: 0 12px; }
.toast { padding: 11px 18px; border-radius: 12px; border: 1px solid; backdrop-filter: blur(10px); background-color: var(--surface) !important; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, .45); max-width: 520px; }

/* ---- static pages ---- */
main.doc { max-width: 860px; margin: 0 auto; padding: 28px 16px 8px; }
main.doc h1 { font-size: 1.9rem; margin-bottom: 6px; }
article ul { padding-inline-start: 22px; }
article h2 { margin-top: 18px; }

/* ---- small screens ---- */
@media (max-width: 860px) {
  #app { display: block; padding-bottom: 72px; }
  .side { position: static; height: auto; flex-direction: row; justify-content: space-between; align-items: center; padding: 10px 14px; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .side-foot { margin: 0; display: flex; align-items: center; gap: 10px; }
  .nav { position: fixed; inset-inline: 0; bottom: 0; flex-direction: row; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 20; }
  .nav a { flex: 1; flex-direction: column; gap: 2px; padding: 6px 2px; font-size: .7rem; text-align: center; }
  .content { padding: 18px 12px 24px; }
  .compose { grid-template-columns: minmax(0, 1fr); }
  .cal { padding: 10px; }
  .cell { min-height: 58px; padding: 4px; align-items: center; }
  .cell-top { flex-direction: column; gap: 2px; }
  .cell-events { display: none; }
  .cell-dots { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; }
  .cell-dots .dot { width: 6px; height: 6px; }
  .cal-head { font-size: .68rem; padding: 6px 1px; }
  #toasts { bottom: 84px; }
}
