/* «مهامي» (assets/tasks.js). Apple Reminders / Microsoft To Do look: grey grouped background, white rounded cards,
   coloured smart-list tiles, round checks. Light by default; body.theme-dark → pure black. No transitions. */
#tasks-app,.tk-chbar{
  --bg:#f2f2f7;--card:#fff;--soft:#f2f2f7;--ink:#111;--sub:#6e6e73;--line:#e5e5ea;--a:#0a84ff;
  --blue:#0a84ff;--red:#ff3b30;--orange:#ff9500;--gray:#8e8e93;--green:#34c759;--late:#e5332a;
  --sh:0 1px 2px rgba(0,0,0,.04);
  font-family:'IBM Plex Sans Arabic',Tahoma,'Segoe UI',Arial,sans-serif
}
body.theme-dark :is(#tasks-app,.tk-chbar){--bg:#000;--card:#1c1c1e;--soft:#2c2c2e;--ink:#f5f5f7;--sub:#98989f;--line:#2c2c2e;--late:#ff6961;--sh:none}
#tasks-app{position:fixed;inset:0;z-index:12007;direction:rtl;color:var(--ink);background:var(--bg);display:flex;flex-direction:column;-webkit-font-smoothing:antialiased}
#tasks-app[hidden]{display:none}
#tasks-app *,.tk-chbar *{box-sizing:border-box}
:where(#tasks-app,.tk-chbar) :is(button,input,textarea,select){font-family:inherit;color:inherit;font-size:inherit}
:where(#tasks-app,.tk-chbar) button{cursor:pointer;-webkit-tap-highlight-color:transparent;background:none;border:0;padding:0;text-align:inherit}
#tasks-app :is(h2,p){margin:0}
:is(#tasks-app,.tk-chbar) .grow{flex:1;min-width:0}

/* top bar */
.tk-top{display:flex;align-items:center;gap:6px;min-height:56px;padding:calc(6px + env(safe-area-inset-top)) 8px 6px;background:var(--bg);flex:0 0 auto}
.tk-top strong{display:block;font-size:17px;font-weight:700}
.tk-top small{display:flex;align-items:center;gap:4px;color:var(--sub);font-size:12.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tk-ib{width:40px;height:40px;display:grid;place-items:center;border-radius:12px;color:var(--a)}
.tk-ib:active{background:var(--soft)}.tk-ib.sm{width:30px;height:30px;color:var(--sub)}
.tk-body{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch;padding:4px 16px 24px}

/* smart lists (Apple Reminders tiles) */
.tk-tiles{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-bottom:18px}
.tk-tile{position:relative;display:grid;grid-template-columns:auto 1fr;grid-template-rows:auto auto;align-items:center;gap:6px 8px;padding:11px 12px 10px;border-radius:14px;background:var(--card);box-shadow:var(--sh);border:2px solid transparent;min-height:78px}
.tk-tile.on{border-color:var(--c)}
.tk-ti{width:32px;height:32px;border-radius:50%;display:grid;place-items:center;background:var(--c);color:#fff}
.tk-tile b{justify-self:end;font-size:24px;font-weight:700;line-height:1}
.tk-tn{grid-column:1/3;color:var(--sub);font-weight:600;font-size:14.5px}
.tk-tile.blue,.tk-lhead.blue,.tk-fi.blue{--c:var(--blue)}.tk-tile.red,.tk-lhead.red,.tk-fi.red{--c:var(--red)}.tk-tile.orange,.tk-lhead.orange,.tk-fi.orange{--c:var(--orange)}.tk-tile.gray,.tk-lhead.gray,.tk-fi.gray{--c:var(--gray)}.tk-lhead.green{--c:var(--green)}

/* list header */
.tk-lhead{display:flex;align-items:flex-end;gap:10px;margin:2px 4px 8px}
.tk-lhead h2{font-size:26px;font-weight:700;color:var(--c);line-height:1.2}
.tk-lhead small{color:var(--sub);font-size:13px}
.tk-link{color:var(--a);font-weight:600;font-size:15px;padding:6px 2px;white-space:nowrap}.tk-link.b{font-weight:700}
.tk-sec{display:flex;align-items:center;gap:6px;margin:16px 6px 6px;font-weight:700;font-size:15px}
.tk-sec i{font-style:normal;color:var(--sub);font-weight:500;font-size:13px}
.tk-sec.late{color:var(--late)}

/* task rows */
.tk-group{background:var(--card);border-radius:14px;box-shadow:var(--sh);overflow:hidden}
.tk-row{display:flex;align-items:flex-start;gap:10px;padding:11px 14px 11px 8px;position:relative}
.tk-row+.tk-row::before{content:"";position:absolute;top:0;left:0;right:48px;border-top:1px solid var(--line)}
.tk-check{flex:0 0 auto;width:24px;height:24px;margin-top:1px;border-radius:50%;border:2px solid #c7c7cc;display:grid;place-items:center;color:#fff}
body.theme-dark #tasks-app .tk-check{border-color:#48484a}
.tk-check.fl{border-color:var(--orange)!important}
.tk-check[aria-pressed="true"]{background:var(--a);border-color:var(--a)!important}
.tk-check.sm{width:20px;height:20px}.tk-check svg{width:14px;height:14px}
.tk-main{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}
.tk-title{font-size:16px;line-height:1.45;word-break:break-word}
.tk-row.is-done .tk-title{color:var(--sub);text-decoration:line-through}
.tk-meta{display:flex;flex-wrap:wrap;gap:4px 10px;color:var(--sub);font-size:13px}
.tk-m{display:inline-flex;align-items:center;gap:3px}.tk-m svg{width:14px;height:14px}
.tk-m.late{color:var(--late);font-weight:600}
.tk-star{flex:0 0 auto;width:32px;height:32px;display:grid;place-items:center;color:#c7c7cc;margin:-4px 0}
body.theme-dark #tasks-app .tk-star{color:#48484a}
.tk-star.on{color:var(--orange)!important}

/* empty + loading */
.tk-empty{text-align:center;padding:34px 20px;background:var(--card);border-radius:16px;box-shadow:var(--sh)}
.tk-empty-i{width:56px;height:56px;margin:0 auto 10px;border-radius:50%;display:grid;place-items:center;background:var(--soft);color:var(--sub)}
.tk-empty strong{display:block;font-size:17px;margin-bottom:4px}.tk-empty p{color:var(--sub);font-size:14px;line-height:1.6}
.tk-skel{height:64px;border-radius:14px;margin-bottom:10px;background:linear-gradient(90deg,var(--card) 25%,var(--soft) 50%,var(--card) 75%);background-size:200% 100%;animation:tk-sh 1.2s linear infinite}
@keyframes tk-sh{0%{background-position:100% 0}100%{background-position:-100% 0}}

/* quick add (bottom) */
.tk-foot{flex:0 0 auto;padding:8px 12px calc(10px + env(safe-area-inset-bottom));background:color-mix(in srgb,var(--bg) 94%,transparent);backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);border-top:1px solid var(--line)}
.tk-chips{display:flex;gap:6px;overflow-x:auto;padding:2px 0 8px;scrollbar-width:none}.tk-chips::-webkit-scrollbar{display:none}
.tk-chip{flex:0 0 auto;display:inline-flex;align-items:center;gap:4px;height:32px;padding:0 12px;border-radius:999px;background:var(--card);border:1px solid var(--line)!important;font-size:13.5px;font-weight:600;color:var(--ink)}
.tk-chip svg{width:14px;height:14px}
.tk-chip.on{background:var(--a);border-color:var(--a)!important;color:#fff}
.tk-hint{display:flex;align-items:center;gap:5px;color:var(--a);font-size:13px;font-weight:600;padding:0 4px 6px}
.tk-add{display:flex;align-items:center;gap:8px;height:48px;padding:0 6px 0 12px;border-radius:24px;background:var(--card);box-shadow:var(--sh);border:1px solid var(--line)}
.tk-add-i{color:var(--a);display:grid;place-items:center}
.tk-add input{flex:1;min-width:0;height:100%;border:0;background:none;outline:none;font-size:16px}
.tk-add input::placeholder{color:var(--sub)}
.tk-send{width:36px;height:36px;border-radius:50%;display:grid;place-items:center;background:var(--a)!important;color:#fff}
.tk-send:disabled{opacity:.35}

/* detail sheet */
.tk-scrim{position:absolute;inset:0;background:rgba(0,0,0,.35);z-index:3}
.tk-sheet{position:absolute;left:0;right:0;bottom:0;top:calc(36px + env(safe-area-inset-top));z-index:4;background:var(--bg);border-radius:16px 16px 0 0;display:flex;flex-direction:column;overflow:hidden}
.tk-sh-top{display:flex;align-items:center;justify-content:space-between;padding:10px 16px;border-bottom:1px solid var(--line);background:var(--bg)}
.tk-sh-top strong{font-size:16px}
.tk-sh-body{flex:1;overflow-y:auto;padding:14px 16px calc(30px + env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:14px}
.tk-card{background:var(--card);border-radius:14px;box-shadow:var(--sh);overflow:hidden}
.tk-card textarea{display:block;width:100%;border:0;background:none;outline:none;resize:none;padding:12px 14px;font-size:15.5px;line-height:1.6}
.tk-titlecard{display:flex;align-items:flex-start;gap:6px;padding:10px 6px 10px 12px}
.tk-titlecard textarea{padding:0 4px;font-size:18px;font-weight:600;min-height:28px}
.tk-titlecard .tk-check{margin-top:3px}
.tk-steps{padding:2px 0}
.tk-step{display:flex;align-items:center;gap:10px;padding:6px 6px 6px 14px;min-height:44px}
.tk-step+.tk-step{border-top:1px solid var(--line)}
.tk-step input{flex:1;min-width:0;border:0;background:none;outline:none;font-size:15px;height:32px}
.tk-step input.done{color:var(--sub);text-decoration:line-through}
.tk-plus-s{width:20px;display:grid;place-items:center;color:var(--a)}.tk-plus-s svg{width:18px;height:18px}
.tk-fields .tk-f{display:flex;align-items:center;gap:10px;padding:8px 12px 8px 14px;min-height:52px;font-size:15.5px}
.tk-fields .tk-f+.tk-f{border-top:1px solid var(--line)}
.tk-fi{width:30px;height:30px;border-radius:8px;display:grid;place-items:center;background:var(--c);color:#fff;flex:0 0 auto}.tk-fi svg{width:17px;height:17px}
.tk-f select{max-width:58%;border:0;background:var(--soft);border-radius:9px;padding:7px 10px;font-size:14.5px;color:var(--a);font-weight:600;outline:none;appearance:none;-webkit-appearance:none;text-align:center}
.tk-del{display:flex;align-items:center;justify-content:center;gap:6px;height:48px;border-radius:14px;background:var(--card)!important;color:var(--red);font-weight:700;box-shadow:var(--sh)}
.tk-when{text-align:center;color:var(--sub);font-size:12.5px}

/* toast */
.tk-toast{position:absolute;left:16px;right:16px;bottom:calc(84px + env(safe-area-inset-bottom));z-index:6;display:flex;align-items:center;gap:12px;background:#1c1c1e;color:#fff;padding:12px 16px;border-radius:14px;font-size:14.5px;box-shadow:0 10px 30px rgba(0,0,0,.25)}
.tk-toast[hidden]{display:none}
.tk-toast span{flex:1}.tk-toast button{color:#64d2ff;font-weight:700}

/* strip on the channel page (owner only) */
.tk-chbar{display:flex;align-items:center;gap:12px;width:calc(100% - 28px);margin:10px 14px 4px;padding:12px 14px;border-radius:16px;background:var(--card);border:1px solid var(--line)!important;box-shadow:0 1px 2px rgba(0,0,0,.04);color:var(--ink);text-align:right;cursor:pointer}
.tk-chbar-i{flex:0 0 auto;width:42px;height:42px;border-radius:12px;display:grid;place-items:center;color:#fff;background:linear-gradient(135deg,#5ac8fa,#0a84ff)}
.tk-chbar strong{display:flex;align-items:center;gap:8px;font-size:15.5px;font-weight:700}
.tk-chbar small{display:block;color:var(--sub);font-size:13px;margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tk-chbar small em{font-style:normal;color:var(--late);font-weight:700}
.tk-priv{display:inline-flex;align-items:center;gap:3px;font-size:11.5px;font-weight:600;color:var(--sub);background:var(--soft);padding:2px 8px;border-radius:999px}
.tk-priv svg{width:12px;height:12px}
.tk-badge{min-width:24px;height:24px;padding:0 7px;border-radius:12px;display:grid;place-items:center;background:var(--blue);color:#fff;font-size:13px;font-weight:700}
.tk-badge.late{background:var(--late)}
.tk-chev{color:var(--sub);font-size:20px}
/* the app's global input styles (focus ring, filled background) must not reach these inputs */
#tasks-app :is(.tk-add input,.tk-step input,.tk-card textarea){background:transparent!important;border:0!important;box-shadow:none!important;outline:none!important;border-radius:0!important;padding-inline:0}
#tasks-app .tk-card textarea{padding:12px 14px!important}#tasks-app .tk-titlecard textarea{padding:0 4px!important}

/* search */
.tk-search{display:flex;align-items:center;gap:8px;height:44px;padding:0 4px 0 12px;margin:2px 0 6px;border-radius:12px;background:var(--card);box-shadow:var(--sh);color:var(--sub)}
#tasks-app .tk-search input{flex:1;min-width:0;height:100%;border:0!important;background:transparent!important;outline:none!important;box-shadow:none!important;font-size:16px;color:var(--ink);padding:0}
.tk-foot[hidden]{display:none}
