:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --ok: #047857;
  --ok-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --info: #1d4ed8;
  --info-bg: #dbeafe;
  --shadow: 0 1px 2px rgb(15 23 42 / .06), 0 4px 16px rgb(15 23 42 / .06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --surface: #111a2e; --surface-2: #17223a; --text: #e5e9f0; --muted: #94a3b8;
    --line: #22304d; --brand: #14b8a6; --brand-ink: #04201d; --ok: #4ade80; --ok-bg: #0f2e1d;
    --warn: #fbbf24; --warn-bg: #33260a; --bad: #f87171; --bad-bg: #3a1414; --info: #93c5fd; --info-bg: #13254a;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120; --surface: #111a2e; --surface-2: #17223a; --text: #e5e9f0; --muted: #94a3b8;
  --line: #22304d; --brand: #14b8a6; --brand-ink: #04201d; --ok: #4ade80; --ok-bg: #0f2e1d;
  --warn: #fbbf24; --warn-bg: #33260a; --bad: #f87171; --bad-bg: #3a1414; --info: #93c5fd; --info-bg: #13254a;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.7 'IBM Plex Sans Arabic', Tahoma, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--brand); }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px 96px; }

/* header */
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 12px; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.brand svg { width: 26px; height: 26px; }
.pills { display: flex; gap: 6px; margin-inline-start: auto; flex-wrap: wrap; }
.pill { font-size: 12px; padding: 2px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.tabs { display: flex; gap: 4px; width: 100%; }
.tab { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 10px; color: var(--muted); font-weight: 600; cursor: pointer; }
.tab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-top: 14px; }
.card h2 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 22px; line-height: 1.2; }
.stat span { font-size: 12px; color: var(--muted); }
.next { border-inline-start: 4px solid var(--brand); }

.filters { display: flex; gap: 6px; margin-top: 16px; overflow-x: auto; padding-bottom: 2px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 4px 12px; cursor: pointer; white-space: nowrap; font-size: 13px; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

.week { margin: 22px 4px 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.post { display: flex; gap: 12px; align-items: stretch; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-top: 8px; cursor: pointer; width: 100%; text-align: right; box-shadow: var(--shadow); }
.post:hover { border-color: var(--brand); }
.thumb { width: 64px; height: 80px; border-radius: 10px; background: var(--surface-2); flex: none; overflow: hidden; display: grid; place-items: center; color: var(--muted); font-size: 22px; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.post .meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.post .ttl { font-weight: 600; margin: 2px 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.post .why { font-size: 12px; color: var(--warn); }
.badge { font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 99px; white-space: nowrap; }
.b-ready { background: var(--ok-bg); color: var(--ok); }
.b-need { background: var(--warn-bg); color: var(--warn); }
.b-pub { background: var(--info-bg); color: var(--info); }
.b-bad { background: var(--bad-bg); color: var(--bad); }
.b-off { background: var(--surface-2); color: var(--muted); }

/* buttons + fields */
.btn { border: 1px solid var(--line); background: var(--surface); padding: 9px 16px; border-radius: 11px; cursor: pointer; font-weight: 600; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.fab { position: fixed; bottom: calc(18px + env(safe-area-inset-bottom)); inset-inline-start: 18px; z-index: 6; border-radius: 99px; padding: 12px 20px; box-shadow: 0 6px 24px rgb(15 118 110 / .35); }
label.f { display: block; margin-top: 14px; font-weight: 600; font-size: 14px; }
label.f small { font-weight: 400; color: var(--muted); }
.in { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 11px; padding: 10px 12px; margin-top: 6px; outline: none; }
.in:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
textarea.in { min-height: 180px; resize: vertical; line-height: 1.8; }
.counter { font-size: 12px; color: var(--muted); text-align: left; margin-top: 2px; }
.counter.over { color: var(--bad); font-weight: 600; }
.seg { display: flex; background: var(--surface-2); border-radius: 11px; padding: 3px; margin-top: 6px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 7px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.switch { display: flex; align-items: center; gap: 10px; margin-top: 14px; cursor: pointer; font-weight: 600; }
.switch input { width: 20px; height: 20px; accent-color: var(--brand); }

/* editor sheet */
.sheet-bg { position: fixed; inset: 0; background: rgb(2 6 23 / .5); z-index: 20; display: flex; justify-content: center; align-items: flex-end; }
.sheet { background: var(--bg); width: 100%; max-width: 720px; max-height: 94vh; overflow: auto; border-radius: 20px 20px 0 0; }
@media (min-width: 760px) { .sheet-bg { align-items: center; } .sheet { border-radius: 20px; } }
.sheet-head { position: sticky; top: 0; background: var(--bg); padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; z-index: 2; }
.sheet-head h3 { margin: 0; font-size: 17px; flex: 1; }
.sheet-body { padding: 4px 16px 16px; }
.sheet-foot { position: sticky; bottom: 0; background: var(--bg); border-top: 1px solid var(--line); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); display: flex; gap: 8px; flex-wrap: wrap; }

.drop { display: block; margin-top: 8px; border: 2px dashed var(--line); border-radius: var(--radius); padding: 18px; text-align: center; cursor: pointer; background: var(--surface); }
.drop.over { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--surface)); }
.drop b { display: block; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .2s; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 10px; }
.tile { position: relative; border-radius: 10px; overflow: hidden; background: var(--surface-2); aspect-ratio: 4 / 5; }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .n { position: absolute; top: 4px; right: 4px; background: rgb(0 0 0 / .6); color: #fff; font-size: 11px; border-radius: 6px; padding: 0 6px; }
.tile .acts { position: absolute; bottom: 0; inset-inline: 0; display: flex; justify-content: space-between; background: linear-gradient(transparent, rgb(0 0 0 / .65)); padding: 14px 4px 4px; }
.tile .acts button { border: 0; background: rgb(255 255 255 / .9); color: #111; width: 26px; height: 26px; border-radius: 7px; cursor: pointer; font-size: 13px; line-height: 1; }
.video-prev { width: 100%; max-height: 420px; border-radius: 12px; background: #000; margin-top: 10px; }

.ready { border-radius: 12px; padding: 10px 14px; margin-top: 16px; font-size: 14px; }
.ready.ok { background: var(--ok-bg); color: var(--ok); }
.ready.no { background: var(--warn-bg); color: var(--warn); }
.ready ul { margin: 4px 0 0; padding-inline-start: 18px; }
.note { background: var(--surface-2); border-radius: 12px; padding: 10px 14px; margin-top: 14px; font-size: 13px; color: var(--muted); }

/* reports + log */
.rep { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rep:last-child { border-bottom: 0; }
.log { font-size: 13px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.frame { width: 100%; height: 70vh; border: 0; background: #fff; border-radius: 12px; }
details { margin-top: 10px; }
summary { cursor: pointer; font-weight: 600; color: var(--brand); }
ol.steps { padding-inline-start: 20px; margin: 8px 0; font-size: 14px; }
ol.steps li { margin-bottom: 4px; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 13px; direction: ltr; unicode-bidi: embed; }

/* login */
.login { max-width: 380px; margin: 12vh auto 0; padding: 0 16px; text-align: center; }
.login svg { width: 56px; height: 56px; }
.login h1 { font-size: 22px; margin: 10px 0 4px; }

#toast { position: fixed; bottom: calc(80px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; max-width: calc(100% - 32px); text-align: center; }
#toast.show { opacity: 1; }
#toast.err { background: var(--bad); color: #fff; }

@media (max-width: 520px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
  .two { grid-template-columns: 1fr; }
}
