@font-face { font-family: Plex; src: url(/fonts/IBMPlexSansArabic-Regular.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Plex; src: url(/fonts/IBMPlexSansArabic-Medium.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: Plex; src: url(/fonts/IBMPlexSansArabic-SemiBold.woff2) format('woff2'); font-weight: 600; font-display: swap; }

:root {
  --bg: #F6F6F3;
  --surface: #FFFFFF;
  --ink: #1B1B1A;
  --ink-2: #5E5E5A;
  --ink-3: #9A9A94;
  --line: #E6E5E0;
  --line-2: #D9D8D2;
  --hover: #F0EFEA;
  --done: #2F8F5B;
  --danger: #C8402F;
  --focus: #1B1B1A;
  --r: 10px;
  --shadow: 0 1px 2px rgba(20,20,15,.06), 0 4px 14px rgba(20,20,15,.06);
  --shadow-lg: 0 2px 4px rgba(20,20,15,.06), 0 12px 32px rgba(20,20,15,.12);
  font-family: Plex, system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-size: 14px; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.ic { display: block; flex: none; }
[hidden] { display: none !important; }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding-inline: 14px;
  border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); font-weight: 500;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #33332F; }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { height: 30px; padding-inline: 10px; font-size: 13px; }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink-2);
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.on { background: var(--ink); color: #fff; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.field { display: grid; gap: 6px; margin-block-end: 14px; }
.field label { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.input {
  height: 40px; padding-inline: 12px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface);
  outline: none; transition: border-color .12s, box-shadow .12s; width: 100%;
}
.input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(27,27,26,.08); }
.input.ltr { direction: ltr; text-align: start; }
.row { display: flex; gap: 8px; align-items: center; }
.err { color: var(--danger); font-size: 13px; min-height: 20px; }

/* ---------- sign in ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.brand-mark { width: 26px; height: 26px; flex: none; }
.login h1 { font-size: 26px; font-weight: 600; margin: 40px 0 4px; letter-spacing: -.01em; }
.login p.sub { color: var(--ink-2); margin: 0 0 28px; }
.login .btn.primary { width: 100%; justify-content: center; height: 42px; }

/* ---------- app shell ---------- */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  height: 60px; padding-inline: 24px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid transparent;
}
.top .spacer { flex: 1; }
.top nav a { color: var(--ink-2); text-decoration: none; padding: 6px 10px; border-radius: 6px; font-weight: 500; }
.top nav a.on, .top nav a:hover { color: var(--ink); background: var(--hover); }
.avatar {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  color: #fff; font-size: 12px; font-weight: 600; flex: none; user-select: none;
}
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }
.avatar-btn { border: 0; padding: 0; background: none; border-radius: 50%; }
.page { max-width: 1080px; margin: 0 auto; padding: 24px 24px 80px; }
.page-head { display: flex; align-items: end; gap: 12px; margin: 16px 0 24px; }
.page-head h1 { font-size: 24px; font-weight: 600; margin: 0; letter-spacing: -.01em; flex: 1; }

