/* ============ NXGN CANVAS AI — design tokens ============ */
:root {
  --font: 'Inter', 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --accent: #6C5CE7;
  --accent-2: #00CEC9;
  --grad: linear-gradient(135deg, #6C5CE7 0%, #8E7BFF 45%, #00CEC9 100%);
  --danger: #E74C3C;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(10, 8, 40, .18);
}
:root[data-theme="dark"] {
  --bg: #0E0E1A;
  --bg-2: #14142400;
  --dots: #2B2B45;
  --panel: rgba(24, 24, 42, .86);
  --panel-solid: #181A2E;
  --border: rgba(255, 255, 255, .09);
  --text: #EDEDF7;
  --muted: #9C9CB8;
  --hover: rgba(255, 255, 255, .07);
  --canvas-bg: #101020;
}
:root[data-theme="light"] {
  --bg: #F4F5FB;
  --dots: #D4D7E6;
  --panel: rgba(255, 255, 255, .88);
  --panel-solid: #FFFFFF;
  --border: rgba(20, 20, 60, .10);
  --text: #1B1B2F;
  --muted: #6A6A85;
  --hover: rgba(20, 20, 60, .06);
  --canvas-bg: #F7F8FC;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea, select { font-family: inherit; color: inherit; }
.hidden { display: none !important; }

.glass {
  background: var(--panel);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.btn {
  padding: 9px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--border); background: var(--hover); transition: .15s;
}
.btn:hover { filter: brightness(1.12); }
.btn-accent { background: var(--grad); color: #fff; border: none; box-shadow: 0 4px 16px rgba(108, 92, 231, .4); }
.btn-ghost { background: transparent; }
.btn.icon { padding: 9px 11px; font-size: 15px; }
.btn-danger { color: var(--danger); }

/* ============ auth ============ */
.auth-wrap {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(60% 80% at 15% 10%, rgba(108, 92, 231, .28), transparent 60%),
    radial-gradient(50% 70% at 90% 85%, rgba(0, 206, 201, .22), transparent 60%),
    var(--bg);
  position: relative; overflow: hidden;
}
.auth-hero {
  position: absolute; inset: 0; object-fit: cover; width: 100%; height: 100%;
  opacity: .35; pointer-events: none;
}
.auth-card {
  position: relative; width: 400px; max-width: 92vw; padding: 38px 36px;
  border-radius: 22px; z-index: 2;
}
.auth-card .brand { display: flex; align-items: center; gap: 11px; margin-bottom: 6px; text-decoration: none; color: var(--text); }
.auth-card h1 { font-size: 21px; margin: 14px 0 4px; font-weight: 800; }
.auth-card p.sub { color: var(--muted); font-size: 13.5px; margin-bottom: 22px; }
.field { margin-bottom: 13px; }
.field input {
  width: 100%; padding: 12px 14px; border-radius: 11px; font-size: 14px;
  background: var(--hover); border: 1px solid var(--border); outline: none; transition: .15s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(108, 92, 231, .22); }
.auth-card .btn-accent { width: 100%; padding: 12px; font-size: 14.5px; margin-top: 6px; }
.auth-alt { text-align: center; margin-top: 16px; font-size: 13px; color: var(--muted); }
.auth-alt a { color: var(--accent-2); cursor: pointer; text-decoration: none; font-weight: 600; }
.auth-err { color: #FF7675; font-size: 12.5px; min-height: 17px; margin-top: 8px; }

.brand img { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; }
.brand img.off { display: none; }
.brand-word { font-size: 15px; font-weight: 500; letter-spacing: .4px; white-space: nowrap; }
.brand-word b { font-weight: 800; }
.brand-word i {
  font-style: normal; font-weight: 800;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ============ dashboard v2 (sidebar + spaces) ============ */
.dash2 { display: flex; height: 100vh; }
.dside {
  width: 240px; flex: none; border-inline-end: 1px solid var(--border); background: var(--panel);
  display: flex; flex-direction: column; padding: 16px 12px; gap: 4px; overflow-y: auto;
}
.dside .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); padding: 4px 8px 16px; }
.dnav { padding: 9px 12px; border-radius: 10px; font-size: 13.5px; font-weight: 600; color: var(--muted); text-align: start; display: flex; gap: 10px; align-items: center; width: 100%; }
.dnav:hover { background: var(--hover); color: var(--text); }
.dnav.on { background: rgba(108, 92, 231, .16); color: var(--text); }
.dside-sec { display: flex; align-items: center; justify-content: space-between; padding: 18px 12px 6px; }
.dside-sec span { font-size: 10.5px; font-weight: 800; letter-spacing: .1em; color: var(--muted); }
.dside-sec button { color: var(--accent); font-size: 16px; padding: 0 4px; }
.sp-item { display: flex; align-items: center; gap: 9px; padding: 8px 12px; border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--muted); width: 100%; position: relative; }
.sp-item:hover { background: var(--hover); color: var(--text); }
.sp-item.on { background: rgba(108, 92, 231, .16); color: var(--text); }
.sp-item .spdot { width: 10px; height: 10px; border-radius: 4px; flex: none; }
.sp-item .spn { flex: 1; text-align: start; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-item .spc { font-size: 11px; opacity: .7; }
.sp-item .spm { opacity: 0; font-size: 13px; padding: 0 3px; }
.sp-item:hover .spm { opacity: .8; }

.dmain { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.dtop { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 13px 26px; background: var(--panel); backdrop-filter: blur(18px); border-bottom: 1px solid var(--border); }
.dtop .dq { flex: 0 1 420px; padding: 9px 14px; border-radius: 10px; background: var(--hover); border: 1px solid var(--border); font-size: 13px; outline: none; }
.dtop .dq:focus { border-color: var(--accent); }
.dtop .sp2 { flex: 1; }

.tpl-strip { display: flex; gap: 12px; padding: 22px 26px 4px; overflow-x: auto; }
.tpl-mini { flex: none; width: 168px; cursor: pointer; transition: .15s; }
.tpl-mini:hover { transform: translateY(-3px); }
.tpl-mini .prev {
  height: 96px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel-solid);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.tpl-mini:hover .prev { border-color: var(--accent); box-shadow: 0 6px 18px rgba(108, 92, 231, .25); }
.tpl-mini .nm { font-size: 12px; font-weight: 600; color: var(--muted); padding: 7px 2px; text-align: center; }
.tpl-mini:hover .nm { color: var(--text); }
.tpl-mini .plusbig { font-size: 30px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.dhead { display: flex; align-items: center; gap: 10px; padding: 24px 26px 6px; }
.dhead h2 { font-size: 20px; font-weight: 800; flex: 1; }
.dsel { padding: 8px 11px; border-radius: 9px; background: var(--hover); border: 1px solid var(--border); font-size: 12.5px; color: var(--text); outline: none; }
:root[data-theme="dark"] .dsel option { background: #181A2E; }
.dlay { display: flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.dlay button { padding: 7px 11px; font-size: 13px; color: var(--muted); }
.dlay button.on { background: var(--grad); color: #fff; }

.boards-grid2 { padding: 14px 26px 60px; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.bstar { position: absolute; top: 8px; inset-inline-start: 8px; width: 28px; height: 28px; border-radius: 8px; background: rgba(0,0,0,.45); color: #FDCB6E; opacity: 0; transition: .15s; font-size: 14px; z-index: 2; }
.bcard:hover .bstar, .bstar.on { opacity: 1; }
.bmenu { position: absolute; top: 8px; inset-inline-end: 8px; width: 28px; height: 28px; border-radius: 8px; background: rgba(0,0,0,.45); color: #fff; opacity: 0; transition: .15s; z-index: 2; }
.bcard:hover .bmenu { opacity: 1; }
.online-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: #00B894; font-weight: 700; }
.online-badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #00B894; box-shadow: 0 0 6px #00B894; }

.boards-list { padding: 10px 26px 60px; }
.brow { display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-radius: 12px; cursor: pointer; border: 1px solid transparent; }
.brow:hover { background: var(--hover); border-color: var(--border); }
.brow .bthumb { width: 64px; height: 40px; border-radius: 7px; background: var(--hover) center/cover; flex: none; }
.brow .bt { flex: 1; min-width: 0; }
.brow .bt .t { font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brow .bt .s { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.brow .meta2 { color: var(--muted); font-size: 12px; width: 110px; flex: none; }
.brow .ic { color: var(--muted); font-size: 14px; padding: 5px 7px; border-radius: 7px; }
.brow .ic:hover { background: var(--hover); color: var(--text); }
.brow .ic.staron { color: #FDCB6E; }

.dd-menu {
  position: fixed; z-index: 300; min-width: 190px; border-radius: 13px; padding: 6px;
  background: var(--panel-solid); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.dd-menu button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 12px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--text); text-align: start; }
.dd-menu .dd-ic { display: inline-flex; color: var(--muted); flex: none; }
.dd-menu button:hover .dd-ic { color: var(--accent); }
.ic-svg { vertical-align: -4px; }
.dnav .ic-svg { color: inherit; }
.dd-menu button:hover { background: var(--hover); }
.dd-menu button.danger { color: var(--danger); }
.dd-menu .dd-sep { height: 1px; background: var(--border); margin: 5px 8px; }
.dd-menu .dd-head { padding: 8px 12px 4px; font-size: 11px; font-weight: 800; color: var(--muted); letter-spacing: .06em; }

.dempty { padding: 70px 26px; text-align: center; color: var(--muted); font-size: 14px; }
.dempty .big { font-size: 40px; margin-bottom: 12px; }

/* ============ dashboard (legacy bits kept for board cards) ============ */
.dash { height: 100vh; overflow-y: auto; }
.dash-top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px;
  padding: 14px 28px; border-bottom: 1px solid var(--border);
  background: var(--panel); backdrop-filter: blur(18px);
}
.dash-top .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.dash-top .spacer { flex: 1; }
.userchip { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; color: #fff; font-size: 12px; font-weight: 700; flex: none;
}
.dash-hero { padding: 40px 32px 10px; max-width: 1200px; margin: 0 auto; }
.dash-hero h2 { font-size: 26px; font-weight: 800; }
.dash-hero p { color: var(--muted); margin-top: 5px; font-size: 14px; }
.boards-grid {
  max-width: 1200px; margin: 22px auto 60px; padding: 0 32px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px;
}
.bcard {
  border-radius: 16px; overflow: hidden; border: 1px solid var(--border);
  background: var(--panel-solid); cursor: pointer; transition: .18s; position: relative;
}
.bcard:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: rgba(108, 92, 231, .5); }
.bcard .thumb {
  height: 140px; background: var(--hover); display: flex; align-items: center; justify-content: center;
  background-size: cover; background-position: center; color: var(--muted); font-size: 30px;
}
.bcard .meta { padding: 12px 14px; }
.bcard .meta .t { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bcard .meta .s { color: var(--muted); font-size: 11.5px; margin-top: 3px; }
.bcard .del {
  position: absolute; top: 8px; inset-inline-end: 8px; width: 28px; height: 28px; border-radius: 8px;
  background: rgba(0, 0, 0, .45); color: #fff; opacity: 0; transition: .15s; font-size: 13px;
}
.bcard:hover .del { opacity: 1; }
.bcard.new {
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 196px;
  border: 1.6px dashed rgba(108, 92, 231, .55); background: transparent; color: var(--accent);
  font-weight: 700; font-size: 14px; gap: 8px;
}
.bcard.new .plus { font-size: 30px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ============ board view ============ */
.board-root { position: fixed; inset: 0; }
/* width/height 100% is REQUIRED: an absolutely-positioned replaced element
   (canvas) ignores inset-derived sizing and falls back to its intrinsic
   300x150 — which froze the board at a tiny top-left band at 5% zoom. */
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; background: var(--canvas-bg); touch-action: none; }
/* Live HTML-widget layer: sits over the canvas, under pins/cursors/chrome.
   The LAYER is click-through; each iframe's pointer-events are managed per
   frame by syncWidgets: interactive by default, inert while its object is
   selected (so move/resize handles work) or a non-select tool is active.
   The painted 40px header stays canvas-owned — drag/select/dblclick there. */
#widgets { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#widgets .wlive { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#widgets .wlive iframe { position: absolute; left: 0; border: 0; background: #fff; border-radius: 0 0 13px 13px; display: block; }
/* widget content dot (top-right) — the widget's text as a prompt preview */
#widgets .wlive .wdot { position: absolute; top: 10px; right: 10px; width: 15px; height: 15px; border-radius: 50%; background: #fff; border: 2px solid rgba(255,255,255,.85); box-shadow: 0 0 0 2px rgba(14,18,32,.3), 0 0 10px rgba(255,255,255,.75); cursor: pointer; pointer-events: auto; transform-origin: 100% 0; transition: .15s; z-index: 2; padding: 0; }
#widgets .wlive .wdot:hover { background: #FDCB6E; }
/* frameless-widget grip (top-left): the select/move handle when there is no card header */
#widgets .wlive .wgrip { position: absolute; top: 6px; left: 6px; width: 20px; height: 20px; border-radius: 7px; background: rgba(14,18,32,.55); color: #fff; font-size: 11px; line-height: 1; display: grid; place-items: center; cursor: grab; pointer-events: auto; transform-origin: 0 0; z-index: 2; border: 1px solid rgba(255,255,255,.35); padding: 0; opacity: .5; transition: .15s; }
#widgets .wlive .wgrip:hover { opacity: 1; }
/* widget text preview popover */
.wtext-pop { position: fixed; z-index: 200; width: 350px; max-height: 440px; display: flex; flex-direction: column; border-radius: 14px; padding: 12px 14px; }
.wtext-pop pre { flex: 1; min-height: 120px; overflow: auto; white-space: pre-wrap; word-break: break-word; font-size: 11.5px; line-height: 1.55; background: var(--hover); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-family: var(--font); color: var(--text); }
.wtext-pop .mrow { display: flex; gap: 6px; justify-content: flex-end; }
/* image polygon cutout editor */
.cutout-layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; z-index: 55; cursor: crosshair; }
.cutout-layer svg { display: block; width: 100%; height: 100%; overflow: visible; }
.cut-bar { z-index: 56; }
#cursors { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.rcursor { position: absolute; z-index: 60; transition: transform .07s linear; will-change: transform; }
.rcursor svg { display: block; filter: drop-shadow(0 1px 3px rgba(0,0,0,.35)); }
.rcursor .tag {
  margin: 2px 0 0 12px; padding: 3px 8px; border-radius: 999px; color: #fff;
  font-size: 11px; font-weight: 600; white-space: nowrap; width: max-content;
}

.board-top {
  position: absolute; top: 12px; left: 12px; right: 12px; z-index: 40; height: 54px;
  display: flex; align-items: center; gap: 14px; padding: 0 14px; border-radius: var(--radius);
}
.board-top .brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text); flex: none; }
.board-title {
  background: transparent; border: 1px solid transparent; border-radius: 9px; padding: 7px 10px;
  font-size: 14.5px; font-weight: 700; color: var(--text); width: 240px; outline: none; transition: .15s;
}
.board-title:hover { border-color: var(--border); }
.board-title:focus { border-color: var(--accent); background: var(--hover); }
.top-right { margin-inline-start: auto; display: flex; align-items: center; gap: 9px; }
.presence { display: flex; align-items: center; }
.presence .avatar { width: 32px; height: 32px; border: 2.5px solid var(--panel-solid); margin-inline-start: -9px; }
.presence .avatar:first-child { margin-inline-start: 0; }

.toolbar {
  position: absolute; top: 50%; transform: translateY(-50%); inset-inline-start: 14px; z-index: 40;
  display: flex; flex-direction: column; gap: 3px; padding: 9px 7px; border-radius: 16px;
}
.tool {
  width: 42px; height: 42px; border-radius: 11px; display: flex; align-items: center; justify-content: center;
  color: var(--muted); transition: .13s; position: relative;
}
.tool svg { width: 21px; height: 21px; fill: currentColor; }
.tool:hover { background: var(--hover); color: var(--text); }
.tool.active { background: var(--grad); color: #fff; box-shadow: 0 4px 14px rgba(108, 92, 231, .45); }
.tb-sep { height: 1px; background: var(--border); margin: 5px 6px; }
.ai-tool { color: var(--accent-2); }
.ai-tool.active, .ai-tool:hover { color: #fff; background: var(--grad); }
.shape-pop {
  position: absolute; inset-inline-start: 62px; top: 130px; display: flex; gap: 4px;
  padding: 7px; border-radius: 13px;
}
.shape-pop button { width: 40px; height: 40px; border-radius: 9px; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.shape-pop button:hover { background: var(--hover); color: var(--text); }
.shape-pop svg { width: 20px; height: 20px; fill: currentColor; }

.ctxbar {
  position: absolute; z-index: 45; display: flex; align-items: center; gap: 5px;
  padding: 7px 9px; border-radius: 13px; transform: translate(-50%, -100%);
}
.ctxbar .sw { width: 22px; height: 22px; border-radius: 7px; border: 2px solid rgba(0,0,0,.12); flex: none; transition: .12s; }
.ctxbar .sw:hover { transform: scale(1.15); }
.ctxbar .cbtn { padding: 5px 8px; font-size: 12px; border-radius: 8px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.ctxbar .cbtn:hover { background: var(--hover); color: var(--text); }
.ctxbar .cbtn.con { background: var(--grad); color: #fff; }
.ctxbar .csep { width: 1px; height: 20px; background: var(--border); margin: 0 3px; }

.zoombar {
  position: absolute; bottom: 16px; inset-inline-start: 16px; z-index: 40; display: flex;
  align-items: center; gap: 2px; padding: 5px 7px; border-radius: 12px; font-size: 12.5px;
}
.zoombar button { padding: 5px 9px; border-radius: 8px; color: var(--muted); font-size: 14px; }
.zoombar button:hover { background: var(--hover); color: var(--text); }
#z-val { min-width: 44px; text-align: center; color: var(--muted); font-weight: 600; }

/* board background picker (zoombar 🎨) */
.bg-pop { position: absolute; bottom: 64px; inset-inline-start: 16px; z-index: 130; padding: 12px 14px; border-radius: 14px; }
.bg-pop .bg-title { font-size: 11px; font-weight: 700; margin-bottom: 8px; color: var(--muted); }
.bg-row { display: flex; gap: 8px; }
.bg-sw { width: 34px; height: 34px; border-radius: 10px; border: 1.5px solid var(--border); cursor: pointer; transition: .15s; }
.bg-sw:hover { transform: scale(1.12); border-color: var(--accent); }

/* text edit overlay */
.edit-ta {
  position: absolute; z-index: 50; resize: none; outline: none; overflow: hidden;
  /* solid panel bg — a transparent editor over the still-painted canvas text
     doubled every word and made long docs unreadable/uneditable */
  background: var(--panel, #fff); border: 1.6px dashed var(--accent); border-radius: 6px;
  line-height: 1.32; padding: 8px; box-shadow: 0 8px 28px rgba(10, 12, 24, .25);
}

/* ============ AI panel ============ */
.ai-panel {
  position: absolute; top: 78px; bottom: 16px; inset-inline-end: 14px; width: 340px; z-index: 44;
  border-radius: 18px; display: flex; flex-direction: column; overflow: hidden;
}
.ai-head { padding: 16px 18px 0; }
.ai-head h3 { font-size: 15px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.ai-head h3 .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--grad); box-shadow: 0 0 10px var(--accent); }
.ai-tabs { display: flex; gap: 4px; padding: 12px 14px 10px; border-bottom: 1px solid var(--border); }
.ai-tabs button { flex: 1; padding: 8px 4px; border-radius: 9px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.ai-tabs button.on { background: var(--grad); color: #fff; }
.ai-body { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.ai-body label { font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.ai-body textarea {
  width: 100%; min-height: 84px; padding: 11px 12px; border-radius: 11px; font-size: 13.5px;
  background: var(--hover); border: 1px solid var(--border); outline: none; resize: vertical;
}
.ai-body textarea:focus { border-color: var(--accent); }
.chiprow { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 7px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); color: var(--muted); transition: .13s;
}
.chip:hover { color: var(--text); border-color: var(--accent); }
.chip.on { background: var(--grad); color: #fff; border-color: transparent; }
.ai-run { margin: 4px 16px 16px; padding: 12px; border-radius: 12px; font-size: 14px; font-weight: 700; }
.ai-note { font-size: 12px; color: var(--muted); line-height: 1.5; }
.ai-busy { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); padding: 6px 2px; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid var(--border);
  border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ stickers & emoji panel ============ */
.fun-panel {
  position: absolute; inset-inline-start: 74px; top: 50%; transform: translateY(-50%);
  width: 300px; max-height: 480px; z-index: 44; border-radius: 16px;
  display: flex; flex-direction: column; overflow: hidden;
}
.fun-head { padding: 13px 16px 8px; font-size: 13.5px; }
.fun-tabs { display: flex; gap: 2px; padding: 0 10px 8px; border-bottom: 1px solid var(--border); }
.fun-tabs button { flex: 1; padding: 7px 2px; border-radius: 8px; font-size: 16px; }
.fun-tabs button.on { background: var(--grad); }
.fun-body { flex: 1; overflow-y: auto; padding: 10px 12px; }
.emo-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; }
.emo-grid button { font-size: 22px; padding: 6px 0; border-radius: 8px; transition: .1s; }
.emo-grid button:hover { background: var(--hover); transform: scale(1.2); }

/* ============ flows ============ */
.flow-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: 100%;
  padding: 11px 13px; border: 1.4px solid var(--border); border-radius: 13px; transition: .14s;
  text-align: start;
}
.flow-card:hover { border-color: var(--accent); background: rgba(108, 92, 231, .1); }
.flow-card .fico { font-size: 18px; }
.flow-card .fname { font-size: 13.5px; font-weight: 700; }
.flow-card .fsteps { font-size: 11px; color: var(--muted); line-height: 1.45; }
.flow-log { display: flex; flex-direction: column; gap: 5px; }
.flow-step { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.flow-step .fdot { color: var(--accent); font-size: 13px; }
.flow-step.running { color: var(--text); font-weight: 600; }
.flow-step.done { color: #00B894; }

/* ============ agents panel ============ */
.agents-panel { display: flex; flex-direction: column; }
.ag-row { display: flex; gap: 6px; padding: 10px 14px; overflow-x: auto; border-bottom: 1px solid var(--border); }
.ag-chip { flex: none; }
.ag-em {
  width: 40px; height: 40px; border-radius: 13px; display: flex; align-items: center; justify-content: center;
  font-size: 19px; border: 1.6px solid var(--border); transition: .13s; background: var(--hover);
  overflow: hidden;
}
.ag-em img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ag-chip:hover .ag-em { transform: translateY(-2px); }
.ag-chip.on .ag-em { box-shadow: 0 4px 14px rgba(108, 92, 231, .4); border-color: var(--accent) !important; }
.ag-name { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px 4px; font-size: 13.5px; }
.ag-msgs { flex: 1; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.ag-m {
  max-width: 88%; padding: 9px 12px; border-radius: 13px; font-size: 12.8px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}
.ag-m.user { align-self: flex-end; background: var(--grad); color: #fff; border-end-end-radius: 4px; }
.ag-m.agent { align-self: flex-start; background: var(--hover); border: 1px solid var(--border); border-end-start-radius: 4px; }

/* ============ sidekick tasks (starters / description / knowledge files) ============ */
.ag-desc { padding: 0 16px 4px; font-size: 11.8px; color: var(--muted); line-height: 1.45; }
.ag-intro { padding: 14px 6px; display: flex; flex-direction: column; gap: 8px; }
.ag-hi { font-size: 16px; font-weight: 800; letter-spacing: -.02em; }
.ag-intro-d { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.ag-canhelp { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 4px; }
.ag-starters { display: flex; flex-wrap: wrap; gap: 7px; }
.st-chip {
  padding: 7px 12px; border-radius: 999px; font-size: 12.3px; font-weight: 600;
  border: 1px solid var(--border); background: var(--hover); color: var(--text);
  transition: .13s; text-align: start;
}
.st-chip:hover { border-color: var(--accent); background: rgba(108, 92, 231, .12); transform: translateY(-1px); }
.st-chip.ro { cursor: default; }
.st-chip.ro:hover { border-color: var(--border); background: var(--hover); transform: none; }
.modal .cbtn {
  padding: 5px 10px; font-size: 12px; border-radius: 8px; font-weight: 600;
  background: var(--hover); border: 1px solid var(--border); color: var(--text);
}
.modal .cbtn:hover { border-color: var(--accent); color: var(--accent); }
.sec-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sec-row .cbtn { padding: 3px 9px; font-size: 11.5px; border-radius: 8px; background: rgba(108, 92, 231, .12); border: none; color: var(--accent); font-weight: 700; }
.sec-row .cbtn:hover { background: rgba(108, 92, 231, .22); }
.st-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.st-row .txt { flex: 1; margin: 0; }
.kn-file {
  display: flex; align-items: center; gap: 8px; padding: 7px 11px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--hover); font-size: 12.3px; margin-bottom: 6px;
}
.kn-file span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kn-file small { color: var(--muted); }
.kf-x { color: var(--muted); font-size: 12px; padding: 2px 6px; border-radius: 6px; flex: none; }
.kf-x:hover { color: var(--danger); background: var(--hover); }

/* ============ focus mode (smart components) ============ */
.focus-root {
  position: fixed; inset: 0; z-index: 120; background: var(--bg);
  display: flex; flex-direction: column;
}
.focus-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 22px;
  border-bottom: 1px solid var(--border); background: var(--panel);
}
.ft-title {
  font-size: 17px; font-weight: 800; background: transparent; border: 1px solid transparent;
  border-radius: 9px; padding: 8px 10px; color: var(--text); outline: none; width: 320px;
}
.ft-title:focus { border-color: var(--accent); background: var(--hover); }
.ft-ai {
  width: 340px; padding: 10px 14px; border-radius: 999px; font-size: 12.5px;
  background: var(--hover); border: 1px solid var(--border); color: var(--text); outline: none;
}
.ft-ai:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(0,206,201,.18); }
.focus-body { flex: 1; overflow: auto; padding: 26px 30px; }
table.ft { border-collapse: collapse; min-width: 640px; }
.ft th, .ft td { border: 1px solid var(--border); padding: 0; }
.ft th { background: rgba(108, 92, 231, .14); }
.ft input {
  border: none; background: transparent; color: var(--text); padding: 10px 13px;
  font-size: 13px; width: 200px; outline: none; font-family: var(--font);
}
.ft th input { font-weight: 800; }
.ft td:focus-within, .ft th:focus-within { outline: 2px solid var(--accent); outline-offset: -2px; }
.ft .ft-x { border: none; background: none; padding: 0 6px; }
.ft .ft-x button { color: var(--muted); font-size: 13px; padding: 4px 7px; border-radius: 7px; }
.ft .ft-x button:hover { color: var(--danger); background: var(--hover); }

/* ============ NEVO ============ */
.nevo-btn {
  display: flex; align-items: center; gap: 8px; padding: 6px 13px 6px 6px; border-radius: 999px;
  background: linear-gradient(135deg, #062A2E, #0B3B3F 55%, #14424A);
  border: 1.4px solid rgba(0, 206, 201, .55); color: #7DF3EC; font-weight: 800; font-size: 12.5px;
  letter-spacing: .06em; box-shadow: 0 0 14px rgba(0, 206, 201, .25); transition: .15s;
}
:root[data-theme="light"] .nevo-btn { background: linear-gradient(135deg, #DFFBF9, #C1F3EF); color: #067E77; }
.nevo-btn:hover { box-shadow: 0 0 22px rgba(0, 206, 201, .5); transform: translateY(-1px); }
.nevo-btn img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.nevo-panel { border: 1.4px solid rgba(0, 206, 201, .4); box-shadow: 0 8px 40px rgba(0, 206, 201, .18); }
.nevo-head {
  display: flex; align-items: center; gap: 11px; padding: 14px 16px;
  background: linear-gradient(135deg, rgba(0, 206, 201, .16), rgba(253, 203, 110, .10));
  border-bottom: 1px solid rgba(0, 206, 201, .3);
}
.nevo-head img { width: 42px; height: 42px; border-radius: 14px; object-fit: cover; box-shadow: 0 0 12px rgba(0,206,201,.4); }
.nevo-head b { display: block; font-size: 15px; letter-spacing: .08em; }
.nevo-head span { font-size: 11px; color: var(--muted); }
.nevo-head div { flex: 1; }
.nevo-auto { display: flex; align-items: center; cursor: pointer; }
.nevo-auto input { display: none; }
.nevo-auto span { font-size: 17px; opacity: .35; transition: .15s; filter: grayscale(1); }
.nevo-auto input:checked + span { opacity: 1; filter: none; text-shadow: 0 0 10px rgba(253, 203, 110, .8); }
.ag-m.nevo { border-color: rgba(0, 206, 201, .4); background: rgba(0, 206, 201, .07); }
.nevo-send { background: linear-gradient(135deg, #00CEC9, #FDCB6E); color: #06302E; font-weight: 800; padding: 8px 13px; }
.plan-card {
  border: 1.4px dashed rgba(253, 203, 110, .6); border-radius: 13px; padding: 12px 14px;
  font-size: 12.5px; background: rgba(253, 203, 110, .06);
}
.plan-card ul { margin: 8px 0 10px 18px; display: flex; flex-direction: column; gap: 4px; }

/* member avatar stacks */
.bcard .thumb { position: relative; }
.bmembers { position: absolute; bottom: 7px; inset-inline-end: 7px; display: flex; }
.bmembers .avatar { border: 2px solid var(--panel-solid); margin-inline-start: -7px; font-size: 9px; }
.bmembers-row { display: flex; }
.bmembers-row .avatar { border: 2px solid var(--panel-solid); margin-inline-start: -8px; font-size: 9.5px; }

/* ============ share popover ============ */
.share-pop {
  position: absolute; top: 76px; inset-inline-end: 14px; z-index: 46; width: 320px;
  border-radius: 16px; padding: 18px;
}
.share-pop h4 { font-size: 14px; font-weight: 800; margin-bottom: 12px; }
.share-row { display: flex; gap: 7px; margin-bottom: 9px; }
.share-row input { flex: 1; padding: 9px 11px; border-radius: 9px; background: var(--hover); border: 1px solid var(--border); font-size: 12px; outline: none; }
.share-note { font-size: 11.5px; color: var(--muted); line-height: 1.5; }

/* ============ comments ============ */
#pins { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 42; }
.pin {
  position: absolute; pointer-events: auto; cursor: pointer; width: 34px; height: 34px;
  border-radius: 50% 50% 50% 4px; background: var(--panel-solid); border: 2.5px solid var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800;
  box-shadow: var(--shadow); transform: translate(-4px, -30px); transition: transform .12s;
}
.pin:hover { transform: translate(-4px, -34px) scale(1.08); }
.thread-pop {
  position: absolute; z-index: 48; width: 300px; max-height: 420px; border-radius: 16px;
  display: flex; flex-direction: column; overflow: hidden;
}
.thread-pop .th-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.thread-pop .th-head .sp { flex: 1; }
.thread-pop .th-head button { font-size: 11.5px; font-weight: 700; color: var(--muted); padding: 5px 9px; border-radius: 8px; }
.thread-pop .th-head button:hover { background: var(--hover); color: var(--text); }
.th-msgs { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.th-msg { font-size: 12.8px; line-height: 1.45; }
.th-msg .who { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); font-weight: 700; margin-bottom: 3px; }
.th-msg .who .dot2 { width: 9px; height: 9px; border-radius: 50%; }
.th-input { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--border); }
.th-input input { flex: 1; padding: 9px 11px; border-radius: 9px; background: var(--hover); border: 1px solid var(--border); font-size: 12.5px; outline: none; }
.th-input input:focus { border-color: var(--accent); }

/* comment composer */
.cmp {
  position: absolute; z-index: 49; display: flex; gap: 6px; padding: 9px; border-radius: 13px; width: 280px;
}
.cmp input { flex: 1; padding: 9px 11px; border-radius: 9px; background: var(--hover); border: 1px solid var(--border); font-size: 12.5px; outline: none; }

/* ============ template gallery ============ */
.tpl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 6px; }
.tpl-card {
  border: 1.4px solid var(--border); border-radius: 14px; padding: 16px 10px 12px; text-align: center;
  cursor: pointer; transition: .14s; font-size: 12px; font-weight: 700;
}
.tpl-card:hover { border-color: var(--accent); background: rgba(108, 92, 231, .1); transform: translateY(-2px); }
.tpl-card .ico { font-size: 26px; display: block; margin-bottom: 8px; }

/* ============ catch-up ============ */
.catchup-btn {
  position: absolute; top: 78px; left: 50%; transform: translateX(-50%); z-index: 44;
  padding: 10px 18px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: var(--grad); color: #fff; box-shadow: 0 6px 20px rgba(108, 92, 231, .5);
  animation: pop .25s ease;
}
.catchup-body { font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; max-height: 50vh; overflow-y: auto; }

/* ============ admin modal ============ */
.modal-back {
  position: fixed; inset: 0; z-index: 150; background: rgba(8, 8, 20, .55);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.modal {
  width: 420px; max-width: 92vw; border-radius: 20px; padding: 26px 26px 22px;
}
.modal h3 { font-size: 16px; font-weight: 800; margin-bottom: 18px; }
.modal label.sec { display: block; font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin: 14px 0 7px; }
.radio-card {
  display: flex; align-items: center; gap: 10px; padding: 11px 13px; border-radius: 12px;
  border: 1.4px solid var(--border); cursor: pointer; margin-bottom: 8px; font-size: 13.5px; font-weight: 600;
  transition: .13s;
}
.radio-card.on { border-color: var(--accent); background: rgba(108, 92, 231, .12); }
.radio-card .rdot { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--muted); flex: none; }
.radio-card.on .rdot { border-color: var(--accent); background: var(--grad); }
.radio-card .rsub { display: block; font-size: 11px; color: var(--muted); font-weight: 500; margin-top: 2px; }
.modal input.txt {
  width: 100%; padding: 9px 12px; border-radius: 10px; font-size: 12.5px;
  background: var(--hover); border: 1px solid var(--border); outline: none; font-family: ui-monospace, monospace;
}
.modal .mrow { display: flex; gap: 9px; justify-content: flex-end; margin-top: 20px; }

/* AI-at-work gradient glow (panels breathe while thinking) */
@keyframes aiGlow {
  0%, 100% { box-shadow: 0 0 22px rgba(108, 92, 231, .45), var(--shadow); }
  50% { box-shadow: 0 0 34px rgba(0, 206, 201, .55), var(--shadow); }
}
.ai-panel:has(.ai-busy:not(.hidden)),
.nevo-panel:has(.ai-busy:not(.hidden)),
.fun-panel:has(.ai-busy:not(.hidden)) { animation: aiGlow 2.2s ease-in-out infinite; }

/* user templates in the strip */
.tpl-mini .prev { position: relative; }
.ut-del {
  position: absolute; top: 5px; inset-inline-end: 5px; width: 22px; height: 22px; border-radius: 7px;
  background: rgba(0,0,0,.5); color: #fff; font-size: 11px; opacity: 0; transition: .15s;
}
.tpl-mini:hover .ut-del { opacity: 1; }

/* invited teammate button */
.cbtn.inv.on { background: var(--grad); color: #fff; }

/* 🌐 web-research composer toggle */
.th-input .cbtn.web { align-self: stretch; padding: 0 10px; font-size: 14px; }
.th-input .cbtn.web.on { border-color: #00CEC9; color: #00CEC9; box-shadow: 0 0 9px rgba(0,206,201,.4); background: rgba(0,206,201,.1); }

/* ask-ai selection popover */
.askai {
  position: fixed; z-index: 160; width: 340px; border-radius: 16px; padding: 14px 16px;
}
.askai textarea {
  width: 100%; min-height: 62px; padding: 10px 12px; border-radius: 11px; font-size: 13px;
  background: var(--hover); border: 1px solid var(--border); outline: none; resize: vertical;
  color: var(--text); font-family: var(--font);
}
.askai textarea:focus { border-color: var(--accent); }

/* AI version bar */
.ver-bar {
  display: flex; align-items: center; gap: 8px; margin: 0 16px 8px; padding: 8px 12px;
  border: 1.3px dashed var(--border); border-radius: 11px; font-size: 12px;
}
.ver-bar span { font-weight: 800; color: var(--accent-2); }
.ver-bar button { font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 8px; border-radius: 7px; }
.ver-bar button:hover { background: var(--hover); color: var(--text); }

/* pulse insight card */
.pulse-card {
  position: absolute; bottom: 20px; inset-inline-end: 16px; z-index: 46; width: 300px;
  border-radius: 15px; padding: 13px 15px; border: 1.4px solid rgba(253, 203, 110, .55);
  animation: pop .25s ease;
}
.pulse-card b { font-size: 12.5px; color: #FDCB6E; letter-spacing: .04em; }
.pulse-card p { font-size: 12.8px; line-height: 1.55; margin: 7px 0 9px; }
.pulse-card .prow { display: flex; gap: 6px; justify-content: flex-end; }
.pulse-card .prow .btn { padding: 6px 10px; font-size: 11.5px; }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200;
  background: var(--panel-solid); border: 1px solid var(--border); color: var(--text);
  padding: 11px 20px; border-radius: 12px; font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow); animation: pop .2s ease;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } }

/* RTL tweaks */
[dir="rtl"] .rcursor .tag { margin: 2px 12px 0 0; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::selection { background: rgba(108, 92, 231, .4); }