/* menu */
.menu {
  position: fixed; z-index: 100; min-width: 200px; padding: 6px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg);
}
.menu button, .menu .mi {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none;
  border-radius: 6px; text-align: start; color: var(--ink);
}
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.menu .who { padding: 8px 10px 10px; }
.menu .who b { display: block; font-weight: 600; }
.menu .who span { color: var(--ink-3); font-size: 12px; }
.menu .seg { display: flex; gap: 2px; padding: 2px; margin: 4px 10px 6px; background: var(--hover); border-radius: 7px; }
.menu .seg button { justify-content: center; padding: 4px 6px; font-size: 12px; }
.menu .seg button.on { background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* board cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card {
  position: relative; display: flex; flex-direction: column; min-height: 168px; padding: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: inherit;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.card:hover { border-color: var(--line-2); box-shadow: var(--shadow); }
.card .thumb { height: 52px; display: flex; gap: 5px; margin-bottom: 16px; }
.card .thumb i { width: 26px; height: 26px; border-radius: 3px; box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.card .thumb i:nth-child(2) { transform: translateY(14px) rotate(-3deg); }
.card .thumb i:nth-child(3) { transform: translateY(4px) rotate(2deg); }
.card h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.card .meta { color: var(--ink-3); font-size: 12px; margin-top: auto; display: flex; align-items: center; gap: 8px; }
.card .progress { height: 4px; background: var(--hover); border-radius: 4px; margin: 10px 0 8px; overflow: hidden; }
.card .progress b { display: block; height: 100%; background: var(--done); border-radius: 4px; }
.card .stats { font-size: 12px; color: var(--ink-2); }
.card .more { position: absolute; top: 10px; inset-inline-end: 10px; opacity: 0; transition: opacity .12s; }
.card:hover .more, .card .more:focus-visible { opacity: 1; }
.card .faces { display: flex; margin-inline-start: auto; }
.card .faces .avatar { border: 2px solid var(--surface); margin-inline-start: -6px; }
.card.new { align-items: center; justify-content: center; gap: 8px; border-style: dashed; color: var(--ink-2); background: transparent; }
.card.new:hover { color: var(--ink); background: var(--surface); }
.empty { text-align: center; padding: 80px 20px; color: var(--ink-2); }
.empty h2 { color: var(--ink); font-size: 18px; margin: 0 0 6px; font-weight: 600; }

/* team list */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.list .item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.list .item:first-child { border-top: 0; }
.list .item .who { flex: 1; min-width: 0; }
.list .item .who b { font-weight: 500; }
.list .item .who span { color: var(--ink-3); font-size: 12px; display: block; direction: ltr; text-align: start; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: var(--hover); color: var(--ink-2); font-weight: 500; }

/* dialog */
dialog {
  border: 0; padding: 24px; border-radius: 14px; width: min(400px, calc(100vw - 32px));
  box-shadow: var(--shadow-lg); color: var(--ink); background: var(--surface);
}
dialog::backdrop { background: rgba(20,20,15,.28); }
dialog h2 { font-size: 17px; margin: 0 0 18px; font-weight: 600; }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
dialog p { color: var(--ink-2); margin: 0 0 18px; }

/* toasts */
#toasts { position: fixed; z-index: 200; inset-block-end: 88px; inset-inline: 0; display: grid; justify-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow-lg); animation: rise .18s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ============ board ============ */
.board-view { position: fixed; inset: 0; overflow: hidden; background: var(--bg); touch-action: none; }
.canvas {
  position: absolute; inset: 0; direction: ltr; cursor: default;
  background-image: radial-gradient(circle, #D3D2CB 1px, transparent 1.2px);
}
.canvas.t-hand, .canvas.panning { cursor: grab; }
.canvas.panning:active { cursor: grabbing; }
.canvas.t-pen, .canvas.t-rect, .canvas.t-ellipse, .canvas.t-arrow, .canvas.t-column, .canvas.t-note, .canvas.t-task, .canvas.t-text { cursor: crosshair; }
.canvas.t-eraser { cursor: cell; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }

.el { position: absolute; left: 0; top: 0; user-select: none; -webkit-user-select: none; }
.el .txt { outline: none; white-space: pre-wrap; overflow-wrap: anywhere; unicode-bidi: plaintext; text-align: start; }
.el .txt:empty::before { content: attr(data-ph); color: rgba(0,0,0,.3); }
.el.editing .txt { user-select: text; -webkit-user-select: text; cursor: text; }
.el.sel { outline: 2px solid #1B1B1A; outline-offset: 2px; }
.el.column.sel, .el.rect.sel, .el.ellipse.sel { outline-offset: 0; }

/* sticky note */
.el.note {
  padding: 16px 16px 30px; border-radius: 2px;
  box-shadow: 0 1px 1px rgba(0,0,0,.06), 0 6px 12px -6px rgba(0,0,0,.18);
  font-size: 17px; line-height: 1.45; overflow: hidden;
}
.el.note .txt { height: 100%; overflow: hidden; }
.el.note .by { position: absolute; inset-inline-start: 16px; bottom: 9px; font-size: 11px; color: rgba(0,0,0,.42); white-space: nowrap; overflow: hidden; max-width: calc(100% - 60px); text-overflow: ellipsis; }
.el.note.done .txt { color: rgba(0,0,0,.45); }
.chk {
  position: absolute; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  border: 1.6px solid rgba(0,0,0,.22); background: rgba(255,255,255,.5); color: transparent; padding: 0;
  transition: background .12s, border-color .12s, transform .12s;
}
.chk:hover { border-color: rgba(0,0,0,.5); }
.done > .chk { background: var(--done); border-color: var(--done); color: #fff; }
.el.note .chk { inset-inline-end: 10px; bottom: 6px; }

/* task card */
.el.task {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; min-height: 48px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.05);
  font-size: 15px; border-inline-start-width: 4px;
}
.el.task .chk { position: static; width: 22px; height: 22px; border-radius: 6px; margin-top: 1px; flex: none; background: #fff; }
.el.task .body { flex: 1; min-width: 0; }
.el.task .by { font-size: 11px; color: var(--ink-3); margin-top: 4px; }
.el.task.done .txt { text-decoration: line-through; text-decoration-color: rgba(0,0,0,.35); color: var(--ink-3); }

/* text */
.el.text { font-size: 20px; line-height: 1.4; font-weight: 500; padding: 2px 4px; }

/* column */
.el.column { border-radius: 14px; padding: 14px; }
.el.column .head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; }
.el.column .head .txt { flex: 1; min-width: 40px; }
.el.column .count { font-size: 12px; font-weight: 500; color: rgba(0,0,0,.5); background: rgba(255,255,255,.65); padding: 2px 8px; border-radius: 20px; white-space: nowrap; }

/* shapes */
.el.rect, .el.ellipse { display: grid; place-items: center; border: 2px solid; padding: 10px; text-align: center; font-size: 16px; }
.el.ellipse { border-radius: 50%; }
.el.rect { border-radius: 6px; }
.el.rect .txt, .el.ellipse .txt { text-align: center; max-width: 100%; }

/* pen & arrow */
.el.svg { pointer-events: none; overflow: visible; }
.el.svg .hit { pointer-events: stroke; stroke: transparent; fill: none; }
.el.svg.sel { outline: none; }
.el.svg.sel .vis { filter: drop-shadow(0 0 1.5px #1B1B1A) drop-shadow(0 0 1px #fff); }

/* image & file */
.el.image img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; border-radius: 4px; }
.el.image { box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.el.file {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.el.file .fi { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; background: var(--hover); color: var(--ink-2); flex: none; }
.el.file .fn { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; unicode-bidi: plaintext; }
.el.file .fs { font-size: 12px; color: var(--ink-3); }
.el.file .fm { min-width: 0; flex: 1; }

/* selection chrome (world space) */
.selbox { position: absolute; left: 0; top: 0; border: 1px solid #1B1B1A; pointer-events: none; }
.marquee { position: absolute; left: 0; top: 0; border: 1px solid rgba(27,27,26,.6); background: rgba(27,27,26,.05); pointer-events: none; }
.handle {
  position: absolute; width: 12px; height: 12px; background: #fff; border: 1.5px solid #1B1B1A; border-radius: 3px;
  cursor: nwse-resize; z-index: 999999;
}
.handle.end { border-radius: 50%; cursor: move; }

/* ui layers (screen space) */
.ui { position: absolute; pointer-events: none; z-index: 20; }
.ui > * { pointer-events: auto; }
.bar {
  display: flex; align-items: center; gap: 2px; padding: 4px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.bar .sep { width: 1px; height: 22px; background: var(--line); margin-inline: 4px; }
.ui.tl { top: 12px; inset-inline-start: 12px; }
.ui.tr { top: 12px; inset-inline-end: 12px; display: flex; gap: 8px; align-items: center; }
.ui.bc { bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; justify-items: center; gap: 8px; }
.ui.br { bottom: 16px; inset-inline-end: 12px; }
.ui.bl { bottom: 16px; inset-inline-start: 12px; }
.title-wrap { display: flex; align-items: center; gap: 4px; padding-inline-end: 8px; }
.board-title {
  font-weight: 600; font-size: 14px; border: 0; background: transparent; padding: 6px 8px; border-radius: 6px;
  max-width: 40vw; min-width: 60px; outline: none; text-overflow: ellipsis;
}
.board-title:hover { background: var(--hover); }
.board-title:focus { background: var(--hover); }
.rtl-flip { transform: scaleX(-1); }
[dir=ltr] .rtl-flip { transform: none; }
[dir=ltr] .back-ic { transform: scaleX(-1); }
.faces { display: flex; align-items: center; }
.faces .avatar { border: 2px solid var(--bg); margin-inline-start: -6px; }
.faces .avatar:first-child { margin-inline-start: 0; }
.status-pill { font-size: 12px; padding: 4px 10px; border-radius: 20px; background: #FFF4D6; color: #7A5A00; }
.zoom-label { min-width: 48px; text-align: center; font-size: 12px; color: var(--ink-2); border: 0; background: none; height: 32px; border-radius: 6px; }
.zoom-label:hover { background: var(--hover); }
.bar .icon-btn { width: 34px; height: 34px; }
.tools .icon-btn { width: 38px; height: 38px; border-radius: 9px; }

.ctx { position: absolute; z-index: 30; transform: translate(-50%, calc(-100% - 12px)); }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(0,0,0,.12); padding: 0; margin: 4px; }
.swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.swatches { display: flex; align-items: center; }
.size-dot { display: grid; place-items: center; width: 30px; height: 30px; border: 0; background: none; border-radius: 6px; }
.size-dot i { display: block; border-radius: 50%; background: var(--ink); }
.size-dot.on, .size-dot:hover { background: var(--hover); }

.cursor { position: absolute; left: 0; top: 0; z-index: 25; pointer-events: none; transition: transform .08s linear; }
.cursor span { position: absolute; left: 14px; top: 16px; font-size: 11px; color: #fff; padding: 1px 7px; border-radius: 10px; white-space: nowrap; font-weight: 500; }

.drop-hint { position: absolute; inset: 12px; border: 2px dashed var(--ink-3); border-radius: 16px; z-index: 40; pointer-events: none; background: rgba(246,246,243,.6); }

@media (max-width: 640px) {
  .top { padding-inline: 16px; }
  .page { padding-inline: 16px; }
  .tools { max-width: calc(100vw - 16px); overflow-x: auto; }
  .tools .icon-btn { width: 36px; height: 36px; }
  .ui.br { bottom: 76px; }
  .ui.bl { display: none; }
  .board-title { max-width: 38vw; }
}
.el.task.done .chk, .el.note.done .chk { background: var(--done); border-color: var(--done); color: #fff; }
